contentstack 0.4.3 → 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 +1 -0
- data/CHANGELOG.md +6 -1
- data/Gemfile.lock +8 -8
- data/lib/contentstack/api.rb +51 -11
- data/lib/contentstack/client.rb +8 -3
- data/lib/contentstack/entry.rb +13 -0
- data/lib/contentstack/query.rb +14 -1
- data/lib/contentstack/version.rb +1 -1
- data/lib/contentstack.rb +2 -0
- data/spec/asset_spec.rb +7 -7
- 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 +14 -3
- metadata +2 -6
- data/coverage/.last_run.json +0 -5
- data/coverage/.resultset.json +0 -1965
- data/coverage/.resultset.json.lock +0 -0
- data/coverage/index.html +0 -21591
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,12 +155,23 @@ 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
176
|
Contentstack::render_content(content, ContentstackUtils::Model::Options.new(entry))
|
166
177
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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
|
@@ -123,10 +123,6 @@ files:
|
|
123
123
|
- LICENSE.txt
|
124
124
|
- README.md
|
125
125
|
- contentstack.gemspec
|
126
|
-
- coverage/.last_run.json
|
127
|
-
- coverage/.resultset.json
|
128
|
-
- coverage/.resultset.json.lock
|
129
|
-
- coverage/index.html
|
130
126
|
- lib/contentstack.rb
|
131
127
|
- lib/contentstack/api.rb
|
132
128
|
- lib/contentstack/asset.rb
|