hotchoc 0.2.1 → 0.3.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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-gemset +1 -0
  3. data/.ruby-version +1 -0
  4. data/CHANGELOG.md +9 -0
  5. data/LICENSE.md +1 -1
  6. data/README.md +3 -2
  7. data/Rakefile +3 -8
  8. data/hotchoc.gemspec +5 -4
  9. data/lib/hotchoc/client/api.rb +21 -0
  10. data/lib/hotchoc/client/configuration.rb +37 -0
  11. data/lib/hotchoc/client/errors.rb +12 -0
  12. data/lib/hotchoc/client/fetcher.rb +44 -0
  13. data/lib/hotchoc/client/version.rb +5 -0
  14. data/lib/hotchoc/client.rb +4 -4
  15. data/lib/hotchoc/presenters/album.rb +0 -4
  16. data/lib/hotchoc/presenters/base.rb +0 -4
  17. data/lib/hotchoc/presenters/blocks/base.rb +0 -4
  18. data/lib/hotchoc/presenters/blocks/image.rb +0 -4
  19. data/lib/hotchoc/presenters/blocks/text.rb +0 -4
  20. data/lib/hotchoc/presenters/file.rb +1 -5
  21. data/lib/hotchoc/presenters/page.rb +0 -4
  22. data/lib/hotchoc/presenters/post.rb +0 -4
  23. data/lib/hotchoc/presenters/thumbnail.rb +0 -4
  24. data/lib/hotchoc/presenters/topic.rb +0 -4
  25. data/lib/hotchoc.rb +6 -6
  26. data/spec/hotchoc/{api_spec.rb → client/api_spec.rb} +7 -12
  27. data/spec/hotchoc/client/configuration_spec.rb +15 -0
  28. data/spec/hotchoc/{main_spec.rb → client/main_spec.rb} +1 -2
  29. data/spec/hotchoc/client_spec.rb +1 -2
  30. data/spec/hotchoc/presenters/album_spec.rb +0 -2
  31. data/spec/hotchoc/presenters/blocks/image_spec.rb +0 -2
  32. data/spec/hotchoc/presenters/blocks/text_spec.rb +0 -2
  33. data/spec/hotchoc/presenters/file_spec.rb +0 -2
  34. data/spec/hotchoc/presenters/page_spec.rb +0 -2
  35. data/spec/hotchoc/presenters/post_spec.rb +0 -2
  36. data/spec/hotchoc/presenters/thumbnail_spec.rb +0 -2
  37. data/spec/hotchoc/presenters/topic_spec.rb +0 -2
  38. data/spec/support/stubs.rb +0 -2
  39. metadata +31 -30
  40. data/.rubocop.yml +0 -558
  41. data/lib/hotchoc/api.rb +0 -21
  42. data/lib/hotchoc/configuration.rb +0 -36
  43. data/lib/hotchoc/errors.rb +0 -12
  44. data/lib/hotchoc/fetcher.rb +0 -35
  45. data/lib/hotchoc/version.rb +0 -3
  46. data/spec/hotchoc/configuration_spec.rb +0 -16
