copycopter_client 1.1.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,24 +6,24 @@ require 'webmock/rspec'
6
6
 
7
7
  PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
8
8
 
9
- $LOAD_PATH << File.join(PROJECT_ROOT, "lib")
9
+ $LOAD_PATH << File.join(PROJECT_ROOT, 'lib')
10
10
 
11
- require "copycopter_client"
11
+ require 'copycopter_client'
12
12
 
13
- Dir.glob(File.join(PROJECT_ROOT, "spec", "support", "**", "*.rb")).each do |file|
13
+ Dir.glob(File.join(PROJECT_ROOT, 'spec', 'support', '**', '*.rb')).each do |file|
14
14
  require(file)
15
15
  end
16
16
 
17
17
  WebMock.disable_net_connect!
18
- ShamRack.mount(FakeCopycopterApp.new, "copycopter.com", 443)
18
+ ShamRack.mount FakeCopycopterApp.new, 'copycopter.com', 80
19
19
 
20
20
  RSpec.configure do |config|
21
21
  config.include ClientSpecHelpers
22
22
  config.include WebMock::API
23
23
  config.mock_with :mocha
24
+
24
25
  config.before do
25
26
  FakeCopycopterApp.reset
26
27
  reset_config
27
28
  end
28
29
  end
29
-
@@ -39,11 +39,15 @@ class FakeClient
39
39
  private
40
40
 
41
41
  def wait_for_delay
42
- sleep(delay) if delay
42
+ if delay
43
+ sleep delay
44
+ end
43
45
  end
44
46
 
45
47
  def raise_error_if_present
46
- raise error if error
48
+ if error
49
+ raise error
50
+ end
47
51
  end
48
52
  end
49
53
 
@@ -12,7 +12,8 @@ class FakeCopycopterApp < Sinatra::Base
12
12
  else
13
13
  Thin::Logging.silent = true
14
14
  end
15
- Rack::Handler::Thin.run(self, :Port => port)
15
+
16
+ Rack::Handler::Thin.run self, :Port => port
16
17
  end
17
18
  end
18
19
 
@@ -21,7 +22,7 @@ class FakeCopycopterApp < Sinatra::Base
21
22
  end
22
23
 
23
24
  def self.add_project(api_key)
24
- Project.create(api_key)
25
+ Project.create api_key
25
26
  end
26
27
 
27
28
  def self.reset
@@ -29,37 +30,37 @@ class FakeCopycopterApp < Sinatra::Base
29
30
  end
30
31
 
31
32
  def self.project(api_key)
32
- Project.find(api_key)
33
+ Project.find api_key
33
34
  end
34
35
 
35
36
  def with_project(api_key)
36
37
  if api_key == 'raise_error'
37
- halt 500, { :error => "Blah ha" }.to_json
38
+ halt 500, { :error => 'Blah ha' }.to_json
38
39
  elsif project = Project.find(api_key)
39
- yield(project)
40
+ yield project
40
41
  else
41
- halt 404, { :error => "No such project" }.to_json
42
+ halt 404, { :error => 'No such project' }.to_json
42
43
  end
43
44
  end
44
45
 
45
- get "/api/v2/projects/:api_key/published_blurbs" do |api_key|
46
+ get '/api/v2/projects/:api_key/published_blurbs' do |api_key|
46
47
  with_project(api_key) do |project|
47
48
  etag project.etag
48
49
  project.published.to_json
49
50
  end
50
51
  end
51
52
 
52
- get "/api/v2/projects/:api_key/draft_blurbs" do |api_key|
53
+ get '/api/v2/projects/:api_key/draft_blurbs' do |api_key|
53
54
  with_project(api_key) do |project|
54
55
  etag project.etag
55
56
  project.draft.to_json
56
57
  end
57
58
  end
58
59
 
59
- post "/api/v2/projects/:api_key/draft_blurbs" do |api_key|
60
+ post '/api/v2/projects/:api_key/draft_blurbs' do |api_key|
60
61
  with_project(api_key) do |project|
61
62
  with_json_data do |data|
