buttercms-ruby 1.7 → 2.1
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/README.md +6 -0
- data/buttercms-ruby.gemspec +2 -2
- data/lib/buttercms/page.rb +6 -0
- data/lib/buttercms/version.rb +1 -1
- data/lib/buttercms-ruby.rb +9 -2
- data/spec/lib/butter-ruby_spec.rb +16 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d847c56b05ed132a90cf0bbcb42f0bc192062a0abb9df0b55bbba6cd8f7afbf
|
4
|
+
data.tar.gz: 961e13a3d995664f1dd0998a19682cf262169cd696df2c3a944238c023cddc67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d27637d790c3671f530a2a0f9899d8fbd846ae3ded2d190099b2567b74375e263229cc0ad74fd1170bfb0fa3b7bfb6f5ccd3b10b553c5d7b35180c53bc1ec81e
|
7
|
+
data.tar.gz: 5b24961cce8dfba0cacf0d55b156d8d562808db660bfc10fa606ab807db262a9726c1921b9e1953b42b63ba681fe79412c9db06516aee53573def2146dc1f5f9
|
data/README.md
CHANGED
@@ -26,6 +26,9 @@ To setup your project, follow these steps:
|
|
26
26
|
|
27
27
|
# Set read timeout (Default is 5.0)
|
28
28
|
# ButterCMS::read_timeout = 5.0
|
29
|
+
|
30
|
+
# Set open timeout (Default is 2.0)
|
31
|
+
# ButterCMS::open_timeout = 2.0
|
29
32
|
```
|
30
33
|
|
31
34
|
## Pages
|
@@ -36,7 +39,10 @@ https://buttercms.com/docs/api/?ruby#pages
|
|
36
39
|
```ruby
|
37
40
|
params = {page: 1, page_size: 10, locale: 'en', preview: 1, 'fields.headline': 'foo bar', levels: 2} # optional
|
38
41
|
pages = ButterCMS::Page.list('news', params)
|
42
|
+
|
39
43
|
page = ButterCMS::Page.get('news', 'hello-world', params)
|
44
|
+
|
45
|
+
pages = ButterCMS::Page.search('query', params)
|
40
46
|
```
|
41
47
|
|
42
48
|
## Collections
|
data/buttercms-ruby.gemspec
CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.name = "buttercms-ruby"
|
8
8
|
s.version = ButterCMS::VERSION
|
9
9
|
s.require_paths = ["lib"]
|
10
|
-
s.summary = '
|
11
|
-
s.description = 'Butter is
|
10
|
+
s.summary = 'Ruby API client for ButterCMS'
|
11
|
+
s.description = 'Butter is the #1 developer rated headless CMS. See https://buttercms.com for details.'
|
12
12
|
s.authors = ["ButterCMS"]
|
13
13
|
s.email= ["support@buttercms.com"]
|
14
14
|
s.homepage = "https://buttercms.com/docs"
|
data/lib/buttercms/page.rb
CHANGED
data/lib/buttercms/version.rb
CHANGED
data/lib/buttercms-ruby.rb
CHANGED
@@ -30,6 +30,7 @@ module ButterCMS
|
|
30
30
|
attr_accessor :write_api_token
|
31
31
|
attr_accessor :test_mode
|
32
32
|
attr_accessor :read_timeout
|
33
|
+
attr_accessor :open_timeout
|
33
34
|
attr_reader :data_store
|
34
35
|
attr_writer :logger
|
35
36
|
end
|
@@ -70,7 +71,13 @@ module ButterCMS
|
|
70
71
|
query[:test] = 1
|
71
72
|
end
|
72
73
|
|
73
|
-
|
74
|
+
# If the user has passed in a "/" leading path, don't interpret that
|
75
|
+
# as wanting to get rid of the API prefix
|
76
|
+
if path.start_with?("/")
|
77
|
+
path = path[1..-1]
|
78
|
+
end
|
79
|
+
|
80
|
+
path = Pathname.new(@api_url.path).join(path).to_s + "?#{URI.encode_www_form(query)}"
|
74
81
|
|
75
82
|
response =
|
76
83
|
Net::HTTP.start(@api_url.host, @api_url.port, http_options) do |http|
|
@@ -172,7 +179,7 @@ module ButterCMS
|
|
172
179
|
|
173
180
|
def self.http_options
|
174
181
|
{
|
175
|
-
open_timeout: 2.0,
|
182
|
+
open_timeout: open_timeout || 2.0,
|
176
183
|
read_timeout: read_timeout || 5.0,
|
177
184
|
ssl_timeout: 2.0,
|
178
185
|
use_ssl: @api_url.scheme == "https",
|
@@ -14,6 +14,22 @@ describe ButterCMS do
|
|
14
14
|
ButterCMS.request('')
|
15
15
|
expect(request).to have_been_made
|
16
16
|
end
|
17
|
+
|
18
|
+
it "should properly escape paths" do
|
19
|
+
request = stub_request(
|
20
|
+
:get,
|
21
|
+
"https://api.buttercms.com/v2/pages/*/homepage%20en?auth_token=test123"
|
22
|
+
).to_return(body: JSON.generate({data: {test: 'test'}}))
|
23
|
+
|
24
|
+
# support leading slashes
|
25
|
+
ButterCMS.request('/pages/*/homepage en')
|
26
|
+
|
27
|
+
# and no leading slashes
|
28
|
+
ButterCMS.request('pages/*/homepage en')
|
29
|
+
|
30
|
+
|
31
|
+
expect(request).to have_been_made.twice
|
32
|
+
end
|
17
33
|
end
|
18
34
|
|
19
35
|
context 'without an api token' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: buttercms-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1
|
4
|
+
version: '2.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ButterCMS
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -38,8 +38,8 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description: Butter is
|
42
|
-
for details.
|
41
|
+
description: 'Butter is the #1 developer rated headless CMS. See https://buttercms.com
|
42
|
+
for details.'
|
43
43
|
email:
|
44
44
|
- support@buttercms.com
|
45
45
|
executables: []
|
@@ -98,7 +98,7 @@ requirements: []
|
|
98
98
|
rubygems_version: 3.0.3
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
|
-
summary:
|
101
|
+
summary: Ruby API client for ButterCMS
|
102
102
|
test_files:
|
103
103
|
- spec/lib/butter-ruby_spec.rb
|
104
104
|
- spec/lib/buttercms/butter_collection_spec.rb
|