lhs 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.localch.yml +190 -0
- data/.rubocop.yml +7 -0
- data/cider-ci.yml +2 -1
- data/cider-ci/jobs/rspec.yml +48 -0
- data/cider-ci/jobs/rubocop.yml +55 -0
- data/cider-ci/scripts/bundle.yml +2 -0
- data/cider-ci/scripts/github_comment.yml +6 -0
- data/cider-ci/scripts/rspec.yml +4 -0
- data/cider-ci/scripts/rubocop.yml +5 -0
- data/cider-ci/scripts/ruby-version.yml +2 -0
- data/cider-ci/scripts/tmp-cache.yml +2 -0
- data/lhs.gemspec +1 -0
- data/lib/lhs/collection.rb +2 -6
- data/lib/lhs/concerns/data/json.rb +1 -1
- data/lib/lhs/concerns/item/save.rb +11 -10
- data/lib/lhs/concerns/item/update.rb +1 -1
- data/lib/lhs/concerns/item/validation.rb +2 -2
- data/lib/lhs/concerns/record/all.rb +1 -2
- data/lib/lhs/concerns/record/batch.rb +2 -3
- data/lib/lhs/concerns/record/create.rb +7 -8
- data/lib/lhs/concerns/record/endpoints.rb +2 -3
- data/lib/lhs/concerns/record/find.rb +6 -6
- data/lib/lhs/concerns/record/find_by.rb +8 -8
- data/lib/lhs/concerns/record/first.rb +0 -1
- data/lib/lhs/concerns/record/includes.rb +0 -1
- data/lib/lhs/concerns/record/mapping.rb +0 -1
- data/lib/lhs/concerns/record/model.rb +0 -1
- data/lib/lhs/concerns/record/request.rb +18 -14
- data/lib/lhs/concerns/record/where.rb +0 -1
- data/lib/lhs/data.rb +3 -4
- data/lib/lhs/endpoint.rb +1 -2
- data/lib/lhs/errors.rb +7 -13
- data/lib/lhs/item.rb +5 -9
- data/lib/lhs/record.rb +12 -8
- data/lib/lhs/version.rb +1 -1
- data/spec/collection/delegate_spec.rb +0 -2
- data/spec/collection/enumerable_spec.rb +2 -4
- data/spec/collection/meta_data_spec.rb +0 -1
- data/spec/collection/respond_to_spec.rb +0 -1
- data/spec/collection/without_object_items_spec.rb +0 -1
- data/spec/data/collection_spec.rb +4 -7
- data/spec/data/item_spec.rb +3 -5
- data/spec/data/merge_spec.rb +7 -9
- data/spec/data/raw_spec.rb +3 -5
- data/spec/data/respond_to_spec.rb +3 -5
- data/spec/data/root_spec.rb +3 -5
- data/spec/data/select_spec.rb +2 -4
- data/spec/data/to_json_spec.rb +5 -7
- data/spec/dummy/bin/rails +1 -1
- data/spec/dummy/config.ru +1 -1
- data/spec/dummy/config/initializers/cookies_serializer.rb +1 -1
- data/spec/endpoint/for_url_spec.rb +3 -5
- data/spec/item/delegate_spec.rb +0 -2
- data/spec/item/destroy_spec.rb +3 -5
- data/spec/item/errors_spec.rb +20 -23
- data/spec/item/getter_spec.rb +1 -3
- data/spec/item/internal_data_structure_spec.rb +2 -3
- data/spec/item/respond_to_spec.rb +1 -1
- data/spec/item/save_spec.rb +7 -10
- data/spec/item/setter_spec.rb +2 -4
- data/spec/item/update_spec.rb +4 -7
- data/spec/item/validation_spec.rb +7 -9
- data/spec/proxy/load_spec.rb +0 -2
- data/spec/record/all_spec.rb +10 -12
- data/spec/record/build_spec.rb +0 -2
- data/spec/record/create_spec.rb +8 -10
- data/spec/record/creation_failed_spec.rb +4 -6
- data/spec/record/definitions_spec.rb +1 -3
- data/spec/record/endpoint_misconfiguration_spec.rb +2 -4
- data/spec/record/endpoint_options_spec.rb +0 -2
- data/spec/record/endpoints_spec.rb +1 -6
- data/spec/record/find_each_spec.rb +2 -4
- data/spec/record/find_in_batches_spec.rb +4 -6
- data/spec/record/find_spec.rb +10 -13
- data/spec/record/first_spec.rb +0 -3
- data/spec/record/includes_spec.rb +15 -20
- data/spec/record/mapping_spec.rb +13 -15
- data/spec/record/model_name_spec.rb +0 -2
- data/spec/record/new_spec.rb +4 -2
- data/spec/record/request_spec.rb +1 -3
- data/spec/record/where_spec.rb +1 -3
- data/spec/spec_helper.rb +1 -1
- data/spec/support/cleanup_configuration.rb +0 -2
- data/spec/support/cleanup_endpoints.rb +0 -1
- data/spec/support/cleanup_records.rb +0 -2
- metadata +26 -4
- data/cider-ci/contexts/rspec.yml +0 -16
- data/cider-ci/jobs/tests.yml +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef6ba468414f035212c331033b23e589a61052c6
|
4
|
+
data.tar.gz: 6b578fc834f3927e835a050fa62013fcd6d40886
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cf686058b99a28eec867a0f00be09cf92902376bc2932c661260776252bad1a0d60fb9e8e6f7ddd12888e6b7d89b20b485aa3b59d52157e50d96e30e97edeb0
|
7
|
+
data.tar.gz: 87d5662298e7bb7de53345fcb08b2271133f6dc0e7eec93e19ae66ae8003c8af02710852862c1eb4f8b050499f3efb8343bbb1e0f5fe4fc747e7e2361fe04f49
|
@@ -0,0 +1,190 @@
|
|
1
|
+
# This is master rubocop configuration.
|
2
|
+
# DO NOT EDIT THIS FILE - it WILL be overwriten on every config update
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.1
|
5
|
+
DisplayCopNames: true
|
6
|
+
DisplayStyleGuide: true
|
7
|
+
Include:
|
8
|
+
- '**/Rakefile'
|
9
|
+
- '**/config.ru'
|
10
|
+
- '**/Capfile'
|
11
|
+
Exclude:
|
12
|
+
- 'db/**/*'
|
13
|
+
- 'script/**/*'
|
14
|
+
- 'vendor/bundle/**/*'
|
15
|
+
- 'bin/**/*'
|
16
|
+
- 'config/unicorn.rb'
|
17
|
+
- 'config/compass.rb'
|
18
|
+
- 'Rakefile'
|
19
|
+
|
20
|
+
Rails:
|
21
|
+
Enabled: true
|
22
|
+
|
23
|
+
require:
|
24
|
+
- rubocop-rspec
|
25
|
+
|
26
|
+
Lint/HandleExceptions:
|
27
|
+
Exclude:
|
28
|
+
- spec/**/*
|
29
|
+
|
30
|
+
Metrics/LineLength:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
Metrics/AbcSize:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
Metrics/MethodLength:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
Metrics/CyclomaticComplexity:
|
40
|
+
Enabled: false
|
41
|
+
|
42
|
+
Metrics/PerceivedComplexity:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
Metrics/ClassLength:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
Metrics/ModuleLength:
|
49
|
+
Enabled: false
|
50
|
+
|
51
|
+
Metrics/ParameterLists:
|
52
|
+
Enabled: false
|
53
|
+
|
54
|
+
Metrics/BlockNesting:
|
55
|
+
Enabled: false
|
56
|
+
|
57
|
+
Performance/StringReplacement:
|
58
|
+
Enabled: false
|
59
|
+
|
60
|
+
Performance/TimesMap:
|
61
|
+
Enabled: false
|
62
|
+
|
63
|
+
Performance/RedundantBlockCall:
|
64
|
+
Enabled: false
|
65
|
+
|
66
|
+
Performance/RedundantMatch:
|
67
|
+
Enabled: false
|
68
|
+
|
69
|
+
Performance/RedundantMerge:
|
70
|
+
Enabled: false
|
71
|
+
|
72
|
+
Performance/Casecmp:
|
73
|
+
Enabled: false
|
74
|
+
|
75
|
+
Style/MultilineOperationIndentation:
|
76
|
+
EnforcedStyle: indented
|
77
|
+
|
78
|
+
Style/StringLiterals:
|
79
|
+
Enabled: false
|
80
|
+
|
81
|
+
Style/RegexpLiteral:
|
82
|
+
Exclude:
|
83
|
+
- spec/**/*
|
84
|
+
|
85
|
+
Style/DotPosition:
|
86
|
+
EnforcedStyle: leading
|
87
|
+
|
88
|
+
Style/AlignParameters:
|
89
|
+
Enabled: false
|
90
|
+
|
91
|
+
Style/NumericLiterals:
|
92
|
+
Enabled: false
|
93
|
+
|
94
|
+
Style/WordArray:
|
95
|
+
Enabled: false
|
96
|
+
|
97
|
+
Style/EmptyLinesAroundClassBody:
|
98
|
+
Enabled: false
|
99
|
+
|
100
|
+
Style/Next:
|
101
|
+
Enabled: false
|
102
|
+
|
103
|
+
Style/PercentLiteralDelimiters:
|
104
|
+
Enabled: false
|
105
|
+
|
106
|
+
Style/GlobalVars:
|
107
|
+
Enabled: false
|
108
|
+
|
109
|
+
Style/CommentAnnotation:
|
110
|
+
Enabled: false
|
111
|
+
|
112
|
+
Style/SymbolProc:
|
113
|
+
Enabled: false
|
114
|
+
|
115
|
+
Style/DoubleNegation:
|
116
|
+
Enabled: false
|
117
|
+
|
118
|
+
Style/FormatString:
|
119
|
+
Enabled: false
|
120
|
+
|
121
|
+
Style/AsciiComments:
|
122
|
+
Enabled: false
|
123
|
+
|
124
|
+
Style/BarePercentLiterals:
|
125
|
+
Enabled: false
|
126
|
+
|
127
|
+
Style/SingleLineBlockParams:
|
128
|
+
Enabled: false
|
129
|
+
|
130
|
+
Style/MultilineBlockChain:
|
131
|
+
Enabled: false
|
132
|
+
|
133
|
+
Style/UnneededCapitalW:
|
134
|
+
Enabled: false
|
135
|
+
|
136
|
+
Style/UnneededPercentQ:
|
137
|
+
Enabled: false
|
138
|
+
|
139
|
+
Style/BlockDelimiters:
|
140
|
+
Exclude:
|
141
|
+
- spec/**/*
|
142
|
+
|
143
|
+
Style/BracesAroundHashParameters:
|
144
|
+
EnforcedStyle: context_dependent
|
145
|
+
|
146
|
+
Style/IfUnlessModifier:
|
147
|
+
Enabled: false
|
148
|
+
|
149
|
+
Style/ClassAndModuleChildren:
|
150
|
+
Enabled: false
|
151
|
+
|
152
|
+
Style/Documentation:
|
153
|
+
Enabled: false
|
154
|
+
|
155
|
+
Style/GuardClause:
|
156
|
+
Enabled: false
|
157
|
+
|
158
|
+
Style/AccessorMethodName:
|
159
|
+
Exclude:
|
160
|
+
- spec/support/pages/**/*
|
161
|
+
|
162
|
+
Style/NegatedIf:
|
163
|
+
Enabled: false
|
164
|
+
|
165
|
+
Style/MutableConstant:
|
166
|
+
Enabled: false
|
167
|
+
|
168
|
+
Style/ConditionalAssignment:
|
169
|
+
Enabled: false
|
170
|
+
|
171
|
+
Style/IndentArray:
|
172
|
+
EnforcedStyle: consistent
|
173
|
+
|
174
|
+
Style/MultilineMethodCallIndentation:
|
175
|
+
EnforcedStyle: indented
|
176
|
+
|
177
|
+
RSpec/DescribeClass:
|
178
|
+
Exclude:
|
179
|
+
- spec/views/**/*
|
180
|
+
- spec/routing/**/*
|
181
|
+
- spec/requests/**/*
|
182
|
+
- spec/features/**/*
|
183
|
+
|
184
|
+
RSpec/FilePath:
|
185
|
+
Enabled: false
|
186
|
+
|
187
|
+
Rails/Output:
|
188
|
+
Exclude:
|
189
|
+
- 'config/application.rb'
|
190
|
+
- 'config/initializers/asset_manifest_warning.rb'
|
data/.rubocop.yml
ADDED
data/cider-ci.yml
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
rspec:
|
2
|
+
name: 'RSPec tests'
|
3
|
+
|
4
|
+
run-on:
|
5
|
+
- type: branch
|
6
|
+
include-match: ^.*$
|
7
|
+
|
8
|
+
context:
|
9
|
+
task-defaults:
|
10
|
+
ports:
|
11
|
+
CAPYBARA_PORT:
|
12
|
+
inet_address: "localhost"
|
13
|
+
min: 8000
|
14
|
+
max: 8999
|
15
|
+
PHANTOMJS_PORT:
|
16
|
+
inet_address: "localhost"
|
17
|
+
min: 44600
|
18
|
+
max: 44999
|
19
|
+
|
20
|
+
scripts:
|
21
|
+
rspec:
|
22
|
+
start-when:
|
23
|
+
- script: bundle
|
24
|
+
- script: ruby-version
|
25
|
+
- script: tmp-cache
|
26
|
+
|
27
|
+
|
28
|
+
_cider-ci_include:
|
29
|
+
- cider-ci/scripts/bundle.yml
|
30
|
+
- cider-ci/scripts/tmp-cache.yml
|
31
|
+
- cider-ci/scripts/ruby-version.yml
|
32
|
+
- cider-ci/scripts/rspec.yml
|
33
|
+
|
34
|
+
|
35
|
+
trial-attachments:
|
36
|
+
logs:
|
37
|
+
include-match: log\/.*\.log$
|
38
|
+
content-type: text/plain
|
39
|
+
image-screenshots:
|
40
|
+
include-match: tmp\/capybara\/.*\.png$
|
41
|
+
content-type: image/png
|
42
|
+
html-screenshots:
|
43
|
+
include-match: tmp\/capybara\/.*\.html$
|
44
|
+
content-type: text/html
|
45
|
+
|
46
|
+
_cider-ci_generate-tasks:
|
47
|
+
include-match: spec/.*_spec.rb
|
48
|
+
exclude-match: spec/support/shared/*
|
@@ -0,0 +1,55 @@
|
|
1
|
+
rubocop:
|
2
|
+
name: 'Rubocop analysis'
|
3
|
+
|
4
|
+
run-on:
|
5
|
+
- type: branch
|
6
|
+
include-match: ^.*$
|
7
|
+
|
8
|
+
context:
|
9
|
+
task-defaults:
|
10
|
+
environment-variables:
|
11
|
+
GIT_REPOSITORY: local-ch/location-app
|
12
|
+
RESULT_PATH: 'tmp/checkstyle.json'
|
13
|
+
|
14
|
+
scripts:
|
15
|
+
rubocop:
|
16
|
+
start-when:
|
17
|
+
- script: bundle
|
18
|
+
- script: ruby-version
|
19
|
+
- script: tmp-cache
|
20
|
+
|
21
|
+
|
22
|
+
github_comment:
|
23
|
+
start-when:
|
24
|
+
- script: rubocop
|
25
|
+
states: [failed]
|
26
|
+
|
27
|
+
|
28
|
+
_cider-ci_include:
|
29
|
+
- cider-ci/scripts/bundle.yml
|
30
|
+
- cider-ci/scripts/tmp-cache.yml
|
31
|
+
- cider-ci/scripts/ruby-version.yml
|
32
|
+
- cider-ci/scripts/rubocop.yml
|
33
|
+
|
34
|
+
- cider-ci/scripts/github_comment.yml
|
35
|
+
|
36
|
+
|
37
|
+
max-auto-trials: 1
|
38
|
+
|
39
|
+
trial-attachments:
|
40
|
+
logs:
|
41
|
+
include-match: tmp\/checkstyle.json$
|
42
|
+
content-type: application/json
|
43
|
+
|
44
|
+
tree-attachments:
|
45
|
+
logs:
|
46
|
+
include-match: tmp\/checkstyle.json$
|
47
|
+
content-type: application/json
|
48
|
+
|
49
|
+
tasks:
|
50
|
+
rubocop:
|
51
|
+
scripts:
|
52
|
+
rubocop: {}
|
53
|
+
|
54
|
+
github_comment: {}
|
55
|
+
|
data/lhs.gemspec
CHANGED
data/lib/lhs/collection.rb
CHANGED
@@ -28,9 +28,7 @@ class LHS::Collection < LHS::Proxy
|
|
28
28
|
Collection.new(raw, _data, _data._record_class)
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
_data._raw
|
33
|
-
end
|
31
|
+
delegate :_raw, to: :_data
|
34
32
|
|
35
33
|
protected
|
36
34
|
|
@@ -49,8 +47,6 @@ class LHS::Collection < LHS::Proxy
|
|
49
47
|
_collection.respond_to?(name, include_all)
|
50
48
|
end
|
51
49
|
|
52
|
-
private
|
53
|
-
|
54
50
|
# The internal collection class that includes enumerable
|
55
51
|
# and insures to return LHS::Items in case of iterating items
|
56
52
|
class Collection
|
@@ -65,7 +61,7 @@ class LHS::Collection < LHS::Proxy
|
|
65
61
|
@record = record
|
66
62
|
end
|
67
63
|
|
68
|
-
def each(&
|
64
|
+
def each(&_block)
|
69
65
|
raw.each do |item|
|
70
66
|
if item.is_a? Hash
|
71
67
|
yield LHS::Data.new(item, @parent, @record)
|
@@ -8,21 +8,22 @@ class LHS::Item < LHS::Proxy
|
|
8
8
|
|
9
9
|
def save
|
10
10
|
save!
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
rescue LHC::Error => e
|
12
|
+
self.errors = LHS::Errors.new(e.response)
|
13
|
+
false
|
14
14
|
end
|
15
15
|
|
16
16
|
def save!
|
17
17
|
record = _data._root._record_class
|
18
18
|
data = _data._raw.dup
|
19
|
-
url =
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
19
|
+
url =
|
20
|
+
if href.present?
|
21
|
+
href
|
22
|
+
else
|
23
|
+
record.find_endpoint(data).compile(data)
|
24
|
+
end
|
25
|
+
data = record.request(method: :post, url: url, body: data.to_json, headers: { 'Content-Type' => 'application/json' })
|
26
|
+
_data.merge_raw!(data)
|
26
27
|
true
|
27
28
|
end
|
28
29
|
end
|
@@ -16,7 +16,7 @@ class LHS::Item < LHS::Proxy
|
|
16
16
|
method: :post,
|
17
17
|
params: params,
|
18
18
|
body: _data.to_json,
|
19
|
-
headers: {'Content-Type' => 'application/json'}
|
19
|
+
headers: { 'Content-Type' => 'application/json' }
|
20
20
|
)
|
21
21
|
true
|
22
22
|
rescue LHC::Error => e
|
@@ -24,7 +24,7 @@ class LHS::Item < LHS::Proxy
|
|
24
24
|
false
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
alias validate valid?
|
28
28
|
|
29
29
|
private
|
30
30
|
|