hotchoc 0.2.0 → 0.2.1

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: 5a893ac926a79c8737afa2810911b2231cd5ad46
4
- data.tar.gz: 0ec2c6f3085b60587ff1208c5b6de95994962786
3
+ metadata.gz: 6755f8467bd572a215a91f2e359ed6bf044b256d
4
+ data.tar.gz: 4a36c9752a34f42825a92413cac48e332f4d721f
5
5
  SHA512:
6
- metadata.gz: 48ac708583876ad9f9aff17ef88aaef4ba59e51c2df0fdcfd9e7bba7c5e796162807798d4cb76f52a22ad299c73064cf2c0ba098f6b59614c533d4887f42fc6a
7
- data.tar.gz: 4483599c8dd62fe8d3a95144fade6f36b853da36f641c9e6dc5c0fae5bab0a50db4848feb12f7ba7631b693c73ca2d7e50a79df52c5b36b971bcbe7d532a7c07
6
+ metadata.gz: ab36bffd5983e96eb34ea1b49243bce98cb4e624e537456a403cadf0d8b0488f829b8d63a3dd2bf44b225d54d16bcf0dbe184b51890cc1c47c6fdc0a1032eedb
7
+ data.tar.gz: e21c2248d0665fbd209833e2d249ca64c9dfb338173a334f7bdba9253ebc0b21eec4b9d81e9d7a08713743a668018d34da2c7f8a6013b61ecb8697a265df171d
data/CHANGELOG.md CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  ## Master
4
4
 
5
+ ## 0.2.1
6
+
7
+ [Full changelog](https://github.com/choc/hotchoc-ruby/compare/v0.2.0...v0.2.1)
8
+
9
+ Changes:
10
+
11
+ * Unused field 'image_count' was dropped from albums
12
+
13
+ Enhancements:
14
+
15
+ * Added specs for presenter classes
16
+ * Various code improvements
17
+
5
18
  ## 0.2.0
6
19
 
7
20
  [Full changelog](https://github.com/choc/hotchoc-ruby/compare/v0.1.0...v0.2.0)
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # hotchoc-ruby
2
2
 
3
- Official Ruby wrapper for the Hotchoc API (in private beta).
3
+ Ruby wrapper for the Hotchoc API (in private beta).
4
4
 
5
5
  [![Gem Version](https://badge.fury.io/rb/hotchoc.svg)](http://badge.fury.io/rb/hotchoc)
6
6
  [![Code Climate](https://codeclimate.com/github/choc/hotchoc-ruby.png)](https://codeclimate.com/github/choc/hotchoc-ruby)
@@ -59,7 +59,7 @@ Or install it manually as:
59
59
 
60
60
  ## Copyright
61
61
 
62
- Copyright (c) 2014 Matthias Siegel. See [LICENSE][] for details.
62
+ Copyright (c) 2014-2015 Matthias Siegel. See [LICENSE][] for details.
63
63
 
64
64
  ## Changelog
65
65
 
data/hotchoc.gemspec CHANGED
@@ -3,24 +3,26 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'hotchoc/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = "hotchoc"
6
+ spec.name = 'hotchoc'
7
7
  spec.version = Hotchoc::VERSION
8
- spec.authors = ["Matthias Siegel"]
9
- spec.email = ["matthias.siegel@gmail.com"]
8
+ spec.authors = ['Matthias Siegel']
9
+ spec.email = ['matthias.siegel@gmail.com']
10
10
  spec.summary = %q{Ruby wrapper for the Hotchoc API.}
11
- spec.description = %q{Ruby wrapper for the Hotchoc API.}
12
- spec.homepage = "https://github.com/choc/hotchoc-ruby"
13
- spec.license = "MIT"
11
+ spec.description = %q{Ruby wrapper for the Hotchoc API (in private beta).}
12
+ spec.homepage = 'https://github.com/choc/hotchoc-ruby'
13
+ spec.license = 'MIT'
14
14
 
15
15
  spec.files = `git ls-files -z`.split("\x0")
16
16
  spec.test_files = spec.files.grep(%r{^(spec)/})
17
- spec.require_paths = ["lib"]
17
+ spec.require_paths = ['lib']
18
18
 
19
- spec.add_dependency "typhoeus", "~> 0.7.0"
19
+ spec.add_dependency 'typhoeus', '~> 0.7.0'
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.7"
22
- spec.add_development_dependency "rake", "~> 10.4"
23
- spec.add_development_dependency "rspec", "~> 3.2"
24
- spec.add_development_dependency "rubocop", "~> 0.24.1"
25
- spec.add_development_dependency "webmock", "~> 1.20"
21
+ spec.add_development_dependency 'binding_of_caller', '~> 0.7.2'
22
+ spec.add_development_dependency 'bundler', '~> 1.7'
23
+ spec.add_development_dependency 'pry', '~> 0.10.1'
24
+ spec.add_development_dependency 'rake', '~> 10.4'
25
+ spec.add_development_dependency 'rspec', '~> 3.2'
26
+ spec.add_development_dependency 'rubocop', '~> 0.24.1'
27
+ spec.add_development_dependency 'webmock', '~> 1.20'
26
28
  end
@@ -31,10 +31,6 @@ module Hotchoc
31
31
  Time.parse(@item['publish_date'])
32
32
  end
33
33
 
34
- def image_count
35
- @item['image_count']
36
- end
37
-
38
34
  def cover
39
35
  @item['cover'] ? block_for(@item['cover']) : nil
40
36
  end
@@ -1,3 +1,3 @@
1
1
  module Hotchoc
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Hotchoc::Presenters::Album' do
4
+
5
+ let(:data) do
6
+ JSON.parse(File.read(response_stub('albums')))['albums'].first
7
+ end
8
+
9
+ let(:album) do
10
+ Hotchoc::Presenters::Album.new(data)
11
+ end
12
+
13
+ it 'has an ID' do
14
+ expect(album.id).to be
15
+ end
16
+
17
+ it 'has a title' do
18
+ expect(album.title).to be
19
+ end
20
+
21
+ it 'has a subtitle' do
22
+ expect(album.subtitle).to be
23
+ end
24
+
25
+ it 'has a description' do
26
+ expect(album.description).to be
27
+ end
28
+
29
+ it 'has an identifier' do
30
+ expect(album.identifier).to be
31
+ end
32
+
33
+ it 'has a status' do
34
+ expect(album.status).to be
35
+ end
36
+
37
+ it 'has a publish_date' do
38
+ expect(album.publish_date).to be_a(Time)
39
+ end
40
+
41
+ it 'has a cover' do
42
+ expect(album.cover).to be_a(Hotchoc::Presenters::Blocks::Image)
43
+ end
44
+
45
+ it 'has blocks' do
46
+ expect(album.blocks).to_not be_empty
47
+ expect(album.blocks.first).to be_a(Hotchoc::Presenters::Blocks::Image)
48
+ end
49
+
50
+ it 'has topics' do
51
+ expect(album.topics).to_not be_empty
52
+ expect(album.topics.first).to be_a(Hotchoc::Presenters::Topic)
53
+ end
54
+
55
+ it 'has a created_at' do
56
+ expect(album.created_at).to be_a(Time)
57
+ end
58
+
59
+ it 'has an updated_at' do
60
+ expect(album.updated_at).to be_a(Time)
61
+ end
62
+
63
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Hotchoc::Presenters::Blocks::Image' do
4
+
5
+ let(:data) do
6
+ JSON.parse(File.read(response_stub('albums')))['albums'].first['blocks'].first
7
+ end
8
+
9
+ let(:block) do
10
+ Hotchoc::Presenters::Blocks::Image.new(data)
11
+ end
12
+
13
+ it 'has a title' do
14
+ expect(block.title).to be
15
+ end
16
+
17
+ it 'has an image' do
18
+ expect(block.image).to be_a(Hotchoc::Presenters::File)
19
+ end
20
+
21
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Hotchoc::Presenters::Blocks::Text' do
4
+
5
+ let(:data) do
6
+ blocks = JSON.parse(File.read(response_stub('pages')))['pages'].first['blocks']
7
+ blocks.detect { |block| block['type'] == 'text' }
8
+ end
9
+
10
+ let(:block) do
11
+ Hotchoc::Presenters::Blocks::Text.new(data)
12
+ end
13
+
14
+ it 'has an html version' do
15
+ expect(block.html).to be
16
+ end
17
+
18
+ it 'has a markdown version' do
19
+ expect(block.markdown).to be
20
+ end
21
+
22
+ end
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Hotchoc::Presenters::File' do
4
+
5
+ let(:data) do
6
+ JSON.parse(File.read(response_stub('albums')))['albums'].first['blocks'].first
7
+ end
8
+
9
+ let(:file) do
10
+ Hotchoc::Presenters::Blocks::Image.new(data).image
11
+ end
12
+
13
+ it 'has an id' do
14
+ expect(file.id).to be
15
+ end
16
+
17
+ it 'has a name' do
18
+ expect(file.name).to be
19
+ end
20
+
21
+ it 'has a url' do
22
+ expect(file.url).to be
23
+ end
24
+
25
+ it 'has a width' do
26
+ expect(file.width).to be
27
+ end
28
+
29
+ it 'has a height' do
30
+ expect(file.height).to be
31
+ end
32
+
33
+ it 'has a size' do
34
+ expect(file.size).to be
35
+ end
36
+
37
+ it 'has a content_type' do
38
+ expect(file.content_type).to be
39
+ end
40
+
41
+ it 'has thumbnails' do
42
+ expect(file.thumbnails).to_not be_empty
43
+ expect(file.thumbnails.first).to be_a(Hotchoc::Presenters::Thumbnail)
44
+ end
45
+
46
+ it 'has exif info' do
47
+ expect(file.exif).to be
48
+ end
49
+
50
+ it 'has a created_at' do
51
+ expect(file.created_at).to be_a(Time)
52
+ end
53
+
54
+ it 'has an updated_at' do
55
+ expect(file.updated_at).to be_a(Time)
56
+ end
57
+
58
+ end
@@ -0,0 +1,71 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Hotchoc::Presenters::Page' do
4
+
5
+ let(:data) do
6
+ JSON.parse(File.read(response_stub('pages')))['pages'].first
7
+ end
8
+
9
+ let(:page) do
10
+ Hotchoc::Presenters::Page.new(data)
11
+ end
12
+
13
+ it 'has an ID' do
14
+ expect(page.id).to be
15
+ end
16
+
17
+ it 'has a title' do
18
+ expect(page.title).to be
19
+ end
20
+
21
+ it 'has a subtitle' do
22
+ expect(page.subtitle).to be
23
+ end
24
+
25
+ it 'has an identifier' do
26
+ expect(page.identifier).to be
27
+ end
28
+
29
+ it 'has a status' do
30
+ expect(page.status).to be
31
+ end
32
+
33
+ it 'has a path' do
34
+ expect(page.path).to be
35
+ end
36
+
37
+ it 'has a parent_id' do
38
+ expect(page.parent_id).to be
39
+ end
40
+
41
+ it 'has a position' do
42
+ expect(page.position).to be
43
+ end
44
+
45
+ it 'has a level' do
46
+ expect(page.level).to be
47
+ end
48
+
49
+ it 'has a publish_date' do
50
+ expect(page.publish_date).to be_a(Time)
51
+ end
52
+
53
+ it 'has blocks' do
54
+ expect(page.blocks).to_not be_empty
55
+ expect(page.blocks.first).to be_a(Hotchoc::Presenters::Blocks::Text)
56
+ end
57
+
58
+ it 'has topics' do
59
+ expect(page.topics).to_not be_empty
60
+ expect(page.topics.first).to be_a(Hotchoc::Presenters::Topic)
61
+ end
62
+
63
+ it 'has a created_at' do
64
+ expect(page.created_at).to be_a(Time)
65
+ end
66
+
67
+ it 'has an updated_at' do
68
+ expect(page.updated_at).to be_a(Time)
69
+ end
70
+
71
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Hotchoc::Presenters::Post' do
4
+
5
+ let(:data) do
6
+ JSON.parse(File.read(response_stub('posts')))['posts'].first
7
+ end
8
+
9
+ let(:post) do
10
+ Hotchoc::Presenters::Post.new(data)
11
+ end
12
+
13
+ it 'has an ID' do
14
+ expect(post.id).to be
15
+ end
16
+
17
+ it 'has a title' do
18
+ expect(post.title).to be
19
+ end
20
+
21
+ it 'has a subtitle' do
22
+ expect(post.subtitle).to be
23
+ end
24
+
25
+ it 'has an identifier' do
26
+ expect(post.identifier).to be
27
+ end
28
+
29
+ it 'has a status' do
30
+ expect(post.status).to be
31
+ end
32
+
33
+ it 'has a publish_date' do
34
+ expect(post.publish_date).to be_a(Time)
35
+ end
36
+
37
+ it 'has blocks' do
38
+ expect(post.blocks).to_not be_empty
39
+ expect(post.blocks.first).to be_a(Hotchoc::Presenters::Blocks::Text)
40
+ end
41
+
42
+ it 'has topics' do
43
+ expect(post.topics).to_not be_empty
44
+ expect(post.topics.first).to be_a(Hotchoc::Presenters::Topic)
45
+ end
46
+
47
+ it 'has a created_at' do
48
+ expect(post.created_at).to be_a(Time)
49
+ end
50
+
51
+ it 'has an updated_at' do
52
+ expect(post.updated_at).to be_a(Time)
53
+ end
54
+
55
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Hotchoc::Presenters::Thumbnail' do
4
+
5
+ let(:data) do
6
+ JSON.parse(File.read(response_stub('albums')))['albums'].first['blocks'].first
7
+ end
8
+
9
+ let(:thumbnail) do
10
+ Hotchoc::Presenters::Blocks::Image.new(data).image.thumbnails.first
11
+ end
12
+
13
+ it 'has a name' do
14
+ expect(thumbnail.name).to be
15
+ end
16
+
17
+ it 'has a width' do
18
+ expect(thumbnail.width).to be
19
+ end
20
+
21
+ it 'has a height' do
22
+ expect(thumbnail.height).to be
23
+ end
24
+
25
+ it 'has a size' do
26
+ expect(thumbnail.size).to be
27
+ end
28
+
29
+ it 'has a square? indicator' do
30
+ expect([true, false]).to include(thumbnail.square?)
31
+ end
32
+
33
+ it 'has a url' do
34
+ expect(thumbnail.url).to be
35
+ end
36
+
37
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Hotchoc::Presenters::Topic' do
4
+
5
+ let(:data) do
6
+ JSON.parse(File.read(response_stub('posts')))['posts'].first
7
+ end
8
+
9
+ let(:topic) do
10
+ Hotchoc::Presenters::Post.new(data).topics.first
11
+ end
12
+
13
+ it 'has an ID' do
14
+ expect(topic.id).to be
15
+ end
16
+
17
+ it 'has a name' do
18
+ expect(topic.name).to be
19
+ end
20
+
21
+ it 'has an identifier' do
22
+ expect(topic.identifier).to be
23
+ end
24
+
25
+ it 'has a created_at' do
26
+ expect(topic.created_at).to be_a(Time)
27
+ end
28
+
29
+ it 'has an updated_at' do
30
+ expect(topic.updated_at).to be_a(Time)
31
+ end
32
+
33
+ end
data/spec/spec_helper.rb CHANGED
@@ -3,6 +3,7 @@ Bundler.setup
3
3
 
4
4
  require 'hotchoc'
5
5
  require 'webmock/rspec'
6
+ require 'pry'
6
7
 
7
8
  WebMock.disable_net_connect!
8
9
 
@@ -25,8 +25,23 @@
25
25
  "status": "published",
26
26
  "subtitle": "Test subtitle 1",
27
27
  "title": "Test page 1",
28
- "topics": [],
29
- "updated_at": "2015-05-04T09:27:22Z"
28
+ "topics": [
29
+ {
30
+ "created_at": "2015-05-04T08:08:27Z",
31
+ "id": "3002a596-252f-4397-aeda-f93b631de857",
32
+ "identifier": "ducati",
33
+ "name": "Ducati",
34
+ "updated_at": "2015-05-05T03:57:28Z"
35
+ },
36
+ {
37
+ "created_at": "2015-05-04T08:08:27Z",
38
+ "id": "37e30b6f-9f51-414e-8c76-bbdda12f11a7",
39
+ "identifier": "victoria",
40
+ "name": "Victoria",
41
+ "updated_at": "2015-05-05T03:57:27Z"
42
+ }
43
+ ],
44
+ "updated_at": "2015-05-05T03:57:28Z"
30
45
  },
31
46
  {
32
47
  "blocks": [],
@@ -39,10 +54,25 @@
39
54
  "position": 0,
40
55
  "publish_date": "2015-05-04T08:08:26Z",
41
56
  "status": "published",
42
- "subtitle": null,
57
+ "subtitle": "",
43
58
  "title": "Home",
44
- "topics": [],
45
- "updated_at": "2015-05-04T08:08:26Z"
59
+ "topics": [
60
+ {
61
+ "created_at": "2015-05-04T08:08:27Z",
62
+ "id": "a1753785-ba93-4846-8bce-9c2af6813317",
63
+ "identifier": "bushwalking",
64
+ "name": "Bushwalking",
65
+ "updated_at": "2015-05-05T03:57:01Z"
66
+ },
67
+ {
68
+ "created_at": "2015-05-04T08:08:27Z",
69
+ "id": "86f6e524-932f-4ddf-a1f9-a6d0132394ef",
70
+ "identifier": "darwin",
71
+ "name": "Darwin",
72
+ "updated_at": "2015-05-05T03:57:06Z"
73
+ }
74
+ ],
75
+ "updated_at": "2015-05-05T03:57:09Z"
46
76
  }
47
77
  ]
48
78
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotchoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthias Siegel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-04 00:00:00.000000000 Z
11
+ date: 2015-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.7.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: binding_of_caller
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.7.2
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.7.2
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +52,20 @@ dependencies:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
54
  version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.10.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.10.1
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: rake
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -94,7 +122,7 @@ dependencies:
94
122
  - - "~>"
95
123
  - !ruby/object:Gem::Version
96
124
  version: '1.20'
97
- description: Ruby wrapper for the Hotchoc API.
125
+ description: Ruby wrapper for the Hotchoc API (in private beta).
98
126
  email:
99
127
  - matthias.siegel@gmail.com
100
128
  executables: []
@@ -131,6 +159,14 @@ files:
131
159
  - spec/hotchoc/client_spec.rb
132
160
  - spec/hotchoc/configuration_spec.rb
133
161
  - spec/hotchoc/main_spec.rb
162
+ - spec/hotchoc/presenters/album_spec.rb
163
+ - spec/hotchoc/presenters/blocks/image_spec.rb
164
+ - spec/hotchoc/presenters/blocks/text_spec.rb
165
+ - spec/hotchoc/presenters/file_spec.rb
166
+ - spec/hotchoc/presenters/page_spec.rb
167
+ - spec/hotchoc/presenters/post_spec.rb
168
+ - spec/hotchoc/presenters/thumbnail_spec.rb
169
+ - spec/hotchoc/presenters/topic_spec.rb
134
170
  - spec/spec_helper.rb
135
171
  - spec/support/helpers.rb
136
172
  - spec/support/matchers.rb
@@ -168,6 +204,14 @@ test_files:
168
204
  - spec/hotchoc/client_spec.rb
169
205
  - spec/hotchoc/configuration_spec.rb
170
206
  - spec/hotchoc/main_spec.rb
207
+ - spec/hotchoc/presenters/album_spec.rb
208
+ - spec/hotchoc/presenters/blocks/image_spec.rb
209
+ - spec/hotchoc/presenters/blocks/text_spec.rb
210
+ - spec/hotchoc/presenters/file_spec.rb
211
+ - spec/hotchoc/presenters/page_spec.rb
212
+ - spec/hotchoc/presenters/post_spec.rb
213
+ - spec/hotchoc/presenters/thumbnail_spec.rb
214
+ - spec/hotchoc/presenters/topic_spec.rb
171
215
  - spec/spec_helper.rb
172
216
  - spec/support/helpers.rb
173
217
  - spec/support/matchers.rb