restorm 1.0.0
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.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.rspec +1 -0
- data/.rubocop.yml +31 -0
- data/.rubocop_todo.yml +232 -0
- data/.ruby-version +1 -0
- data/.travis.yml +55 -0
- data/.yardopts +2 -0
- data/CONTRIBUTING.md +26 -0
- data/Gemfile +10 -0
- data/HER_README.md +1065 -0
- data/LICENSE +7 -0
- data/README.md +7 -0
- data/Rakefile +11 -0
- data/UPGRADE.md +101 -0
- data/gemfiles/Gemfile.activemodel-4.2 +6 -0
- data/gemfiles/Gemfile.activemodel-5.0 +6 -0
- data/gemfiles/Gemfile.activemodel-5.1 +6 -0
- data/gemfiles/Gemfile.activemodel-5.2 +6 -0
- data/gemfiles/Gemfile.faraday-1.0 +6 -0
- data/lib/restorm/api.rb +121 -0
- data/lib/restorm/collection.rb +13 -0
- data/lib/restorm/errors.rb +29 -0
- data/lib/restorm/json_api/model.rb +42 -0
- data/lib/restorm/middleware/accept_json.rb +18 -0
- data/lib/restorm/middleware/first_level_parse_json.rb +37 -0
- data/lib/restorm/middleware/json_api_parser.rb +37 -0
- data/lib/restorm/middleware/parse_json.rb +22 -0
- data/lib/restorm/middleware/second_level_parse_json.rb +37 -0
- data/lib/restorm/middleware.rb +12 -0
- data/lib/restorm/model/associations/association.rb +128 -0
- data/lib/restorm/model/associations/association_proxy.rb +44 -0
- data/lib/restorm/model/associations/belongs_to_association.rb +95 -0
- data/lib/restorm/model/associations/has_many_association.rb +100 -0
- data/lib/restorm/model/associations/has_one_association.rb +79 -0
- data/lib/restorm/model/associations.rb +141 -0
- data/lib/restorm/model/attributes.rb +322 -0
- data/lib/restorm/model/base.rb +33 -0
- data/lib/restorm/model/deprecated_methods.rb +61 -0
- data/lib/restorm/model/http.rb +119 -0
- data/lib/restorm/model/introspection.rb +67 -0
- data/lib/restorm/model/nested_attributes.rb +45 -0
- data/lib/restorm/model/orm.rb +299 -0
- data/lib/restorm/model/parse.rb +223 -0
- data/lib/restorm/model/paths.rb +125 -0
- data/lib/restorm/model/relation.rb +209 -0
- data/lib/restorm/model.rb +75 -0
- data/lib/restorm/version.rb +3 -0
- data/lib/restorm.rb +19 -0
- data/restorm.gemspec +29 -0
- data/spec/api_spec.rb +120 -0
- data/spec/collection_spec.rb +41 -0
- data/spec/json_api/model_spec.rb +169 -0
- data/spec/middleware/accept_json_spec.rb +11 -0
- data/spec/middleware/first_level_parse_json_spec.rb +63 -0
- data/spec/middleware/json_api_parser_spec.rb +52 -0
- data/spec/middleware/second_level_parse_json_spec.rb +35 -0
- data/spec/model/associations/association_proxy_spec.rb +29 -0
- data/spec/model/associations_spec.rb +911 -0
- data/spec/model/attributes_spec.rb +354 -0
- data/spec/model/callbacks_spec.rb +176 -0
- data/spec/model/dirty_spec.rb +133 -0
- data/spec/model/http_spec.rb +201 -0
- data/spec/model/introspection_spec.rb +81 -0
- data/spec/model/nested_attributes_spec.rb +135 -0
- data/spec/model/orm_spec.rb +704 -0
- data/spec/model/parse_spec.rb +520 -0
- data/spec/model/paths_spec.rb +348 -0
- data/spec/model/relation_spec.rb +247 -0
- data/spec/model/validations_spec.rb +43 -0
- data/spec/model_spec.rb +45 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/support/macros/her_macros.rb +17 -0
- data/spec/support/macros/model_macros.rb +36 -0
- data/spec/support/macros/request_macros.rb +27 -0
- metadata +203 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3b0ebf081af188f6503f1edc2064389b6475cde25753ead33e4536ce8d6fbf32
|
4
|
+
data.tar.gz: f2b8d83778dc7e86c19ba59c4998e9b6eeb96f3e9b7376900992395ec34f945a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ece953ed152baafcd1708a5d6eb922d9078e8b16750db1571f9bcadeda9fbeac44bb40171e9319ef8995dd9af8c5990ac0128968412e228df21fe5f40e5accb0
|
7
|
+
data.tar.gz: 9be5c67622f0988bba117e2f0dfc09368698c5476533226058ee629c2ede02f10e8be71d2aaff99b96564d7ac5021a21da2fa982a7fa0fd0bef76cb88ff3919f
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour --format=documentation
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
Layout/CaseIndentation:
|
4
|
+
EnforcedStyle: end
|
5
|
+
|
6
|
+
Layout/EmptyLinesAroundClassBody:
|
7
|
+
EnforcedStyle: beginning_only
|
8
|
+
|
9
|
+
Lint/AmbiguousBlockAssociation:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Lint/AmbiguousOperator:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Lint/AssignmentInCondition:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Naming/UncommunicativeMethodParamName:
|
19
|
+
AllowedNames: io, id, to, by
|
20
|
+
|
21
|
+
Style/AsciiComments:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Style/GuardClause:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
Style/RescueModifier:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Style/SymbolArray:
|
31
|
+
Enabled: false
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,232 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2018-05-16 14:33:11 -0300 using RuboCop version 0.54.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 2
|
10
|
+
# Configuration parameters: Include.
|
11
|
+
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
|
12
|
+
Bundler/DuplicatedGem:
|
13
|
+
Exclude:
|
14
|
+
- 'Gemfile'
|
15
|
+
|
16
|
+
# Offense count: 1
|
17
|
+
Lint/EmptyWhen:
|
18
|
+
Exclude:
|
19
|
+
- 'lib/her/model/parse.rb'
|
20
|
+
|
21
|
+
# Offense count: 1
|
22
|
+
Lint/IneffectiveAccessModifier:
|
23
|
+
Exclude:
|
24
|
+
- 'lib/her/api.rb'
|
25
|
+
|
26
|
+
# Offense count: 6
|
27
|
+
# Cop supports --auto-correct.
|
28
|
+
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
|
29
|
+
Lint/UnusedMethodArgument:
|
30
|
+
Exclude:
|
31
|
+
- 'lib/her/api.rb'
|
32
|
+
- 'lib/her/model/associations/association.rb'
|
33
|
+
- 'lib/her/model/attributes.rb'
|
34
|
+
- 'lib/her/model/orm.rb'
|
35
|
+
- 'spec/model/attributes_spec.rb'
|
36
|
+
|
37
|
+
# Offense count: 1
|
38
|
+
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
|
39
|
+
Lint/UselessAccessModifier:
|
40
|
+
Exclude:
|
41
|
+
- 'lib/her/api.rb'
|
42
|
+
|
43
|
+
# Offense count: 10
|
44
|
+
Metrics/AbcSize:
|
45
|
+
Max: 38
|
46
|
+
|
47
|
+
# Offense count: 91
|
48
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
49
|
+
Metrics/BlockLength:
|
50
|
+
Max: 694
|
51
|
+
|
52
|
+
# Offense count: 4
|
53
|
+
Metrics/CyclomaticComplexity:
|
54
|
+
Max: 12
|
55
|
+
|
56
|
+
# Offense count: 10
|
57
|
+
# Configuration parameters: CountComments.
|
58
|
+
Metrics/MethodLength:
|
59
|
+
Max: 28
|
60
|
+
|
61
|
+
# Offense count: 1
|
62
|
+
# Configuration parameters: CountComments.
|
63
|
+
Metrics/ModuleLength:
|
64
|
+
Max: 106
|
65
|
+
|
66
|
+
# Offense count: 4
|
67
|
+
Metrics/PerceivedComplexity:
|
68
|
+
Max: 12
|
69
|
+
|
70
|
+
# Offense count: 4
|
71
|
+
Naming/MemoizedInstanceVariableName:
|
72
|
+
Exclude:
|
73
|
+
- 'lib/her/model/associations.rb'
|
74
|
+
- 'lib/her/model/attributes.rb'
|
75
|
+
- 'lib/her/model/relation.rb'
|
76
|
+
|
77
|
+
# Offense count: 7
|
78
|
+
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros.
|
79
|
+
# NamePrefix: is_, has_, have_
|
80
|
+
# NamePrefixBlacklist: is_, has_, have_
|
81
|
+
# NameWhitelist: is_a?
|
82
|
+
# MethodDefinitionMacros: define_method, define_singleton_method
|
83
|
+
Naming/PredicateName:
|
84
|
+
Exclude:
|
85
|
+
- 'spec/**/*'
|
86
|
+
- 'lib/her/model/associations.rb'
|
87
|
+
- 'lib/her/model/attributes.rb'
|
88
|
+
- 'lib/her/model/base.rb'
|
89
|
+
- 'lib/her/model/deprecated_methods.rb'
|
90
|
+
|
91
|
+
# Offense count: 1
|
92
|
+
# Cop supports --auto-correct.
|
93
|
+
Performance/RegexpMatch:
|
94
|
+
Exclude:
|
95
|
+
- 'spec/support/macros/model_macros.rb'
|
96
|
+
|
97
|
+
# Offense count: 23
|
98
|
+
Style/Documentation:
|
99
|
+
Enabled: false
|
100
|
+
|
101
|
+
# Offense count: 21
|
102
|
+
# Cop supports --auto-correct.
|
103
|
+
Style/Encoding:
|
104
|
+
Enabled: false
|
105
|
+
|
106
|
+
# Offense count: 2
|
107
|
+
# Cop supports --auto-correct.
|
108
|
+
Style/ExpandPathArguments:
|
109
|
+
Exclude:
|
110
|
+
- 'her.gemspec'
|
111
|
+
- 'spec/spec_helper.rb'
|
112
|
+
|
113
|
+
# Offense count: 59
|
114
|
+
# Cop supports --auto-correct.
|
115
|
+
# Configuration parameters: EnforcedStyle.
|
116
|
+
# SupportedStyles: when_needed, always, never
|
117
|
+
Style/FrozenStringLiteralComment:
|
118
|
+
Enabled: false
|
119
|
+
|
120
|
+
# Offense count: 89
|
121
|
+
# Cop supports --auto-correct.
|
122
|
+
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
123
|
+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
124
|
+
Style/HashSyntax:
|
125
|
+
Enabled: false
|
126
|
+
|
127
|
+
# Offense count: 6
|
128
|
+
# Cop supports --auto-correct.
|
129
|
+
Style/IfUnlessModifier:
|
130
|
+
Exclude:
|
131
|
+
- 'lib/her/json_api/model.rb'
|
132
|
+
- 'lib/her/model/associations/association_proxy.rb'
|
133
|
+
- 'lib/her/model/nested_attributes.rb'
|
134
|
+
- 'lib/her/model/orm.rb'
|
135
|
+
- 'lib/her/model/parse.rb'
|
136
|
+
|
137
|
+
# Offense count: 2
|
138
|
+
Style/MethodMissing:
|
139
|
+
Exclude:
|
140
|
+
- 'lib/her/model/associations/association_proxy.rb'
|
141
|
+
- 'lib/her/model/relation.rb'
|
142
|
+
|
143
|
+
# Offense count: 2
|
144
|
+
# Cop supports --auto-correct.
|
145
|
+
Style/MutableConstant:
|
146
|
+
Exclude:
|
147
|
+
- 'lib/her/model/http.rb'
|
148
|
+
- 'lib/her/version.rb'
|
149
|
+
|
150
|
+
# Offense count: 3
|
151
|
+
# Cop supports --auto-correct.
|
152
|
+
Style/PerlBackrefs:
|
153
|
+
Exclude:
|
154
|
+
- 'lib/her/model/paths.rb'
|
155
|
+
|
156
|
+
# Offense count: 1
|
157
|
+
# Cop supports --auto-correct.
|
158
|
+
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
|
159
|
+
# SupportedStyles: slashes, percent_r, mixed
|
160
|
+
Style/RegexpLiteral:
|
161
|
+
Exclude:
|
162
|
+
- 'lib/her/model/paths.rb'
|
163
|
+
|
164
|
+
# Offense count: 1
|
165
|
+
# Cop supports --auto-correct.
|
166
|
+
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, Whitelist.
|
167
|
+
# Whitelist: present?, blank?, presence, try
|
168
|
+
Style/SafeNavigation:
|
169
|
+
Exclude:
|
170
|
+
- 'spec/model/orm_spec.rb'
|
171
|
+
|
172
|
+
# Offense count: 1
|
173
|
+
# Cop supports --auto-correct.
|
174
|
+
# Configuration parameters: EnforcedStyle.
|
175
|
+
# SupportedStyles: use_perl_names, use_english_names
|
176
|
+
Style/SpecialGlobalVars:
|
177
|
+
Exclude:
|
178
|
+
- 'her.gemspec'
|
179
|
+
|
180
|
+
# Offense count: 1613
|
181
|
+
# Cop supports --auto-correct.
|
182
|
+
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
183
|
+
# SupportedStyles: single_quotes, double_quotes
|
184
|
+
Style/StringLiterals:
|
185
|
+
Enabled: false
|
186
|
+
|
187
|
+
# Offense count: 1
|
188
|
+
# Cop supports --auto-correct.
|
189
|
+
# Configuration parameters: EnforcedStyle.
|
190
|
+
# SupportedStyles: single_quotes, double_quotes
|
191
|
+
Style/StringLiteralsInInterpolation:
|
192
|
+
Exclude:
|
193
|
+
- 'lib/her/model/introspection.rb'
|
194
|
+
|
195
|
+
# Offense count: 1
|
196
|
+
# Cop supports --auto-correct.
|
197
|
+
# Configuration parameters: IgnoredMethods.
|
198
|
+
# IgnoredMethods: respond_to, define_method
|
199
|
+
Style/SymbolProc:
|
200
|
+
Exclude:
|
201
|
+
- 'lib/her/model/parse.rb'
|
202
|
+
|
203
|
+
# Offense count: 2
|
204
|
+
# Cop supports --auto-correct.
|
205
|
+
# Configuration parameters: EnforcedStyle, AllowSafeAssignment.
|
206
|
+
# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex
|
207
|
+
Style/TernaryParentheses:
|
208
|
+
Exclude:
|
209
|
+
- 'lib/her/model/http.rb'
|
210
|
+
- 'lib/her/model/orm.rb'
|
211
|
+
|
212
|
+
# Offense count: 1
|
213
|
+
# Cop supports --auto-correct.
|
214
|
+
# Configuration parameters: EnforcedStyleForMultiline.
|
215
|
+
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
|
216
|
+
Style/TrailingCommaInHashLiteral:
|
217
|
+
Exclude:
|
218
|
+
- 'lib/her/middleware/json_api_parser.rb'
|
219
|
+
|
220
|
+
# Offense count: 6
|
221
|
+
# Cop supports --auto-correct.
|
222
|
+
# Configuration parameters: EnforcedStyle, MinSize, WordRegex.
|
223
|
+
# SupportedStyles: percent, brackets
|
224
|
+
Style/WordArray:
|
225
|
+
Exclude:
|
226
|
+
- 'spec/model/orm_spec.rb'
|
227
|
+
|
228
|
+
# Offense count: 409
|
229
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
230
|
+
# URISchemes: http, https
|
231
|
+
Metrics/LineLength:
|
232
|
+
Max: 377
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.4
|
data/.travis.yml
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
sudo: false
|
4
|
+
|
5
|
+
rvm:
|
6
|
+
- 1.9.3
|
7
|
+
- 2.0.0
|
8
|
+
- 2.1.6
|
9
|
+
- 2.2.10
|
10
|
+
- 2.3.7
|
11
|
+
- 2.4.3
|
12
|
+
- 2.5.1
|
13
|
+
- 2.6.6
|
14
|
+
|
15
|
+
gemfile:
|
16
|
+
- gemfiles/Gemfile.activemodel-4.2
|
17
|
+
- gemfiles/Gemfile.activemodel-5.0
|
18
|
+
- gemfiles/Gemfile.activemodel-5.1
|
19
|
+
- gemfiles/Gemfile.activemodel-5.2
|
20
|
+
- gemfiles/Gemfile.faraday-1.0
|
21
|
+
|
22
|
+
matrix:
|
23
|
+
exclude:
|
24
|
+
- gemfile: gemfiles/Gemfile.activemodel-5.0
|
25
|
+
rvm: 1.9.3
|
26
|
+
- gemfile: gemfiles/Gemfile.activemodel-5.0
|
27
|
+
rvm: 2.0.0
|
28
|
+
- gemfile: gemfiles/Gemfile.activemodel-5.0
|
29
|
+
rvm: 2.1.6
|
30
|
+
- gemfile: gemfiles/Gemfile.activemodel-5.1
|
31
|
+
rvm: 1.9.3
|
32
|
+
- gemfile: gemfiles/Gemfile.activemodel-5.1
|
33
|
+
rvm: 2.0.0
|
34
|
+
- gemfile: gemfiles/Gemfile.activemodel-5.1
|
35
|
+
rvm: 2.1.6
|
36
|
+
- gemfile: gemfiles/Gemfile.activemodel-5.2
|
37
|
+
rvm: 1.9.3
|
38
|
+
- gemfile: gemfiles/Gemfile.activemodel-5.2
|
39
|
+
rvm: 2.0.0
|
40
|
+
- gemfile: gemfiles/Gemfile.activemodel-5.2
|
41
|
+
rvm: 2.1.6
|
42
|
+
- gemfile: gemfiles/Gemfile.faraday-1.0
|
43
|
+
rvm: 1.9.3
|
44
|
+
- gemfile: gemfiles/Gemfile.faraday-1.0
|
45
|
+
rvm: 2.0.0
|
46
|
+
- gemfile: gemfiles/Gemfile.faraday-1.0
|
47
|
+
rvm: 2.1.6
|
48
|
+
- gemfile: gemfiles/Gemfile.faraday-1.0
|
49
|
+
rvm: 2.2.10
|
50
|
+
|
51
|
+
before_install:
|
52
|
+
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
53
|
+
- gem install bundler -v '< 2'
|
54
|
+
|
55
|
+
script: "echo 'COME ON!' && bundle exec rake spec"
|
data/.yardopts
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# How to contribute
|
2
|
+
|
3
|
+
_(This file is heavily based on [factory\_girl\_rails](https://github.com/thoughtbot/factory_girl_rails/blob/master/CONTRIBUTING.md)’s Contribution Guide)_
|
4
|
+
|
5
|
+
We love pull requests. Here’s a quick guide:
|
6
|
+
|
7
|
+
* Fork the repository.
|
8
|
+
* Run `rake spec` (to make sure you start with a clean slate).
|
9
|
+
* Implement your feature or fix.
|
10
|
+
* Add examples that describe it (in the `spec` directory). Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, we need examples!
|
11
|
+
* Make sure `rake spec` passes after your modifications.
|
12
|
+
* Commit (bonus points for doing it in a `feature-*` branch).
|
13
|
+
* Push to your fork and send your pull request!
|
14
|
+
|
15
|
+
If we have not replied to your pull request in three or four days, do not hesitate to post another comment in it — yes, we can be lazy sometimes.
|
16
|
+
|
17
|
+
## Syntax Guide
|
18
|
+
|
19
|
+
Do not hesitate to submit patches that fix syntax issues. Some may have slipped under our nose.
|
20
|
+
|
21
|
+
* Two spaces, no tabs (but you already knew that, right?).
|
22
|
+
* No trailing whitespace. Blank lines should not have any space. There are few things we **hate** more than trailing whitespace. Seriously.
|
23
|
+
* `MyClass.my_method(my_arg)` not `my_method( my_arg )` or `my_method my_arg`.
|
24
|
+
* `[:foo, :bar]` and not `[ :foo, :bar ]`, `{ :foo => :bar }` and not `{:foo => :bar}`
|
25
|
+
* `a = b` and not `a=b`.
|
26
|
+
* Follow the conventions you see used in the source already.
|
data/Gemfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
gemspec
|
3
|
+
|
4
|
+
if RbConfig::CONFIG['RUBY_PROGRAM_VERSION'] && RbConfig::CONFIG['RUBY_PROGRAM_VERSION'] >= '1.9.3'
|
5
|
+
gem 'activemodel', '>= 3.2.0'
|
6
|
+
gem 'activesupport', '>= 3.2.0'
|
7
|
+
else
|
8
|
+
gem 'activemodel', '>= 3.2.0'
|
9
|
+
gem 'activesupport', '>= 3.2.0'
|
10
|
+
end
|