62
- project.update('draft' => data)
63
+ project.update 'draft' => data
63
64
  201
64
65
  end
65
66
  end
@@ -67,13 +68,13 @@ class FakeCopycopterApp < Sinatra::Base
67
68
 
68
69
  def with_json_data
69
70
  if request.content_type == 'application/json'
70
- yield(JSON.parse(request.body.read))
71
+ yield JSON.parse(request.body.read)
71
72
  else
72
73
  406
73
74
  end
74
75
  end
75
76
 
76
- post "/api/v2/projects/:api_key/deploys" do |api_key|
77
+ post '/api/v2/projects/:api_key/deploys' do |api_key|
77
78
  with_project(api_key) do |project|
78
79
  project.deploy
79
80
  201
@@ -84,33 +85,41 @@ class FakeCopycopterApp < Sinatra::Base
84
85
  attr_reader :draft, :published, :api_key
85
86
 
86
87
  def initialize(attrs)
87
- @api_key = attrs['api_key']
88
- @draft = attrs['draft'] || {}
88
+ @api_key = attrs['api_key']
89
+ @draft = attrs['draft'] || {}
90
+ @etag = attrs['etag'] || 1
89
91
  @published = attrs['published'] || {}
90
- @etag = attrs['etag'] || 1
91
92
  end
92
93
 
93
94
  def to_hash
94
- { 'api_key' => @api_key,
95
- 'etag' => @etag,
96
- 'draft' => @draft,
97
- 'published' => @published }
95
+ {
96
+ 'api_key' => @api_key,
97
+ 'etag' => @etag,
98
+ 'draft' => @draft,
99
+ 'published' => @published
100
+ }
98
101
  end
99
102
 
100
103
  def update(attrs)
101
- @draft. update(attrs['draft']) if attrs['draft']
102
- @published.update(attrs['published']) if attrs['published']
104
+ if attrs['draft']
105
+ @draft.update attrs['draft']
106
+ end
107
+
108
+ if attrs['published']
109
+ @published.update attrs['published']
110
+ end
111
+
103
112
  @etag += 1
104
- self.class.save(self)
113
+ self.class.save self
105
114
  end
106
115
 
107
116
  def reload
108
- self.class.find(api_key)
117
+ self.class.find api_key
109
118
  end
110
119
 
111
120
  def deploy
112
- @published.update(@draft)
113
- self.class.save(self)
121
+ @published.update @draft
122
+ self.class.save self
114
123
  end
115
124
 
116
125
  def etag
@@ -119,14 +128,14 @@ class FakeCopycopterApp < Sinatra::Base
119
128
 
120
129
  def self.create(api_key)
121
130
  project = Project.new('api_key' => api_key)
122
- save(project)
131
+ save project
123
132
  project
124
133
  end
125
134
 
126
135
  def self.find(api_key)
127
136
  open_project_data do |data|
128
137
  if project_hash = data[api_key]
129
- Project.new(project_hash.dup)
138
+ Project.new project_hash.dup
130
139
  else
131
140
  nil
132
141
  end
@@ -147,7 +156,8 @@ class FakeCopycopterApp < Sinatra::Base
147
156
 
148
157
  def self.open_project_data
149
158
  project_file = File.expand_path('/../../../tmp/projects.json', __FILE__)
150
- if File.exist?(project_file)
159
+
160
+ if File.exist? project_file
151
161
  data = JSON.parse(IO.read(project_file))
152
162
  else
153
163
  data = {}
@@ -155,10 +165,11 @@ class FakeCopycopterApp < Sinatra::Base
155
165
 
156
166
  result = yield(data)
157
167
 
158
- File.open(project_file, "w") { |file| file.write(data.to_json) }
168
+ File.open(project_file, 'w') do |file|
169
+ file.write data.to_json
170
+ end
159
171
 
160
172
  result
161
173
  end
162
174
  end
163
175
  end
