action_kit_rest 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MTE1ZjRkMmQxNzE3ZjNhYTk0ZDMwMjg0OGI5OThhODBjMjdiMzBkMQ==
5
- data.tar.gz: !binary |-
6
- YTZjNzQ1N2EwNDg4N2ZiNDYxMTk4YjJlYWM2YTJiZDYzMTUwMjRjMg==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- YjI4YzVlNWM0YzJlNDA1OWFhY2EyNjQ3YjgzZmY5NjUyYmQ4YTM2ZDYzNzQz
10
- NDIwYzBlZGRhMzY1NDNkZWYwZTg2ZjIxZmFmNzk2OGM0ZWVmMWRjMTJkNmFl
11
- M2Y5NjRhMGY3MDk3ZWM0NjgxNWU4MjY2N2Y0YTVmNjBlNjBhMzc=
12
- data.tar.gz: !binary |-
13
- YTdjYzIwODBlYjQ5YWU1M2Y0MzBjN2U1NTFmNzVlYWJkNzRmOWY2NDFiNGYx
14
- ZWFiYjI4YzIyOGExMmIwYmUwM2I2Yzk0MDA1MWNlNzU0NjVhMGViZWFlZTU3
15
- ZDVlMmEwMjA1YmY1M2U2MjcyM2M2YjIyOTU0MDI1NDMzNjEyODM=
2
+ SHA1:
3
+ metadata.gz: eaa557044c4eacef66001a924fbf0cdfd1935a9d
4
+ data.tar.gz: 99d79998adb78f7cf2cd00d1fd3d27edd7623da0
5
+ SHA512:
6
+ metadata.gz: 524a2dfe95d1591ce98cfa809f94a480f919b96c95c74962f97ba5537ceefd00481cde68d8029f12102a11f606f1ce3de0848ffb08c7338a38dcb465519143e4
7
+ data.tar.gz: 4ad684d5709c2f8d3e5216e4ac5c147cab46e0288280e08cddd2324e3a03aed264533cd7404541c0006969818ed63e3af4b1ea6613359130334b6180986c3255
@@ -1,13 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- action_kit_rest (0.1.1)
4
+ action_kit_rest (0.2.0)
5
5
  action_kit_rest
6
+ vertebrae
6
7
 
7
8
  GEM
8
9
  remote: http://rubygems.org/
9
10
  specs:
11
+ activesupport (4.0.0)
12
+ i18n (~> 0.6, >= 0.6.4)
13
+ minitest (~> 4.2)
14
+ multi_json (~> 1.3)
15
+ thread_safe (~> 0.1)
16
+ tzinfo (~> 0.3.37)
10
17
  addressable (2.3.3)
18
+ atomic (1.1.14)
11
19
  builder (3.2.2)
12
20
  coderay (1.0.9)
13
21
  columnize (0.3.6)
@@ -22,6 +30,8 @@ GEM
22
30
  diff-lcs (1.2.1)
23
31
  faraday (0.8.8)
24
32
  multipart-post (~> 1.2.0)
33
+ faraday_middleware (0.9.0)
34
+ faraday (>= 0.7.4, < 0.9)
25
35
  git (1.2.6)
26
36
  github_api (0.10.1)
27
37
  addressable
@@ -42,6 +52,7 @@ GEM
42
52
  hashie (2.0.5)
43
53
  highline (1.6.19)
44
54
  httpauth (0.2.0)
55
+ i18n (0.6.5)
45
56
  jeweler (1.8.7)
46
57
  builder
47
58
  bundler (~> 1.0)
@@ -57,6 +68,7 @@ GEM
57
68
  listen (0.7.3)
58
69
  lumberjack (1.0.2)
59
70
  method_source (0.8.1)
71
+ minitest (4.7.5)
60
72
  multi_json (1.8.0)
61
73
  multi_xml (0.5.5)
62
74
  multipart-post (1.2.0)
@@ -91,6 +103,14 @@ GEM
91
103
  slop (3.4.4)
