contentstack 0.4.0 → 0.5.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/.gitignore +2 -1
- data/CHANGELOG.md +30 -0
- data/CODEOWNERS +1 -0
- data/Gemfile.lock +17 -15
- data/contentstack.gemspec +2 -2
- data/lib/contentstack/api.rb +53 -12
- data/lib/contentstack/asset.rb +2 -0
- data/lib/contentstack/asset_collection.rb +2 -0
- data/lib/contentstack/client.rb +10 -3
- data/lib/contentstack/content_type.rb +2 -0
- data/lib/contentstack/entry.rb +15 -0
- data/lib/contentstack/entry_collection.rb +2 -0
- data/lib/contentstack/query.rb +16 -1
- data/lib/contentstack/version.rb +1 -1
- data/lib/contentstack.rb +5 -2
- data/lib/util.rb +106 -102
- data/spec/asset_spec.rb +7 -7
- data/spec/contentstack_spec.rb +7 -0
- data/spec/entry_spec.rb +9 -1
- data/spec/fixtures/asset.json +1 -1
- data/spec/fixtures/asset_collection.json +1 -1
- data/spec/fixtures/category_content_type.json +1 -1
- data/spec/fixtures/category_entry.json +1 -1
- data/spec/fixtures/category_entry_collection.json +1 -1
- data/spec/fixtures/category_entry_collection_without_count.json +1 -1
- data/spec/fixtures/content_types.json +1 -1
- data/spec/fixtures/product_entry.json +1 -1
- data/spec/fixtures/product_entry_collection.json +1 -1
- data/spec/fixtures/sync_init.json +785 -785
- data/spec/query_spec.rb +8 -0
- data/spec/spec_helper.rb +18 -4
- metadata +19 -10
- data/coverage/.last_run.json +0 -5
- data/coverage/.resultset.json +0 -1838
- data/coverage/.resultset.json.lock +0 -0
- data/coverage/index.html +0 -20198
data/spec/query_spec.rb
CHANGED
@@ -3,7 +3,9 @@ require_relative '../lib/contentstack.rb'
|
|
3
3
|
|
4
4
|
describe Contentstack::Query do
|
5
5
|
let(:client) { create_client }
|
6
|
+
let(:preview_client) { create_preview_client }
|
6
7
|
let(:category_query) {client.content_type("category").query}
|
8
|
+
let(:preview_category) {preview_client.content_type("category").query}
|
7
9
|
let(:product_query) {client.content_type("product").query}
|
8
10
|
|
9
11
|
it "should get data using `where` method" do
|
@@ -16,6 +18,12 @@ describe Contentstack::Query do
|
|
16
18
|
expect(data.length).to eq 5
|
17
19
|
end
|
18
20
|
|
21
|
+
it "is preview entry featch" do
|
22
|
+
preview_client.live_preview_query({hash: 'hash', content_type_uid: 'category'})
|
23
|
+
data = preview_category.fetch
|
24
|
+
expect(data.length).to eq 5
|
25
|
+
end
|
26
|
+
|
19
27
|
it "should get data using `less_than` method" do
|
20
28
|
data = product_query.less_than("price", 150).fetch
|
21
29
|
expect(data.length).to eq 3
|
data/spec/spec_helper.rb
CHANGED
@@ -127,7 +127,7 @@ RSpec.configure do |config|
|
|
127
127
|
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
128
128
|
to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/asset_collection.json'), :headers => {})
|
129
129
|
|
130
|
-
stub_request(:get, /cdn.contentstack.io\/v3\/assets\/
|
130
|
+
stub_request(:get, /cdn.contentstack.io\/v3\/assets\/image_1/).
|
131
131
|
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
132
132
|
to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/asset.json'), :headers => {})
|
133
133
|
|
@@ -135,7 +135,7 @@ RSpec.configure do |config|
|
|
135
135
|
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
136
136
|
to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/product_entry_collection.json'), :headers => {})
|
137
137
|
|
138
|
-
stub_request(:get, /cdn.contentstack.io\/v3\/content_types\/product\/entries\/
|
138
|
+
stub_request(:get, /cdn.contentstack.io\/v3\/content_types\/product\/entries\/uid/).
|
139
139
|
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
140
140
|
to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/product_entry.json'), :headers => {})
|
141
141
|
|
@@ -147,7 +147,7 @@ RSpec.configure do |config|
|
|
147
147
|
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
148
148
|
to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/category_entry_collection.json'), :headers => {})
|
149
149
|
|
150
|
-
stub_request(:get, /cdn.contentstack.io\/v3\/content_types\/category\/entries\/
|
150
|
+
stub_request(:get, /cdn.contentstack.io\/v3\/content_types\/category\/entries\/uid/).
|
151
151
|
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
152
152
|
to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/category_entry.json'), :headers => {})
|
153
153
|
|
@@ -155,13 +155,27 @@ RSpec.configure do |config|
|
|
155
155
|
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
156
156
|
to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/sync_init.json'), :headers => {})
|
157
157
|
|
158
|
+
stub_request(:get, /preview.contentstack.io\/v3\/content_types\/category\/entries/).
|
159
|
+
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
160
|
+
to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/category_entry_collection_without_count.json'), :headers => {})
|
161
|
+
|
162
|
+
stub_request(:get, /preview.contentstack.io\/v3\/content_types\/category\/entries\/uid/).
|
163
|
+
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
164
|
+
to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/category_entry.json'), :headers => {})
|
158
165
|
end
|
159
166
|
|
160
167
|
def create_client(delivery_token = ENV['DELIVERY_TOKEN'], api_key = ENV['API_KEY'], environment = ENV['ENVIRONMENT'], options = {})
|
161
168
|
Contentstack::Client.new(api_key, delivery_token, environment, options)
|
162
169
|
end
|
163
170
|
|
171
|
+
def create_preview_client(delivery_token = ENV['DELIVERY_TOKEN'], api_key = ENV['API_KEY'], environment = ENV['ENVIRONMENT'], options = {live_preview: {host: 'https://preview.contentstack.io', enable: true, management_token: 'auth'}})
|
172
|
+
Contentstack::Client.new(api_key, delivery_token, environment, options)
|
173
|
+
end
|
174
|
+
|
164
175
|
def render(content, entry)
|
165
|
-
Contentstack
|
176
|
+
Contentstack::render_content(content, ContentstackUtils::Model::Options.new(entry))
|
177
|
+
end
|
178
|
+
def json_to_html(content, entry)
|
179
|
+
Contentstack::json_to_html(content, ContentstackUtils::Model::Options.new(entry))
|
166
180
|
end
|
167
181
|
end
|
metadata
CHANGED
@@ -1,43 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contentstack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Contentstack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.2'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '6.2'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '3.2'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '6.2'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: contentstack_utils
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - "~>"
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.0
|
39
|
+
version: '1.0'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.0.1
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
37
46
|
requirements:
|
38
47
|
- - "~>"
|
39
48
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.0
|
49
|
+
version: '1.0'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.0.1
|
41
53
|
- !ruby/object:Gem::Dependency
|
42
54
|
name: rspec
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,16 +116,13 @@ files:
|
|
104
116
|
- ".gitignore"
|
105
117
|
- ".yardopts"
|
106
118
|
- CHANGELOG.md
|
119
|
+
- CODEOWNERS
|
107
120
|
- CODE_OF_CONDUCT.md
|
108
121
|
- Gemfile
|
109
122
|
- Gemfile.lock
|
110
123
|
- LICENSE.txt
|
111
124
|
- README.md
|
112
125
|
- contentstack.gemspec
|
113
|
-
- coverage/.last_run.json
|
114
|
-
- coverage/.resultset.json
|
115
|
-
- coverage/.resultset.json.lock
|
116
|
-
- coverage/index.html
|
117
126
|
- lib/contentstack.rb
|
118
127
|
- lib/contentstack/api.rb
|
119
128
|
- lib/contentstack/asset.rb
|