164
-
metadata CHANGED
@@ -1,274 +1,202 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: copycopter_client
3
- version: !ruby/object:Gem::Version
4
- hash: 23
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 1
9
- - 2
10
- version: 1.1.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - thoughtbot
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-11-14 00:00:00 -05:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2012-03-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: i18n
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70204562771880 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 11
30
- segments:
31
- - 0
32
- - 5
33
- - 0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
34
21
  version: 0.5.0
35
22
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: json
39
23
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70204562771880
25
+ - !ruby/object:Gem::Dependency
26
+ name: json
27
+ requirement: &70204562770040 !ruby/object:Gem::Requirement
41
28
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 3
46
- segments:
47
- - 0
48
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
49
33
  type: :runtime
50
- version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
52
- name: rails
53
34
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *70204562770040
36
+ - !ruby/object:Gem::Dependency
37
+ name: appraisal
38
+ requirement: &70204562768960 !ruby/object:Gem::Requirement
55
39
  none: false
56
- requirements:
40
+ requirements:
57
41
  - - ~>
58
- - !ruby/object:Gem::Version
59
- hash: 3
60
- segments:
61
- - 3
62
- - 1
63
- - 0
64
- version: 3.1.0
42
+ - !ruby/object:Gem::Version
43
+ version: '0.4'
65
44
  type: :development
66
- version_requirements: *id003
67
- - !ruby/object:Gem::Dependency
68
- name: sqlite3-ruby
69
45
  prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *70204562768960
47
+ - !ruby/object:Gem::Dependency
48
+ name: aruba
49
+ requirement: &70204562767460 !ruby/object:Gem::Requirement
71
50
  none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- hash: 3
76
- segments:
77
- - 0
78
- version: "0"
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.3.2
79
55
  type: :development
80
- version_requirements: *id004
81
- - !ruby/object:Gem::Dependency
82
- name: rspec
83
56
  prerelease: false
84
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *70204562767460
58
+ - !ruby/object:Gem::Dependency
59
+ name: bourne
60
+ requirement: &70204562785260 !ruby/object:Gem::Requirement
85
61
  none: false
86
- requirements:
87
- - - ~>
88
- - !ruby/object:Gem::Version
89
- hash: 5
90
- segments:
91
- - 2
92
- - 3
93
- version: "2.3"
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
94
66
  type: :development
95
- version_requirements: *id005
96
- - !ruby/object:Gem::Dependency
97
- name: bourne
98
67
  prerelease: false
99
- requirement: &id006 !ruby/object:Gem::Requirement
68
+ version_requirements: *70204562785260
69
+ - !ruby/object:Gem::Dependency
70
+ name: cucumber
71
+ requirement: &70204574966100 !ruby/object:Gem::Requirement
100
72
  none: false
101
- requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- hash: 3
105
- segments:
106
- - 0
107
- version: "0"
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: 0.10.0
108
77
  type: :development
109
- version_requirements: *id006
110
- - !ruby/object:Gem::Dependency
111
- name: webmock
112
78
  prerelease: false
113
- requirement: &id007 !ruby/object:Gem::Requirement
79
+ version_requirements: *70204574966100
80
+ - !ruby/object:Gem::Dependency
81
+ name: i18n
82
+ requirement: &70204575028840 !ruby/object:Gem::Requirement
114
83
  none: false
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- hash: 3
119
- segments:
120
- - 0
121
- version: "0"
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
122
88
  type: :development
123
- version_requirements: *id007
124
- - !ruby/object:Gem::Dependency
125
- name: rake
126
89
  prerelease: false
127
- requirement: &id008 !ruby/object:Gem::Requirement
90
+ version_requirements: *70204575028840
91
+ - !ruby/object:Gem::Dependency
92
+ name: rails
93
+ requirement: &70204575024560 !ruby/object:Gem::Requirement
128
94
  none: false
129
- requirements:
130
- - - "="
131
- - !ruby/object:Gem::Version
132
- hash: 63
133
- segments:
134
- - 0
135
- - 9
136
- - 2
137
- version: 0.9.2
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: 3.1.0
138
99
  type: :development
139
- version_requirements: *id008
140
- - !ruby/object:Gem::Dependency
141
- name: sham_rack
142
100
  prerelease: false
