grape-roar 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rspec +1 -0
  4. data/.rubocop.yml +6 -2
  5. data/.rubocop_todo.yml +38 -9
  6. data/.travis.yml +29 -3
  7. data/Appraisals +9 -0
  8. data/CHANGELOG.md +10 -0
  9. data/Gemfile +6 -3
  10. data/README.md +218 -0
  11. data/Rakefile +3 -1
  12. data/gemfiles/with_activerecord.gemfile +22 -0
  13. data/gemfiles/with_mongoid.gemfile +22 -0
  14. data/grape-roar.gemspec +3 -0
  15. data/lib/grape-roar.rb +2 -0
  16. data/lib/grape/roar.rb +3 -0
  17. data/lib/grape/roar/decorator.rb +2 -0
  18. data/lib/grape/roar/extensions.rb +3 -0
  19. data/lib/grape/roar/extensions/relations.rb +23 -0
  20. data/lib/grape/roar/extensions/relations/adapters.rb +22 -0
  21. data/lib/grape/roar/extensions/relations/adapters/active_record.rb +35 -0
  22. data/lib/grape/roar/extensions/relations/adapters/base.rb +49 -0
  23. data/lib/grape/roar/extensions/relations/adapters/mongoid.rb +38 -0
  24. data/lib/grape/roar/extensions/relations/dsl_methods.rb +86 -0
  25. data/lib/grape/roar/extensions/relations/exceptions.rb +14 -0
  26. data/lib/grape/roar/extensions/relations/mapper.rb +89 -0
  27. data/lib/grape/roar/extensions/relations/validations.rb +5 -0
  28. data/lib/grape/roar/extensions/relations/validations/active_record.rb +67 -0
  29. data/lib/grape/roar/extensions/relations/validations/misc.rb +18 -0
  30. data/lib/grape/roar/extensions/relations/validations/mongoid.rb +88 -0
  31. data/lib/grape/roar/formatter.rb +2 -0
  32. data/lib/grape/roar/representer.rb +2 -0
  33. data/lib/grape/roar/version.rb +3 -1
  34. data/spec/config/mongoid.yml +6 -0
  35. data/spec/decorator_spec.rb +3 -1
  36. data/spec/extensions/relations/adapters/active_record_spec.rb +26 -0
  37. data/spec/extensions/relations/adapters/adapters_module_spec.rb +11 -0
  38. data/spec/extensions/relations/adapters/mongoid_spec.rb +26 -0
  39. data/spec/extensions/relations/dsl_methods_spec.rb +159 -0
  40. data/spec/extensions/relations/mapper_spec.rb +88 -0
  41. data/spec/extensions/relations/validations/active_record_spec.rb +46 -0
  42. data/spec/extensions/relations/validations/mongoid_spec.rb +88 -0
  43. data/spec/nested_representer_spec.rb +4 -13
  44. data/spec/present_with_spec.rb +3 -12
  45. data/spec/relations_spec.rb +76 -0
  46. data/spec/representer_spec.rb +3 -12
  47. data/spec/spec_helper.rb +15 -1
  48. data/spec/support/{article.rb → all/article.rb} +3 -1
  49. data/spec/support/{article_representer.rb → all/article_representer.rb} +2 -0
  50. data/spec/support/all/grape_app_context.rb +18 -0
  51. data/spec/support/{order.rb → all/order.rb} +3 -1
  52. data/spec/support/{order_representer.rb → all/order_representer.rb} +3 -1
  53. data/spec/support/{product.rb → all/product.rb} +2 -0
  54. data/spec/support/{product_representer.rb → all/product_representer.rb} +3 -1
  55. data/spec/support/{user.rb → all/user.rb} +2 -0
  56. data/spec/support/{user_representer.rb → all/user_representer.rb} +2 -0
  57. data/spec/support/mongoid/relational_models/cart.rb +7 -0
  58. data/spec/support/mongoid/relational_models/item.rb +7 -0
  59. data/spec/support/mongoid/relational_models/mongoid_cart_representer.rb +27 -0
  60. data/spec/support/mongoid/relational_models/mongoid_item_representer.rb +13 -0
  61. metadata +55 -11
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class MongoidItemRepresenter < Grape::Roar::Decorator
4
+ include Roar::JSON
5
+ include Roar::JSON::HAL
6
+ include Roar::Hypermedia
7
+
8
+ include Grape::Roar::Extensions::Relations
9
+
10
+ relation :belongs_to, :cart, embedded: true
11
+
12
+ link_self
13
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-roar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-18 00:00:00.000000000 Z
11
+ date: 2017-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: multi_json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: roar
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -50,6 +64,7 @@ files:
50
64
  - ".rubocop.yml"
