contentstack 0.4.0 → 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 +2 -1
- data/CHANGELOG.md +30 -0
- data/CODEOWNERS +1 -0
- data/Gemfile.lock +17 -15
- data/contentstack.gemspec +2 -2
- 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 +5 -2
- data/lib/util.rb +106 -102
- data/spec/asset_spec.rb +7 -7
- data/spec/contentstack_spec.rb +7 -0
- 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 +18 -4
- metadata +19 -10
- data/coverage/.last_run.json +0 -5
- data/coverage/.resultset.json +0 -1838
- data/coverage/.resultset.json.lock +0 -0
- data/coverage/index.html +0 -20198
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a123ae65668a6bf29833ecc4afcb2a2928e1732714972f6435a454b73aaf4ad
|
4
|
+
data.tar.gz: 62e2227a92867dc87c0924a9739f8992ec48f315b36bd6dddd4c67695dec4312
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46d3100475b3e04a49b01982ac0ffe39bc75669da2127256275ad4b9264f265e298391ea7da6f24c00a91e58307daf519a34baf71b4d21a54b6a6d365a4d1792
|
7
|
+
data.tar.gz: d666b92d9b25fe675187cebac7f04f4fc426cc731636022ba6350293fbe61f9e5ef258ceae7df363abfc78dc6fbc37b1f0c294e79debaaba7b1a8dbb90b90f0c
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,35 @@
|
|
1
1
|
## CHANGELOG
|
2
2
|
------------------------------------------------
|
3
|
+
## Version 0.5.0
|
4
|
+
### Date: 14th-Oct-2021
|
5
|
+
### New Features
|
6
|
+
- Live Preview feature support added
|
7
|
+
|
8
|
+
------------------------------------------------
|
9
|
+
## Version 0.4.3
|
10
|
+
### Date: 17th-Sept-2021
|
11
|
+
### Dependency update
|
12
|
+
- Issue for Monkey patching resolved. Implemented Refine to extend class within module scope.
|
13
|
+
|
14
|
+
------------------------------------------------
|
15
|
+
## Version 0.4.2
|
16
|
+
### Date: 2nd-Sept-2021
|
17
|
+
### Dependency update
|
18
|
+
- Added URI open on open uri deprecation
|
19
|
+
|
20
|
+
------------------------------------------------
|
21
|
+
## Version 0.4.1
|
22
|
+
### Date: 2nd-Jun-2021
|
23
|
+
### Dependency update
|
24
|
+
- Updated gemspec dependency
|
25
|
+
|
26
|
+
------------------------------------------------
|
27
|
+
## Version 0.4.0
|
28
|
+
### Date: 16th-Apr-2021
|
29
|
+
### New Features
|
30
|
+
- Embedded feature Support added
|
31
|
+
|
32
|
+
------------------------------------------------
|
3
33
|
|
4
34
|
## Version 0.3.0
|
5
35
|
### Date: 17th-Mar-2021
|
data/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @contentstack/security-admin @contentstack/sdk-admin
|
data/Gemfile.lock
CHANGED
@@ -1,37 +1,39 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
contentstack (0.
|
5
|
-
activesupport (
|
6
|
-
contentstack_utils (~> 1.0.0)
|
4
|
+
contentstack (0.5.0)
|
5
|
+
activesupport (>= 3.2, < 6.2)
|
6
|
+
contentstack_utils (~> 1.0, >= 1.0.1)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (6.1.
|
11
|
+
activesupport (6.1.4.1)
|
12
12
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
13
|
i18n (>= 1.6, < 2)
|
14
14
|
minitest (>= 5.1)
|
15
15
|
tzinfo (~> 2.0)
|
16
16
|
zeitwerk (~> 2.3)
|
17
|
-
addressable (2.
|
17
|
+
addressable (2.8.0)
|
18
18
|
public_suffix (>= 2.0.2, < 5.0)
|
19
|
-
concurrent-ruby (1.1.
|
20
|
-
contentstack_utils (1.
|
21
|
-
activesupport (
|
22
|
-
nokogiri (~> 1.11.0)
|
19
|
+
concurrent-ruby (1.1.9)
|
20
|
+
contentstack_utils (1.1.0)
|
21
|
+
activesupport (>= 3.2, < 6.2)
|
22
|
+
nokogiri (~> 1.11, >= 1.11.0)
|
23
23
|
crack (0.4.5)
|
24
24
|
rexml
|
25
25
|
diff-lcs (1.4.4)
|
26
|
-
docile (1.
|
26
|
+
docile (1.4.0)
|
27
27
|
hashdiff (1.0.1)
|
28
28
|
i18n (1.8.10)
|
29
29
|
concurrent-ruby (~> 1.0)
|
30
|
+
mini_portile2 (2.6.1)
|
30
31
|
minitest (5.14.4)
|
31
|
-
nokogiri (1.
|
32
|
+
nokogiri (1.12.5)
|
33
|
+
mini_portile2 (~> 2.6.1)
|
32
34
|
racc (~> 1.4)
|
33
35
|
public_suffix (4.0.6)
|
34
|
-
racc (1.
|
36
|
+
racc (1.6.0)
|
35
37
|
rexml (3.2.5)
|
36
38
|
rspec (3.10.0)
|
37
39
|
rspec-core (~> 3.10.0)
|
@@ -51,7 +53,7 @@ GEM
|
|
51
53
|
simplecov-html (~> 0.11)
|
52
54
|
simplecov_json_formatter (~> 0.1)
|
53
55
|
simplecov-html (0.12.3)
|
54
|
-
simplecov_json_formatter (0.1.
|
56
|
+
simplecov_json_formatter (0.1.3)
|
55
57
|
tzinfo (2.0.4)
|
56
58
|
concurrent-ruby (~> 1.0)
|
57
59
|
webmock (3.11.3)
|
@@ -59,10 +61,10 @@ GEM
|
|
59
61
|
crack (>= 0.3.2)
|
60
62
|
hashdiff (>= 0.4.0, < 2.0.0)
|
61
63
|
yard (0.9.26)
|
62
|
-
zeitwerk (2.
|
64
|
+
zeitwerk (2.5.1)
|
63
65
|
|
64
66
|
PLATFORMS
|
65
|
-
|
67
|
+
ruby
|
66
68
|
|
67
69
|
DEPENDENCIES
|
68
70
|
contentstack!
|
data/contentstack.gemspec
CHANGED
@@ -20,8 +20,8 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.files = `git ls-files`.split("\n")
|
21
21
|
s.require_paths = ["lib"]
|
22
22
|
|
23
|
-
s.add_dependency 'activesupport',
|
24
|
-
s.add_dependency "contentstack_utils",
|
23
|
+
s.add_dependency 'activesupport', '>= 3.2', '< 6.2'
|
24
|
+
s.add_dependency "contentstack_utils", '~> 1.0', '>= 1.0.1'
|
25
25
|
|
26
26
|
s.add_development_dependency 'rspec', '~> 3.10.0'
|
27
27
|
s.add_development_dependency 'webmock', '~> 3.11.0'
|
data/lib/contentstack/api.rb
CHANGED
@@ -3,16 +3,24 @@ 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
|
-
|
9
|
+
using Utility
|
10
|
+
def self.init_api(api_key, delivery_token, environment, host, branch, live_preview)
|
10
11
|
@host = host
|
11
12
|
@api_version = '/v3'
|
12
13
|
@environment = environment
|
13
14
|
@api_key = api_key
|
14
15
|
@access_token = delivery_token
|
16
|
+
@branch = branch
|
15
17
|
@headers = {environment: @environment}
|
18
|
+
@live_preview = live_preview
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.live_preview_query(query= {})
|
22
|
+
@live_preview[:content_type_uid] = query[:content_type_uid]
|
23
|
+
@live_preview[:live_preview] = query[:live_preview]
|
16
24
|
end
|
17
25
|
|
18
26
|
def self.fetch_content_types(uid="")
|
@@ -25,13 +33,23 @@ module Contentstack
|
|
25
33
|
end
|
26
34
|
|
27
35
|
def self.fetch_entries(content_type, query)
|
28
|
-
|
29
|
-
|
36
|
+
if @live_preview[:enable] && @live_preview[:content_type_uid] == content_type
|
37
|
+
path = "/content_types/#{content_type}/entries"
|
38
|
+
send_preview_request(path, query)
|
39
|
+
else
|
40
|
+
path = "/content_types/#{content_type}/entries"
|
41
|
+
send_request(path, query)
|
42
|
+
end
|
30
43
|
end
|
31
44
|
|
32
45
|
def self.fetch_entry(content_type, entry_uid, query)
|
33
|
-
|
34
|
-
|
46
|
+
if @live_preview[:enable] && @live_preview[:content_type_uid] == content_type
|
47
|
+
path = "/content_types/#{content_type}/entries/#{entry_uid}"
|
48
|
+
send_preview_request(path, query)
|
49
|
+
else
|
50
|
+
path = "/content_types/#{content_type}/entries/#{entry_uid}"
|
51
|
+
send_request(path, query)
|
52
|
+
end
|
35
53
|
end
|
36
54
|
|
37
55
|
def self.get_assets(asset_uid=nil)
|
@@ -53,12 +71,35 @@ module Contentstack
|
|
53
71
|
|
54
72
|
query = "?" + q.to_query
|
55
73
|
# puts "Request URL:- #{@host}#{@api_version}#{path}#{query} \n\n"
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
74
|
+
params = {
|
75
|
+
"api_key" => @api_key,
|
76
|
+
"access_token"=> @access_token,
|
77
|
+
"user_agent"=> "ruby-sdk/#{Contentstack::VERSION}",
|
78
|
+
"x-user-agent" => "ruby-sdk/#{Contentstack::VERSION}"
|
79
|
+
}
|
80
|
+
if !@branch.nil? && !@branch.empty?
|
81
|
+
params["branch"] = @branch
|
82
|
+
end
|
83
|
+
ActiveSupport::JSON.decode(open("#{@host}#{@api_version}#{path}#{query}",params).read)
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.send_preview_request(path, q=nil)
|
87
|
+
q ||= {}
|
88
|
+
|
89
|
+
q.merge!({live_preview: (!@live_preview.key?(:live_preview) ? 'init' : @live_preview[:live_preview]),})
|
90
|
+
|
91
|
+
query = "?" + q.to_query
|
92
|
+
preview_host = @live_preview[:host]
|
93
|
+
params = {
|
94
|
+
"api_key" => @api_key,
|
95
|
+
"authorization" => @live_preview[:management_token],
|
96
|
+
"user_agent"=> "ruby-sdk/#{Contentstack::VERSION}",
|
97
|
+
"x-user-agent" => "ruby-sdk/#{Contentstack::VERSION}"
|
98
|
+
}
|
99
|
+
if !@branch.nil? && !@branch.empty?
|
100
|
+
params["branch"] = @branch
|
101
|
+
end
|
102
|
+
ActiveSupport::JSON.decode(open("#{preview_host}#{@api_version}#{path}#{query}",params).read)
|
62
103
|
end
|
63
104
|
end
|
64
105
|
end
|
data/lib/contentstack/asset.rb
CHANGED
data/lib/contentstack/client.rb
CHANGED
@@ -2,14 +2,18 @@ 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={})
|
10
12
|
@region = options[:region].nil? ? Contentstack::Region::US : options[:region]
|
11
13
|
@host = options[:host].nil? ? get_default_region_hosts(@region) : options[:host]
|
12
|
-
|
14
|
+
@live_preview = !options.key?(:live_preview) ? {} : options[:live_preview]
|
15
|
+
@branch = options[:branch].nil? ? "" : options[:branch]
|
16
|
+
API.init_api(api_key, delivery_token, environment, @host, @branch, @live_preview)
|
13
17
|
end
|
14
18
|
|
15
19
|
def content_types
|
@@ -28,6 +32,9 @@ module Contentstack
|
|
28
32
|
Asset.new(uid)
|
29
33
|
end
|
30
34
|
|
35
|
+
def live_preview_query(query={})
|
36
|
+
API.live_preview_query(query)
|
37
|
+
end
|
31
38
|
|
32
39
|
# Syncs your Contentstack data with your app and ensures that the data is always up-to-date by providing delta updates
|
33
40
|
#
|
@@ -41,9 +48,9 @@ module Contentstack
|
|
41
48
|
#
|
42
49
|
# Stack.sync({'init': true, 'type': 'entry_published'}) // Use the type parameter to get a specific type of content.Supports 'asset_published', 'entry_published', 'asset_unpublished', 'entry_unpublished', 'asset_deleted', 'entry_deleted', 'content_type_deleted'.
|
43
50
|
#
|
44
|
-
# Stack.sync({'pagination_token': '<
|
51
|
+
# Stack.sync({'pagination_token': '<pagination>'}) // For fetching the next batch of entries using pagination token
|
45
52
|
#
|
46
|
-
# Stack.sync({'sync_token': '<
|
53
|
+
# Stack.sync({'sync_token': '<sync>'}) // For performing subsequent sync after initial sync
|
47
54
|
#
|
48
55
|
# @param params [Hash] params is an object that supports ‘locale’, ‘start_date’, ‘content_type_uid’, and ‘type’ queries.
|
49
56
|
def sync(params)
|
@@ -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)
|
@@ -152,6 +154,19 @@ module Contentstack
|
|
152
154
|
self
|
153
155
|
end
|
154
156
|
|
157
|
+
# Include the branch for publish content.
|
158
|
+
#
|
159
|
+
# Example
|
160
|
+
#
|
161
|
+
# @entry = @stack.content_type('product').entry(entry_uid)
|
162
|
+
# @entry.include_branch
|
163
|
+
#
|
164
|
+
# @return [Contentstack::Entry]
|
165
|
+
def include_branch(flag=true)
|
166
|
+
@query[:include_branch] = flag
|
167
|
+
self
|
168
|
+
end
|
169
|
+
|
155
170
|
# Include Embedded Objects (Entries and Assets) along with entry/entries details.
|
156
171
|
#
|
157
172
|
# Example
|
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
|
|
@@ -287,7 +289,7 @@ module Contentstack
|
|
287
289
|
end
|
288
290
|
|
289
291
|
# This method provides only the entries matching the specified value.
|
290
|
-
#
|
292
|
+
# @deprecated since version 0.5.0
|
291
293
|
# @param [String] text value used to match or compare
|
292
294
|
#
|
293
295
|
# Example
|
@@ -516,6 +518,19 @@ module Contentstack
|
|
516
518
|
self
|
517
519
|
end
|
518
520
|
|
521
|
+
# Include the branch for publish content.
|
522
|
+
#
|
523
|
+
# Example
|
524
|
+
#
|
525
|
+
# @query = @stack.content_type('product').query
|
526
|
+
# @query.include_branch
|
527
|
+
#
|
528
|
+
# @return [Contentstack::Entry]
|
529
|
+
def include_branch(flag=true)
|
530
|
+
@query[:include_branch] = flag
|
531
|
+
self
|
532
|
+
end
|
533
|
+
|
519
534
|
# Include Embedded Objects (Entries and Assets) along with entry/entries details.
|
520
535
|
#
|
521
536
|
# Example
|
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.
|
@@ -17,6 +15,8 @@ require "util"
|
|
17
15
|
# @stack = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name", {"region": Contentstack::Region::EU })
|
18
16
|
# == Initialize the Stack for custom host
|
19
17
|
# @stack = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name", {"host": "https://custom-cdn.contentstack.com" })
|
18
|
+
# == Initialize the Stack for EU region
|
19
|
+
# @stack = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name", {"branch":"branch_name" })
|
20
20
|
# == Usage
|
21
21
|
# ==== Get single entry
|
22
22
|
# @stack.content_type('blog').entry('<entry_uid_here>').fetch
|
@@ -26,4 +26,7 @@ module Contentstack
|
|
26
26
|
def self.render_content(content, options)
|
27
27
|
ContentstackUtils.render_content(content, options)
|
28
28
|
end
|
29
|
+
def self.json_to_html(content, options)
|
30
|
+
ContentstackUtils.json_to_html(content, options)
|
31
|
+
end
|
29
32
|
end
|
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
|