143
- requirement: &id009 !ruby/object:Gem::Requirement
101
+ version_requirements: *70204575024560
102
+ - !ruby/object:Gem::Dependency
103
+ name: rake
104
+ requirement: &70204575079300 !ruby/object:Gem::Requirement
144
105
  none: false
145
- requirements:
146
- - - ">="
147
- - !ruby/object:Gem::Version
148
- hash: 3
149
- segments:
150
- - 0
151
- version: "0"
106
+ requirements:
107
+ - - =
108
+ - !ruby/object:Gem::Version
109
+ version: 0.9.2
152
110
  type: :development
153
- version_requirements: *id009
154
- - !ruby/object:Gem::Dependency
155
- name: cucumber
156
111
  prerelease: false
157
- requirement: &id010 !ruby/object:Gem::Requirement
112
+ version_requirements: *70204575079300
113
+ - !ruby/object:Gem::Dependency
114
+ name: rspec
115
+ requirement: &70204575077840 !ruby/object:Gem::Requirement
158
116
  none: false
159
- requirements:
117
+ requirements:
160
118
  - - ~>
161
- - !ruby/object:Gem::Version
162
- hash: 55
163
- segments:
164
- - 0
165
- - 10
166
- - 0
167
- version: 0.10.0
119
+ - !ruby/object:Gem::Version
120
+ version: '2.3'
168
121
  type: :development
169
- version_requirements: *id010
170
- - !ruby/object:Gem::Dependency
171
- name: aruba
172
122
  prerelease: false
173
- requirement: &id011 !ruby/object:Gem::Requirement
123
+ version_requirements: *70204575077840
124
+ - !ruby/object:Gem::Dependency
125
+ name: sham_rack
126
+ requirement: &70204575077260 !ruby/object:Gem::Requirement
174
127
  none: false
175
- requirements:
176
- - - ~>
177
- - !ruby/object:Gem::Version
178
- hash: 23
179
- segments:
180
- - 0
181
- - 3
182
- - 2
183
- version: 0.3.2
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
184
132
  type: :development
185
- version_requirements: *id011
186
- - !ruby/object:Gem::Dependency
187
- name: sinatra
188
133
  prerelease: false
189
- requirement: &id012 !ruby/object:Gem::Requirement
134
+ version_requirements: *70204575077260
135
+ - !ruby/object:Gem::Dependency
136
+ name: sinatra
137
+ requirement: &70204575076360 !ruby/object:Gem::Requirement
190
138
  none: false
191
- requirements:
192
- - - ">="
193
- - !ruby/object:Gem::Version
194
- hash: 3
195
- segments:
196
- - 0
197
- version: "0"
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
198
143
  type: :development
199
- version_requirements: *id012
200
- - !ruby/object:Gem::Dependency
201
- name: yard
202
144
  prerelease: false
203
- requirement: &id013 !ruby/object:Gem::Requirement
145
+ version_requirements: *70204575076360
146
+ - !ruby/object:Gem::Dependency
147
+ name: sqlite3-ruby
148
+ requirement: &70204575075680 !ruby/object:Gem::Requirement
204
149
  none: false
205
- requirements:
206
- - - ">="
207
- - !ruby/object:Gem::Version
208
- hash: 3
209
- segments:
210
- - 0
211
- version: "0"
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
212
154
  type: :development
213
- version_requirements: *id013
214
- - !ruby/object:Gem::Dependency
215
- name: thin
216
155
  prerelease: false
217
- requirement: &id014 !ruby/object:Gem::Requirement
156
+ version_requirements: *70204575075680
157
+ - !ruby/object:Gem::Dependency
158
+ name: thin
159
+ requirement: &70204575075060 !ruby/object:Gem::Requirement
218
160
  none: false
219
- requirements:
220
- - - ">="
221
- - !ruby/object:Gem::Version
222
- hash: 3
223
- segments:
224
- - 0
225
- version: "0"
161
+ requirements:
162
+ - - ! '>='
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
226
165
  type: :development
