contentstack 0.4.3 → 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/.github/workflows/codeql-analysis.yml +68 -0
- data/.github/workflows/sast-scan.yml +11 -0
- data/.github/workflows/sca-scan.yml +13 -0
- data/.github/workflows/secrets-scan.yml +11 -0
- data/.gitignore +1 -0
- data/.talismanrc +1 -0
- data/Gemfile.lock +12 -12
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/SECURITY.md +27 -0
- data/lib/contentstack/api.rb +137 -14
- data/lib/contentstack/client.rb +28 -3
- data/lib/contentstack/entry.rb +13 -0
- data/lib/contentstack/query.rb +25 -3
- 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 +12 -10
- 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.6.0
|
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-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -113,7 +113,12 @@ executables: []
|
|
113
113
|
extensions: []
|
114
114
|
extra_rdoc_files: []
|
115
115
|
files:
|
116
|
+
- ".github/workflows/codeql-analysis.yml"
|
117
|
+
- ".github/workflows/sast-scan.yml"
|
118
|
+
- ".github/workflows/sca-scan.yml"
|
119
|
+
- ".github/workflows/secrets-scan.yml"
|
116
120
|
- ".gitignore"
|
121
|
+
- ".talismanrc"
|
117
122
|
- ".yardopts"
|
118
123
|
- CHANGELOG.md
|
119
124
|
- CODEOWNERS
|
@@ -122,11 +127,8 @@ files:
|
|
122
127
|
- Gemfile.lock
|
123
128
|
- LICENSE.txt
|
124
129
|
- README.md
|
130
|
+
- SECURITY.md
|
125
131
|
- contentstack.gemspec
|
126
|
-
- coverage/.last_run.json
|
127
|
-
- coverage/.resultset.json
|
128
|
-
- coverage/.resultset.json.lock
|
129
|
-
- coverage/index.html
|
130
132
|
- lib/contentstack.rb
|
131
133
|
- lib/contentstack/api.rb
|
132
134
|
- lib/contentstack/asset.rb
|
@@ -165,7 +167,7 @@ homepage: https://github.com/contentstack/contentstack-ruby
|
|
165
167
|
licenses:
|
166
168
|
- MIT
|
167
169
|
metadata: {}
|
168
|
-
post_install_message:
|
170
|
+
post_install_message:
|
169
171
|
rdoc_options: []
|
170
172
|
require_paths:
|
171
173
|
- lib
|
@@ -180,8 +182,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
182
|
- !ruby/object:Gem::Version
|
181
183
|
version: '0'
|
182
184
|
requirements: []
|
183
|
-
rubygems_version: 3.
|
184
|
-
signing_key:
|
185
|
+
rubygems_version: 3.1.6
|
186
|
+
signing_key:
|
185
187
|
specification_version: 4
|
186
188
|
summary: Contentstack Ruby client for the Content Delivery API
|
187
189
|
test_files: []
|