anmo 0.0.18 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- data/.ruby-version +1 -0
- data/anmo.gemspec +1 -2
- data/lib/anmo/application.rb +46 -11
- data/lib/anmo/version.rb +1 -1
- data/test/anmo/application_test.rb +2 -2
- metadata +151 -165
- data/Guardfile +0 -3
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.9.3-p0
|
data/anmo.gemspec
CHANGED
@@ -21,12 +21,11 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_runtime_dependency "rack"
|
22
22
|
s.add_runtime_dependency "thin"
|
23
23
|
s.add_runtime_dependency "httparty"
|
24
|
+
s.add_runtime_dependency "dalli"
|
24
25
|
|
25
26
|
s.add_development_dependency "rake"
|
26
27
|
s.add_development_dependency "minitest"
|
27
28
|
s.add_development_dependency "rack-test"
|
28
29
|
s.add_development_dependency "cucumber"
|
29
30
|
s.add_development_dependency "rspec"
|
30
|
-
s.add_development_dependency "guard"
|
31
|
-
s.add_development_dependency "guard-shell"
|
32
31
|
end
|
data/lib/anmo/application.rb
CHANGED
@@ -1,14 +1,49 @@
|
|
1
|
+
require "dalli"
|
2
|
+
|
1
3
|
module Anmo
|
2
4
|
class ApplicationDataStore
|
3
|
-
|
4
|
-
|
5
|
+
def self.objects
|
6
|
+
cached_objects = server.get("objects")
|
7
|
+
return JSON.load(cached_objects) if cached_objects
|
8
|
+
[]
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.requests
|
12
|
+
cached_requests = server.get("requests")
|
13
|
+
return JSON.load(cached_requests) if cached_requests
|
14
|
+
[]
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.insert_object object
|
18
|
+
all_objects = objects
|
19
|
+
all_objects.unshift(object)
|
20
|
+
server.set("objects", JSON.dump(all_objects))
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.save_request request
|
24
|
+
all_requests = requests
|
25
|
+
all_requests << request
|
26
|
+
server.set("requests", JSON.dump(all_requests))
|
5
27
|
end
|
28
|
+
|
29
|
+
def self.clear_objects
|
30
|
+
server.delete("objects")
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.clear_requests
|
34
|
+
server.delete("requests")
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
def self.server
|
39
|
+
@server ||= Dalli::Client.new "localhost:11211"
|
40
|
+
end
|
6
41
|
end
|
7
42
|
|
8
43
|
class Application
|
9
44
|
def initialize
|
10
|
-
ApplicationDataStore.
|
11
|
-
ApplicationDataStore.
|
45
|
+
ApplicationDataStore.clear_objects
|
46
|
+
ApplicationDataStore.clear_requests
|
12
47
|
end
|
13
48
|
|
14
49
|
def call env
|
@@ -49,17 +84,17 @@ module Anmo
|
|
49
84
|
|
50
85
|
def create_object request
|
51
86
|
request_info = JSON.parse(read_request_body(request))
|
52
|
-
ApplicationDataStore.
|
87
|
+
ApplicationDataStore.insert_object(request_info)
|
53
88
|
text "", 201
|
54
89
|
end
|
55
90
|
|
56
91
|
def delete_all_objects request
|
57
|
-
ApplicationDataStore.
|
92
|
+
ApplicationDataStore.clear_objects
|
58
93
|
text ""
|
59
94
|
end
|
60
95
|
|
61
96
|
def process_normal_request request
|
62
|
-
ApplicationDataStore.
|
97
|
+
ApplicationDataStore.save_request(request.env)
|
63
98
|
|
64
99
|
if found_request = find_stored_request(request)
|
65
100
|
text found_request["body"], Integer(found_request["status"]||200)
|
@@ -69,22 +104,22 @@ module Anmo
|
|
69
104
|
end
|
70
105
|
|
71
106
|
def requests request
|
72
|
-
json ApplicationDataStore.
|
107
|
+
json ApplicationDataStore.requests.to_json
|
73
108
|
end
|
74
109
|
|
75
110
|
def delete_all_requests request
|
76
|
-
ApplicationDataStore.
|
111
|
+
ApplicationDataStore.clear_requests
|
77
112
|
text ""
|
78
113
|
end
|
79
114
|
|
80
115
|
def objects request
|
81
|
-
json ApplicationDataStore.
|
116
|
+
json ApplicationDataStore.objects.to_json
|
82
117
|
end
|
83
118
|
|
84
119
|
def find_stored_request actual_request
|
85
120
|
actual_request_query = Rack::Utils.parse_query(actual_request.query_string)
|
86
121
|
|
87
|
-
suspected_request = ApplicationDataStore.
|
122
|
+
suspected_request = ApplicationDataStore.objects.find do |r|
|
88
123
|
r["path"].gsub(/\?.*/, "") == actual_request.path_info
|
89
124
|
end
|
90
125
|
|
data/lib/anmo/version.rb
CHANGED
@@ -14,8 +14,8 @@ module Anmo
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def setup
|
17
|
-
ApplicationDataStore.
|
18
|
-
ApplicationDataStore.
|
17
|
+
ApplicationDataStore.clear_objects
|
18
|
+
ApplicationDataStore.clear_requests
|
19
19
|
end
|
20
20
|
|
21
21
|
def save_object path, body, status, required_headers, method
|
metadata
CHANGED
@@ -1,177 +1,172 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: anmo
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.19
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 18
|
10
|
-
version: 0.0.18
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Andrew Vos
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-06-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: rack
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
hash: 3
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
32
22
|
type: :runtime
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: thin
|
36
23
|
prerelease: false
|
37
|
-
|
38
|
-
none: false
|
39
|
-
requirements:
|
40
|
-
- -
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: thin
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
46
38
|
type: :runtime
|
47
|
-
version_requirements: *id002
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: httparty
|
50
39
|
prerelease: false
|
51
|
-
|
52
|
-
none: false
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: httparty
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
60
54
|
type: :runtime
|
61
|
-
version_requirements: *id003
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: rake
|
64
55
|
prerelease: false
|
65
|
-
|
66
|
-
none: false
|
67
|
-
requirements:
|
68
|
-
- -
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
- !
|
77
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: dalli
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
78
71
|
prerelease: false
|
79
|
-
|
80
|
-
none: false
|
81
|
-
requirements:
|
82
|
-
- -
|
83
|
-
- !ruby/object:Gem::Version
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rake
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
88
86
|
type: :development
|
89
|
-
version_requirements: *id005
|
90
|
-
- !ruby/object:Gem::Dependency
|
91
|
-
name: rack-test
|
92
87
|
prerelease: false
|
93
|
-
|
94
|
-
none: false
|
95
|
-
requirements:
|
96
|
-
- -
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: minitest
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
102
|
type: :development
|
103
|
-
version_requirements: *id006
|
104
|
-
- !ruby/object:Gem::Dependency
|
105
|
-
name: cucumber
|
106
103
|
prerelease: false
|
107
|
-
|
108
|
-
none: false
|
109
|
-
requirements:
|
110
|
-
- -
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: rack-test
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
116
118
|
type: :development
|
117
|
-
version_requirements: *id007
|
118
|
-
- !ruby/object:Gem::Dependency
|
119
|
-
name: rspec
|
120
119
|
prerelease: false
|
121
|
-
|
122
|
-
none: false
|
123
|
-
requirements:
|
124
|
-
- -
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: cucumber
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
130
134
|
type: :development
|
131
|
-
version_requirements: *id008
|
132
|
-
- !ruby/object:Gem::Dependency
|
133
|
-
name: guard
|
134
135
|
prerelease: false
|
135
|
-
|
136
|
-
none: false
|
137
|
-
requirements:
|
138
|
-
- -
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: rspec
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
144
150
|
type: :development
|
145
|
-
version_requirements: *id009
|
146
|
-
- !ruby/object:Gem::Dependency
|
147
|
-
name: guard-shell
|
148
151
|
prerelease: false
|
149
|
-
|
150
|
-
none: false
|
151
|
-
requirements:
|
152
|
-
- -
|
153
|
-
- !ruby/object:Gem::Version
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
version: "0"
|
158
|
-
type: :development
|
159
|
-
version_requirements: *id010
|
160
|
-
description: ""
|
161
|
-
email:
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
description: ''
|
159
|
+
email:
|
162
160
|
- andrew.vos@gmail.com
|
163
161
|
executables: []
|
164
|
-
|
165
162
|
extensions: []
|
166
|
-
|
167
163
|
extra_rdoc_files: []
|
168
|
-
|
169
|
-
files:
|
164
|
+
files:
|
170
165
|
- .gitignore
|
166
|
+
- .ruby-version
|
171
167
|
- .rvmrc
|
172
168
|
- .travis.yml
|
173
169
|
- Gemfile
|
174
|
-
- Guardfile
|
175
170
|
- README.md
|
176
171
|
- Rakefile
|
177
172
|
- anmo.gemspec
|
@@ -182,40 +177,31 @@ files:
|
|
182
177
|
- lib/anmo/application.rb
|
183
178
|
- lib/anmo/version.rb
|
184
179
|
- test/anmo/application_test.rb
|
185
|
-
homepage:
|
180
|
+
homepage: ''
|
186
181
|
licenses: []
|
187
|
-
|
188
182
|
post_install_message:
|
189
183
|
rdoc_options: []
|
190
|
-
|
191
|
-
require_paths:
|
184
|
+
require_paths:
|
192
185
|
- lib
|
193
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
186
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
194
187
|
none: false
|
195
|
-
requirements:
|
196
|
-
- -
|
197
|
-
- !ruby/object:Gem::Version
|
198
|
-
|
199
|
-
|
200
|
-
- 0
|
201
|
-
version: "0"
|
202
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
|
+
requirements:
|
189
|
+
- - ! '>='
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: '0'
|
192
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
203
193
|
none: false
|
204
|
-
requirements:
|
205
|
-
- -
|
206
|
-
- !ruby/object:Gem::Version
|
207
|
-
|
208
|
-
segments:
|
209
|
-
- 0
|
210
|
-
version: "0"
|
194
|
+
requirements:
|
195
|
+
- - ! '>='
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '0'
|
211
198
|
requirements: []
|
212
|
-
|
213
199
|
rubyforge_project: anmo
|
214
|
-
rubygems_version: 1.8.
|
200
|
+
rubygems_version: 1.8.23
|
215
201
|
signing_key:
|
216
202
|
specification_version: 3
|
217
|
-
summary:
|
218
|
-
test_files:
|
203
|
+
summary: ''
|
204
|
+
test_files:
|
219
205
|
- features/api.feature
|
220
206
|
- features/step_definitions/api_steps.rb
|
221
207
|
- features/support/env.rb
|
data/Guardfile
DELETED