contentstack 0.4.2 → 0.4.3
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/CHANGELOG.md +6 -0
- data/CODEOWNERS +1 -0
- data/coverage/.last_run.json +1 -1
- data/coverage/.resultset.json +132 -115
- data/coverage/index.html +1665 -1478
- data/lib/contentstack/api.rb +2 -1
- data/lib/contentstack/asset.rb +2 -0
- data/lib/contentstack/asset_collection.rb +2 -0
- data/lib/contentstack/client.rb +2 -0
- data/lib/contentstack/content_type.rb +2 -0
- data/lib/contentstack/entry.rb +2 -0
- data/lib/contentstack/entry_collection.rb +2 -0
- data/lib/contentstack/query.rb +2 -0
- data/lib/contentstack/version.rb +1 -1
- data/lib/contentstack.rb +0 -2
- data/lib/util.rb +106 -102
- metadata +3 -2
data/lib/contentstack/api.rb
CHANGED
@@ -3,9 +3,10 @@ require 'net/http'
|
|
3
3
|
require 'active_support'
|
4
4
|
require 'active_support/json'
|
5
5
|
require 'open-uri'
|
6
|
-
|
6
|
+
require 'util'
|
7
7
|
module Contentstack
|
8
8
|
class API
|
9
|
+
using Utility
|
9
10
|
def self.init_api(api_key, delivery_token, environment,host)
|
10
11
|
@host = host
|
11
12
|
@api_version = '/v3'
|
data/lib/contentstack/asset.rb
CHANGED
data/lib/contentstack/client.rb
CHANGED
@@ -2,8 +2,10 @@ require 'contentstack/api'
|
|
2
2
|
require 'contentstack/content_type'
|
3
3
|
require 'contentstack/asset_collection'
|
4
4
|
require 'contentstack/sync_result'
|
5
|
+
require 'util'
|
5
6
|
module Contentstack
|
6
7
|
class Client
|
8
|
+
using Utility
|
7
9
|
attr_reader :region, :host
|
8
10
|
# Initialize "Contentstack" Client instance
|
9
11
|
def initialize(api_key, delivery_token, environment, options={})
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'contentstack/query'
|
2
|
+
require 'util'
|
2
3
|
|
3
4
|
module Contentstack
|
4
5
|
class ContentType
|
6
|
+
using Utility
|
5
7
|
[:title, :uid, :created_at, :updated_at, :attributes].each do |method_name|
|
6
8
|
if [:created_at, :updated_at].include?(method_name)
|
7
9
|
define_method method_name do
|
data/lib/contentstack/entry.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'active_support/core_ext'
|
2
|
+
require 'util'
|
2
3
|
|
3
4
|
module Contentstack
|
4
5
|
class Entry
|
6
|
+
using Utility
|
5
7
|
attr_reader :fields, :content_type, :uid, :owner, :query, :schema, :content_type
|
6
8
|
def initialize(attrs, content_type_uid=nil)
|
7
9
|
setup(attrs, content_type_uid)
|
data/lib/contentstack/query.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'contentstack/entry_collection'
|
2
|
+
require 'util'
|
2
3
|
|
3
4
|
module Contentstack
|
4
5
|
# A class that defines a query that is used to query for Entry instance.
|
5
6
|
class Query
|
7
|
+
using Utility
|
6
8
|
# @!attribute [r] query
|
7
9
|
# Attribute which has all the information about the query which will be executed against Contentstack API
|
8
10
|
|
data/lib/contentstack/version.rb
CHANGED
data/lib/contentstack.rb
CHANGED
@@ -4,8 +4,6 @@ require "contentstack/version"
|
|
4
4
|
require "contentstack/client"
|
5
5
|
require "contentstack/region"
|
6
6
|
require "contentstack_utils"
|
7
|
-
require "util"
|
8
|
-
|
9
7
|
|
10
8
|
# == Contentstack - Ruby SDK
|
11
9
|
# Contentstack is a content management system that facilitates the process of publication by separating the content from site-related programming and design.
|
data/lib/util.rb
CHANGED
@@ -1,107 +1,111 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
module Contentstack
|
2
|
+
module Utility
|
3
|
+
refine Hash do
|
4
|
+
def to_query(namespace = nil)
|
5
|
+
collect do |key, value|
|
6
|
+
value.to_query(namespace ? "#{namespace}[#{key}]" : key)
|
7
|
+
end.sort * '&'
|
8
|
+
end
|
9
|
+
|
10
|
+
def symbolize_keys
|
11
|
+
new_hash = {}
|
12
|
+
self.each do |key,value|
|
13
|
+
if [Hash, Array].include?(value.class)
|
14
|
+
new_hash[key.to_sym] = value.symbolize_keys
|
15
|
+
else
|
16
|
+
new_hash[key.to_sym] = value
|
17
|
+
end
|
18
|
+
end
|
19
|
+
new_hash
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
refine Array do
|
24
|
+
def to_query(key)
|
25
|
+
prefix = "#{key}[]"
|
26
|
+
collect { |value| value.to_query(prefix) }.join '&'
|
27
|
+
end
|
28
|
+
|
29
|
+
def symbolize_keys
|
30
|
+
collect do |entry|
|
31
|
+
if entry.class == Hash
|
32
|
+
entry.symbolize_keys
|
33
|
+
else
|
34
|
+
entry
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
refine String do
|
41
|
+
def to_query(key)
|
42
|
+
require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
|
43
|
+
"#{CGI.escape(key.to_param)}=#{CGI.escape(to_param.to_s)}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_param
|
47
|
+
to_s
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
refine Symbol do
|
52
|
+
def to_query(key)
|
53
|
+
to_s.to_query(key)
|
54
|
+
end
|
55
|
+
|
56
|
+
def to_param
|
57
|
+
to_s
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
refine NilClass do
|
62
|
+
def to_query(key)
|
63
|
+
to_s.to_query(key)
|
64
|
+
end
|
65
|
+
|
66
|
+
def to_param
|
67
|
+
to_s
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
refine TrueClass do
|
72
|
+
def to_query(key)
|
73
|
+
to_s.to_query(key)
|
74
|
+
end
|
75
|
+
|
76
|
+
def to_query(val)
|
77
|
+
"#{CGI.escape(val.to_param)}=#{CGI.escape(to_s)}"
|
15
78
|
end
|
16
79
|
end
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
def symbolize_keys
|
28
|
-
collect do |entry|
|
29
|
-
if entry.class == Hash
|
30
|
-
entry.symbolize_keys
|
31
|
-
else
|
32
|
-
entry
|
80
|
+
|
81
|
+
refine FalseClass do
|
82
|
+
def to_query(key)
|
83
|
+
to_s.to_query(key)
|
84
|
+
end
|
85
|
+
|
86
|
+
def to_query(val)
|
87
|
+
"#{CGI.escape(val.to_param)}=#{CGI.escape(to_s)}"
|
33
88
|
end
|
34
89
|
end
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
class NilClass
|
60
|
-
def to_query(key)
|
61
|
-
to_s.to_query(key)
|
62
|
-
end
|
63
|
-
|
64
|
-
def to_param
|
65
|
-
to_s
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
class TrueClass
|
70
|
-
def to_query(key)
|
71
|
-
to_s.to_query(key)
|
72
|
-
end
|
73
|
-
|
74
|
-
def to_query(val)
|
75
|
-
"#{CGI.escape(val.to_param)}=#{CGI.escape(to_s)}"
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
class FalseClass
|
80
|
-
def to_query(key)
|
81
|
-
to_s.to_query(key)
|
82
|
-
end
|
83
|
-
|
84
|
-
def to_query(val)
|
85
|
-
"#{CGI.escape(val.to_param)}=#{CGI.escape(to_s)}"
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
class Integer
|
90
|
-
def to_query(key)
|
91
|
-
to_s.to_query(key)
|
92
|
-
end
|
93
|
-
|
94
|
-
def to_query(val)
|
95
|
-
"#{CGI.escape(val.to_param)}=#{CGI.escape(to_s)}"
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
class Numeric
|
100
|
-
def to_query(key)
|
101
|
-
to_s.to_query(key)
|
102
|
-
end
|
103
|
-
|
104
|
-
def to_query(val)
|
105
|
-
"#{CGI.escape(val.to_param)}=#{CGI.escape(to_s)}"
|
106
|
-
end
|
90
|
+
|
91
|
+
refine Integer do
|
92
|
+
def to_query(key)
|
93
|
+
to_s.to_query(key)
|
94
|
+
end
|
95
|
+
|
96
|
+
def to_query(val)
|
97
|
+
"#{CGI.escape(val.to_param)}=#{CGI.escape(to_s)}"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
refine Numeric do
|
102
|
+
def to_query(key)
|
103
|
+
to_s.to_query(key)
|
104
|
+
end
|
105
|
+
|
106
|
+
def to_query(val)
|
107
|
+
"#{CGI.escape(val.to_param)}=#{CGI.escape(to_s)}"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
107
111
|
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.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Contentstack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- ".gitignore"
|
117
117
|
- ".yardopts"
|
118
118
|
- CHANGELOG.md
|
119
|
+
- CODEOWNERS
|
119
120
|
- CODE_OF_CONDUCT.md
|
120
121
|
- Gemfile
|
121
122
|
- Gemfile.lock
|