data/.rubocop.yml DELETED
@@ -1,558 +0,0 @@
1
- AllCops:
2
- RunRailsCops: true
3
-
4
-
5
- Style/AccessModifierIndentation:
6
- Enabled: true
7
- EnforcedStyle: indent
8
-
9
- Style/AccessorMethodName:
10
- Enabled: false
11
-
12
- Style/Alias:
13
- Enabled: true
14
-
15
- Style/AlignArray:
16
- Enabled: true
17
-
18
- Style/AlignHash:
19
- Enabled: false
20
- EnforcedLastArgumentHashStyle: always_ignore
21
-
22
- Style/AlignParameters:
23
- Enabled: false
24
-
25
- Style/AndOr:
26
- Enabled: false
27
-
28
- Style/ArrayJoin:
29
- Enabled: true
30
-
31
- Style/AsciiComments:
32
- Enabled: true
33
-
34
- Style/AsciiIdentifiers:
35
- Enabled: true
36
-
37
- Style/Attr:
38
- Enabled: false
39
-
40
- Style/BeginBlock:
41
- Enabled: false
42
-
43
- Style/BlockComments:
44
- Enabled: false
45
-
46
- Style/BlockNesting:
47
- Enabled: false
48
-
49
- Style/Blocks:
50
- Enabled: false
51
-
52
- Style/BracesAroundHashParameters:
53
- Enabled: false
54
-
55
- Style/CaseEquality:
56
- Enabled: true
57
-
58
- Style/CaseIndentation:
59
- Enabled: true
60
-
61
- Style/CharacterLiteral:
62
- Enabled: false
63
-
64
- Style/ClassAndModuleCamelCase:
65
- Enabled: true
66
-
67
- Style/ClassAndModuleChildren:
68
- Enabled: false
69
-
70
- Style/ClassCheck:
71
- Enabled: true
72
-
73
- Style/ClassLength:
74
- Enabled: false
75
-
76
- Style/ClassMethods:
77
- Enabled: false
78
-
79
- Style/ClassVars:
80
- Enabled: false
81
-
82
- Style/CollectionMethods:
83
- Enabled: false
84
-
85
- Style/ColonMethodCall:
86
- Enabled: false
87
-
88
- Style/CommentAnnotation:
89
- Enabled: false
90
-
91
- Style/CommentIndentation:
92
- Enabled: true
93
-
94
- Style/ConstantName:
95
- Enabled: false
96
-
97
- Style/CyclomaticComplexity:
98
- Enabled: false
99
-
100
- Style/DefWithParentheses:
101
- Enabled: true
102
-
103
- Style/DeprecatedHashMethods:
104
- Enabled: true
105
-
106
- Style/Documentation:
107
- Enabled: false
108
-
109
- Style/DotPosition:
110
- Enabled: false
111
-
112
- Style/DoubleNegation:
113
- Enabled: false
114
-
115
- Style/EachWithObject:
116
- Enabled: true
117
-
118
- Style/EmptyLineBetweenDefs:
119
- Enabled: true
120
-
121
- Style/EmptyLines:
122
- Enabled: false
123
-
124
- Style/EmptyLinesAroundAccessModifier:
125
- Enabled: false
126
-
127
- Style/EmptyLinesAroundBody:
128
- Enabled: false
129
-
130
- Style/EmptyLiteral:
131
- Enabled: false
132
-
133
- Style/Encoding:
134
- Enabled: false
135
-
136
- Style/EndBlock:
137
- Enabled: false
138
-
139
- Style/EndOfLine:
140
- Enabled: true
141
-
142
- Style/EvenOdd:
143
- Enabled: false
144
-
145
- Style/FileName:
146
- Enabled: true
147
-
148
- Style/FlipFlop:
149
- Enabled: false
150
-
151
- Style/For:
152
- Enabled: true
153
-
154
- Style/FormatString:
155
- Enabled: false
156
-
157
- Style/GlobalVars:
158
- Enabled: false
159
-
160
- Style/GuardClause:
161
- Enabled: true
162
-
163
- Style/HashSyntax:
164
- Enabled: true
165
-
166
- Style/IfUnlessModifier:
167
- Enabled: false
168
-
169
- Style/IfWithSemicolon:
170
- Enabled: false
171
-
172
- Style/IndentationConsistency:
173
- Enabled: true
174
-
175
- Style/IndentationWidth:
176
- Enabled: false
177
-
178
- Style/IndentArray:
179
- Enabled: false
180
-
181
- Style/IndentHash:
182
- Enabled: false
183
-
184
- Style/InlineComment:
185
- Enabled: false
186
-
187
- Style/Lambda:
188
- Enabled: true
189
-
190
- Style/LambdaCall:
191
- Enabled: false
192
-
193
- Style/LeadingCommentSpace:
194
- Enabled: false
195
-
196
- Style/LineEndConcatenation:
197
- Enabled: false
198
-
199
- Style/LineLength:
200
- Max: 198
201
- Enabled: true
202
-
203
- Style/MethodCalledOnDoEndBlock:
204
- Enabled: true
205
-
206
- Style/MethodCallParentheses:
207
- Enabled: false
208
-
209
- Style/MethodDefParentheses:
210
- Enabled: false
211
-
212
- Style/MethodLength:
213
- Enabled: false
214
-
215
- Style/MethodName:
216
- Enabled: false
217
-
218
- Style/ModuleFunction:
219
- Enabled: false
220
-
221
- Style/MultilineBlockChain:
222
- Enabled: false
223
-
224
- Style/MultilineIfThen:
225
- Enabled: false
226
-
227
- Style/MultilineTernaryOperator:
228
- Enabled: false
229
-
230
- Style/NegatedIf:
231
- Enabled: false
232
-
233
- Style/NegatedWhile:
234
- Enabled: false
235
-
236
- Style/NestedTernaryOperator:
237
- Enabled: false
238
-
239
- Style/Next:
240
- Enabled: true
241
-
242
- Style/NilComparison:
243
- Enabled: false
244
-
245
- Style/NonNilCheck:
246
- Enabled: false
247
-
248
- Style/Not:
249
- Enabled: true
250
-
251
- Style/NumericLiterals:
252
- Enabled: false
253
-
254
- Style/OneLineConditional:
255
- Enabled: false
256
-
257
- Style/OpMethod:
258
- Enabled: false
259
-
260
- Style/ParameterLists:
261
- Enabled: false
262
-
263
- Style/ParenthesesAroundCondition:
264
- Enabled: false
265
-
266
- Style/PercentLiteralDelimiters:
267
- Enabled: false
268
-
269
- Style/PerlBackrefs:
270
- Enabled: false
271
-
272
- Style/PredicateName:
273
- Enabled: false
274
-
275
- Style/Proc:
276
- Enabled: false
277
-
278
- Style/RaiseArgs:
279
- Enabled: false
280
-
281
- Style/RedundantBegin:
282
- Enabled: false
283
-
284
- Style/RedundantException:
285
- Enabled: false
286
-
287
- Style/RedundantReturn:
288
- Enabled: true
289
-
290
- Style/RedundantSelf:
291
- Enabled: false
292
-
293
- Style/RegexpLiteral:
294
- Enabled: false
295
-
296
- Style/RescueModifier:
297
- Enabled: false
298
-
299
- Style/SelfAssignment:
300
- Enabled: true
301
-
302
- Style/Semicolon:
303
- Enabled: true
304
-
305
- Style/SignalException:
306
- Enabled: false
307
-
308
- Style/SingleLineBlockParams:
309
- Enabled: false
310
-
311
- Style/SingleLineMethods:
312
- Enabled: true
313
-
314
- Style/SingleSpaceBeforeFirstArg:
315
- Enabled: true
316
-
317
- Style/SpaceAfterColon:
318
- Enabled: true
319
-
320
- Style/SpaceAfterComma:
321
- Enabled: true
322
-
323
- Style/SpaceAfterControlKeyword:
324
- Enabled: false
325
-
326
- Style/SpaceAfterMethodName:
327
- Enabled: false
328
-
329
- Style/SpaceAfterNot:
330
- Enabled: false
331
-
332
- Style/SpaceAfterSemicolon:
333
- Enabled: false
334
-
335
- Style/SpaceBeforeBlockBraces:
336
- Enabled: true
337
-
338
- Style/SpaceBeforeComma:
339
- Enabled: true
340
-
341
- Style/SpaceBeforeComment:
342
- Enabled: true
343
-
344
- Style/SpaceBeforeSemicolon:
345
- Enabled: true
346
-
347
- Style/SpaceInsideBlockBraces:
348
- Enabled: true
349
-
350
- Style/SpaceAroundEqualsInParameterDefault:
351
- Enabled: true
352
-
353
- Style/SpaceAroundOperators:
354
- Enabled: true
355
-
356
- Style/SpaceBeforeModifierKeyword:
357
- Enabled: true
358
-
359
- Style/SpaceInsideBrackets:
360
- Enabled: true
361
-
362
- Style/SpaceInsideHashLiteralBraces:
363
- Enabled: true
364
-
365
- Style/SpaceInsideParens:
366
- Enabled: false
367
-
368
- Style/SpecialGlobalVars:
369
- Enabled: false
370
-
371
- Style/StringLiterals:
372
- Enabled: false
373
-
374
- Style/Tab:
375
- Enabled: true
376
-
377
- Style/Tab:
378
- Enabled: true
379
-
380
- Style/TrailingBlankLines:
381
- Enabled: true
382
-
383
- Style/TrailingComma:
384
- Enabled: false
385
-
386
- Style/TrailingWhitespace:
387
- Enabled: true
388
-
389
- Style/TrivialAccessors:
390
- Enabled: false
391
-
392
- Style/UnlessElse:
393
- Enabled: true
394
-
395
- Style/UnneededCapitalW:
396
- Enabled: true
397
-
398
- Style/UnneededPercentQ:
399
- Enabled: true
400
-
401
- Style/UnneededPercentX:
402
- Enabled: true
403
-
404
- Style/VariableInterpolation:
405
- Enabled: false
406
-
407
- Style/VariableName:
408
- Enabled: false
409
-
410
- Style/WhenThen:
411
- Enabled: true
412
-
413
- Style/WhileUntilDo:
414
- Enabled: false
415
-
416
- Style/WhileUntilModifier:
417
- Enabled: false
418
-
419
- Style/WordArray:
420
- Enabled: false
421
-
422
- #################### Lint ################################
423
- ### Warnings
424
-
425
- Lint/AmbiguousOperator:
426
- Enabled: false
427
-
428
- Lint/AmbiguousRegexpLiteral:
429
- Enabled: false
430
-
431
- Lint/AssignmentInCondition:
432
- Enabled: false
433
-
434
- Lint/BlockAlignment:
435
- Enabled: false
436
-
437
- Lint/ConditionPosition:
438
- Enabled: false
439
-
440
- Lint/Debugger:
441
- Enabled: true
442
-
443
- Lint/DefEndAlignment:
444
- Enabled: true
445
-
446
- Lint/DeprecatedClassMethods:
447
- Enabled: true
448
-
449
- Lint/ElseLayout:
450
- Enabled: false
451
-
452
- Lint/EmptyEnsure:
453
- Enabled: true
454
-
455
- Lint/EmptyInterpolation:
456
- Enabled: true
457
-
458
- Lint/EndAlignment:
459
- Enabled: true
460
- AlignWith: variable
461
-
462
- Lint/EndInMethod:
463
- Enabled: false
464
-
465
- Lint/EnsureReturn:
466
- Enabled: false
467
-
468
- Lint/Eval:
469
- Enabled: true
470
-
471
- Lint/HandleExceptions:
472
- Enabled: false
473
-
474
- Lint/InvalidCharacterLiteral:
475
- Enabled: false
476
-
477
- Lint/LiteralInCondition:
478
- Enabled: false
479
-
480
- Lint/LiteralInInterpolation:
481
- Enabled: false
482
-
483
- Lint/Loop:
484
- Enabled: false
485
-
486
- Lint/ParenthesesAsGroupedExpression:
487
- Enabled: false
488
-
489
- Lint/RequireParentheses:
490
- Enabled: false
491
-
492
- Lint/RescueException:
493
- Enabled: false
494
-
495
- Lint/ShadowingOuterLocalVariable:
496
- Enabled: false
497
-
498
- Lint/SpaceBeforeFirstArg:
499
- Enabled: true
500
-
501
- Lint/StringConversionInInterpolation:
502
- Enabled: true
503
-
504
- Lint/UnderscorePrefixedVariableName:
505
- Enabled: true
506
-
507
- Lint/UnusedBlockArgument:
508
- Enabled: true
509
-
510
- Lint/UnusedMethodArgument:
511
- Enabled: false
512
-
513
- Lint/UnreachableCode:
514
- Enabled: true
515
-
516
- Lint/UselessAccessModifier:
517
- Enabled: true
518
-
519
- Lint/UselessAssignment:
520
- Enabled: false
521
-
522
- Lint/UselessComparison:
523
- Enabled: true
524
-
525
- Lint/UselessElseWithoutRescue:
526
- Enabled: true
527
-
528
- Lint/UselessSetterCall:
529
- Enabled: true
530
-
531
- Lint/Void:
532
- Enabled: true
533
-
534
- ##################### Rails ##################################
535
-
536
- Rails/ActionFilter:
537
- Enabled: true
538
-
539
- Rails/DefaultScope:
540
- Enabled: false
541
-
542
- Rails/Delegate:
543
- Enabled: true
544
-
545
- Rails/HasAndBelongsToMany:
546
- Enabled: false
547
-
548
- Rails/Output:
549
- Enabled: false
550
-
551
- Rails/ReadWriteAttribute:
552
- Enabled: false
553
-
554
- Rails/ScopeArgs:
555
- Enabled: false
556
-
557
- Rails/Validation:
558
- Enabled: true
data/lib/hotchoc/api.rb DELETED
@@ -1,21 +0,0 @@
1
- module Hotchoc
2
- module API
3
-
4
- def get_albums(opts = {})
5
- get('albums', opts)['albums'].map { |album| Hotchoc::Presenters::Album.new(album) }
6
- end
7
-
8
- def get_pages(opts = {})
9
- get('pages', opts)['pages'].map { |page| Hotchoc::Presenters::Page.new(page) }
10
- end
11
-
12
- def get_posts(opts = {})
13
- get('posts', opts)['posts'].map { |post| Hotchoc::Presenters::Post.new(post) }
14
- end
15
-
16
- def get_topics(opts = {})
17
- get('topics', opts)['topics'].map { |topic| Hotchoc::Presenters::Topic.new(topic) }
18
- end
19
-
20
- end
21
- end
@@ -1,36 +0,0 @@
1
- module Hotchoc
2
- module Configuration
3
-
4
- VALID_CONFIG_KEYS = [:api_key, :site, :hostname, :verify].freeze
5
-
6
- DEFAULT_API_KEY = nil
7
- DEFAULT_SITE = nil
8
- DEFAULT_HOSTNAME = 'hotchoc.io'
9
- DEFAULT_VERIFY = true
10
-
11
- #
12
- # Build accessor methods for every config options so we can do this, for example:
13
- #
14
- # Hotchoc.site = 'mattdownunder'
15
- #
16
- attr_accessor *VALID_CONFIG_KEYS
17
-
18
- #
19
- # Make sure we have the default values set when we get 'extended'
20
- #
21
- def self.extended(base)
22
- base.reset
23
- end
24
-
25
- def reset
26
- self.api_key = DEFAULT_API_KEY
27
- self.site = DEFAULT_SITE
28
- self.hostname = DEFAULT_HOSTNAME
29
- self.verify = DEFAULT_VERIFY
30
- end
31
-
32
- def options
33
- Hash[*VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten]
34
- end
35
- end
36
- end
@@ -1,12 +0,0 @@
1
- module Hotchoc
2
- module Errors
3
-
4
- # Base error class for all custom errors
5
- class HotchocError < StandardError
6
- end
7
-
8
- class RequestError < HotchocError
9
- end
10
-
11
- end
12
- end
@@ -1,35 +0,0 @@
1
- require 'typhoeus'
2
- require 'json'
3
-
4
- module Hotchoc
5
- class Fetcher
6
-
7
- DEFAULT_OPTIONS = {
8
- headers: {
9
- Accept: "application/json",
10
- "User-Agent" => "Hotchoc Ruby #{Hotchoc::VERSION}"
11
- },
12
- followlocation: true,
13
- accept_encoding: 'gzip'
14
- }
15
-
16
- def self.get(url, opts, verify)
17
- request = Typhoeus::Request.new(url, {
18
- method: :get,
19
- params: opts,
20
- ssl_verifypeer: verify
21
- }.merge(DEFAULT_OPTIONS))
22
-
23
- request.on_complete do |response|
24
- if response.timed_out?
25
- raise Hotchoc::Errors::RequestError, "Request timed out"
26
- elsif !response.success?
27
- raise Hotchoc::Errors::RequestError, "Request failed with code #{response.code}. #{response.return_message == 'No error' ? '' : response.return_message}"
28
- end
29
- end
30
-
31
- JSON.parse(request.run.body)
32
- end
33
-
34
- end
35
- end
@@ -1,3 +0,0 @@
1
- module Hotchoc
2
- VERSION = "0.2.1"
3
- end
@@ -1,16 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Hotchoc::Configuration' do
4
-
5
- after do
6
- Hotchoc.reset
7
- end
8
-
9
- Hotchoc::Configuration::VALID_CONFIG_KEYS.each do |key|
10
- describe ".#{key}" do
11
- it "should return the default #{key}" do
12
- expect(Hotchoc.send(key)).to eq Hotchoc::Configuration.const_get("DEFAULT_#{key.upcase}")
13
- end
14
- end
15
- end
16
- end