lhs 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.localch.yml +190 -0
  3. data/.rubocop.yml +7 -0
  4. data/cider-ci.yml +2 -1
  5. data/cider-ci/jobs/rspec.yml +48 -0
  6. data/cider-ci/jobs/rubocop.yml +55 -0
  7. data/cider-ci/scripts/bundle.yml +2 -0
  8. data/cider-ci/scripts/github_comment.yml +6 -0
  9. data/cider-ci/scripts/rspec.yml +4 -0
  10. data/cider-ci/scripts/rubocop.yml +5 -0
  11. data/cider-ci/scripts/ruby-version.yml +2 -0
  12. data/cider-ci/scripts/tmp-cache.yml +2 -0
  13. data/lhs.gemspec +1 -0
  14. data/lib/lhs/collection.rb +2 -6
  15. data/lib/lhs/concerns/data/json.rb +1 -1
  16. data/lib/lhs/concerns/item/save.rb +11 -10
  17. data/lib/lhs/concerns/item/update.rb +1 -1
  18. data/lib/lhs/concerns/item/validation.rb +2 -2
  19. data/lib/lhs/concerns/record/all.rb +1 -2
  20. data/lib/lhs/concerns/record/batch.rb +2 -3
  21. data/lib/lhs/concerns/record/create.rb +7 -8
  22. data/lib/lhs/concerns/record/endpoints.rb +2 -3
  23. data/lib/lhs/concerns/record/find.rb +6 -6
  24. data/lib/lhs/concerns/record/find_by.rb +8 -8
  25. data/lib/lhs/concerns/record/first.rb +0 -1
  26. data/lib/lhs/concerns/record/includes.rb +0 -1
  27. data/lib/lhs/concerns/record/mapping.rb +0 -1
  28. data/lib/lhs/concerns/record/model.rb +0 -1
  29. data/lib/lhs/concerns/record/request.rb +18 -14
  30. data/lib/lhs/concerns/record/where.rb +0 -1
  31. data/lib/lhs/data.rb +3 -4
  32. data/lib/lhs/endpoint.rb +1 -2
  33. data/lib/lhs/errors.rb +7 -13
  34. data/lib/lhs/item.rb +5 -9
  35. data/lib/lhs/record.rb +12 -8
  36. data/lib/lhs/version.rb +1 -1
  37. data/spec/collection/delegate_spec.rb +0 -2
  38. data/spec/collection/enumerable_spec.rb +2 -4
  39. data/spec/collection/meta_data_spec.rb +0 -1
  40. data/spec/collection/respond_to_spec.rb +0 -1
  41. data/spec/collection/without_object_items_spec.rb +0 -1
  42. data/spec/data/collection_spec.rb +4 -7
  43. data/spec/data/item_spec.rb +3 -5
  44. data/spec/data/merge_spec.rb +7 -9
  45. data/spec/data/raw_spec.rb +3 -5
  46. data/spec/data/respond_to_spec.rb +3 -5
  47. data/spec/data/root_spec.rb +3 -5
  48. data/spec/data/select_spec.rb +2 -4
  49. data/spec/data/to_json_spec.rb +5 -7
  50. data/spec/dummy/bin/rails +1 -1
  51. data/spec/dummy/config.ru +1 -1
  52. data/spec/dummy/config/initializers/cookies_serializer.rb +1 -1
  53. data/spec/endpoint/for_url_spec.rb +3 -5
  54. data/spec/item/delegate_spec.rb +0 -2
  55. data/spec/item/destroy_spec.rb +3 -5
  56. data/spec/item/errors_spec.rb +20 -23
  57. data/spec/item/getter_spec.rb +1 -3
  58. data/spec/item/internal_data_structure_spec.rb +2 -3
  59. data/spec/item/respond_to_spec.rb +1 -1
  60. data/spec/item/save_spec.rb +7 -10
  61. data/spec/item/setter_spec.rb +2 -4
  62. data/spec/item/update_spec.rb +4 -7
  63. data/spec/item/validation_spec.rb +7 -9
  64. data/spec/proxy/load_spec.rb +0 -2
  65. data/spec/record/all_spec.rb +10 -12
  66. data/spec/record/build_spec.rb +0 -2
  67. data/spec/record/create_spec.rb +8 -10
  68. data/spec/record/creation_failed_spec.rb +4 -6
  69. data/spec/record/definitions_spec.rb +1 -3
  70. data/spec/record/endpoint_misconfiguration_spec.rb +2 -4
  71. data/spec/record/endpoint_options_spec.rb +0 -2
  72. data/spec/record/endpoints_spec.rb +1 -6
  73. data/spec/record/find_each_spec.rb +2 -4
  74. data/spec/record/find_in_batches_spec.rb +4 -6
  75. data/spec/record/find_spec.rb +10 -13
  76. data/spec/record/first_spec.rb +0 -3
  77. data/spec/record/includes_spec.rb +15 -20
  78. data/spec/record/mapping_spec.rb +13 -15
  79. data/spec/record/model_name_spec.rb +0 -2
  80. data/spec/record/new_spec.rb +4 -2
  81. data/spec/record/request_spec.rb +1 -3
  82. data/spec/record/where_spec.rb +1 -3
  83. data/spec/spec_helper.rb +1 -1
  84. data/spec/support/cleanup_configuration.rb +0 -2
  85. data/spec/support/cleanup_endpoints.rb +0 -1
  86. data/spec/support/cleanup_records.rb +0 -2
  87. metadata +26 -4
  88. data/cider-ci/contexts/rspec.yml +0 -16
  89. data/cider-ci/jobs/tests.yml +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23beb0804ec8b041eaa4e920e395a5d9b2bf394f
