tourcms 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/README.md +4 -0
- data/VERSION +1 -1
- data/lib/tour_cms/connection.rb +5 -13
- data/lib/tourcms.rb +1 -2
- data/tourcms.gemspec +6 -7
- metadata +22 -19
- data/lib/tour_cms/hash.rb +0 -67
data/Gemfile
CHANGED
@@ -2,7 +2,7 @@ source "http://rubygems.org"
|
|
2
2
|
# Add dependencies required to use your gem here.
|
3
3
|
# Example:
|
4
4
|
# gem "activesupport", ">= 2.3.5"
|
5
|
-
gem '
|
5
|
+
gem 'activesupport', ">= 3.0.0"
|
6
6
|
|
7
7
|
# Add dependencies to develop your gem here.
|
8
8
|
# Include everything needed to run rake, tests, features, etc.
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
activesupport (3.0.7)
|
4
5
|
git (1.2.5)
|
5
6
|
jeweler (1.5.2)
|
6
7
|
bundler (~> 1.0.0)
|
7
8
|
git (>= 1.2.5)
|
8
9
|
rake
|
9
|
-
nokogiri (1.4.4)
|
10
10
|
rake (0.8.7)
|
11
11
|
rcov (0.9.9)
|
12
12
|
shoulda (2.11.3)
|
@@ -15,8 +15,8 @@ PLATFORMS
|
|
15
15
|
ruby
|
16
16
|
|
17
17
|
DEPENDENCIES
|
18
|
+
activesupport (>= 3.0.0)
|
18
19
|
bundler (~> 1.0.0)
|
19
20
|
jeweler (~> 1.5.2)
|
20
|
-
nokogiri
|
21
21
|
rcov
|
22
22
|
shoulda
|
data/README.md
CHANGED
@@ -77,6 +77,10 @@ Many TourCMS methods accept parameters. Most methods take a hash of parameters l
|
|
77
77
|
* show\_tour\_departures
|
78
78
|
* show\_tour\_freesale
|
79
79
|
|
80
|
+
## Dependencies
|
81
|
+
|
82
|
+
This gem depends on ActiveSupport 3.0.0+
|
83
|
+
|
80
84
|
## Contributing to tourcms
|
81
85
|
|
82
86
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/tour_cms/connection.rb
CHANGED
@@ -73,16 +73,6 @@ module TourCMS
|
|
73
73
|
end
|
74
74
|
|
75
75
|
private
|
76
|
-
|
77
|
-
def construct_params(param_hash)
|
78
|
-
if param_hash.empty?
|
79
|
-
res = ""
|
80
|
-
else
|
81
|
-
qs = param_hash.stringify.reject{|k,v| v.nil? || v.empty?}.collect{|k,v|"#{CGI.escape(k)}=#{CGI.escape(v)}"}.join("&")
|
82
|
-
qs.empty? ? res = "" : res = "?#{qs}"
|
83
|
-
end
|
84
|
-
res
|
85
|
-
end
|
86
76
|
|
87
77
|
def generate_signature(path, verb, channel, outbound_time)
|
88
78
|
string_to_sign = "#{channel}/#{@marketp_id}/#{verb}/#{outbound_time}#{path}".strip
|
@@ -93,14 +83,16 @@ module TourCMS
|
|
93
83
|
end
|
94
84
|
|
95
85
|
def request(path, channel = 0, params = {}, verb = "GET")
|
96
|
-
url = @base_url + path +
|
86
|
+
url = @base_url + path + "?#{params.to_query}"
|
97
87
|
req_time = Time.now.utc
|
98
|
-
signature = generate_signature(path +
|
88
|
+
signature = generate_signature(path + "?#{params.to_query}", verb, channel, req_time.to_i)
|
99
89
|
|
100
90
|
headers = {"Content-type" => "text/xml", "charset" => "utf-8", "Date" => req_time.strftime("%a, %d %b %Y %H:%M:%S GMT"),
|
101
91
|
"Authorization" => "TourCMS #{channel}:#{@marketp_id}:#{signature}" }
|
102
92
|
|
103
|
-
|
93
|
+
response = open(url, headers).read
|
94
|
+
|
95
|
+
@result_type == "raw" ? response : Hash.from_xml(response)["response"]
|
104
96
|
end
|
105
97
|
end
|
106
98
|
end
|
data/lib/tourcms.rb
CHANGED
data/tourcms.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{tourcms}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Alex Kremer"]
|
12
|
-
s.date = %q{2011-04-
|
12
|
+
s.date = %q{2011-04-20}
|
13
13
|
s.description = %q{A simple Ruby wrapper for interacting with the TourCMS API}
|
14
14
|
s.email = %q{alex@flextrip.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -24,7 +24,6 @@ Gem::Specification.new do |s|
|
|
24
24
|
"Rakefile",
|
25
25
|
"VERSION",
|
26
26
|
"lib/tour_cms/connection.rb",
|
27
|
-
"lib/tour_cms/hash.rb",
|
28
27
|
"lib/tourcms.rb",
|
29
28
|
"test/helper.rb",
|
30
29
|
"test/test_tourcms.rb",
|
@@ -33,7 +32,7 @@ Gem::Specification.new do |s|
|
|
33
32
|
s.homepage = %q{http://github.com/flextrip/tourcms}
|
34
33
|
s.licenses = ["MIT"]
|
35
34
|
s.require_paths = ["lib"]
|
36
|
-
s.rubygems_version = %q{1.
|
35
|
+
s.rubygems_version = %q{1.6.2}
|
37
36
|
s.summary = %q{A Ruby Library for the TourCMS API}
|
38
37
|
s.test_files = [
|
39
38
|
"test/helper.rb",
|
@@ -44,20 +43,20 @@ Gem::Specification.new do |s|
|
|
44
43
|
s.specification_version = 3
|
45
44
|
|
46
45
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
|
-
s.add_runtime_dependency(%q<
|
46
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 3.0.0"])
|
48
47
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
49
48
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
50
49
|
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
51
50
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
52
51
|
else
|
53
|
-
s.add_dependency(%q<
|
52
|
+
s.add_dependency(%q<activesupport>, [">= 3.0.0"])
|
54
53
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
55
54
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
56
55
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
57
56
|
s.add_dependency(%q<rcov>, [">= 0"])
|
58
57
|
end
|
59
58
|
else
|
60
|
-
s.add_dependency(%q<
|
59
|
+
s.add_dependency(%q<activesupport>, [">= 3.0.0"])
|
61
60
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
62
61
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
63
62
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tourcms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alex Kremer
|
@@ -15,23 +15,27 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-20 00:00:00 +02:00
|
19
|
+
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
22
|
+
prerelease: false
|
21
23
|
type: :runtime
|
22
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
23
25
|
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
27
|
-
hash:
|
29
|
+
hash: 7
|
28
30
|
segments:
|
31
|
+
- 3
|
29
32
|
- 0
|
30
|
-
|
33
|
+
- 0
|
34
|
+
version: 3.0.0
|
35
|
+
name: activesupport
|
31
36
|
version_requirements: *id001
|
32
|
-
name: nokogiri
|
33
|
-
prerelease: false
|
34
37
|
- !ruby/object:Gem::Dependency
|
38
|
+
prerelease: false
|
35
39
|
type: :development
|
36
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
37
41
|
none: false
|
@@ -42,10 +46,10 @@ dependencies:
|
|
42
46
|
segments:
|
43
47
|
- 0
|
44
48
|
version: "0"
|
45
|
-
version_requirements: *id002
|
46
49
|
name: shoulda
|
47
|
-
|
50
|
+
version_requirements: *id002
|
48
51
|
- !ruby/object:Gem::Dependency
|
52
|
+
prerelease: false
|
49
53
|
type: :development
|
50
54
|
requirement: &id003 !ruby/object:Gem::Requirement
|
51
55
|
none: false
|
@@ -58,10 +62,10 @@ dependencies:
|
|
58
62
|
- 0
|
59
63
|
- 0
|
60
64
|
version: 1.0.0
|
61
|
-
version_requirements: *id003
|
62
65
|
name: bundler
|
63
|
-
|
66
|
+
version_requirements: *id003
|
64
67
|
- !ruby/object:Gem::Dependency
|
68
|
+
prerelease: false
|
65
69
|
type: :development
|
66
70
|
requirement: &id004 !ruby/object:Gem::Requirement
|
67
71
|
none: false
|
@@ -74,10 +78,10 @@ dependencies:
|
|
74
78
|
- 5
|
75
79
|
- 2
|
76
80
|
version: 1.5.2
|
77
|
-
version_requirements: *id004
|
78
81
|
name: jeweler
|
79
|
-
|
82
|
+
version_requirements: *id004
|
80
83
|
- !ruby/object:Gem::Dependency
|
84
|
+
prerelease: false
|
81
85
|
type: :development
|
82
86
|
requirement: &id005 !ruby/object:Gem::Requirement
|
83
87
|
none: false
|
@@ -88,9 +92,8 @@ dependencies:
|
|
88
92
|
segments:
|
89
93
|
- 0
|
90
94
|
version: "0"
|
91
|
-
version_requirements: *id005
|
92
95
|
name: rcov
|
93
|
-
|
96
|
+
version_requirements: *id005
|
94
97
|
description: A simple Ruby wrapper for interacting with the TourCMS API
|
95
98
|
email: alex@flextrip.com
|
96
99
|
executables: []
|
@@ -108,11 +111,11 @@ files:
|
|
108
111
|
- Rakefile
|
109
112
|
- VERSION
|
110
113
|
- lib/tour_cms/connection.rb
|
111
|
-
- lib/tour_cms/hash.rb
|
112
114
|
- lib/tourcms.rb
|
113
115
|
- test/helper.rb
|
114
116
|
- test/test_tourcms.rb
|
115
117
|
- tourcms.gemspec
|
118
|
+
has_rdoc: true
|
116
119
|
homepage: http://github.com/flextrip/tourcms
|
117
120
|
licenses:
|
118
121
|
- MIT
|
@@ -142,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
145
|
requirements: []
|
143
146
|
|
144
147
|
rubyforge_project:
|
145
|
-
rubygems_version: 1.
|
148
|
+
rubygems_version: 1.6.2
|
146
149
|
signing_key:
|
147
150
|
specification_version: 3
|
148
151
|
summary: A Ruby Library for the TourCMS API
|
data/lib/tour_cms/hash.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
class Hash
|
2
|
-
def stringify
|
3
|
-
inject({}) do |options, (key, value)|
|
4
|
-
options[key.to_s] = value.to_s
|
5
|
-
options
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
class << self
|
10
|
-
def from_xml(xml_io)
|
11
|
-
begin
|
12
|
-
result = Nokogiri::XML(xml_io)
|
13
|
-
return { result.root.name.to_sym => xml_node_to_hash(result.root)}
|
14
|
-
rescue Exception => e
|
15
|
-
raise StandardError, "Could not parse TourCMS XML Response. Server error?"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def xml_node_to_hash(node)
|
20
|
-
# If we are at the root of the document, start the hash
|
21
|
-
if node.element?
|
22
|
-
result_hash = {}
|
23
|
-
if node.attributes != {}
|
24
|
-
result_hash[:attributes] = {}
|
25
|
-
node.attributes.keys.each do |key|
|
26
|
-
result_hash[:attributes][node.attributes[key].name.to_sym] = prepare(node.attributes[key].value)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
if node.children.size > 0
|
30
|
-
node.children.each do |child|
|
31
|
-
result = xml_node_to_hash(child)
|
32
|
-
|
33
|
-
if child.name == "text" || child.name == "#cdata-section"
|
34
|
-
unless child.next_sibling || child.previous_sibling
|
35
|
-
return prepare(result)
|
36
|
-
end
|
37
|
-
elsif result_hash[child.name.to_sym]
|
38
|
-
if result_hash[child.name.to_sym].is_a?(Object::Array)
|
39
|
-
result_hash[child.name.to_sym] << prepare(result)
|
40
|
-
else
|
41
|
-
result_hash[child.name.to_sym] = [result_hash[child.name.to_sym]] << prepare(result)
|
42
|
-
end
|
43
|
-
else
|
44
|
-
result_hash[child.name.to_sym] = prepare(result)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
return result_hash
|
49
|
-
else
|
50
|
-
return result_hash
|
51
|
-
end
|
52
|
-
else
|
53
|
-
return prepare(node.content.to_s)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def prepare(data)
|
58
|
-
data = "" if data == "\n\t"
|
59
|
-
(data.class == String && data.to_i.to_s == data) ? data.to_i : data
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def to_struct(struct_name)
|
64
|
-
Struct.new(struct_name,*keys).new(*values)
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|