92
104
  terminal-table (1.4.5)
93
105
  thor (0.17.0)
106
+ thread_safe (0.1.3)
107
+ atomic
108
+ tzinfo (0.3.38)
109
+ vertebrae (0.2.2)
110
+ activesupport
111
+ faraday
112
+ faraday_middleware
113
+ hashie
94
114
  webmock (1.11.0)
95
115
  addressable (>= 2.2.7)
96
116
  crack (>= 0.3.2)
data/README.md CHANGED
@@ -14,6 +14,12 @@ end
14
14
 
15
15
  ```
16
16
 
17
+ With eventmachine:
18
+
19
+ ```ruby
20
+ ak = ActionKitRest.new(host: 'roboticdogs.actionkit.com', username: 'name', password: 'pass', adapter: :em_synchrony)
21
+ ```
22
+
17
23
  This is very experimental still, but starting to be usable.
18
24
 
19
25
  ## Copyright
data/Rakefile CHANGED
@@ -25,6 +25,7 @@ Jeweler::Tasks.new do |gem|
25
25
  gem.email = "woodhull@gmail.com"
26
26
  gem.authors = ["Nathan Woodhull"]
27
27
  # dependencies defined in Gemfile
28
+ gem.add_dependency 'vertebrae'
28
29
  end
29
30
  Jeweler::RubygemsDotOrgTasks.new
30
31
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "action_kit_rest"
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 = ["Nathan Woodhull"]
12
- s.date = "2013-10-03"
12
+ s.date = "2013-10-22"
13
13
  s.description = "Gem for interacting with the ActionKit API"
14
14
  s.email = "woodhull@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -49,6 +49,8 @@ Gem::Specification.new do |s|
49
49
  "spec/action_kit_rest/logger_spec.rb",
50
50
  "spec/action_kit_rest/page_spec.rb",
51
51
  "spec/action_kit_rest/pages/input_page_spec.rb",
52
+ "spec/action_kit_rest/response/collection_spec.rb",
53
+ "spec/action_kit_rest/response/wrapper_spec.rb",
52
54
  "spec/action_kit_rest/user_spec.rb",
53
55
  "spec/fixtures/error.json",
54
56
  "spec/fixtures/page/collection.json",
@@ -77,6 +79,7 @@ Gem::Specification.new do |s|
77
79
  s.add_development_dependency(%q<bundler>, [">= 0"])
78
80
  s.add_development_dependency(%q<webmock>, [">= 0"])
79
81
  s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
82
+ s.add_runtime_dependency(%q<vertebrae>, [">= 0"])
80
83
  else
81
84
  s.add_dependency(%q<action_kit_rest>, [">= 0"])
82
85
  s.add_dependency(%q<rspec>, [">= 0"])
@@ -89,6 +92,7 @@ Gem::Specification.new do |s|
89
92
  s.add_dependency(%q<bundler>, [">= 0"])
90
93
  s.add_dependency(%q<webmock>, [">= 0"])
91
94
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
95
+ s.add_dependency(%q<vertebrae>, [">= 0"])
92
96
  end
93
97
  else
94
98
  s.add_dependency(%q<action_kit_rest>, [">= 0"])
@@ -102,6 +106,7 @@ Gem::Specification.new do |s|
102
106
  s.add_dependency(%q<bundler>, [">= 0"])
103
107
  s.add_dependency(%q<webmock>, [">= 0"])
104
108
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
109
+ s.add_dependency(%q<vertebrae>, [">= 0"])
105
110
  end
106
111
  end
107
112
 
@@ -1,8 +1,8 @@
1
1
  module ActionKitRest
2
2
  module VERSION
3
3
  MAJOR = 0
4
- MINOR = 1
5
- PATCH = 1
4
+ MINOR = 2
5
+ PATCH = 0
6
6
  BUILD = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ActionKitRest::Page do
4
- before(:each) do
5
- @actionkit = ActionKitRest.new(host: 'test.com')
4
+ subject { ActionKitRest.new(host: 'test.com') }
6
5
 
6
+ before(:each) do
7
7
  logger = mock
8
8
  logger.stub(:debug).and_return(true)
9
9
 
@@ -13,11 +13,19 @@ describe ActionKitRest::Page do
13
13
 
14
14
  describe 'configuration' do
15
15
  it 'should propagate the host to the page' do
16
- @actionkit.connection.configuration.host.should == 'test.com'
16
+ subject.connection.configuration.host.should == 'test.com'
17
17
  end
18
18
 
19
19
  it "should have a client" do
20
- @actionkit.page.client.should_not be_nil
20
+ subject.page.client.should_not be_nil
21
+ end
22
+
23
+ describe 'adapter' do
24
+ subject { ActionKitRest.new(host: 'test.com', adapter: :em_synchrony) }
25
+
26
+ it 'should propagate the adapter' do
27
+ subject.connection.configuration.adapter.should == :em_synchrony
28
+ end
21
29
  end
22
30
  end
23
31
 
@@ -34,7 +42,7 @@ describe ActionKitRest::Page do
34
42
  let(:request_path) { 'page/' }
35
43
 
36
44
  it "should allow listing the objects" do
37
- pages = @actionkit.page.list
45
+ pages = subject.page.list
38
46
 
39
47
  pages.should be_an_instance_of(ActionKitRest::Response::Wrapper)
40
48
 
@@ -53,7 +61,7 @@ describe ActionKitRest::Page do
53
61
  describe "success" do
54
62
  let(:status) { 200 }
55
63
  it "should return a single object" do
56
- page = @actionkit.page.get(1)
64
+ page = subject.page.get(1)
57
65
  page.goal.should == 10
58
66
  end
59
67
  end
@@ -62,7 +70,7 @@ describe ActionKitRest::Page do
62
70
  let(:status) { 404 }
63
71
 
64
72
  it "should return nil" do
65
- lambda{ @actionkit.page.get(1).should == nil }.should raise_exception(ActionKitRest::Response::NotFound)
73
+ lambda{ subject.page.get(1).should == nil }.should raise_exception(ActionKitRest::Response::NotFound)
66
74
  end
67
75
  end
68
76
 
@@ -71,7 +79,7 @@ describe ActionKitRest::Page do
71
79
  let(:body) { fixture('error.json') }
72
80
 
73
81
  it "should raise an ak validation response error" do
74
- lambda{ @actionkit.page.get(1) }.should raise_exception(ActionKitRest::Response::ValidationError)
82
+ lambda{ subject.page.get(1) }.should raise_exception(ActionKitRest::Response::ValidationError)
75
83
  end
76
84
  end
77
85
 
@@ -79,7 +87,7 @@ describe ActionKitRest::Page do
79
87
  let(:status) { 500 }
80
88
 
81
89
  it "should return nil" do
82
- lambda{ @actionkit.page.get(1).should == nil }.should raise_exception
90
+ lambda{ subject.page.get(1).should == nil }.should raise_exception
83
91
  end
84
92
  end
85
93
  end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe ActionKitRest::Response::Collection do
4
+ let(:meta) { double() }
5
+ let(:objects) { double() }
6
+ subject { ActionKitRest::Response::Collection.new(meta, objects) }
7
+
8
+ describe 'initialization' do
9
+ it 'should set meta and objects' do
10
+ subject.meta.should == meta
11
+ subject.objects.should == objects
12
+ end
13
+ end
14
+
15
+ describe 'each' do
16
+ let(:item1) { double }
17
+ let(:item2) { double }
18
+ let(:objects) { [ item1, item2 ] }
19
+
20
+ it "should return all collection items" do
21
+ subject.count.should == 2
22
+ subject.any? { |i| i == item1 }
23
+ subject.any? { |i| i == item2 }
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe ActionKitRest::Response::Wrapper do
4
+ describe 'initialization' do
5
+ it "should be kind 'object' for objects" do
6
+ body = double
7
+ response = double(:body => body)
8
+
9
+ wrapper = ActionKitRest::Response::Wrapper.new(response)
10
+
11
+ wrapper.object?.should be_true
12
+ wrapper.collection?.should be_false
13
+ end
14
+
15
+ it "should be kind 'collection' for collections" do
16
+ body = double(:meta => '', :objects => [])
17
+ response = double(:body => body)
18
+
19
+ wrapper = ActionKitRest::Response::Wrapper.new(response)
20
+
21
+ wrapper.object?.should be_false
22
+ wrapper.collection?.should be_true
23
+ end
24
+ end
25
+ end
@@ -12,21 +12,30 @@ describe ActionKitRest::User do
12
12
  end
13
13
 
14
14
 
15
-
16
15
  describe "retrieval" do
16
+ let(:request_path) { 'user/1/' }
17
+
17
18
  before(:each) do
18
19
  stub_get(request_path).to_return(:body => body, :status => status,
19
20
  :headers => {:content_type => "application/json; charset=utf-8"})
20
21
  end
21
22
 
22
23
  describe ".get" do
23
- let(:status) { 200 }
24
24
  let(:body) { fixture('user/object.json') }
25
- let(:request_path) { 'user/1/' }
26
-
25
+ let(:status) { 200 }
26
+
27
27
  it 'should return a user object' do
28
28
  @actionkit.user.get(1).email.should == 'walkers@wawd.com'
29
29
  end
30
30
  end
31
+
32
+ describe 'user not found' do
33
+ let(:body) { '' }
34
+ let(:status) { 404 }
35
+
36
+ it "should raise an exception" do
37
+ expect { @actionkit.user.get(1) }.to raise_error(ActionKitRest::Response::NotFound)
38
+ end
39
+ end
31
40
  end
32
41
  end
metadata CHANGED
@@ -1,153 +1,153 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_kit_rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Woodhull
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-03 00:00:00.000000000 Z
11
+ date: 2013-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: action_kit_rest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: guard
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: guard-rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pry
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: pry-debugger
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ! '>='
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ! '>='
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rb-fsevent
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ! '>='
101
+ - - '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ! '>='
108
+ - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rdoc
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ! '>='
115
+ - - '>='
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ! '>='
122
+ - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: bundler
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ! '>='
129
+ - - '>='
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ! '>='
136
+ - - '>='
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: webmock
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ! '>='
143
+ - - '>='
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ! '>='
150
+ - - '>='
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - ~>
165
165
  - !ruby/object:Gem::Version
166
166
  version: 1.8.4
167
+ - !ruby/object:Gem::Dependency
168
+ name: vertebrae
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '>='
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
167
181
  description: Gem for interacting with the ActionKit API
168
182
  email: woodhull@gmail.com
169
183
  executables: []
@@ -204,6 +218,8 @@ files:
204
218
  - spec/action_kit_rest/logger_spec.rb
205
219
  - spec/action_kit_rest/page_spec.rb
206
220
  - spec/action_kit_rest/pages/input_page_spec.rb
221
+ - spec/action_kit_rest/response/collection_spec.rb
222
+ - spec/action_kit_rest/response/wrapper_spec.rb
207
223
  - spec/action_kit_rest/user_spec.rb
208
224
  - spec/fixtures/error.json
209
225
  - spec/fixtures/page/collection.json
@@ -220,12 +236,12 @@ require_paths:
220
236
  - lib
221
237
  required_ruby_version: !ruby/object:Gem::Requirement
222
238
  requirements:
223
- - - ! '>='
239
+ - - '>='
224
240
  - !ruby/object:Gem::Version
225
241
  version: '0'
226
242
  required_rubygems_version: !ruby/object:Gem::Requirement
227
243
  requirements:
228
- - - ! '>='
244
+ - - '>='
229
245
  - !ruby/object:Gem::Version
230
246
  version: '0'
231
247
  requirements: []