227
- version_requirements: *id014
228
- - !ruby/object:Gem::Dependency
229
- name: i18n
230
166
  prerelease: false
231
- requirement: &id015 !ruby/object:Gem::Requirement
167
+ version_requirements: *70204575075060
168
+ - !ruby/object:Gem::Dependency
169
+ name: webmock
170
+ requirement: &70204575074380 !ruby/object:Gem::Requirement
232
171
  none: false
233
- requirements:
234
- - - ">="
235
- - !ruby/object:Gem::Version
236
- hash: 3
237
- segments:
238
- - 0
239
- version: "0"
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
240
176
  type: :development
241
- version_requirements: *id015
242
- - !ruby/object:Gem::Dependency
243
- name: appraisal
244
177
  prerelease: false
245
- requirement: &id016 !ruby/object:Gem::Requirement
178
+ version_requirements: *70204575074380
179
+ - !ruby/object:Gem::Dependency
180
+ name: yard
181
+ requirement: &70204575073640 !ruby/object:Gem::Requirement
246
182
  none: false
247
- requirements:
248
- - - ~>
249
- - !ruby/object:Gem::Version
250
- hash: 3
251
- segments:
252
- - 0
253
- - 4
254
- version: "0.4"
183
+ requirements:
184
+ - - ! '>='
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
255
187
  type: :development
256
- version_requirements: *id016
188
+ prerelease: false
189
+ version_requirements: *70204575073640
257
190
  description:
258
191
  email: support@thoughtbot.com
259
192
  executables: []
260
-
261
193
  extensions: []
262
-
263
194
  extra_rdoc_files: []
264
-
265
- files:
266
- - .bundle/config
195
+ files:
267
196
  - .gitignore
268
197
  - .rspec
269
- - AddTrustExternalCARoot.crt
198
+ - .travis.yml
270
199
  - Appraisals
271
- - CONTRIBUTING.md
272
200
  - Gemfile
273
201
  - Gemfile.lock
274
202
  - MIT-LICENSE
@@ -323,41 +251,37 @@ files:
323
251
  - spec/support/middleware_stack.rb
324
252
  - spec/support/writing_cache.rb
325
253
  - tmp/projects.json
326
- has_rdoc: true
327
- homepage: http://github.com/thoughtbot/copycopter_client
254
+ homepage: http://github.com/copycopter/copycopter-ruby-client
328
255
  licenses: []
329
-
330
256
  post_install_message:
331
257
  rdoc_options: []
332
-
333
- require_paths:
258
+ require_paths:
334
259
  - lib
335
- required_ruby_version: !ruby/object:Gem::Requirement
260
+ required_ruby_version: !ruby/object:Gem::Requirement
336
261
  none: false
337
- requirements:
338
- - - ">="
339
- - !ruby/object:Gem::Version
340
- hash: 3
341
- segments:
262
+ requirements:
263
+ - - ! '>='
264
+ - !ruby/object:Gem::Version
265
+ version: '0'
266
+ segments:
342
267
  - 0
343
- version: "0"
344
- required_rubygems_version: !ruby/object:Gem::Requirement
268
+ hash: -1148726401025819001
269
+ required_rubygems_version: !ruby/object:Gem::Requirement
345
270
  none: false
346
- requirements:
347
- - - ">="
348
- - !ruby/object:Gem::Version
349
- hash: 3
350
- segments:
271
+ requirements:
272
+ - - ! '>='
273
+ - !ruby/object:Gem::Version
274
+ version: '0'
275
+ segments:
351
276
  - 0
352
- version: "0"
277
+ hash: -1148726401025819001
353
278
  requirements: []
354
-
355
279
  rubyforge_project:
356
- rubygems_version: 1.6.2
280
+ rubygems_version: 1.8.10
357
281
  signing_key:
358
282
  specification_version: 3
359
- summary: Client for the Copycopter content management service
360
- test_files:
283
+ summary: Client for the Copycopter copy management service
284
+ test_files:
361
285
  - features/rails.feature
362
286
  - features/step_definitions/copycopter_server_steps.rb
363
287
  - features/step_definitions/rails_steps.rb