supplejack_client 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f40b6b28bd0108c37c997ef3fd6c0e346e48341
4
- data.tar.gz: 0eb25481a3fdea69d0597739ba2aeb966fc671f8
3
+ metadata.gz: a4dab73234e69432fb7307710644e9334d8390d5
4
+ data.tar.gz: 8e7a12fc595c18b2effeaecc3c7f1dbabc39f886
5
5
  SHA512:
6
- metadata.gz: f4520818d551545b38294f5d157fe6b52caf1af07379cf329e138ab67b674687944305a3503d807e1f9966834e1e9245a4545228071b12ffed50e32d06d9762e
7
- data.tar.gz: 8a72b8a32b0365258c722781db9b52ddcd29705612d7e3a0170f5d1220d6bce9c89b9f5cad4856db6a30de55f4c70f9bd57532aad77cad29634afece752a1d9a
6
+ metadata.gz: 07fdb8b8380510afd16e72e7833f031323e9986ebc6690a643e239b55c2106637d21eafa1f1a032ad32fa901485704eeda8b1685d65abb9007fcc77c76052a7a
7
+ data.tar.gz: 5a36fb4d103c64dab9127e2942c1dcc3e04db2d58432d72a00f40e2cdc88d5b0aacd6a761be84a3224abc059660a3879f1cca3e9995d645652cd2a34e847f821
data/.rubocop.yml ADDED
@@ -0,0 +1,21 @@
1
+ inherit_from: .rubocop_todo.yml
2
+ AllCops:
3
+ Exclude:
4
+ - 'vendor/**/*'
5
+ - 'db/**/*'
6
+ - 'config/**/*'
7
+ - 'script/**/*'
8
+ - 'spec/**/*'
9
+ # Excluded because it's in such a bad state
10
+ - 'lib/supplejack/controllers/helpers.rb'
11
+ - 'lib/supplejack/config.rb'
12
+ DisplayStyleGuide: true
13
+ # prevent bug caused by https://github.com/bbatsov/rubocop/issues/2213 on travis
14
+ # TODO remove
15
+ UseCache: false
16
+ Metrics/LineLength:
17
+ Max: 120
18
+ Metrics/MethodLength:
19
+ Max: 25
20
+ Style/MultilineOperationIndentation:
21
+ Enabled: false
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,506 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2015-09-09 01:57:40 +0000 using RuboCop version 0.34.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: 3
10
+ Lint/AmbiguousOperator:
11
+ Exclude:
12
+ - 'lib/supplejack/config.rb'
13
+ - 'lib/supplejack/item.rb'
14
+ - 'lib/supplejack/user_set.rb'
15
+
16
+ # Offense count: 1
17
+ # Cop supports --auto-correct.
18
+ Lint/BlockAlignment:
19
+ Exclude:
20
+ - 'spec/supplejack/item_spec.rb'
21
+
22
+ # Offense count: 1
23
+ # Cop supports --auto-correct.
24
+ # Configuration parameters: AlignWith, SupportedStyles, AutoCorrect.
25
+ Lint/DefEndAlignment:
26
+ Enabled: false
27
+
28
+ # Offense count: 2
29
+ Lint/DuplicateMethods:
30
+ Exclude:
31
+ - 'lib/supplejack/controllers/helpers.rb'
32
+ - 'lib/supplejack/search.rb'
33
+
34
+ # Offense count: 6
35
+ # Cop supports --auto-correct.
36
+ Lint/StringConversionInInterpolation:
37
+ Exclude:
38
+ - 'lib/supplejack/controllers/helpers.rb'
39
+ - 'lib/supplejack/record.rb'
40
+ - 'lib/supplejack/request.rb'
41
+
42
+ # Offense count: 7
43
+ # Cop supports --auto-correct.
44
+ Lint/UnusedBlockArgument:
45
+ Exclude:
46
+ - 'lib/supplejack/facet.rb'
47
+ - 'lib/supplejack/search.rb'
48
+ - 'lib/supplejack/url_formats/item_hash.rb'
49
+ - 'lib/supplejack/util.rb'
50
+
51
+ # Offense count: 9
52
+ # Cop supports --auto-correct.
53
+ Lint/UnusedMethodArgument:
54
+ Exclude:
55
+ - 'lib/supplejack/item.rb'
56
+ - 'lib/supplejack/record.rb'
57
+ - 'lib/supplejack/search.rb'
58
+ - 'spec/supplejack/search_spec.rb'
59
+
60
+ # Offense count: 11
61
+ Lint/UselessAssignment:
62
+ Exclude:
63
+ - 'lib/supplejack/record.rb'
64
+ - 'lib/supplejack/search.rb'
65
+ - 'lib/supplejack/url_formats/item_hash.rb'
66
+ - 'lib/supplejack/user.rb'
67
+ - 'lib/supplejack/user_set.rb'
68
+ - 'spec/supplejack/user_set_relation_spec.rb'
69
+
70
+ # Offense count: 19
71
+ Metrics/AbcSize:
72
+ Max: 100
73
+
74
+ # Offense count: 3
75
+ # Configuration parameters: CountComments.
76
+ Metrics/ClassLength:
77
+ Max: 211
78
+
79
+ # Offense count: 10
80
+ Metrics/CyclomaticComplexity:
81
+ Max: 25
82
+
83
+ # Offense count: 548
84
+ # Configuration parameters: AllowURI, URISchemes.
85
+ Metrics/LineLength:
86
+ Max: 258
87
+
88
+ # Offense count: 24
89
+ # Configuration parameters: CountComments.
90
+ Metrics/MethodLength:
91
+ Max: 60
92
+
93
+ # Offense count: 9
94
+ # Configuration parameters: CountComments.
95
+ Metrics/ModuleLength:
96
+ Max: 564
97
+
98
+ # Offense count: 3
99
+ # Configuration parameters: CountKeywordArgs.
100
+ Metrics/ParameterLists:
101
+ Max: 6
102
+
103
+ # Offense count: 9
104
+ Metrics/PerceivedComplexity:
105
+ Max: 29
106
+
107
+ # Offense count: 1
108
+ # Cop supports --auto-correct.
109
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
110
+ Style/AccessModifierIndentation:
111
+ Enabled: false
112
+
113
+ # Offense count: 4
114
+ # Cop supports --auto-correct.
115
+ Style/Alias:
116
+ Exclude:
117
+ - 'lib/supplejack/paginated_collection.rb'
118
+
119
+ # Offense count: 3
120
+ # Cop supports --auto-correct.
121
+ # Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
122
+ Style/AlignHash:
123
+ Exclude:
124
+ - 'lib/supplejack/controllers/helpers.rb'
125
+
126
+ # Offense count: 2
127
+ # Cop supports --auto-correct.
128
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
129
+ Style/AndOr:
130
+ Exclude:
131
+ - 'lib/supplejack/controllers/helpers.rb'
132
+ - 'lib/supplejack/url_formats/item_hash.rb'
133
+
134
+ # Offense count: 240
135
+ # Cop supports --auto-correct.
136
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
137
+ Style/BracesAroundHashParameters:
138
+ Enabled: false
139
+
140
+ # Offense count: 3
141
+ # Cop supports --auto-correct.
142
+ Style/DeprecatedHashMethods:
143
+ Exclude:
144
+ - 'lib/supplejack/record.rb'
145
+
146
+ # Offense count: 35
147
+ Style/Documentation:
148
+ Enabled: false
149
+
150
+ # Offense count: 4
151
+ Style/DoubleNegation:
152
+ Exclude:
153
+ - 'lib/supplejack/record.rb'
154
+ - 'lib/supplejack/user.rb'
155
+ - 'lib/supplejack/user_set.rb'
156
+
157
+ # Offense count: 1
158
+ # Cop supports --auto-correct.
159
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
160
+ Style/EmptyElse:
161
+ Exclude:
162
+ - 'lib/supplejack/user_set.rb'
163
+
164
+ # Offense count: 1
165
+ # Cop supports --auto-correct.
166
+ # Configuration parameters: AllowAdjacentOneLineDefs.
167
+ Style/EmptyLineBetweenDefs:
168
+ Exclude:
169
+ - 'lib/supplejack/util.rb'
170
+
171
+ # Offense count: 1
172
+ # Cop supports --auto-correct.
173
+ Style/EmptyLines:
174
+ Exclude:
175
+ - 'lib/supplejack/config.rb'
176
+
177
+ # Offense count: 13
178
+ # Cop supports --auto-correct.
179
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
180
+ Style/EmptyLinesAroundBlockBody:
181
+ Exclude:
182
+ - 'lib/generators/templates/supplejack_client.rb'
183
+ - 'spec/supplejack/controllers/helpers_spec.rb'
184
+ - 'spec/supplejack/item_spec.rb'
185
+ - 'spec/supplejack/record_spec.rb'
186
+ - 'spec/supplejack/request_spec.rb'
187
+ - 'spec/supplejack/search_spec.rb'
188
+ - 'spec/supplejack/url_formats/item_hash_spec.rb'
189
+ - 'spec/supplejack/user_set_relation_spec.rb'
190
+ - 'spec/supplejack/user_spec.rb'
191
+
192
+ # Offense count: 5
193
+ # Cop supports --auto-correct.
194
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
195
+ Style/EmptyLinesAroundClassBody:
196
+ Exclude:
197
+ - 'lib/supplejack/engine.rb'
198
+ - 'lib/supplejack/log_subscriber.rb'
199
+ - 'lib/supplejack/paginated_collection.rb'
200
+ - 'lib/supplejack/user_set_relation.rb'
201
+
202
+ # Offense count: 10
203
+ # Cop supports --auto-correct.
204
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
205
+ Style/EmptyLinesAroundModuleBody:
206
+ Exclude:
207
+ - 'lib/supplejack/config.rb'
208
+ - 'lib/supplejack/controllers/helpers.rb'
209
+ - 'lib/supplejack/item.rb'
210
+ - 'lib/supplejack/item_relation.rb'
211
+ - 'lib/supplejack/record.rb'
212
+ - 'lib/supplejack/request.rb'
213
+ - 'lib/supplejack/user.rb'
214
+ - 'lib/supplejack/user_set.rb'
215
+ - 'lib/supplejack/user_set_relation.rb'
216
+
217
+ # Offense count: 2
218
+ # Cop supports --auto-correct.
219
+ # Configuration parameters: AllowForAlignment.
220
+ Style/ExtraSpacing:
221
+ Exclude:
222
+ - 'Guardfile'
223
+ - 'lib/supplejack/controllers/helpers.rb'
224
+
225
+ # Offense count: 1
226
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
227
+ Style/FormatString:
228
+ Exclude:
229
+ - 'lib/supplejack/log_subscriber.rb'
230
+
231
+ # Offense count: 4
232
+ # Configuration parameters: MinBodyLength.
233
+ Style/GuardClause:
234
+ Exclude:
235
+ - 'lib/supplejack/controllers/helpers.rb'
236
+ - 'lib/supplejack/search.rb'
237
+ - 'spec/supplejack/record_spec.rb'
238
+
239
+ # Offense count: 554
240
+ # Cop supports --auto-correct.
241
+ # Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
242
+ Style/HashSyntax:
243
+ Enabled: false
244
+
245
+ # Offense count: 1
246
+ # Cop supports --auto-correct.
247
+ # Configuration parameters: MaxLineLength.
248
+ Style/IfUnlessModifier:
249
+ Exclude:
250
+ - 'lib/supplejack/record.rb'
251
+
252
+ # Offense count: 6
253
+ # Cop supports --auto-correct.
254
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
255
+ Style/IndentationConsistency:
256
+ Exclude:
257
+ - 'lib/supplejack/request.rb'
258
+
259
+ # Offense count: 6
260
+ # Cop supports --auto-correct.
261
+ # Configuration parameters: Width.
262
+ Style/IndentationWidth:
263
+ Exclude:
264
+ - 'lib/supplejack/request.rb'
265
+ - 'spec/supplejack/item_spec.rb'
266
+ - 'spec/supplejack/search_spec.rb'
267
+
268
+ # Offense count: 1
269
+ # Cop supports --auto-correct.
270
+ Style/LeadingCommentSpace:
271
+ Exclude:
272
+ - 'Rakefile'
273
+
274
+ # Offense count: 1
275
+ # Cop supports --auto-correct.
276
+ Style/MethodCallParentheses:
277
+ Exclude:
278
+ - 'spec/supplejack/url_formats/item_hash_spec.rb'
279
+
280
+ # Offense count: 3
281
+ # Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
282
+ Style/Next:
283
+ Exclude:
284
+ - 'lib/supplejack/controllers/helpers.rb'
285
+ - 'lib/supplejack/record.rb'
286
+ - 'lib/supplejack/search.rb'
287
+
288
+ # Offense count: 4
289
+ # Cop supports --auto-correct.
290
+ Style/NumericLiterals:
291
+ MinDigits: 7
292
+
293
+ # Offense count: 1
294
+ # Cop supports --auto-correct.
295
+ # Configuration parameters: AllowSafeAssignment.
296
+ Style/ParenthesesAroundCondition:
297
+ Exclude:
298
+ - 'lib/supplejack/request.rb'
299
+
300
+ # Offense count: 29
301
+ # Cop supports --auto-correct.
302
+ # Configuration parameters: PreferredDelimiters.
303
+ Style/PercentLiteralDelimiters:
304
+ Exclude:
305
+ - 'spec/supplejack/controllers/helpers_spec.rb'
306
+ - 'spec/supplejack/record_spec.rb'
307
+ - 'spec/supplejack/request_spec.rb'
308
+ - 'supplejack_client.gemspec'
309
+
310
+ # Offense count: 3
311
+ # Cop supports --auto-correct.
312
+ Style/PerlBackrefs:
313
+ Exclude:
314
+ - 'lib/supplejack/search.rb'
315
+ - 'lib/supplejack/url_formats/item_hash.rb'
316
+
317
+ # Offense count: 3
318
+ # Configuration parameters: NamePrefix, NamePrefixBlacklist.
319
+ Style/PredicateName:
320
+ Exclude:
321
+ - 'lib/supplejack/search.rb'
322
+ - 'lib/supplejack/url_formats/item_hash.rb'
323
+ - 'lib/supplejack/user_set.rb'
324
+
325
+ # Offense count: 7
326
+ # Cop supports --auto-correct.
327
+ Style/RedundantBegin:
328
+ Exclude:
329
+ - 'lib/supplejack/item.rb'
330
+ - 'lib/supplejack/user.rb'
331
+ - 'lib/supplejack/user_set.rb'
332
+
333
+ # Offense count: 4
334
+ # Cop supports --auto-correct.
335
+ # Configuration parameters: AllowMultipleReturnValues.
336
+ Style/RedundantReturn:
337
+ Exclude:
338
+ - 'lib/supplejack/item.rb'
339
+ - 'lib/supplejack/search.rb'
340
+ - 'lib/supplejack/url_formats/item_hash.rb'
341
+
342
+ # Offense count: 82
343
+ # Cop supports --auto-correct.
344
+ Style/RedundantSelf:
345
+ Exclude:
346
+ - 'lib/supplejack/item.rb'
347
+ - 'lib/supplejack/item_relation.rb'
348
+ - 'lib/supplejack/record.rb'
349
+ - 'lib/supplejack/search.rb'
350
+ - 'lib/supplejack/url_formats/item_hash.rb'
351
+ - 'lib/supplejack/user.rb'
352
+ - 'lib/supplejack/user_set.rb'
353
+ - 'lib/supplejack/user_set_relation.rb'
354
+ - 'spec/supplejack/record_spec.rb'
355
+
356
+ # Offense count: 1
357
+ # Cop supports --auto-correct.
358
+ # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
359
+ Style/RegexpLiteral:
360
+ Exclude:
361
+ - 'lib/supplejack/controllers/helpers.rb'
362
+
363
+ # Offense count: 9
364
+ # Cop supports --auto-correct.
365
+ Style/RescueModifier:
366
+ Exclude:
367
+ - 'lib/supplejack/controllers/helpers.rb'
368
+ - 'lib/supplejack/item.rb'
369
+ - 'lib/supplejack/record.rb'
370
+ - 'lib/supplejack/request.rb'
371
+ - 'lib/supplejack/search.rb'
372
+ - 'lib/supplejack/url_formats/item_hash.rb'
373
+
374
+ # Offense count: 1
375
+ # Cop supports --auto-correct.
376
+ Style/SelfAssignment:
377
+ Exclude:
378
+ - 'lib/supplejack/facet.rb'
379
+
380
+ # Offense count: 3
381
+ # Cop supports --auto-correct.
382
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
383
+ Style/SignalException:
384
+ Exclude:
385
+ - 'lib/supplejack/record.rb'
386
+
387
+ # Offense count: 4
388
+ # Cop supports --auto-correct.
389
+ Style/SpaceAfterColon:
390
+ Exclude:
391
+ - 'spec/supplejack/request_spec.rb'
392
+
393
+ # Offense count: 20
394
+ # Cop supports --auto-correct.
395
+ Style/SpaceAfterComma:
396
+ Exclude:
397
+ - 'lib/supplejack/facet.rb'
398
+ - 'spec/supplejack/record_spec.rb'
399
+ - 'spec/supplejack/request_spec.rb'
400
+ - 'spec/supplejack/url_formats/item_hash_spec.rb'
401
+ - 'spec/supplejack/user_set_relation_spec.rb'
402
+ - 'spec/supplejack/user_set_spec.rb'
403
+
404
+ # Offense count: 73
405
+ # Cop supports --auto-correct.
406
+ # Configuration parameters: SupportedStyles.
407
+ Style/SpaceAroundEqualsInParameterDefault:
408
+ EnforcedStyle: no_space
409
+
410
+ # Offense count: 19
411
+ # Cop supports --auto-correct.
412
+ # Configuration parameters: MultiSpaceAllowedForOperators.
413
+ Style/SpaceAroundOperators:
414
+ Exclude:
415
+ - 'lib/supplejack/controllers/helpers.rb'
416
+ - 'lib/supplejack/request.rb'
417
+ - 'lib/supplejack/url_formats/item_hash.rb'
418
+ - 'lib/supplejack/user_set.rb'
419
+ - 'spec/supplejack/record_spec.rb'
420
+ - 'spec/supplejack/user_set_relation_spec.rb'
421
+ - 'spec/supplejack/user_spec.rb'
422
+
423
+ # Offense count: 1
424
+ # Cop supports --auto-correct.
425
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
426
+ Style/SpaceBeforeBlockBraces:
427
+ Enabled: false
428
+
429
+ # Offense count: 28
430
+ # Cop supports --auto-correct.
431
+ # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
432
+ Style/SpaceInsideBlockBraces:
433
+ Enabled: false
434
+
435
+ # Offense count: 2
436
+ # Cop supports --auto-correct.
437
+ Style/SpaceInsideBrackets:
438
+ Exclude:
439
+ - 'spec/supplejack/user_set_spec.rb'
440
+
441
+ # Offense count: 1161
442
+ # Cop supports --auto-correct.
443
+ # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
444
+ Style/SpaceInsideHashLiteralBraces:
445
+ Enabled: false
446
+
447
+ # Offense count: 108
448
+ # Cop supports --auto-correct.
449
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
450
+ Style/StringLiterals:
451
+ Enabled: false
452
+
453
+ # Offense count: 6
454
+ # Cop supports --auto-correct.
455
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
456
+ Style/StringLiteralsInInterpolation:
457
+ Enabled: false
458
+
459
+ # Offense count: 1
460
+ # Cop supports --auto-correct.
461
+ # Configuration parameters: IgnoredMethods.
462
+ Style/SymbolProc:
463
+ Exclude:
464
+ - 'lib/supplejack/user_set_relation.rb'
465
+
466
+ # Offense count: 5
467
+ # Cop supports --auto-correct.
468
+ Style/Tab:
469
+ Exclude:
470
+ - 'lib/supplejack/request.rb'
471
+ - 'spec/supplejack/item_spec.rb'
472
+
473
+ # Offense count: 12
474
+ # Cop supports --auto-correct.
475
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
476
+ Style/TrailingBlankLines:
477
+ Exclude:
478
+ - 'Gemfile'
479
+ - 'Guardfile'
480
+ - 'Rakefile'
481
+ - 'lib/generators/supplejack/install_generator.rb'
482
+ - 'lib/supplejack/engine.rb'
483
+ - 'lib/supplejack/search.rb'
484
+ - 'lib/supplejack/util.rb'
485
+ - 'lib/supplejack/version.rb'
486
+ - 'spec/supplejack/item_relation_spec.rb'
487
+ - 'spec/supplejack/item_spec.rb'
488
+ - 'spec/supplejack/record_spec.rb'
489
+ - 'spec/supplejack/search_spec.rb'
490
+
491
+ # Offense count: 138
492
+ # Cop supports --auto-correct.
493
+ Style/TrailingWhitespace:
494
+ Enabled: false
495
+
496
+ # Offense count: 2
497
+ # Cop supports --auto-correct.
498
+ Style/UnneededPercentQ:
499
+ Exclude:
500
+ - 'supplejack_client.gemspec'
501
+
502
+ # Offense count: 24
503
+ # Cop supports --auto-correct.
504
+ # Configuration parameters: WordRegex.
505
+ Style/WordArray:
506
+ MinSize: 4
data/.travis.yml ADDED
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.1.2
5
+ cache: bundler
6
+ bundler_args: --without production
7
+ sudo: false
8
+ script: bundle exec rspec
9
+ addons:
10
+ code_climate:
11
+ repo_token:
12
+ secure: m8cpu/I6W+mlQ9x9qxIZqsCJcrM/CyxwnvlUnSeNyCw2fPdGbj4P0waXVfG13E/xl/P5d+Sb3cz5Pb0e5csDRkO1Q0u+wXHZgTlUldQljleGjox2qhTLdDC+vM7osyTDHxZCbo+nFrimJL1HMwLXwoQT7uOhC6ynltvy5/RHvMc=
13
+ notifications:
14
+ slack:
15
+ secure: g4J7x0H2sPORDxwrXSVc9a7Jh4V3HRePZ0XV0h4CQpToRu/PQlglcqfNtZq94hWaQiM1aztDvb6M+bAj03/7kpE1aGk7bIT9AZTvgjHEqEhhw9td4KhcBKKJ1NWck1efkRNgHVGL+uNaP8jFyG2tDk8iHTfe3ljXaKnS2sZhK1Y=
data/Gemfile CHANGED
@@ -13,4 +13,8 @@ gemspec
13
13
  group :development do
