tom 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/README.md +9 -3
  2. data/VERSION +1 -1
  3. data/lib/adapter.rb +5 -2
  4. data/lib/tom.rb +1 -4
  5. data/tom.gemspec +2 -2
  6. metadata +31 -31
data/README.md CHANGED
@@ -7,6 +7,12 @@ To go into technical detail: Tom uses [Goliath](http://goliath.io) to dispatch H
7
7
 
8
8
  All you have to do is define some `Adapter`s that get activated for certain routes and some `Merger`s for certain routes.
9
9
 
10
+ As you have seen in the video above, Tom Smykowski talks extra much when
11
+ consultants are present who might fire him. So this gem will log to
12
+ STDOUT when you're in development mode or the BOBS environment variable
13
+ is set. Useful for debugging, but nothing you really want in
14
+ production/testing.
15
+
10
16
  # TL;DR
11
17
 
12
18
  The general flow goes like this:
@@ -63,7 +69,7 @@ In your initializer you can configure `Adapter`s like this:
63
69
 
64
70
  Sheldon.host = 'http://localhost:9292'
65
71
 
66
- This causes the aforementioned `rewrite_request` method to use that host name. The `forward_request` method uses an instance variable called `@request` to know what to do. `rewrite_request`, for example, takes a rack env and initializes `@request` with `:host`, `:method` and `:uri`.
72
+ This causes the aforementioned `rewrite_request` method to use that host name. The `forward_request` method uses an instance variable called `@request` to know what to do. `rewrite_request`, for example, takes a rack env and initializes `@request` with `:host`, `:method` and `:uri`.
67
73
 
68
74
  If the method is `POST` or `PUT`, then you should also set the appropriate `@request[:body]` if you want to use the automatic `forward_request` method.
69
75
 
@@ -72,9 +78,9 @@ If the method is `POST` or `PUT`, then you should also set the appropriate `@req
72
78
  `Mergers` work very similar to `Adapter`s. But all you have to do here is subclass it and implement the `merge` method. For example we could create a `Merger` that always ignores everything and just returns the response from Sheldon:
73
79
 
74
80
  class OnlySheldon < Tom::Merger
75
-
81
+
76
82
  register_route "^/nodes/[0-9]+$"
77
-
83
+
78
84
  def self.merge(env, responses)
79
85
  responses[Sheldon]
80
86
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
@@ -62,11 +62,14 @@ module Tom
62
62
  opts
63
63
  end
64
64
 
65
- # Extracts the given POT/PUST (hehe) body
65
+ # Extracts the given POT/PUST (hehe) body. Overwrite this
66
+ # if you want to do your own thing (e.g. if the params middleware
67
+ # made the params an object, you should return a string here as
68
+ # this is what we feed into the EM::HttpRequest
66
69
  #
67
70
  # @param env [Array] A rack env object
68
71
  def extract_request_body(env)
69
- Rack::Request.new(env).POST.keys.first rescue "{}"
72
+ Rack::Request.new(env).POST rescue {}
70
73
  end
71
74
 
72
75
  # Takes a request from rack and extracts the request
data/lib/tom.rb CHANGED
@@ -5,7 +5,7 @@ Goliath.env rescue Goliath.env = (ENV['RACK_ENV'] || 'development').to_sym
5
5
 
6
6
  # In dev mode, we do some logging (defaults to Logger::ERROR in other
7
7
  # envs)
8
- if Goliath.env == :development
8
+ if Goliath.env == :development || ENV['BOBS']
9
9
  Tom::LOG.level = Logger::INFO
10
10
  end
11
11
  Tom::LOG.info "Started goliath in #{Goliath.env} environment (change with ruby your_app.rb -e development or by setting $RACK_ENV)"
@@ -28,9 +28,6 @@ module Tom
28
28
  # it when it comes to parallel stuff and so on...
29
29
  #
30
30
  class GoliathAPI < Goliath::API
31
- use Goliath::Rack::JSONP
32
- use Goliath::Rack::Params
33
- use Goliath::Rack::Formatters::JSON
34
31
  use Goliath::Rack::Render
35
32
 
36
33
  def response(env)
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "tom"
8
- s.version = "0.1.1"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jannis Hermanns"]
12
- s.date = "2011-12-03"
12
+ s.date = "2011-12-06"
13
13
  s.description = " Tom uses Goliath to dispatch HTTP requests to multiple other APIs (via Adapters) in parallel. In a next step, a Merger merges the result and responds to the clients request."
14
14
  s.email = "jannis@gmail.com"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-03 00:00:00.000000000Z
12
+ date: 2011-12-06 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: goliath
16
- requirement: &70331478259800 !ruby/object:Gem::Requirement
16
+ requirement: &70326256348120 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70331478259800
24
+ version_requirements: *70326256348120
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: em-synchrony
27
- requirement: &70331478259160 !ruby/object:Gem::Requirement
27
+ requirement: &70326256347400 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70331478259160
35
+ version_requirements: *70326256347400
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: em-http-request
38
- requirement: &70331478258580 !ruby/object:Gem::Requirement
38
+ requirement: &70326256346700 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70331478258580
46
+ version_requirements: *70326256346700
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: json
49
- requirement: &70331478258020 !ruby/object:Gem::Requirement
49
+ requirement: &70326256345860 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70331478258020
57
+ version_requirements: *70326256345860
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &70331478257520 !ruby/object:Gem::Requirement
60
+ requirement: &70326256345260 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.9.2
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70331478257520
68
+ version_requirements: *70326256345260
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
- requirement: &70331478257040 !ruby/object:Gem::Requirement
71
+ requirement: &70326256344680 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.0.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70331478257040
79
+ version_requirements: *70326256344680
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: jeweler
82
- requirement: &70331478256480 !ruby/object:Gem::Requirement
82
+ requirement: &70326256344180 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 1.6.4
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70331478256480
90
+ version_requirements: *70326256344180
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: shoulda
93
- requirement: &70331478255940 !ruby/object:Gem::Requirement
93
+ requirement: &70326256343660 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70331478255940
101
+ version_requirements: *70326256343660
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rcov
104
- requirement: &70331478255420 !ruby/object:Gem::Requirement
104
+ requirement: &70326256343040 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70331478255420
112
+ version_requirements: *70326256343040
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: ruby-debug19
115
- requirement: &70331478254880 !ruby/object:Gem::Requirement
115
+ requirement: &70326256342520 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70331478254880
123
+ version_requirements: *70326256342520
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: rspec
126
- requirement: &70331478254360 !ruby/object:Gem::Requirement
126
+ requirement: &70326256342000 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *70331478254360
134
+ version_requirements: *70326256342000
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: webmock
137
- requirement: &70331478253820 !ruby/object:Gem::Requirement
137
+ requirement: &70326256341460 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: '0'
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *70331478253820
145
+ version_requirements: *70326256341460
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: yard
148
- requirement: &70331478253300 !ruby/object:Gem::Requirement
148
+ requirement: &70326256340960 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ! '>='
@@ -153,10 +153,10 @@ dependencies:
153
153
  version: '0'
154
154
  type: :development
155
155
  prerelease: false
156
- version_requirements: *70331478253300
156
+ version_requirements: *70326256340960
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: rdiscount
159
- requirement: &70331478252780 !ruby/object:Gem::Requirement
159
+ requirement: &70326256340460 !ruby/object:Gem::Requirement
160
160
  none: false
161
161
  requirements:
162
162
  - - ! '>='
@@ -164,7 +164,7 @@ dependencies:
164
164
  version: '0'
165
165
  type: :development
166
166
  prerelease: false
167
- version_requirements: *70331478252780
167
+ version_requirements: *70326256340460
168
168
  description: ! ' Tom uses Goliath to dispatch HTTP requests to multiple other APIs
169
169
  (via Adapters) in parallel. In a next step, a Merger merges the result and responds
170
170
  to the clients request.'
@@ -208,7 +208,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
208
208
  version: '0'
209
209
  segments:
210
210
  - 0
211
- hash: 480202980293159198
211
+ hash: -2944832155486996740
212
212
  required_rubygems_version: !ruby/object:Gem::Requirement
213
213
  none: false
214
214
  requirements: