test

Ruby code posted
created at 09 Oct 02:01, updated at 09 Oct 02:13

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env ruby
require 'ramaze'

class MainController < Ramaze::Controller
  def index
    super
     "Hello World!"
  end
end

require 'camping'

Camping.goes :Hello

module Hello::Controllers
  class Index < R '/'
     def get
        render :hello
     end
  end
end

module Hello::Views
  def hello
     p  "Hello World!"
  end
end

require './hello'
run Rack::Adapter::Camping.new(Hello)

require 'activerecord'
require 'uri'

db = URI.parse(ENV['DATABASE_URL'] || 'postgres://localhost/mydb')

ActiveRecord::Base.establish_connection(
  :adapter  => db.scheme == 'postgres' ? 'postgresql' : db.scheme,
  :host     => db.host,
  :port     => db.port,
  :username => db.user,
  :password => db.password,
  :database => db.path[1..-1],
  :encoding => 'utf8'
)

class SessionsController < ApplicationController
  def create
    ENV['sfdc_token'] = request.env['omniauth.auth']['credentials']['token']
    ENV['sfdc_instance_url'] = request.env['omniauth.auth']['instance_url']
    #render :text => request.env['omniauth.auth'].inspect
    render :text => Accounts.get_first_hundred.inspect
  end
end

foo = 124
bar = :symbol
baz = "string"
hoge = Hoge.new do |test|
  @fuga = test
end
foo = 0.14

proc do |a, b|
end

lambda { :hi }

[].inject(&hoge)
[1, 2, 3]
%W!foo bar baz!
1.32 KB in 4 ms with coderay