riaction 1.2.7 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format doc
2
+ --colour
3
+ --profile
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG #
2
2
 
3
+ ## 1.3.0 ##
4
+
5
+ * Added new feature to have a riaction profile class return the raw json from the IActionable API instead of the objects they get wrapped in by ruby-iactionable gem
6
+
3
7
  ## 1.2.7 ##
4
8
 
5
9
  * Fixed a bug where the event parameters on the instance of class defining multiple events raises an error when one of those events does not point to a valid profile. Now, that event will simply be missing from the returned event parameters. Attempting to log an event that does not point to a valid profile will raise the appropriate error.
@@ -1,30 +1,30 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- riaction (1.2.6)
4
+ riaction (1.2.7)
5
5
  activerecord (>= 3.0.0)
6
6
  activesupport (>= 3.0.0)
7
7
  rake
8
8
  resque
9
- ruby-iactionable (>= 0.0.2)
9
+ ruby-iactionable (>= 0.1.0)
10
10
 
11
11
  GEM
12
12
  remote: http://rubygems.org/
13
13
  specs:
14
- activemodel (3.2.1)
15
- activesupport (= 3.2.1)
14
+ activemodel (3.2.2)
15
+ activesupport (= 3.2.2)
16
16
  builder (~> 3.0.0)
17
- activerecord (3.2.1)
18
- activemodel (= 3.2.1)
19
- activesupport (= 3.2.1)
20
- arel (~> 3.0.0)
17
+ activerecord (3.2.2)
18
+ activemodel (= 3.2.2)
19
+ activesupport (= 3.2.2)
20
+ arel (~> 3.0.2)
21
21
  tzinfo (~> 0.3.29)
22
- activesupport (3.2.1)
22
+ activesupport (3.2.2)
23
23
  i18n (~> 0.6)
24
24
  multi_json (~> 1.0)
25
- addressable (2.2.6)
25
+ addressable (2.2.7)
26
26
  archive-tar-minitar (0.5.2)
27
- arel (3.0.0)
27
+ arel (3.0.2)
28
28
  builder (3.0.0)
29
29
  columnize (0.3.6)
30
30
  diff-lcs (1.1.3)
@@ -37,8 +37,8 @@ GEM
37
37
  i18n (0.6.0)
38
38
  linecache19 (0.5.12)
39
39
  ruby_core_source (>= 0.1.4)
40
- multi_json (1.0.4)
41
- multipart-post (1.1.4)
40
+ multi_json (1.1.0)
41
+ multipart-post (1.1.5)
42
42
  rack (1.4.1)
43
43
  rack-protection (1.2.0)
44
44
  rack
@@ -47,7 +47,7 @@ GEM
47
47
  redis (2.2.2)
48
48
  redis-namespace (1.0.3)
49
49
  redis (< 3.0.0)
50
- resque (1.19.0)
50
+ resque (1.20.0)
51
51
  multi_json (~> 1.0)
52
52
  redis-namespace (~> 1.0.2)
53
53
  sinatra (>= 0.9.2)
@@ -68,7 +68,7 @@ GEM
68
68
  columnize (>= 0.3.1)
69
69
  linecache19 (>= 0.5.11)
70
70
  ruby-debug-base19 (>= 0.11.19)
71
- ruby-iactionable (0.0.2)
71
+ ruby-iactionable (0.1.0)
72
72
  activesupport (>= 3.0.0)
73
73
  faraday
74
74
  faraday-stack
@@ -81,7 +81,7 @@ GEM
81
81
  tilt (~> 1.3, >= 1.3.3)
82
82
  sqlite3 (1.3.5)
83
83
  tilt (1.3.3)
84
- tzinfo (0.3.31)
84
+ tzinfo (0.3.32)
85
85
  vegas (0.1.11)
86
86
  rack (>= 1.0.0)
87
87
  yard (0.7.5)
data/README.md CHANGED
@@ -193,7 +193,7 @@ To process all of the models in your application that declare themselves as prof
193
193
 
194
194
  To run a specific event on all instances off a class that define that event:
195
195
 
196
- rake riaction:rails:process:event['ClassName', :event_name]
196
+ rake riaction:rails:process:event[ClassName, event_name]
197
197
 
198
198
  ----------------
199
199
 
