contentstack 0.0.4 → 0.1.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 +5 -5
- data/.gitignore +3 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +59 -0
- data/README.md +5 -5
- data/contentstack.gemspec +1 -1
- data/lib/contentstack.rb +5 -5
- data/lib/contentstack/api.rb +10 -4
- data/lib/contentstack/client.rb +3 -3
- data/lib/contentstack/entry.rb +2 -0
- data/lib/contentstack/version.rb +1 -1
- data/spec/content_type_spec.rb +2 -2
- data/spec/contentstack_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -2
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cc7aab29132806e94f049f49be18f7bbb285423f13a949dfc6ea8288d4d52a51
|
4
|
+
data.tar.gz: d290838ee0df496dedf6cc1912fd180cc646b018041bac733afccce190a9dd24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff4947a727bcb0f195c7e9712b6072192942c2de8be5edfc420ec16176924eaf24f61ddef3ee13dca2659d1c5c3abefe598dbf43efee9ae1e81d9571dcddad3f
|
7
|
+
data.tar.gz: 9625bc07c44f7cc31d7f43212fc3f9cb9cfe108063b894e9cd17d1c49fa8b45d68f37d828796333448033c8d05db2cdd8ab4e02693e34db3e70cd51f56cf45bf
|
data/.gitignore
CHANGED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (6.0.2.2)
|
5
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
6
|
+
i18n (>= 0.7, < 2)
|
7
|
+
minitest (~> 5.1)
|
8
|
+
tzinfo (~> 1.1)
|
9
|
+
zeitwerk (~> 2.2)
|
10
|
+
addressable (2.7.0)
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
12
|
+
concurrent-ruby (1.1.6)
|
13
|
+
crack (0.4.3)
|
14
|
+
safe_yaml (~> 1.0.0)
|
15
|
+
diff-lcs (1.3)
|
16
|
+
docile (1.3.2)
|
17
|
+
hashdiff (1.0.1)
|
18
|
+
i18n (1.8.2)
|
19
|
+
concurrent-ruby (~> 1.0)
|
20
|
+
minitest (5.14.0)
|
21
|
+
public_suffix (4.0.4)
|
22
|
+
rspec (3.9.0)
|
23
|
+
rspec-core (~> 3.9.0)
|
24
|
+
rspec-expectations (~> 3.9.0)
|
25
|
+
rspec-mocks (~> 3.9.0)
|
26
|
+
rspec-core (3.9.1)
|
27
|
+
rspec-support (~> 3.9.1)
|
28
|
+
rspec-expectations (3.9.1)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.9.0)
|
31
|
+
rspec-mocks (3.9.1)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.9.0)
|
34
|
+
rspec-support (3.9.2)
|
35
|
+
safe_yaml (1.0.5)
|
36
|
+
simplecov (0.18.5)
|
37
|
+
docile (~> 1.1)
|
38
|
+
simplecov-html (~> 0.11)
|
39
|
+
simplecov-html (0.12.2)
|
40
|
+
thread_safe (0.3.6)
|
41
|
+
tzinfo (1.2.7)
|
42
|
+
thread_safe (~> 0.1)
|
43
|
+
webmock (3.8.3)
|
44
|
+
addressable (>= 2.3.6)
|
45
|
+
crack (>= 0.3.2)
|
46
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
47
|
+
zeitwerk (2.3.0)
|
48
|
+
|
49
|
+
PLATFORMS
|
50
|
+
ruby
|
51
|
+
|
52
|
+
DEPENDENCIES
|
53
|
+
activesupport
|
54
|
+
rspec
|
55
|
+
simplecov
|
56
|
+
webmock
|
57
|
+
|
58
|
+
BUNDLED WITH
|
59
|
+
2.1.4
|
data/README.md
CHANGED
@@ -22,13 +22,13 @@ Or you can run this command in your terminal (you might need administrator privi
|
|
22
22
|
To start using the SDK in your application, you will need to initialize the stack by providing the values for the keys given in the code snippet below.
|
23
23
|
|
24
24
|
# with default region
|
25
|
-
client = Contentstack::Client.new("site_api_key", "
|
25
|
+
client = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name")
|
26
26
|
|
27
27
|
# with specific region
|
28
|
-
client = Contentstack::Client.new("site_api_key", "
|
28
|
+
client = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name",{"region": Contentstack::Region::EU})
|
29
29
|
|
30
30
|
# with custom host
|
31
|
-
client = Contentstack::Client.new("site_api_key", "
|
31
|
+
client = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name",{"host": "https://custom-cdn.contentstack.com"})
|
32
32
|
|
33
33
|
|
34
34
|
|
@@ -61,7 +61,7 @@ A publishing environment corresponds to one or more deployment servers or a cont
|
|
61
61
|
|
62
62
|
To initialize the SDK, you need to provide values for the keys given in the snippet below:
|
63
63
|
|
64
|
-
stack = Contentstack::Client.new("site_api_key", "
|
64
|
+
stack = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name")
|
65
65
|
|
66
66
|
To get the API credentials mentioned above, log in to your Contentstack account and then in your top panel navigation, go to Settings > Stack to view the API Key and Access Token.
|
67
67
|
|
@@ -101,7 +101,7 @@ SDK functions for Image Delivery API coming soon.
|
|
101
101
|
|
102
102
|
## **The MIT License (MIT)**
|
103
103
|
|
104
|
-
Copyright © 2012-
|
104
|
+
Copyright © 2012-2020 [Contentstack](https://www.contentstack.com). All Rights Reserved
|
105
105
|
|
106
106
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
107
107
|
|
data/contentstack.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.required_ruby_version = '>= 2.0'
|
13
13
|
|
14
14
|
s.license = "MIT"
|
15
|
-
s.homepage = "https://github.com/
|
15
|
+
s.homepage = "https://github.com/contentstack/contentstack-ruby"
|
16
16
|
|
17
17
|
s.summary = %q{Contentstack Ruby client for the Content Delivery API}
|
18
18
|
s.description = %q{Contentstack Ruby client for the Content Delivery API}
|
data/lib/contentstack.rb
CHANGED
@@ -6,16 +6,16 @@ require "contentstack/region"
|
|
6
6
|
require "util"
|
7
7
|
|
8
8
|
|
9
|
-
# ==
|
10
|
-
#
|
9
|
+
# == Contentstack - Ruby SDK
|
10
|
+
# Contentstack is a content management system that facilitates the process of publication by separating the content from site-related programming and design.
|
11
11
|
# == Installation
|
12
12
|
# gem install contentstack
|
13
13
|
# == Initialize the Stack
|
14
|
-
# @stack = Contentstack::Client.new("site_api_key", "
|
14
|
+
# @stack = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name")
|
15
15
|
# == Initialize the Stack for EU region
|
16
|
-
# @stack = Contentstack::Client.new("site_api_key", "
|
16
|
+
# @stack = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name", {"region": Contentstack::Region::EU })
|
17
17
|
# == Initialize the Stack for custom host
|
18
|
-
# @stack = Contentstack::Client.new("site_api_key", "
|
18
|
+
# @stack = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name", {"host": "https://custom-cdn.contentstack.com" })
|
19
19
|
# == Usage
|
20
20
|
# ==== Get single entry
|
21
21
|
# @stack.content_type('blog').entry('<entry_uid_here>').fetch
|
data/lib/contentstack/api.rb
CHANGED
@@ -6,11 +6,13 @@ require 'open-uri'
|
|
6
6
|
|
7
7
|
module Contentstack
|
8
8
|
class API
|
9
|
-
def self.init_api(api_key,
|
9
|
+
def self.init_api(api_key, delivery_token, environment,host)
|
10
10
|
@host = host
|
11
11
|
@api_version = '/v3'
|
12
12
|
@environment = environment
|
13
|
-
@
|
13
|
+
@api_key = api_key
|
14
|
+
@access_token = delivery_token
|
15
|
+
@headers = {environment: @environment}
|
14
16
|
end
|
15
17
|
|
16
18
|
def self.fetch_content_types(uid="")
|
@@ -47,7 +49,11 @@ module Contentstack
|
|
47
49
|
query = "?" + q.to_query
|
48
50
|
# puts "Request URL:- #{@host}#{@api_version}#{path}#{query} \n\n"
|
49
51
|
|
50
|
-
ActiveSupport::JSON.decode(open("#{@host}#{@api_version}#{path}#{query}"
|
52
|
+
ActiveSupport::JSON.decode(open("#{@host}#{@api_version}#{path}#{query}",
|
53
|
+
"api_key" => @api_key,
|
54
|
+
"access_token"=> @access_token,
|
55
|
+
"user_agent"=> "ruby-sdk/#{Contentstack::VERSION}",
|
56
|
+
"x-user-agent" => "ruby-sdk/#{Contentstack::VERSION}").read)
|
51
57
|
end
|
52
58
|
end
|
53
|
-
end
|
59
|
+
end
|
data/lib/contentstack/client.rb
CHANGED
@@ -5,11 +5,11 @@ require 'contentstack/asset_collection'
|
|
5
5
|
module Contentstack
|
6
6
|
class Client
|
7
7
|
attr_reader :region, :host
|
8
|
-
# Initialize "
|
9
|
-
def initialize(api_key,
|
8
|
+
# Initialize "Contentstack" Client instance
|
9
|
+
def initialize(api_key, delivery_token, environment, options={})
|
10
10
|
@region = options[:region].nil? ? Contentstack::Region::US : options[:region]
|
11
11
|
@host = options[:host].nil? ? get_default_region_hosts(@region) : options[:host]
|
12
|
-
API.init_api(api_key,
|
12
|
+
API.init_api(api_key, delivery_token, environment, @host)
|
13
13
|
end
|
14
14
|
|
15
15
|
|
data/lib/contentstack/entry.rb
CHANGED
data/lib/contentstack/version.rb
CHANGED
data/spec/content_type_spec.rb
CHANGED
@@ -3,8 +3,8 @@ require_relative '../lib/contentstack.rb'
|
|
3
3
|
|
4
4
|
describe Contentstack::ContentType do
|
5
5
|
let(:client) { create_client }
|
6
|
-
let(:eu_client) { create_client('
|
7
|
-
let(:custom_host_client) { create_client('
|
6
|
+
let(:eu_client) { create_client('DELIVERY_TOKEN', 'API_KEY', 'STACK_ENV', {region: Contentstack::Region::EU}) }
|
7
|
+
let(:custom_host_client) { create_client('DELIVERY_TOKEN', 'API_KEY', 'STACK_ENV', {host: "https://custom-cdn.contentstack.com"}) }
|
8
8
|
|
9
9
|
describe "Fetch data from API" do
|
10
10
|
it "has class as Contentstack::ContentType" do
|
data/spec/contentstack_spec.rb
CHANGED
@@ -3,8 +3,8 @@ require_relative '../lib/contentstack.rb'
|
|
3
3
|
|
4
4
|
describe Contentstack do
|
5
5
|
let(:client) { create_client }
|
6
|
-
let(:eu_client) { create_client('
|
7
|
-
let(:custom_host_client) { create_client('
|
6
|
+
let(:eu_client) { create_client('DELIVERY_TOKEN_TOKEN', 'API_KEY', 'STACK_ENV', {region: Contentstack::Region::EU}) }
|
7
|
+
let(:custom_host_client) { create_client('DELIVERY_TOKEN_TOKEN', 'API_KEY', 'STACK_ENV', {host: "https://custom-cdn.contentstack.com"}) }
|
8
8
|
|
9
9
|
it "has a version number" do
|
10
10
|
expect(Contentstack::VERSION).not_to be nil
|
data/spec/spec_helper.rb
CHANGED
@@ -148,7 +148,7 @@ RSpec.configure do |config|
|
|
148
148
|
to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/category_entry.json'), :headers => {})
|
149
149
|
end
|
150
150
|
|
151
|
-
def create_client(
|
152
|
-
Contentstack::Client.new(
|
151
|
+
def create_client(delivery_token = ENV['ACCESS_TOKEN'], api_key = ENV['API_KEY'], environment = ENV['STACK_ENV'], options = {})
|
152
|
+
Contentstack::Client.new(delivery_token, api_key, environment, options)
|
153
153
|
end
|
154
154
|
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.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Contentstack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -76,6 +76,8 @@ files:
|
|
76
76
|
- ".gitignore"
|
77
77
|
- ".yardopts"
|
78
78
|
- CODE_OF_CONDUCT.md
|
79
|
+
- Gemfile
|
80
|
+
- Gemfile.lock
|
79
81
|
- LICENSE.txt
|
80
82
|
- README.md
|
81
83
|
- contentstack.gemspec
|
@@ -137,7 +139,7 @@ files:
|
|
137
139
|
- spec/fixtures/product_entry_collection.json
|
138
140
|
- spec/query_spec.rb
|
139
141
|
- spec/spec_helper.rb
|
140
|
-
homepage: https://github.com/
|
142
|
+
homepage: https://github.com/contentstack/contentstack-ruby
|
141
143
|
licenses:
|
142
144
|
- MIT
|
143
145
|
metadata: {}
|
@@ -156,8 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
158
|
- !ruby/object:Gem::Version
|
157
159
|
version: '0'
|
158
160
|
requirements: []
|
159
|
-
|
160
|
-
rubygems_version: 2.5.2.3
|
161
|
+
rubygems_version: 3.1.2
|
161
162
|
signing_key:
|
162
163
|
specification_version: 4
|
163
164
|
summary: Contentstack Ruby client for the Content Delivery API
|