freckly 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,5 +1,2 @@
1
1
  source "http://rubygems.org"
2
-
3
- gem "faraday", :git => "git://github.com/railslove/faraday.git", :branch => "hacking"
4
-
5
2
  gemspec
@@ -1,17 +1,8 @@
1
- GIT
2
- remote: git://github.com/railslove/faraday.git
3
- revision: 1c4337bfd46a0a524ec510daf8d9ab21df645767
4
- branch: hacking
5
- specs:
6
- faraday (0.5.3)
7
- addressable (~> 2.2.2)
8
- multipart-post (~> 1.0.1)
9
- rack (>= 1.1.0, < 2)
10
-
11
1
  PATH
12
2
  remote: .
13
3
  specs:
14
- freckly (0.0.2)
4
+ freckly (0.0.3)
5
+ faraday (~> 0.5.7)
15
6
  faraday_middleware (~> 0.3.0)
16
7
  hashie (~> 0.4.0)
17
8
  multi_xml (~> 0.2.0)
@@ -19,15 +10,19 @@ PATH
19
10
  GEM
20
11
  remote: http://rubygems.org/
21
12
  specs:
22
- addressable (2.2.2)
13
+ addressable (2.2.4)
23
14
  crack (0.1.8)
24
15
  diff-lcs (1.1.2)
25
- faraday_middleware (0.3.0)
26
- faraday (~> 0.5.3)
16
+ faraday (0.5.7)
17
+ addressable (~> 2.2.4)
18
+ multipart-post (~> 1.1.0)
19
+ rack (>= 1.1.0, < 2)
20
+ faraday_middleware (0.3.2)
21
+ faraday (~> 0.5.4)
27
22
  hashie (0.4.0)
28
- multi_xml (0.2.0)
29
- multipart-post (1.0.1)
30
- rack (1.2.1)
23
+ multi_xml (0.2.2)
24
+ multipart-post (1.1.0)
25
+ rack (1.2.2)
31
26
  rake (0.8.7)
32
27
  rspec (2.1.0)
33
28
  rspec-core (~> 2.1.0)
@@ -37,7 +32,7 @@ GEM
37
32
  rspec-expectations (2.1.0)
38
33
  diff-lcs (~> 1.1.2)
39
34
  rspec-mocks (2.1.0)
40
- webmock (1.6.1)
35
+ webmock (1.6.2)
41
36
  addressable (>= 2.2.2)
42
37
  crack (>= 0.1.7)
43
38
 
@@ -45,11 +40,7 @@ PLATFORMS
45
40
  ruby
46
41
 
47
42
  DEPENDENCIES
48
- faraday!
49
- faraday_middleware (~> 0.3.0)
50
43
  freckly!
51
- hashie (~> 0.4.0)
52
- multi_xml (~> 0.2.0)
53
44
  rake (~> 0.8.7)
54
45
  rspec (~> 2.1.0)
55
46
  webmock (~> 1.6.1)
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.rubyforge_project = "freckly"
16
16
 
17
- #s.add_dependency "faraday", "~> 0.5.3"
17
+ s.add_dependency "faraday", "~> 0.5.7"
18
18
  s.add_dependency "faraday_middleware", "~> 0.3.0"
19
19
  s.add_dependency "multi_xml", "~> 0.2.0"
20
20
  s.add_dependency "hashie", "~> 0.4.0"
@@ -9,6 +9,8 @@ require "multi_xml"
9
9
  require "freckly/project"
10
10
  require "freckly/entry"
11
11
  require "freckly/faraday/parse_xml"
12
+ require "freckly/ext/enumerable"
13
+ require "freckly/faraday/utils"
12
14
 
13
15
  module Freckly
14
16
  class << self
@@ -0,0 +1,47 @@
1
+ module Enumerable
2
+ def to_param(options={})
3
+ escape = options[:escape]
4
+ previous_base = options[:base]
5
+ parts = []
6
+
7
+ self.to_a.each do |key, value|
8
+ base = build_base(key, previous_base)
9
+
10
+ case value
11
+ when Array
12
+ values = value.map(&:strip).join(",")
13
+ parts << build_param(base, values)
14
+ when Hash
15
+ parts << value.to_param(:escape => false, :base => base)
16
+ else
17
+ parts << (escape ? build_escaped_param(base, value) : build_param(base, value))
18
+ end
19
+ end
20
+
21
+ parts.join("&")
22
+ end
23
+
24
+ private
25
+
26
+ def escape(s)
27
+ s.to_s.gsub(/([^a-zA-Z0-9_.-]+)/n) do
28
+ '%' << $1.unpack('H2'* $1.bytesize).join('%').tap { |c| c.upcase! }
29
+ end
30
+ end
31
+
32
+ # {:a => {:b => {:c => "d"}}} => a[b][c]...
33
+ # {:a => {:b => "d"}} => a[b]...
34
+ def build_base(key, previous_base)
35
+ return key unless previous_base
36
+
37
+ "#{previous_base}[#{key}]"
38
+ end
39
+
40
+ def build_param(base, value)
41
+ "#{base}=#{value}"
42
+ end
43
+
44
+ def build_escaped_param(base, value)
45
+ "#{escape(base)}=#{escape(value)}"
46
+ end
47
+ end
@@ -0,0 +1,7 @@
1
+ module Faraday
2
+ module Utils
3
+ def build_query(params)
4
+ params.to_param(:escape => true)
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module Freckly
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freckly
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 3
10
- version: 0.0.3
4
+ prerelease:
5
+ version: 0.0.5
11
6
  platform: ruby