@@ -243,6 +243,11 @@ module Riaction
243
243
  raise RuntimeError.new("#{self.to_s} does not define a profile type #{riaction_use_profile}")
244
244
  end
245
245
 
246
+ def riaction_objectify_response_data(bool)
247
+ @riaction_objectify_response_data = !!bool
248
+ self
249
+ end
250
+
246
251
  #################
247
252
  # API wrappers #
248
253
  #################
@@ -250,7 +255,7 @@ module Riaction
250
255
  def riaction_profile_summary(achievement_count=nil)
251
256
  @iactionable_api ||= IActionable::Api.new
252
257
  keys = riaction_profile_keys.fetch(riaction_use_profile)
253
- @iactionable_api.get_profile_summary(riaction_use_profile.to_s, keys.first[0].to_s, keys.first[1].to_s, achievement_count)
258
+ @iactionable_api.set_object_wrapping(@riaction_objectify_response_data).get_profile_summary(riaction_use_profile.to_s, keys.first[0].to_s, keys.first[1].to_s, achievement_count)
254
259
  rescue KeyError => e
255
260
  raise RuntimeError.new("#{self.to_s} does not define a profile type #{riaction_use_profile}")
256
261
  rescue IActionable::Error::BadRequest => e
@@ -260,7 +265,7 @@ module Riaction
260
265
  def riaction_profile_achievements(filter_type=nil)
261
266
  @iactionable_api ||= IActionable::Api.new
262
267
  keys = riaction_profile_keys.fetch(riaction_use_profile)
263
- @iactionable_api.get_profile_achievements(riaction_use_profile.to_s, keys.first[0].to_s, keys.first[1].to_s, filter_type)
268
+ @iactionable_api.set_object_wrapping(@riaction_objectify_response_data).get_profile_achievements(riaction_use_profile.to_s, keys.first[0].to_s, keys.first[1].to_s, filter_type)
264
269
  rescue KeyError => e
265
270
  raise RuntimeError.new("#{self.to_s} does not define a profile type #{riaction_use_profile}")
266
271
  rescue IActionable::Error::BadRequest => e
@@ -270,7 +275,7 @@ module Riaction
270
275
  def riaction_profile_challenges(filter_type=nil)
271
276
  @iactionable_api ||= IActionable::Api.new
272
277
  keys = riaction_profile_keys.fetch(riaction_use_profile)
273
- @iactionable_api.get_profile_challenges(riaction_use_profile.to_s, keys.first[0].to_s, keys.first[1].to_s, filter_type)
278
+ @iactionable_api.set_object_wrapping(@riaction_objectify_response_data).get_profile_challenges(riaction_use_profile.to_s, keys.first[0].to_s, keys.first[1].to_s, filter_type)
274
279
  rescue KeyError => e
275
280
  raise RuntimeError.new("#{self.to_s} does not define a profile type #{riaction_use_profile}")
276
281
  rescue IActionable::Error::BadRequest => e
@@ -280,7 +285,7 @@ module Riaction
280
285
  def riaction_profile_goals(filter_type=nil)
281
286
  @iactionable_api ||= IActionable::Api.new
282
287
  keys = riaction_profile_keys.fetch(riaction_use_profile)
283
- @iactionable_api.get_profile_goals(riaction_use_profile.to_s, keys.first[0].to_s, keys.first[1].to_s, filter_type)
288
+ @iactionable_api.set_object_wrapping(@riaction_objectify_response_data).get_profile_goals(riaction_use_profile.to_s, keys.first[0].to_s, keys.first[1].to_s, filter_type)
284
289
  rescue KeyError => e
285
290
  raise RuntimeError.new("#{self.to_s} does not define a profile type #{riaction_use_profile}")
286
291
  rescue IActionable::Error::BadRequest => e
@@ -290,7 +295,7 @@ module Riaction
290
295
  def riaction_profile_notifications
291
296
  @iactionable_api ||= IActionable::Api.new
292
297
  keys = riaction_profile_keys.fetch(riaction_use_profile)
293
- @iactionable_api.get_profile_notifications(riaction_use_profile.to_s, keys.first[0].to_s, keys.first[1].to_s)
298
+ @iactionable_api.set_object_wrapping(@riaction_objectify_response_data).get_profile_notifications(riaction_use_profile.to_s, keys.first[0].to_s, keys.first[1].to_s)
294
299
  rescue KeyError => e
