mambanation 0.1.25 → 0.1.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION.yml +3 -3
  2. data/lib/mambanation/base.rb +19 -2
  3. metadata +4 -4
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- :minor: 1
3
- :patch: 25
4
- :build:
5
2
  :major: 0
3
+ :build:
4
+ :minor: 1
5
+ :patch: 26
@@ -151,8 +151,25 @@ module MambaNation
151
151
  perform_get("/posts/#{id}.json", :query => query)
152
152
  end
153
153
 
154
- def user_posts(id, application_id, query = {})
155
- perform_get("/users/#{id.to_i}/posts.json", :query => { :application_id => application_id }.merge(query))
154
+ # options:
155
+ # application_id Integer,
156
+ # posts Array, Hash, String
157
+ def user_posts(id, query = {})
158
+ query[:posts] = CGI.escape(urlencode_array({:posts => query[:posts]})) if query.is_a?(Hash) && query[:posts]
159
+
160
+ perform_get("/users/#{id.to_i}/posts.json", :query => query)
161
+ end
162
+
163
+ def urlencode_array(value_hash)
164
+ return_string = ''
165
+ value_hash.each_pair do |k,v|
166
+ return_string = case v.class.to_s
167
+ when "Hash" then urlencode_array(v)
168
+ when "Array" then v.map { |value| value.is_a?(Hash) ? urlencode_array(value) : "#{k}[]=#{value}" }.join('&')
169
+ else "#{k}[]=#{v}"
170
+ end
171
+ end
172
+ return_string
156
173
  end
157
174
 
158
175
  def create_post(id, post, application_id, query = {})
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mambanation
3
3
  version: !ruby/object:Gem::Version
4
- hash: 41
4
+ hash: 47
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 25
10
- version: 0.1.25
9
+ - 26
10
+ version: 0.1.26
11
11
  platform: ruby
12
12
  authors:
13
13
  - "J\xC3\xA9r\xC3\xA9my Van de Wyngaert"
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-10-20 00:00:00 +02:00
20
+ date: 2010-10-25 00:00:00 +02:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency