hotchoc 0.5.0 → 0.6.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/hotchoc/client/configuration.rb +3 -3
- data/lib/hotchoc/client/fetcher.rb +6 -9
- data/lib/hotchoc/client/version.rb +1 -1
- data/lib/hotchoc/client.rb +2 -2
- data/spec/hotchoc/album_spec.rb +1 -1
- data/spec/hotchoc/blocks/image_spec.rb +1 -1
- data/spec/hotchoc/blocks/text_spec.rb +1 -1
- data/spec/hotchoc/client/api_spec.rb +4 -4
- data/spec/hotchoc/client_spec.rb +2 -2
- data/spec/hotchoc/file_spec.rb +1 -1
- data/spec/hotchoc/page_spec.rb +1 -1
- data/spec/hotchoc/post_spec.rb +1 -1
- data/spec/hotchoc/thumbnail_spec.rb +1 -1
- data/spec/hotchoc/topic_spec.rb +1 -1
- data/spec/support/responses/albums.json +481 -483
- data/spec/support/responses/pages.json +75 -77
- data/spec/support/responses/posts.json +78 -80
- data/spec/support/responses/topics.json +121 -123
- data/spec/support/stubs.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 861c7314101175aed1f8e95ebb240e12fe0fe406
|
4
|
+
data.tar.gz: 389e3e46b305d1ed80e43cb99da820f7809c6536
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffee16f71aded938646f11c3765292d810c9adcfc88c67bd2541b9d866b40de38ec92e1d22f40de73e286a082cc525520e1dd870fb3b1308eb9883340231eae0
|
7
|
+
data.tar.gz: 9d287d520b323f889fda92c50c19ccb0f260f9023b9f16756859b0e0dceb6704cb5de1b43199ef4a383df25efcf11664df163b67c137ce3a042190281d000f0d
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
## Master
|
4
4
|
|
5
|
+
## 0.6.0
|
6
|
+
|
7
|
+
[Full changelog](https://github.com/choc/hotchoc-ruby/compare/v0.5.0...v0.6.0)
|
8
|
+
|
9
|
+
Changes:
|
10
|
+
|
11
|
+
* Removed `verify` option
|
12
|
+
* Added `protocol` option
|
13
|
+
|
5
14
|
## 0.5.0
|
6
15
|
|
7
16
|
[Full changelog](https://github.com/choc/hotchoc-ruby/compare/v0.4.1...v0.5.0)
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module Hotchoc
|
2
2
|
class Client
|
3
3
|
module Configuration
|
4
|
-
VALID_CONFIG_KEYS = [:api_key, :site, :hostname, :
|
4
|
+
VALID_CONFIG_KEYS = [:api_key, :site, :hostname, :protocol].freeze
|
5
5
|
|
6
6
|
DEFAULT_API_KEY = nil
|
7
7
|
DEFAULT_SITE = nil
|
8
8
|
DEFAULT_HOSTNAME = 'hotchoc.io'
|
9
|
-
|
9
|
+
DEFAULT_PROTOCOL = 'https'
|
10
10
|
|
11
11
|
#
|
12
12
|
# Build accessor methods for every config options so we can do this, for example:
|
@@ -26,7 +26,7 @@ module Hotchoc
|
|
26
26
|
self.api_key = DEFAULT_API_KEY
|
27
27
|
self.site = DEFAULT_SITE
|
28
28
|
self.hostname = DEFAULT_HOSTNAME
|
29
|
-
self.
|
29
|
+
self.protocol = DEFAULT_PROTOCOL
|
30
30
|
end
|
31
31
|
|
32
32
|
def options
|
@@ -13,12 +13,12 @@ module Hotchoc
|
|
13
13
|
follow_redirects: true
|
14
14
|
}
|
15
15
|
|
16
|
-
def self.get(url, opts = {}
|
17
|
-
new.get(url, opts
|
16
|
+
def self.get(url, opts = {})
|
17
|
+
new.get(url, opts)
|
18
18
|
end
|
19
19
|
|
20
|
-
def get(url, opts = {}
|
21
|
-
response = HTTParty.get(url, params(opts
|
20
|
+
def get(url, opts = {})
|
21
|
+
response = HTTParty.get(url, params(opts))
|
22
22
|
|
23
23
|
if response.success?
|
24
24
|
JSON.parse(response.body)
|
@@ -29,11 +29,8 @@ module Hotchoc
|
|
29
29
|
|
30
30
|
private
|
31
31
|
|
32
|
-
def params(opts
|
33
|
-
{
|
34
|
-
query: opts,
|
35
|
-
verify: verify
|
36
|
-
}.merge(DEFAULT_OPTIONS)
|
32
|
+
def params(opts)
|
33
|
+
{ query: opts }.merge(DEFAULT_OPTIONS)
|
37
34
|
end
|
38
35
|
|
39
36
|
def request_error_message(response)
|
data/lib/hotchoc/client.rb
CHANGED
@@ -32,9 +32,9 @@ module Hotchoc
|
|
32
32
|
private
|
33
33
|
|
34
34
|
def get(path, opts = {})
|
35
|
-
url = "
|
35
|
+
url = "#{protocol}://#{site}.#{hostname}/api/#{path}"
|
36
36
|
|
37
|
-
Fetcher.get(url, merged_options(opts)
|
37
|
+
Fetcher.get(url, merged_options(opts))
|
38
38
|
end
|
39
39
|
|
40
40
|
def merged_options(opts)
|
data/spec/hotchoc/album_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Hotchoc::Blocks::Text do
|
4
4
|
let(:data) do
|
5
|
-
blocks = JSON.parse(File.read(response_stub('pages')))
|
5
|
+
blocks = JSON.parse(File.read(response_stub('pages'))).first['blocks']
|
6
6
|
blocks.detect { |block| block['type'] == 'text' }
|
7
7
|
end
|
8
8
|
|
@@ -11,7 +11,7 @@ describe Hotchoc::Client::API do
|
|
11
11
|
describe 'Albums' do
|
12
12
|
context 'GET collection' do
|
13
13
|
let(:albums) do
|
14
|
-
JSON.parse(File.read(response_stub('albums')))
|
14
|
+
JSON.parse(File.read(response_stub('albums'))).map { |album| Hotchoc::Album.new(album) }
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'returns an array with the albums' do
|
@@ -23,7 +23,7 @@ describe Hotchoc::Client::API do
|
|
23
23
|
describe 'Pages' do
|
24
24
|
context 'GET collection' do
|
25
25
|
let(:pages) do
|
26
|
-
JSON.parse(File.read(response_stub('pages')))
|
26
|
+
JSON.parse(File.read(response_stub('pages'))).map { |page| Hotchoc::Page.new(page) }
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'returns an array with the pages' do
|
@@ -35,7 +35,7 @@ describe Hotchoc::Client::API do
|
|
35
35
|
describe 'Posts' do
|
36
36
|
context 'GET collection' do
|
37
37
|
let(:posts) do
|
38
|
-
JSON.parse(File.read(response_stub('posts')))
|
38
|
+
JSON.parse(File.read(response_stub('posts'))).map { |post| Hotchoc::Post.new(post) }
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'returns an array with the posts' do
|
@@ -47,7 +47,7 @@ describe Hotchoc::Client::API do
|
|
47
47
|
describe 'Topics' do
|
48
48
|
context 'GET collection' do
|
49
49
|
let(:topics) do
|
50
|
-
JSON.parse(File.read(response_stub('topics')))
|
50
|
+
JSON.parse(File.read(response_stub('topics'))).map { |topic| Hotchoc::Topic.new(topic) }
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'returns an array with the topics' do
|
data/spec/hotchoc/client_spec.rb
CHANGED
@@ -9,7 +9,7 @@ describe Hotchoc::Client do
|
|
9
9
|
api_key: 'abc',
|
10
10
|
site: 'def',
|
11
11
|
hostname: 'ghi',
|
12
|
-
|
12
|
+
protocol: 'http'
|
13
13
|
}
|
14
14
|
end
|
15
15
|
|
@@ -23,7 +23,7 @@ describe Hotchoc::Client do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'overrides module configuration after' do
|
26
|
-
client = described_class.new(api_key: 'rst', site: 'uvw', hostname: 'xyz',
|
26
|
+
client = described_class.new(api_key: 'rst', site: 'uvw', hostname: 'xyz', protocol: 'https')
|
27
27
|
|
28
28
|
config.each do |key, value|
|
29
29
|
client.send("#{key}=", value)
|
data/spec/hotchoc/file_spec.rb
CHANGED
data/spec/hotchoc/page_spec.rb
CHANGED
data/spec/hotchoc/post_spec.rb
CHANGED