295
300
  raise RuntimeError.new("#{self.to_s} does not define a profile type #{riaction_use_profile}")
296
301
  rescue IActionable::Error::BadRequest => e
@@ -300,7 +305,7 @@ module Riaction
300
305
  def riaction_profile_points(point_type)
301
306
  @iactionable_api ||= IActionable::Api.new
302
307
  keys = riaction_profile_keys.fetch(riaction_use_profile)
303
- @iactionable_api.get_profile_points(riaction_use_profile.to_s, keys.first[0].to_s, keys.first[1].to_s, point_type)
308
+ @iactionable_api.set_object_wrapping(@riaction_objectify_response_data).get_profile_points(riaction_use_profile.to_s, keys.first[0].to_s, keys.first[1].to_s, point_type)
304
309
  rescue KeyError => e
305
310
  raise RuntimeError.new("#{self.to_s} does not define a profile type #{riaction_use_profile}")
306
311
  rescue IActionable::Error::BadRequest => e
@@ -1,3 +1,3 @@
1
1
  module Riaction
2
- VERSION = "1.2.7"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -29,5 +29,5 @@ Gem::Specification.new do |s|
29
29
  s.add_runtime_dependency "activerecord", ">= 3.0.0"
30
30
  s.add_runtime_dependency "activesupport", ">= 3.0.0"
31
31
  s.add_runtime_dependency "resque"
32
- s.add_runtime_dependency "ruby-iactionable", ">= 0.0.2"
32
+ s.add_runtime_dependency "ruby-iactionable", ">= 0.1.0"
33
33
  end
@@ -42,6 +42,7 @@ describe "Riaction" do
42
42
  ActiveRecord::Base.connection.begin_db_transaction
43
43
 
44
44
  @api = mock("mocked IActionable API")
45
+ @api.stub(:set_object_wrapping).and_return(@api)
45
46
  IActionable::Api.stub!(:new).and_return(@api)
46
47
  Resque.stub(:enqueue).and_return true
47
48
 
@@ -138,30 +139,77 @@ describe "Riaction" do
138
139
  @user = User.riactionless{ User.create(:name => 'zortnac') }
139
140
  @mock_response = mock("mock API response").as_null_object
140
141
  end
141
-
142
- it "should load a profile through the API with the correct parameters" do
143
- @api.should_receive(:get_profile_summary).once.with("player", "custom", @user.id.to_s, 10).and_return(@mock_response)
144
- @user.riaction_profile_summary(10).should == @mock_response
145
- end
146
142
 
147
- it "should load profile achievments through the API with the correct parameters" do
148
- @api.should_receive(:get_profile_achievements).once.with("player", "custom", @user.id.to_s, nil).and_return(@mock_response)
149
- @user.riaction_profile_achievements.should == @mock_response
150
- end
151
-
152
- it "should load profile challenges through the API with the correct parameters" do
153
- @api.should_receive(:get_profile_challenges).once.with("player", "custom", @user.id.to_s, nil).and_return(@mock_response)
154
- @user.riaction_profile_challenges.should == @mock_response
143
+ describe "when told to return raw JSON from the API" do
144
+ before do
145
+ @user.riaction_objectify_response_data(false)
146
+ end
147
+
148
+ it "should load a profile through the API, set to not wrap the response, with the correct parameters" do
149
+ @api.should_receive(:set_object_wrapping).once.ordered.with(false).and_return(@api)
150
+ @api.should_receive(:get_profile_summary).once.ordered.with("player", "custom", @user.id.to_s, 10).and_return(@mock_response)
151
+ @user.riaction_profile_summary(10).should == @mock_response
152
+ end
153
+
154
+ it "should load profile achievments through the API, set to not wrap the response, with the correct parameters" do
155
+ @api.should_receive(:set_object_wrapping).once.ordered.with(false).and_return(@api)
156
+ @api.should_receive(:get_profile_achievements).once.ordered.with("player", "custom", @user.id.to_s, nil).and_return(@mock_response)
157
+ @user.riaction_profile_achievements.should == @mock_response
158
+ end
159
+
160
+ it "should load profile challenges through the API, set to not wrap the response, with the correct parameters" do
161
+ @api.should_receive(:set_object_wrapping).once.ordered.with(false).and_return(@api)
162
+ @api.should_receive(:get_profile_challenges).once.ordered.with("player", "custom", @user.id.to_s, nil).and_return(@mock_response)
163
+ @user.riaction_profile_challenges.should == @mock_response
164
+ end
165
+
166
+ it "should load profile goals through the API, set to not wrap the response, with the correct parameters" do
167
+ @api.should_receive(:set_object_wrapping).once.ordered.with(false).and_return(@api)
168
+ @api.should_receive(:get_profile_goals).once.ordered.with("player", "custom", @user.id.to_s, nil).and_return(@mock_response)
169
+ @user.riaction_profile_goals.should == @mock_response
170
+ end
171
+
172
+ it "should load profile notifications through the API, set to not wrap the response, with the correct parameters" do
173
+ @api.should_receive(:set_object_wrapping).once.ordered.with(false).and_return(@api)
174
+ @api.should_receive(:get_profile_notifications).once.ordered.with("player", "custom", @user.id.to_s).and_return(@mock_response)
175
+ @user.riaction_profile_notifications.should == @mock_response
176
+ end
155
177
  end