4
- data.tar.gz: 3329ba17fc8d206210d143a8b8ad4aae09561316
3
+ metadata.gz: ef6ba468414f035212c331033b23e589a61052c6
4
+ data.tar.gz: 6b578fc834f3927e835a050fa62013fcd6d40886
5
5
  SHA512:
6
- metadata.gz: 451e95f0aa50d9f41eedd21f7339f36904d146f36c3ca880effe675f5b9b7c6a6198592e4a4d6e2c284a10fadbe4b7aa8a96b3f1e60748fae1988bc4e805f788
7
- data.tar.gz: df8f2a78480a2ead8098c786e04f620e6541420c78803adaf2ee2524c31274a2ddd756d6dd4b7309d08c76cacea9bda907c797a1b6a346e3c2ecdf59a04ae45b
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'
@@ -0,0 +1,7 @@
1
+ # This is project specific rubocop configuration file.
2
+ # You can tweak project settings here
3
+ inherit_from:
4
+ - ./.rubocop.localch.yml
5
+
6
+ Lint/IneffectiveAccessModifier:
7
+ Enabled: false
@@ -1,3 +1,4 @@
1
1
  jobs:
2
2
  _cider-ci_include:
3
- - cider-ci/jobs/tests.yml
3
+ - cider-ci/jobs/rubocop.yml
4
+ - cider-ci/jobs/rspec.yml
@@ -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
+
@@ -0,0 +1,2 @@
1
+ bundle:
2
+ body: sed 's/^source.*/source "http\:\/\/52.29.7.59:9292"/g' Gemfile > Gemfile.tmp ; mv Gemfile.tmp Gemfile && bundle install
@@ -0,0 +1,6 @@
1
+ github_comment:
2
+ ignore-state: true
3
+ body: |
4
+ #!/usr/bin/env bash
5
+
6
+ bundle exec rake checkstyle
@@ -0,0 +1,4 @@
1
+ rspec:
2
+ body: |
3
+ #!/usr/bin/env bash
4
+ bundle exec rspec $CIDER_CI_TASK_FILE
@@ -0,0 +1,5 @@
1
+ rubocop:
2
+ body: |
3
+ #!/usr/bin/env bash
4
+
5
+ bundle exec rubocop --config .rubocop.yml --format json --out $RESULT_PATH --format progress
@@ -0,0 +1,2 @@
1
+ ruby-version:
2
+ body: ruby --version
@@ -0,0 +1,2 @@
1
+ tmp-cache:
2
+ body: mkdir -p tmp/cache
@@ -28,4 +28,5 @@ Gem::Specification.new do |s|
28
28
  s.add_development_dependency 'webmock'
29
29
  s.add_development_dependency 'geminabox'
30
30
  s.add_development_dependency 'pry'
31
+ s.add_development_dependency 'ciderizer'
31
32
  end
@@ -28,9 +28,7 @@ class LHS::Collection < LHS::Proxy
28
28
  Collection.new(raw, _data, _data._record_class)
29
29
  end
30
30
 
31
- def _raw
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(&block)
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)
@@ -5,7 +5,7 @@ class LHS::Data
5
5
  module Json
6
6
  extend ActiveSupport::Concern
7
7
 
8
- def as_json(options = {})
8
+ def as_json(_options = {})
9
9
  _data._raw.as_json
10
10
  end
11
11
  end
@@ -8,21 +8,22 @@ class LHS::Item < LHS::Proxy
8
8
 
9
9
  def save
10
10
  save!
11
- rescue LHC::Error => e
12
- self.errors = LHS::Errors.new(e.response)
13
- false
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 = if href.present?
20
- href
21
- else
22
- record.find_endpoint(data).compile(data)
23
- end
24
- data = record.request(method: :post, url: url, body: data.to_json, headers: {'Content-Type' => 'application/json'})
25
- self._data.merge_raw!(data)
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
@@ -20,7 +20,7 @@ class LHS::Item < LHS::Proxy
20
20
  method: :post,
21
21
  url: href,
22
22
  body: _data.to_json,
23
- headers: {'Content-Type' => 'application/json'}
23
+ headers: { 'Content-Type' => 'application/json' }
24
24
  )
25
25
  _data.merge_raw!(response_data)
26
26
  true
@@ -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
- alias_method :validate, :valid?
27
+ alias validate valid?
28
28
 
29
29
  private
30
30