code
stringlengths
1
1.73M
language
stringclasses
1 value
require "test/unit" class AboutControlStatements<Test::Unit::TestCase def test_string1 if true result = :true_value else result = :false_value end assert_equal :true_value, result end #控制语句,表明不同的情况,在这里result为真,故为:true_value def test_string2 result = :defult_value if true ...
Ruby
require "test/unit" class Test_Koans<Test::Unit::TestCase def test_symbols_are_symbols symbol = :ruby assert_equal true, symbol.is_a?(Symbol) end def test_symbols_can_be_compared symbol1 = :a_symbol symbol2 = :a_symbol symbol3 = :something_else assert_equal true, symbol1 == symbol2 a...
Ruby
require "test/unit" class Test_Koans<Test::Unit::TestCase def my_global_method(a,b) a + b end def test_calling_global_methods assert_equal 5, my_global_method(2,3) end def test_calling_global_methods_without_parentheses result = my_global_method 2, 3 assert_equal 5, result end # 可以不用括号,但...
Ruby
require "test/unit" class MyFriend<Test::Unit::TestCase def setup @friends = ['dell', 'apple', 'sony'] end def teardown end def test_add assert_instance_of(Array, @friends, "The @friends must be Array") assert_equal(3, @friends.size, "The size is not 3") @friends << 'acer' assert_equal(4...
Ruby
require "test/unit" class AboutTriangleProject2 < Test::Unit::TestCase class TriangleError < NameError end def triangle(a, b, c) triangle = if (a <= 0 or b <= 0 or c <= 0) raise TriangleError.new elsif((a + b) <= c or (b + c) <= a or (a + c) <= b) raise Triang...
Ruby
require "test/unit" class Test_Koans<Test::Unit::TestCase def test_non_parallel_assignment names = ["John", "Smith"] assert_equal ["John", "Smith"], names end def test_parallel_assignments first_name, last_name = ["John", "Smith"] assert_equal "John", first_name assert_equal "Smith", last_nam...
Ruby
require "test/unit" class Test_Koans<Test::Unit::TestCase def test_everything_is_an_object assert_equal true, 1.is_a?(Object) assert_equal true, 1.5.is_a?(Object) assert_equal true, "string".is_a?(Object) assert_equal true, nil.is_a?(Object) assert_equal true, Object.is_a?(Object) end # 在ru...
Ruby
require "test/unit" class AboutTrueAndFalse<Test::Unit::TestCase def truth_value(condition) if condition :true_stuff else :false_stuff end end # 如果有条件,则为真, 否则为假 def test_string1 assert_equal :true_stuff, truth_value(true) end # true作为真值 def test_string2 assert_equal :fals...
Ruby
# A comment, this is so you can read your program later. # Anything after the # is ignored by Ruby. puts "I could have code like this." # and the comment after is ignored. # You can also use a comment to "disable" or comment out a piece of code # print "This won't run." puts "This will run."
Ruby
puts "I will now count my chickens:" puts "Hens", 25 + 30 /6 #公鸡的数量 puts "Roosters",100 - 25 * 3 % 4 # 母鸡的数量 puts "Now I will count the eggs:" #数鸡蛋 ,后面加:更连贯 puts 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 #鸡蛋数量,符号两边必须空格,谁说的?如果是这样,那下面一行岂不会出错?加空格只是一种比较好的习惯,看着更清爽,你肯定是把这个跟另一个东西搞混了,不过我一时想不想来了 puts 3+2 puts "Is it true that 3...
Ruby
# Here's some new strange stuff, remember type it exactly. days = "Mon Tue Wed Thu Fri Sat Sun" months = "Jan \n Feb \n Mar \n Apr \n May \n Jun \n Jul \n Aug" puts "Here are the days:", days puts "Here are the months:", months puts <<PARAGRAPH There's something going on here. With the three double-quotes. We'll be...
Ruby
from_file, to_file = ARGV script = $0 puts "Copying from #{from_file} to #{to_file}" # we coule do these two on one line too, how? input = File.open(from_file) indata = input.read() puts "The input file is #{indata.length} bytes long" puts "Does the output file exist? #{File.exists? to_file}" puts "Ready, hit RETUR...
Ruby
def prompt() print">" end def gold_room() puts "This room is full of gold, How much do you take?" prompt; next_move = gets.chomp if next_move.include?"0" or next_move.include?"1" how_much = next_move.to_i() else dead("Man, learn to rype a number.") end if how_much < 50 puts...
Ruby
print "How old are you?" age = gets.chomp() print "How tall are you?" height = gets.chomp() print "How much do you weight?" weight = gets.chomp() puts "So,you're #{age} old,#{height} tall and #{weight} heavy." #这一节主要就是讲gets和gets.chomp()的用法,不同的是,gets是会自动换行的,而gets.chomp()则不会,视情况而使用,再本例里面用gets.chomp()就会更连贯,不然最后一句就会变成几段语...
Ruby
"I am 6'2 \" tall." # escape double-quote inside string 'I am 6\'2" tall.' # escape single-quote inside string tabby_cat = "\t I'm tabbed in." persian_cat = "I'm split \n on a line." backslash_cat = "I'm \\ a \\cat." fat_cat = <<MY_HEREDOC I'll do a list: \t* cat food \t* Fishies \t* Catnip\n\t* Grass MY_HEREDOC #不...
Ruby
# This function will break up words for us. def break_words(stuff) words = stuff.split(' ') return words end # Sorts the words. def sort_words(words) return sorted(words) end # Prints the first word after popping it off. def puts_first_word(words) word = words.poop(0) puts word end # Prints the l...
Ruby
cities = {'CA' => 'San Francisco', 'MI' => 'Detroit', 'FL' => 'Jacksonville'} cities ['NY'] = 'New York' cities ['OR'] = 'Portland' #简单定义cities包含的一些值 #什么叫包含一些值? 包含的是什么值? 说明你根本就没搞清楚用大括号是干什么的, 也没搞清楚map是个什么东西 def find_city(map, state) if map.include? state return map[state] else return "Not found." end...
Ruby
puts "I will now count my chickens:" puts "Hens", 25 + 30 / 6 puts "Roosters", 100 - 25 * 3 % 4 puts "Now I will count the eggs:" puts 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 puts "Is it true that 3 + 2 < 5 - 7?" puts 3 + 2 < 5 - 7 puts "What is 3 + 2?", 3 + 2 puts "What is 5 - 7?", 5 - 7 puts "Oh, that's why it's fal...
Ruby
my_name = 'Zed A. Shaw' my_age = 35 # not a lie my_height = 74 # inches my_weight = 180 # lbs my_eyes = 'Blue' my_teeth = 'White' my_hair = 'Brown' puts "Let's talk about %s." % my_name puts "He's %d inches tall." % my_height puts "He's %d pounds heavy." % my_weight puts "Actually ...
Ruby
puts "Hello World!" puts "Hello Again" puts "I like typing this." puts "This is fun." puts "Yay! Printing." puts "I'd much rather you 'not'." puts 'I "said" do not touch this.' #这里就是简单的ruby输出测试,puts , p ,print都可以将内容输出到终端,irb可以用来进行测试这三个的区别 #puts 可以将“”里面的转义内容进行转义,而p则不能,例如puts "a","/b"将显示 a b #p "a","\nb"则显示 a,/nb #put...
Ruby
cars = 100 space_in_a_car = 4.0 drivers = 30 passengers = 90 cars_not_driven = cars - drivers cars_driven = drivers carpool_capacity = cars_driven * space_in_a_car average_passengers_per_car = passengers / cars_driven puts "There are #{cars} cars available." puts "There are only #{drivers} drivers available." puts "Th...
Ruby
# A comment, this is so you can read your program later. # Anything after the # is ignored by ruby. puts "I could have code like this ." # and the comment after is ignored # You can also use a comment to "disable" or comment out a piece of code: # print "This won't run." puts "This will run." #注释,在运行时会被忽略,注释提供给使用...
Ruby
require 'open-uri' open("http://www.ruby-lang.org/en") do |f| f.each_line {|line| p line} puts f.base_uri puts f.content_type puts f.charset puts f.content_encoding puts f.last_modified end #这一节是我觉得前面20节里面最让我模不着头脑的一节,它的作用是显示出该网站的开源码?中间的那个|f|又是什么用法?这一节说是讲的模组,但这一节里面的这些用法都不懂, f.each_line {|line| p line},这又是什么用法...
Ruby
people = 20 cats = 30 dogs = 15 if people < cats puts "Too many cats! The world is doomed!" end if people > cats puts "Not many cats! The world is saved!" end if people < dogs puts "The world is drooled on!" end if people > dogs puts "The world is dry!" end dogs += 5 if people >= dogs puts "People are g...
Ruby
ten_things = "Apples Oranges Crows Telephone Light Sugar" puts "Wait there's not 10 things in that list, let's fix that." stuff = ten_things.split(' ') # 注意split的用法,进行分离,在这个里面是将空格键作为分离,遇到空格就分离,如果不输入空格就会出问题,''不含空格会默认为任何一个字符都是单个独立的,在后面的stff.length里面就会发现有42个,加入' '会把这42个分离成6个,空格相当分割线 more_stuff = %w(Day Night Song Frisb...
Ruby
puts "Let's practice everthing." puts "You \'d need to know\' bout escapes with \\ that do \n newlines and \t tabs." abc = <<PAD \tThe lovely world with logic so firmly planted cannot discern \n the needs of love nor comprehend passion from intuition and requires an explanation \n\t\twhere there is none. PAD puts "...
Ruby
my_name = 'Chen Xiao Qing' my_age = 22 my_height = 176 #cm my_weight = 65 #pounds my_eyes = 'Black' my_teeth = 'White' my_hair = 'Black' puts "Let's talk about %s." % my_name puts "He's %d tall." % my_height puts "He's %d pounds heavy." % my_weight puts "Actually that's not too heavy." puts "He's got %s eyes and %s h...
Ruby
def prompt() print "=>" end def death puts "You always a handsome boy,Game over!" Process.exit end def night puts "which clothes do you like?" prompt() likes = gets.chomp if likes == "red" puts "Yes, this is so beautiful!" Process.exit elsif likes == "green" puts "Green is nice ,but it not fit...
Ruby
the_count = [1 ,2 ,3 , 4, 5] fruits = ['apples', 'oranges', 'pears','apricots'] change = [1, 'pennies', 2, 'dimes', 3, 'quarters'] #this first kind of for-loop goes through an array for number in the_count puts "This is count #{number}" end #for 循环语句,number 代表阵列里面到内容 # same as above, but using a block instead fr...
Ruby
def prompt print ">" end # 定义提示符 puts "You enter a dark room with two doors. Do you go through door #1 or door #2?" prompt; door = gets.chomp #进入哪个门接受用户输入 if door == "1" puts "There's a giant bear here eating a cheese cake, what do you do?" puts "1.Take the cake." puts "2.Scream at the bear." #如果是进入第一个的话后面...
Ruby
x = "There are #{10} types of people."//这一句执行出现什么? binary = "binary" do_not = "don't" y = "Those who know #{binary} and those who #{do_not}." puts x puts y puts "I said: #{x}." puts "I also said:'#{y}'." hilarious = false joke_evaluation = "Isn't that joke so funny?! #{hilarious}" puts joke_evaluation w = "This is...
Ruby
cars = 100 space_in_a_car = 4.0 drivers = 30 passengers = 90 cars_not_driven = cars - drivers cars_driven = drivers carpool_capacity = cars_driven * space_in_a_car average_passengers_per_car = passengers / cars_driven puts "There are #{cars} cars available." puts "There are only #{drivers} drivers available." puts "Th...
Ruby
filename = ARGV.first script = $0 puts "We're going to erase #{filename}." puts "If you don't want that,hit CTRL-C(^C)." puts "If you do want that ,hit RETURN." print "?" STDIN.gets puts "Opening the file..." target = File.open(filename,'w') puts "Truncating the file.Goodbye!" target.truncate(target.size) puts "No...
Ruby
def add(a,b) puts "ADDING #{a} + #{b}" a + b end def subtract(a,b) puts "SUBTRACTING #{a} - #{b}" a - b end def multiply(a,b) puts "MULTIPLYING #{a} * #{b}" a * b end def divide(a,b) puts "DIVIDING #{a} / #{b}" a / b end puts "Let's do some math with just functions!" ...
Ruby
i = 0 numbers = [] #定义numbers为一个阵列 while i < 6 puts "At the top i is #{i}" numbers.push(i) #push 的用法,向数组到末尾添加一个或多个元素,并返回到新的阵列长度 i = i + 1 #可以用i += 1 puts "Numbers now:#{numbers}" #排列出阵列元素 puts "At the bottom i is #{i}" end puts "The numbers:" for num in numbers puts num end #最后是利用前面的i ...
Ruby
first, second, third = ARGV puts "The script is called:#{$0}" puts "Your first variable is:#{first}" puts "Your second variable is:#{second}" puts "Your third variable is:#{third}" #这一节主要讲的变数的解包,ARGV的用法,ARGV表示变数参数,当其赋值以后就不能更改,只能使用运行时所传入的参数,然后在脚本里面就不能再另外更改成其他值,不能再在这个变数参数里面添加变数,$0表示当前文件名,我试了用其它的如$2.$1.$4之类的都没有效果,都是空值,搜...
Ruby
people = 30 cars = 30 buses = 15 if cars > people puts "We should take the cars." elsif cars < people puts "We should not take the cars." else puts "We can't decide." end if buses > cars puts "That's too many buses." elsif buses < cars puts "Maybe we could take the buses." else puts "We still can't deci...
Ruby
def cheese_and_crackers(cheese_count, boxes_of_crackers) puts "You have #{cheese_count} cheeses!" puts "You have #{boxes_of_crackers} boxes of crackers!" puts "Man that's enough for a party!" puts "Get a blanket." puts # a blank line end puts "We can just give the function numbers directly:" cheese_and_crac...
Ruby
def prompt() print ">" end def hot_room() puts "There is a wolf in this room," puts "The wolf have a black look at you," puts "How can you fell your life with the wolf?" prompt next_move = gets.chomp if next_move == "taunt wolf" dead("The wolf scared and you run away.") elsif next_move == "take...
Ruby
user = ARGV.first prompt = '>' puts "Hi #{user},I'm the #{$0} script." puts "I'd like to ask you a few questions." puts "Do you like me #{user}?" print prompt likes = STDIN.gets.chomp() puts "Where do you live #{user}?" print prompt lives = STDIN.gets.chomp() puts "What kind of computer do you have?" print prompt co...
Ruby
filename = ARGV.first #表示文件名是用户第一个输入值 prompt = '>' #定义提示符 txt = File.open(filename) #用File.open创建一个文件对象并指定这个文件对象到filename,同时作为txt的值, puts "Here's your file:#{filename}" puts txt.read() # 将txt执行read这个命令,阅读txt里的东西 puts "Type the filename again:" print prompt file_again = STDIN.gets.chomp() #file_again这个参数接受用户输入,...
Ruby
require 'test/unit' class MyUnitTests < Test :: Unit :: TestCase def setup puts "setup!" end def teardown puts "tearsdown!" end def test_basic puts "I RAN!" end end
Ruby
# A sample Gemfile source "https://rubygems.org" # gem "rails"
Ruby
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", _FILE_) require "NAME/version" Gem :: specification.new do |s| s.name = "NAME" S.version = NAME::VERSION s.authors = ["vbird"] s.email = ["a617265919@gmail.com"] s.hoomepage = "" s.summary = %q{TODO:write a gem summary} s.descrip...
Ruby
# this one is like your scripts with argv def puts_two(*args) arg1,arg2 = args puts "arg1:#{arg1},arg2:#{arg2}" end # ok, that *args is actually pointless, we can just do this def puts_two_again(arg1,arg2) puts "arg1:#{arg1}, arg2:#{arg2}" end # this just takes one argument def puts_one(arg1) puts "arg1:#{arg1}"...
Ruby
puts "Mary had a little lamb." puts "Its fleece was white as %s." % 'snow' puts "And everywhere that Mary went." puts "." * 10 # what'd that do? 加入省略号 end1 = "c" end2 = "h" end3 = "e" end4 = "e" end5 = "s" end6 = "e" end7 = "B" end8 = "u" end9 = "r" end10 = "g" end11 = "e" end12 = "r" #notice how we are using print i...
Ruby
#A comment,this is so you can read your promgram later. #Anything after the # is ignored by Ruby. puts "I could have code like this." # and the comment after is ignored #You can also use a comment to "disable" or comment out a piece of code: #print "This won't run." puts "This will run." #就是一个注释,只是作为以后参考使用,能让其他人看懂你...
Ruby
input_file = ARGV[0]//前面说过ARGV就是个数组,应该知道这是取这个数组的每一个元素 def print_all(f) puts f.read() end def rewind(f) f.seek(0, IO::SEEK_SET)//搞清楚IO::SEEK_SET这是什么意思 end def print_a_line(line_count, f) puts "#{line_count} #{f.readline()}" end current_file = File.open(input_file) puts "First let's print the whole file:" puts ...
Ruby
class Animal end #定义Animal这个类 class Dog < Animal def initialize(name) @name = name #定义Dog这个类包含在Animal类里面,并初始化Dog的名字, end end class Cat < Animal def initialize(name) @name = name #定义Cat这个类包含在Animal类里面,初始化cat名字 end end class Person attr_accessor :pet #为pet命名,我查的,attr_accessor是为@_name命名的,不知道对不对...
Ruby
#这一节比较简单,就是讲到序数和基数的差别,简单到看就所基数排序等于序数减1 我反正是看不懂得你說了什麼的
Ruby
formatter = "%s %s %s %s" puts formatter % [1,2,3,4] puts formatter % ["one", "two", "three", "four"] puts formatter % [true, false, false, true] puts formatter % [formatter,formatter,formatter,formatter] puts formatter % [ "I had this thing.", "That you could type up right.", "But it didn't sing.", "So I ...
Ruby
hello,world!
Ruby
require 'test/unit' class MyUnitTests < Test::Unit::TestCase def setup puts "setup!" end def teardown puts "teardown!" end def test_basic puts "I RAN!" end end
Ruby
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "NAME/version" Gem::Specification.new do |s| s.name = "NAME" s.version = NAME::VERSION s.authors = ["Livingston.Chen"] s.email = ["livingston.chen@gmail.com"] s.homepage = "" s.summary = %q{Just a exa...
Ruby
puts "Hello, world" a = "Aries" b = a puts "Hello, #{a}" if(a == b) puts "a equals b" end def say_goodbye puts "Good bye!" puts "Good bye again" end say_goodbye
Ruby
module LineItemsHelper end
Ruby
module CartsHelper end
Ruby
module ApplicationHelper end
Ruby
module ProductsHelper end
Ruby
module StoreHelper end
Ruby
class Product < ActiveRecord::Base default_scope :order => 'title' validates :title, :description, :image_url, :presence => true validates :price, :numericality => {:greater_than_or_equal_to => 0.01} validates :title, :uniqueness => true validates :image_url, :format => { :with => %r{\.(gif|jpg|png)$}i, ...
Ruby
class LineItem < ActiveRecord::Base end
Ruby
class Cart < ActiveRecord::Base end
Ruby
class ApplicationController < ActionController::Base protect_from_forgery private def current_cart Cart.find(session[:cart_id]) rescue ActiveRecord::RecordNotFound cart = Cart.create session[:cart_id] = cart.id cart end end
Ruby
class StoreController < ApplicationController def index @products = Product.all end end
Ruby
class CartsController < ApplicationController # GET /carts # GET /carts.xml def index @carts = Cart.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @carts } end end # GET /carts/1 # GET /carts/1.xml def show @cart = Cart.find(params[:id]) ...
Ruby
class ProductsController < ApplicationController # GET /products # GET /products.xml def index @products = Product.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @products } end end # GET /products/1 # GET /products/1.xml def show @produc...
Ruby
class LineItemsController < ApplicationController # GET /line_items # GET /line_items.xml def index @line_items = LineItem.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @line_items } end end # GET /line_items/1 # GET /line_items/1.xml def sh...
Ruby
source 'http://rubygems.org' gem 'rails', '3.0.5' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'sqlite3' # Use unicorn as the web server # gem 'unicorn' # Deploy with Capistrano # gem 'capistrano' # To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1....
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. # # Note: You'll currently still have to declare fixtures explicitly in integrati...
Ruby
#--- # Excerpted from "Agile Web Development with Rails, 4rd Ed.", # published by The Pragmatic Bookshelf. # Copyrights apply to this code. It may not be used to create training material, # courses, books, articles, and the like. Contact us if you are in doubt. # We make no guarantees that this code is fit for any pur...
Ruby
class CreateCarts < ActiveRecord::Migration def self.up create_table :carts do |t| t.timestamps end end def self.down drop_table :carts end end
Ruby
class CreateProducts < ActiveRecord::Migration def self.up create_table :products do |t| t.string :title t.text :description t.string :image_url t.decimal :price, :precision => 8, :scale => 2 t.timestamps end end def self.down drop_table :products end end
Ruby
class CreateLineItems < ActiveRecord::Migration def self.up create_table :line_items do |t| t.integer :product_id t.integer :cart_id t.timestamps end end def self.down drop_table :line_items end end
Ruby
#!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands'
Ruby
#!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands'
Ruby
# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path('../config/application', __FILE__) require 'rake' Depot::Application.load_tasks
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run Depot::Application
Ruby
Depot::Application.routes.draw do resources :line_items resources :carts get "store/index" resources :products # The priority is based upon order of creation: # first created -> highest priority. # Sample of regular route: # match 'products/:id' => 'catalog#view' # Keep in mind you can assign v...
Ruby
require File.expand_path('../boot', __FILE__) require 'rails/all' # If you have a Gemfile, require the gems listed there, including any gems # you've limited to :test, :development, or :production. Bundler.require(:default, Rails.env) if defined?(Bundler) module Depot class Application < Rails::Application # S...
Ruby
Depot::Application.configure do # Settings specified here will take precedence over those in config/application.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the webserv...
Ruby
Depot::Application.configure do # Settings specified here will take precedence over those in config/application.rb # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test su...
Ruby
Depot::Application.configure do # Settings specified here will take precedence over those in config/application.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Full error reports are disabled and caching is turned on ...
Ruby
require 'rubygems' # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
Ruby
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying to debug a probl...
Ruby
# Be sure to restart your server when you modify this file. Depot::Application.config.session_store :cookie_store, :key => '_Depot_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the session table with "rails ge...
Ruby
# Be sure to restart your server when you modify this file. # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attac...
Ruby
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf # Mime::Type.register_alias "text/html", :iphone
Ruby
# Be sure to restart your server when you modify this file. # Add new inflection rules using the following format # (all these examples are active by default): # ActiveSupport::Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', ...
Ruby
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application Depot::Application.initialize!
Ruby
require 'mkmf' $CPPFLAGS = $CPPFLAGS + " -I../../include" $LDFLAGS = $LDFLAGS + " -L../../" $LIBS = $LIBS + " -lhpdf -lpng -lz" create_makefile 'hpdf'
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- demo.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appea...
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- encryption.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice...
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- font_example.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright noti...
Ruby
# # << Haru Free PDF Library 2.0.2 >> -- arc_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appear ...
Ruby
# # << Haru Free PDF Library 2.0.6 >> -- ext_gstate_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice ...
Ruby
# # << Haru Free PDF Library 2.0.2 >> -- ttfont_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appe...
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- text_demo2.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice...
Ruby
# # << Haru Free PDF Library 2.0.2 >> -- line_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appear...
Ruby
# # << Haru Free PDF Library 2.0.6 >> -- slideshow_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice a...
Ruby