156
178
 
157
- it "should load profile goals through the API with the correct parameters" do
158
- @api.should_receive(:get_profile_goals).once.with("player", "custom", @user.id.to_s, nil).and_return(@mock_response)
159
- @user.riaction_profile_goals.should == @mock_response
160
- end
179
+ describe "when told to return json from the API wrapped as objects" do
180
+ before do
181
+ @user.riaction_objectify_response_data(true)
182
+ end
183
+
184
+ it "should load a profile through the API, set to wrap the response, with the correct parameters" do
185
+ @api.should_receive(:set_object_wrapping).once.ordered.with(true).and_return(@api)
186
+ @api.should_receive(:get_profile_summary).once.ordered.with("player", "custom", @user.id.to_s, 10).and_return(@mock_response)
187
+ @user.riaction_profile_summary(10).should == @mock_response
188
+ end
161
189
 
162
- it "should load profile notifications through the API with the correct parameters" do
163
- @api.should_receive(:get_profile_notifications).once.with("player", "custom", @user.id.to_s).and_return(@mock_response)
164
- @user.riaction_profile_notifications.should == @mock_response
190
+ it "should load profile achievments through the API, set to wrap the response, with the correct parameters" do
191
+ @api.should_receive(:set_object_wrapping).once.ordered.with(true).and_return(@api)
192
+ @api.should_receive(:get_profile_achievements).once.ordered.with("player", "custom", @user.id.to_s, nil).and_return(@mock_response)
193
+ @user.riaction_profile_achievements.should == @mock_response
194
+ end
195
+
196
+ it "should load profile challenges through the API, set to wrap the response, with the correct parameters" do
197
+ @api.should_receive(:set_object_wrapping).once.ordered.with(true).and_return(@api)
198
+ @api.should_receive(:get_profile_challenges).once.ordered.with("player", "custom", @user.id.to_s, nil).and_return(@mock_response)
199
+ @user.riaction_profile_challenges.should == @mock_response
200
+ end
201
+
202
+ it "should load profile goals through the API, set to wrap the response, with the correct parameters" do
203
+ @api.should_receive(:set_object_wrapping).once.ordered.with(true).and_return(@api)
204
+ @api.should_receive(:get_profile_goals).once.ordered.with("player", "custom", @user.id.to_s, nil).and_return(@mock_response)
205
+ @user.riaction_profile_goals.should == @mock_response
206
+ end
207
+
208
+ it "should load profile notifications through the API, set to wrap the response, with the correct parameters" do
209
+ @api.should_receive(:set_object_wrapping).once.ordered.with(true).and_return(@api)
210
+ @api.should_receive(:get_profile_notifications).once.ordered.with("player", "custom", @user.id.to_s).and_return(@mock_response)
211
+ @user.riaction_profile_notifications.should == @mock_response
212
+ end
165
213
  end
166
214
  end
167
215
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riaction
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.7
4
+ version: 1.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-03-08 00:00:00.000000000Z
14
+ date: 2012-03-21 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec
18
- requirement: &2153231060 !ruby/object:Gem::Requirement
18
+ requirement: &2156448140 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: '2.8'
24
24
  type: :development
25
25
  prerelease: false