14
14
  gem 'guard'
15
15
  gem 'guard-rspec'
16
- end
16
+ end
17
+
18
+ group :test do
19
+ gem 'simplecov', require: false
20
+ end
data/Guardfile CHANGED
@@ -9,16 +9,16 @@ guard :rspec do
9
9
  # Rails example
10
10
  watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
11
  watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
- watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
12
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) do |m|
13
+ ["spec/routing/#{m[1]}_routing_spec.rb",
14
+ "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb",
15
+ "spec/acceptance/#{m[1]}_spec.rb"]
16
+ end
13
17
  watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
18
  watch('config/routes.rb') { "spec/routing" }
15
19
  watch('app/controllers/application_controller.rb') { "spec/controllers" }
16
20
 
17
21
  # Capybara features specs
18
22
  watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
19
-
20
- # Turnip features and steps
21
- watch(%r{^spec/acceptance/(.+)\.feature$})
22
- watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23
23
  end
24
24
 
@@ -0,0 +1,87 @@
1
+ # The Supplejack Client code is Crown copyright (C) 2014, New Zealand Government,
2
+ # and is licensed under the GNU General Public License, version 3.
3
+ # See https://github.com/DigitalNZ/supplejack_client for details.
4
+ #
5
+ # Supplejack was created by DigitalNZ at the National Library of NZ
6
+ # and the Department of Internal Affairs. http://digitalnz.org/supplejack
7
+
8
+ require 'supplejack/search'
9
+
10
+ module Supplejack
11
+ module Concept
12
+ extend ActiveSupport::Concern
13
+
14
+ attr_accessor :attributes
15
+
16
+ included do
17
+ extend Supplejack::Request
18
+ extend ActiveModel::Naming
19
+ include ActiveModel::Conversion
20
+ end
21
+
22
+ def initialize(attributes={})
23
+ if attributes.is_a?(String)
24
+ attributes = JSON.parse(attributes) rescue {}
25
+ end
26
+ @attributes = attributes.symbolize_keys rescue {}
27
+ end
28
+
29
+ def id
30
+ id = @attributes[:id] || @attributes[:concept_id]
31
+ id.to_i
32
+ end
33
+
34
+ def to_param
35
+ self.id
36
+ end
37
+
38
+ def name
39
+ @attributes[:name].present? ? @attributes[:name] : "Unknown"
40
+ end
41
+
42
+ [:next_page, :previous_page, :next_concept, :previous_concept].each do |pagination_field|
43
+ define_method(pagination_field) do
44
+ @attributes[pagination_field]
45
+ end
46
+ end
47
+
48
+ def persisted?
49
+ true
50
+ end
51
+
52
+ def method_missing(symbol, *args, &block)
53
+ unless @attributes.has_key?(symbol)
54
+ raise NoMethodError, "undefined method '#{symbol.to_s}' for Supplejack::Concept:Module"
55
+ end
56
+ @attributes[symbol]
57
+ end
58
+
59
+ module ClassMethods
60
+
61
+ # Finds a record or array of records from the Supplejack API
62
+ #
63
+ # @params [ Integer ] id an integer representing the id of a concept
64
+ # @params [ Hash ] options Search options used to perform a search in order to get the next/previous
65
+ # concepts within the search results.
66
+ #
67
+ # @return [ Supplejack::Concept ] A concept initialized with the class of where the
68
+ # Supplejack::Concept module was included
69
+ #
70
+ def find(id, options={})
71
+ begin
72
+ # handle malformed id's before requesting anything.
73
+ id = id.to_i
74
+ raise(Supplejack::MalformedRequest, "'#{id}' is not a valid concept id") if id <= 0
75
+
76
+ # This will not work until the Concepts API supports groups properly
77
+ #options = options.merge({fields: 'default'})
78
+
79
+ response = get("/concepts/#{id}", options)
80
+ new(response)
81
+ rescue RestClient::ResourceNotFound => e
82
+ raise Supplejack::ConceptNotFound, "Concept with ID #{id} was not found"
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
@@ -41,6 +41,8 @@ module Supplejack
41
41
  LABEL_TAG = :strong
42
42
  LABEL_CLASS = nil
43
43
  STICKY_FACETS = false
44
+ NON_TEXT_FIELDS = []
45
+
44
46
 
45
47
  VALID_OPTIONS_KEYS = [
46
48
  :api_key,
@@ -65,7 +67,8 @@ module Supplejack
65
67
  :attribute_tag,
66
68
  :label_tag,
67
69
  :label_class,
68
- :sticky_facets
70
+ :sticky_facets,
71
+ :non_text_fields
69
72
  ]
70
73
 
71
74
  SINGLE_VALUE_METHODS = [
@@ -116,6 +119,7 @@ module Supplejack
116
119
  self.attribute_tag = ATTRIBUTE_TAG
117
120
  self.label_tag = LABEL_TAG
118
121
  self.label_class = LABEL_CLASS
122
+ self.non_text_fields = NON_TEXT_FIELDS
119
123
  self
120
124
  end
121
125
  end