51
65
  - ".rubocop_todo.yml"
52
66
  - ".travis.yml"
67
+ - Appraisals
53
68
  - CHANGELOG.md
54
69
  - CONTRIBUTING.md
55
70
  - Gemfile
@@ -58,26 +73,55 @@ files:
58
73
  - RELEASING.md
59
74
  - Rakefile
60
75
  - UPGRADING.md
76
+ - gemfiles/with_activerecord.gemfile
77
+ - gemfiles/with_mongoid.gemfile
61
78
  - grape-roar.gemspec
62
79
  - lib/grape-roar.rb
63
80
  - lib/grape/roar.rb
64
81
  - lib/grape/roar/decorator.rb
82
+ - lib/grape/roar/extensions.rb
83
+ - lib/grape/roar/extensions/relations.rb
84
+ - lib/grape/roar/extensions/relations/adapters.rb
85
+ - lib/grape/roar/extensions/relations/adapters/active_record.rb
86
+ - lib/grape/roar/extensions/relations/adapters/base.rb
87
+ - lib/grape/roar/extensions/relations/adapters/mongoid.rb
88
+ - lib/grape/roar/extensions/relations/dsl_methods.rb
89
+ - lib/grape/roar/extensions/relations/exceptions.rb
90
+ - lib/grape/roar/extensions/relations/mapper.rb
91
+ - lib/grape/roar/extensions/relations/validations.rb
92
+ - lib/grape/roar/extensions/relations/validations/active_record.rb
93
+ - lib/grape/roar/extensions/relations/validations/misc.rb
94
+ - lib/grape/roar/extensions/relations/validations/mongoid.rb
65
95
  - lib/grape/roar/formatter.rb
66
96
  - lib/grape/roar/representer.rb
67
97
  - lib/grape/roar/version.rb
98
+ - spec/config/mongoid.yml
68
99
  - spec/decorator_spec.rb
100
+ - spec/extensions/relations/adapters/active_record_spec.rb
101
+ - spec/extensions/relations/adapters/adapters_module_spec.rb
102
+ - spec/extensions/relations/adapters/mongoid_spec.rb
103
+ - spec/extensions/relations/dsl_methods_spec.rb
104
+ - spec/extensions/relations/mapper_spec.rb
105
+ - spec/extensions/relations/validations/active_record_spec.rb
106
+ - spec/extensions/relations/validations/mongoid_spec.rb
69
107
  - spec/nested_representer_spec.rb
70
108
  - spec/present_with_spec.rb
109
+ - spec/relations_spec.rb
71
110
  - spec/representer_spec.rb
72
111
  - spec/spec_helper.rb
73
- - spec/support/article.rb
74
- - spec/support/article_representer.rb
75
- - spec/support/order.rb
76
- - spec/support/order_representer.rb
77
- - spec/support/product.rb
78
- - spec/support/product_representer.rb
79
- - spec/support/user.rb
80
- - spec/support/user_representer.rb
112
+ - spec/support/all/article.rb
113
+ - spec/support/all/article_representer.rb
114
+ - spec/support/all/grape_app_context.rb
115
+ - spec/support/all/order.rb
116
+ - spec/support/all/order_representer.rb
117
+ - spec/support/all/product.rb
118
+ - spec/support/all/product_representer.rb
119
+ - spec/support/all/user.rb
120
+ - spec/support/all/user_representer.rb
121
+ - spec/support/mongoid/relational_models/cart.rb
122
+ - spec/support/mongoid/relational_models/item.rb
123
+ - spec/support/mongoid/relational_models/mongoid_cart_representer.rb
124
+ - spec/support/mongoid/relational_models/mongoid_item_representer.rb
81
125
  homepage: http://github.com/ruby-grape/grape-roar
82
126
  licenses:
83
127
  - MIT
@@ -98,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
142
  version: '0'
99
143
  requirements: []
100
144
  rubyforge_project:
101
- rubygems_version: 2.5.2
145
+ rubygems_version: 2.6.11
102
146
  signing_key:
103
147
  specification_version: 4
104
148
  summary: Enable Resource-Oriented Architectures in Grape API DSL