26
- version_requirements: *2153231060
26
+ version_requirements: *2156448140
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sqlite3
29
- requirement: &2153230620 !ruby/object:Gem::Requirement
29
+ requirement: &2156446940 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
- version_requirements: *2153230620
37
+ version_requirements: *2156446940
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: ruby-debug19
40
- requirement: &2153230160 !ruby/object:Gem::Requirement
40
+ requirement: &2156446200 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ! '>='
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: '0'
46
46
  type: :development
47
47
  prerelease: false
48
- version_requirements: *2153230160
48
+ version_requirements: *2156446200
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: yard
51
- requirement: &2153229740 !ruby/object:Gem::Requirement
51
+ requirement: &2156445320 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ! '>='
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: '0'
57
57
  type: :development
58
58
  prerelease: false
59
- version_requirements: *2153229740
59
+ version_requirements: *2156445320
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: redcarpet
62
- requirement: &2153229320 !ruby/object:Gem::Requirement
62
+ requirement: &2156444300 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ! '>='
@@ -67,10 +67,10 @@ dependencies:
67
67
  version: '0'
68
68
  type: :development
69
69
  prerelease: false
70
- version_requirements: *2153229320
70
+ version_requirements: *2156444300
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: rake
73
- requirement: &2153228860 !ruby/object:Gem::Requirement
73
+ requirement: &2156443200 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ! '>='
@@ -78,10 +78,10 @@ dependencies:
78
78
  version: '0'
79
79
  type: :runtime
80
80
  prerelease: false
81
- version_requirements: *2153228860
81
+ version_requirements: *2156443200
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: activerecord
84
- requirement: &2153228200 !ruby/object:Gem::Requirement
84
+ requirement: &2156441840 !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
87
87
  - - ! '>='
@@ -89,10 +89,10 @@ dependencies:
89
89
  version: 3.0.0
90
90
  type: :runtime
91
91
  prerelease: false
92
- version_requirements: *2153228200
92
+ version_requirements: *2156441840
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: activesupport
95
- requirement: &2153227560 !ruby/object:Gem::Requirement
95
+ requirement: &2156440980 !ruby/object:Gem::Requirement
96
96
  none: false
97
97
  requirements:
98
98
  - - ! '>='
@@ -100,10 +100,10 @@ dependencies:
100
100
  version: 3.0.0
101
101
  type: :runtime
102
102
  prerelease: false
103
- version_requirements: *2153227560
103
+ version_requirements: *2156440980
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: resque
106
- requirement: &2153226980 !ruby/object:Gem::Requirement
106
+ requirement: &2156440340 !ruby/object:Gem::Requirement
107
107
  none: false
108
108
  requirements:
109
109
  - - ! '>='
@@ -111,18 +111,18 @@ dependencies:
111
111
  version: '0'
112
112
  type: :runtime
113
113
  prerelease: false
114
- version_requirements: *2153226980
114
+ version_requirements: *2156440340
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: ruby-iactionable
117
- requirement: &2153226140 !ruby/object:Gem::Requirement
117
+ requirement: &2156439380 !ruby/object:Gem::Requirement
118
118
  none: false
119
119
  requirements:
120
120
  - - ! '>='
121
121
  - !ruby/object:Gem::Version
122
- version: 0.0.2
122
+ version: 0.1.0
123
123
  type: :runtime
124
124
  prerelease: false
125
- version_requirements: *2153226140
125
+ version_requirements: *2156439380
126
126
  description: Wrapper for IActionable's restful API and an "acts-as" style interface
127
127
  for models to behave as profiles and drive game events.
128
128
  email:
@@ -132,6 +132,7 @@ extensions: []
132
132
  extra_rdoc_files: []
133
133
  files:
134
134
  - .gitignore
135
+ - .rspec
135
136
  - .yardoc/checksums
136
137
  - .yardoc/objects/root.dat
137
138
  - .yardoc/proxy_types
@@ -141,7 +142,6 @@ files:
141
142
  - MIT-LICENSE.txt
142
143
  - README.md
143
144
  - Rakefile
144
- - db/riaction.db
145
145
  - doc/Riaction.html
146
146
  - doc/Riaction/ConfigurationError.html
147
147
  - doc/Riaction/Constants.html
@@ -227,3 +227,4 @@ test_files:
227
227
  - spec/profile_creation_spec.rb
228
228
  - spec/riaction_spec.rb
229
229
  - spec/spec_helper.rb
230
+ has_rdoc: