restly 0.0.1.alpha.16 → 0.0.1.alpha.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. data/README.md +2 -112
  2. data/lib/restly.rb +26 -1
  3. data/lib/restly/associations.rb +25 -12
  4. data/lib/restly/associations/base/conditionals.rb +2 -2
  5. data/lib/restly/base.rb +1 -0
  6. data/lib/restly/base/fields.rb +21 -17
  7. data/lib/restly/base/includes.rb +7 -2
  8. data/lib/restly/base/instance.rb +31 -12
  9. data/lib/restly/base/instance/actions.rb +2 -2
  10. data/lib/restly/base/instance/attributes.rb +46 -40
  11. data/lib/restly/base/instance/comparable.rb +13 -0
  12. data/lib/restly/base/instance/error_handling.rb +60 -0
  13. data/lib/restly/base/instance/persistence.rb +1 -1
  14. data/lib/restly/base/resource/specification/fields.rb +2 -2
  15. data/lib/restly/base/resource/specification/mass_assignment_security.rb +1 -1
  16. data/lib/restly/client.rb +20 -7
  17. data/lib/restly/collection.rb +48 -12
  18. data/lib/restly/collection/error_handling.rb +17 -0
  19. data/lib/restly/connection.rb +55 -11
  20. data/lib/restly/error.rb +5 -9
  21. data/lib/restly/middleware.rb +15 -2
  22. data/lib/restly/nested_attributes.rb +29 -23
  23. data/lib/restly/notifications.rb +65 -0
  24. data/lib/restly/version.rb +1 -1
  25. data/spec/restly/active_model_lint_spec.rb +11 -0
  26. data/spec/restly/associations/base/builders_spec.rb +8 -0
  27. data/spec/restly/associations/base/conditionals_spec.rb +8 -0
  28. data/spec/restly/associations/base/loaders_spec.rb +8 -0
  29. data/spec/restly/associations/base/modifiers_spec.rb +8 -0
  30. data/spec/restly/associations/base/stubs_spec.rb +8 -0
  31. data/spec/restly/associations/class_methods.rb +0 -0
  32. data/spec/restly/base/instance/comparable_spec.rb +8 -0
  33. metadata +22 -2
@@ -0,0 +1,65 @@
1
+ require 'colorize'
2
+
3
+ module Restly
4
+ class LogSubscriber < ActiveSupport::LogSubscriber
5
+
6
+ def request(event)
7
+ event.payload[:color] ||= :light_green
8
+ log_items = []
9
+ log_items << event.payload[:name].colorize(event.payload[:color].to_sym)
10
+ log_items << "(#{event.duration.round(1)} ms)"
11
+ log_items << event.payload[:method].to_s.upcase.light_white
12
+ log_items << event.payload[:url].light_white
13
+
14
+ info " " + log_items.join(" ")
15
+ end
16
+
17
+ def cache(event)
18
+ event.payload[:color] ||= :green
19
+ log_items = []
20
+ log_items << event.payload[:name].colorize(event.payload[:color].to_sym)
21
+ log_items << "(#{event.duration.round(1)} ms)"
22
+ log_items << event.payload[:key].light_white
23
+
24
+ info " " + log_items.join(" ")
25
+ end
26
+
27
+ def load_collection(event)
28
+ log_items = []
29
+ log_items << "#{event.payload[:model]} Collection Load".blue
30
+ log_items << "(#{event.duration.round(1)} ms)"
31
+
32
+ info " " + log_items.join(" ")
33
+ end
34
+
35
+ def missing_attribute(event)
36
+ log_items = []
37
+ log_items << " WARNING: Attribute `#{event.payload[:attr]}` not written.".light_black
38
+ log_items << " To fix this add the following the the model -- field :#{event.payload[:attr]}".light_black
39
+
40
+ warn log_items.join("\n")
41
+ end
42
+
43
+ def load_association(event)
44
+ log_items = []
45
+ log_items << "#{event.payload[:model]}##{event.payload[:association]} Association Load".cyan
46
+ log_items << "(#{event.duration.round(1)} ms)"
47
+
48
+ info " " + log_items.join(" ")
49
+ end
50
+
51
+ def load_instance(event)
52
+ log_items = []
53
+ log_items << "#{event.payload[:instance].class.name} Instance Load".blue
54
+ log_items << "(#{event.duration.round(1)} ms)"
55
+
56
+ info " " + log_items.join(" ") if event.payload[:instance].response
57
+ end
58
+
59
+ def logger
60
+ Rails.logger
61
+ end
62
+ end
63
+ end
64
+
65
+ Restly::LogSubscriber.attach_to :restly
@@ -1,3 +1,3 @@
1
1
  module Restly
