contentstack 0.4.2 → 0.5.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/.gitignore +1 -0
- data/.talismanrc +1 -0
- data/CHANGELOG.md +6 -0
- data/CODEOWNERS +1 -0
- data/Gemfile.lock +11 -11
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/SECURITY.md +27 -0
- 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 +2 -2
- data/lib/util.rb +106 -102
- 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 +9 -10
- data/coverage/.last_run.json +0 -5
- data/coverage/.resultset.json +0 -1948
- data/coverage/.resultset.json.lock +0 -0
- data/coverage/index.html +0 -21404
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Contentstack
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -114,18 +114,17 @@ extensions: []
|
|
114
114
|
extra_rdoc_files: []
|
115
115
|
files:
|
116
116
|
- ".gitignore"
|
117
|
+
- ".talismanrc"
|
117
118
|
- ".yardopts"
|
118
119
|
- CHANGELOG.md
|
120
|
+
- CODEOWNERS
|
119
121
|
- CODE_OF_CONDUCT.md
|
120
122
|
- Gemfile
|
121
123
|
- Gemfile.lock
|
122
124
|
- LICENSE.txt
|
123
125
|
- README.md
|
126
|
+
- SECURITY.md
|
124
127
|
- contentstack.gemspec
|
125
|
-
- coverage/.last_run.json
|
126
|
-
- coverage/.resultset.json
|
127
|
-
- coverage/.resultset.json.lock
|
128
|
-
- coverage/index.html
|
129
128
|
- lib/contentstack.rb
|
130
129
|
- lib/contentstack/api.rb
|
131
130
|
- lib/contentstack/asset.rb
|
@@ -164,7 +163,7 @@ homepage: https://github.com/contentstack/contentstack-ruby
|
|
164
163
|
licenses:
|
165
164
|
- MIT
|
166
165
|
metadata: {}
|
167
|
-
post_install_message:
|
166
|
+
post_install_message:
|
168
167
|
rdoc_options: []
|
169
168
|
require_paths:
|
170
169
|
- lib
|
@@ -179,8 +178,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
178
|
- !ruby/object:Gem::Version
|
180
179
|
version: '0'
|
181
180
|
requirements: []
|
182
|
-
rubygems_version: 3.
|
183
|
-
signing_key:
|
181
|
+
rubygems_version: 3.3.7
|
182
|
+
signing_key:
|
184
183
|
specification_version: 4
|
185
184
|
summary: Contentstack Ruby client for the Content Delivery API
|
186
185
|
test_files: []
|