12
7
  authors:
13
8
  - Red Davis
@@ -15,105 +10,86 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2010-11-16 00:00:00 +00:00
13
+ date: 2011-03-21 00:00:00 +00:00
19
14
  default_executable:
20
15
  dependencies:
21
16
  - !ruby/object:Gem::Dependency
22
- name: faraday_middleware
17
+ name: faraday
23
18
  prerelease: false
24
19
  requirement: &id001 !ruby/object:Gem::Requirement
25
20
  none: false
26
21
  requirements:
27
22
  - - ~>
28
23
  - !ruby/object:Gem::Version
29
- hash: 19
30
- segments:
31
- - 0
32
- - 3
33
- - 0
34
- version: 0.3.0
24
+ version: 0.5.7
35
25
  type: :runtime
36
26
  version_requirements: *id001
37
27
  - !ruby/object:Gem::Dependency
38
- name: multi_xml
28
+ name: faraday_middleware
39
29
  prerelease: false
40
30
  requirement: &id002 !ruby/object:Gem::Requirement
41
31
  none: false
42
32
  requirements:
43
33
  - - ~>
44
34
  - !ruby/object:Gem::Version
45
- hash: 23
46
- segments:
47
- - 0
48
- - 2
49
- - 0
50
- version: 0.2.0
35
+ version: 0.3.0
51
36
  type: :runtime
52
37
  version_requirements: *id002
53
38
  - !ruby/object:Gem::Dependency
54
- name: hashie
39
+ name: multi_xml
55
40
  prerelease: false
56
41
  requirement: &id003 !ruby/object:Gem::Requirement
57
42
  none: false
58
43
  requirements:
59
44
  - - ~>
60
45
  - !ruby/object:Gem::Version
61
- hash: 15
62
- segments:
63
- - 0
64
- - 4
65
- - 0
66
- version: 0.4.0
46
+ version: 0.2.0
67
47
  type: :runtime
68
48
  version_requirements: *id003
69
49
  - !ruby/object:Gem::Dependency
70
- name: rspec
50
+ name: hashie
71
51
  prerelease: false
72
52
  requirement: &id004 !ruby/object:Gem::Requirement
73
53
  none: false
74
54
  requirements:
75
55
  - - ~>
76
56
  - !ruby/object:Gem::Version
77
- hash: 11
78
- segments:
79
- - 2
80
- - 1
81
- - 0
57
+ version: 0.4.0
58
+ type: :runtime
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: rspec
62
+ prerelease: false
63
+ requirement: &id005 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
82
68
  version: 2.1.0
83
69
  type: :development
84
- version_requirements: *id004
70
+ version_requirements: *id005
85
71
  - !ruby/object:Gem::Dependency
86
72
  name: webmock
87
73
  prerelease: false
88
- requirement: &id005 !ruby/object:Gem::Requirement
74
+ requirement: &id006 !ruby/object:Gem::Requirement
89
75
  none: false
90
76
  requirements:
91
77
  - - ~>
92
78
  - !ruby/object:Gem::Version
93
- hash: 13
94
- segments:
95
- - 1
96
- - 6
97
- - 1
98
79
  version: 1.6.1
99
80
  type: :development
100
- version_requirements: *id005
81
+ version_requirements: *id006
101
82
  - !ruby/object:Gem::Dependency
102
83
  name: rake
103
84
  prerelease: false
104
- requirement: &id006 !ruby/object:Gem::Requirement
85
+ requirement: &id007 !ruby/object:Gem::Requirement
105
86
  none: false
106
87
  requirements:
107
88
  - - ~>
108
89
  - !ruby/object:Gem::Version
109
- hash: 49
110
- segments:
111
- - 0
112
- - 8
113
- - 7
114
90
  version: 0.8.7
115
91
  type: :development
116
- version_requirements: *id006
92
+ version_requirements: *id007
117
93
  description: Wrapper for Freckle
118
94
  email:
119
95
  - red@railslove.com
@@ -135,7 +111,9 @@ files:
135
111
  - freckly.gemspec
136
112
  - lib/freckly.rb
137
113
  - lib/freckly/entry.rb
114
+ - lib/freckly/ext/enumerable.rb
138
115
  - lib/freckly/faraday/parse_xml.rb
116
+ - lib/freckly/faraday/utils.rb
139
117
  - lib/freckly/project.rb
140
118
  - lib/freckly/version.rb
141
119
  - spec/fixtures/entries.xml
@@ -158,23 +136,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
136
  requirements:
159
137
  - - ">="
160
138
  - !ruby/object:Gem::Version
161
- hash: 3
162
- segments:
163
- - 0
164
139
  version: "0"
165
140
  required_rubygems_version: !ruby/object:Gem::Requirement
166
141
  none: false
167
142
  requirements:
168
143
  - - ">="
169
144
  - !ruby/object:Gem::Version
170
- hash: 3
171
- segments:
172
- - 0
173
145
  version: "0"
174
146
  requirements: []
175
147
 
176
148
  rubyforge_project: freckly
177
- rubygems_version: 1.3.7
149
+ rubygems_version: 1.5.2
178
150
  signing_key:
179
151
  specification_version: 3
180
152
  summary: Wrapper for Freckle