2
- VERSION = "0.0.1.alpha.16"
2
+ VERSION = "0.0.1.alpha.18"
3
3
  end
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+ require "pry"
3
+
4
+ describe ActiveModel::Lint do
5
+
6
+ include_context "sample_class"
7
+
8
+ it "should have specs"
9
+
10
+
11
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "spec_helper"
3
+
4
+ describe Restly::Associations::Base::Builders do
5
+
6
+ it "should have specs"
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "spec_helper"
3
+
4
+ describe Restly::Associations::Base::Conditionals do
5
+
6
+ it "should have specs"
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "spec_helper"
3
+
4
+ describe Restly::Associations::Base::Loaders do
5
+
6
+ it "should have specs"
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "spec_helper"
3
+
4
+ describe Restly::Associations::Base::Modifiers do
5
+
6
+ it "should have specs"
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "spec_helper"
3
+
4
+ describe Restly::Associations::Base::Stubs do
5
+
6
+ it "should have specs"
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "spec_helper"
3
+
4
+ describe Restly::Base::Instance::Comparable do
5
+
6
+ it "should have specs"
7
+
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.alpha.16
4
+ version: 0.0.1.alpha.18
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-16 00:00:00.000000000 Z
12
+ date: 2012-11-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth2
@@ -191,6 +191,8 @@ files:
191
191
  - lib/restly/base/instance.rb
192
192
  - lib/restly/base/instance/actions.rb
193
193
  - lib/restly/base/instance/attributes.rb
194
+ - lib/restly/base/instance/comparable.rb
195
+ - lib/restly/base/instance/error_handling.rb
194
196
  - lib/restly/base/instance/persistence.rb
195
197
  - lib/restly/base/instance/write_callbacks.rb
196
198
  - lib/restly/base/resource.rb
@@ -201,6 +203,7 @@ files:
201
203
  - lib/restly/base/resource/specification/mass_assignment_security.rb
202
204
  - lib/restly/client.rb
203
205
  - lib/restly/collection.rb
206
+ - lib/restly/collection/error_handling.rb
204
207
  - lib/restly/collection/pagination.rb
205
208
  - lib/restly/concerned_inheritance.rb
206
209
  - lib/restly/configuration.rb
@@ -215,6 +218,7 @@ files:
215
218
  - lib/restly/error.rb
216
219
  - lib/restly/middleware.rb
217
220
  - lib/restly/nested_attributes.rb
221
+ - lib/restly/notifications.rb
218
222
  - lib/restly/proxies.rb
219
223
  - lib/restly/proxies/associations/collection.rb
220
224
  - lib/restly/proxies/associations/instance.rb
@@ -290,8 +294,15 @@ files:
290
294
  - spec/dummy/vendor/assets/javascripts/.gitkeep
291
295
  - spec/dummy/vendor/assets/stylesheets/.gitkeep
292
296
  - spec/dummy/vendor/plugins/.gitkeep
297
+ - spec/restly/active_model_lint_spec.rb
298
+ - spec/restly/associations/base/builders_spec.rb
299
+ - spec/restly/associations/base/conditionals_spec.rb
300
+ - spec/restly/associations/base/loaders_spec.rb
301
+ - spec/restly/associations/base/modifiers_spec.rb
302
+ - spec/restly/associations/base/stubs_spec.rb
293
303
  - spec/restly/associations/base_spec.rb
294
304
  - spec/restly/associations/belongs_to_spec.rb
305
+ - spec/restly/associations/class_methods.rb
295
306
  - spec/restly/associations/has_many_spec.rb
296
307
  - spec/restly/associations/has_one_spec.rb
297
308
  - spec/restly/associations_spec.rb
@@ -300,6 +311,7 @@ files:
300
311
  - spec/restly/base/includes_spec.rb
301
312
  - spec/restly/base/instance/actions_spec.rb
302
313
  - spec/restly/base/instance/attributes_spec.rb
314
+ - spec/restly/base/instance/comparable_spec.rb
303
315
  - spec/restly/base/instance/persistence_spec.rb
304
316
  - spec/restly/base/instance/write_callbacks_spec.rb
305
317
  - spec/restly/base/instance_spec.rb
@@ -423,8 +435,15 @@ test_files:
423
435
  - spec/dummy/vendor/assets/javascripts/.gitkeep
424
436
  - spec/dummy/vendor/assets/stylesheets/.gitkeep
425
437
  - spec/dummy/vendor/plugins/.gitkeep
438
+ - spec/restly/active_model_lint_spec.rb
439
+ - spec/restly/associations/base/builders_spec.rb
440
+ - spec/restly/associations/base/conditionals_spec.rb
441
+ - spec/restly/associations/base/loaders_spec.rb
442
+ - spec/restly/associations/base/modifiers_spec.rb
443
+ - spec/restly/associations/base/stubs_spec.rb
426
444
  - spec/restly/associations/base_spec.rb
427
445
  - spec/restly/associations/belongs_to_spec.rb
446
+ - spec/restly/associations/class_methods.rb
428
447
  - spec/restly/associations/has_many_spec.rb
429
448
  - spec/restly/associations/has_one_spec.rb
430
449
  - spec/restly/associations_spec.rb
@@ -433,6 +452,7 @@ test_files:
433
452
  - spec/restly/base/includes_spec.rb
434
453
  - spec/restly/base/instance/actions_spec.rb
435
454
  - spec/restly/base/instance/attributes_spec.rb
455
+ - spec/restly/base/instance/comparable_spec.rb
436
456
  - spec/restly/base/instance/persistence_spec.rb
437
457
  - spec/restly/base/instance/write_callbacks_spec.rb
438
458
  - spec/restly/base/instance_spec.rb