snoo 0.1.0.pre.2 → 0.1.0.pre.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -163,7 +163,7 @@ module Snoo
163
163
  # @param (see #delete_header)
164
164
  # @return (see #clear_sessions)
165
165
  def add_moderator container, user, subreddit
166
- friend_wrapper api_container = container, api_name = user, api_subreddit = subreddit, api_type = "moderator"
166
+ friend_wrapper container: container, name: user, r: subreddit, type: "moderator"
167
167
  end
168
168
 
169
169
  # Add a contributor to the subreddit
@@ -171,7 +171,7 @@ module Snoo
171
171
  # @param (see #add_moderator)
172
172
  # @return (see #clear_sessions)
173
173
  def add_contributor container, user, subreddit
174
- friend_wrapper api_container = container, api_name = user, api_subreddit = subreddit, api_type = "contributor"
174
+ friend_wrapper container: container, name: user, r: subreddit, type: "contributor"
175
175
  end
176
176
 
177
177
  # Ban a user from a subreddit
@@ -179,7 +179,7 @@ module Snoo
179
179
  # @param (see #add_moderator)
180
180
  # @return (see #clear_sessions)
181
181
  def ban_user container, user, subreddit
182
- friend_wrapper api_container = container, api_name = user, api_subreddit = subreddit, api_type ="banned"
182
+ friend_wrapper container: container, name: user, r: subreddit, type: "banned"
183
183
  end
184
184
 
185
185
  # Remove a moderator from a subreddit
@@ -187,24 +187,24 @@ module Snoo
187
187
  # @param id [String] The user id
188
188
  # @param (see #add_moderator)
189
189
  # @return (see #clear_sessions)
190
- def remove_moderator id, container, user, subreddit
191
- unfriend_wrapper api_id = id, api_container = container, api_name = user, api_subreddit = subreddit, api_type = "moderator"
190
+ def remove_moderator container, user, subreddit
191
+ unfriend_wrapper container: container, name: user, r: subreddit, type: "moderator"
192
192
  end
193
193
 
194
194
  # Remove a contributor from a subreddit
195
195
  #
196
196
  # @param (see #remove_moderator)
197
197
  # @return (see #clear_sessions)
198
- def remove_contributor id, container, user, subreddit
199
- unfriend_wrapper api_id = id, api_container = container, api_name = user, api_subreddit = subreddit, api_type = "contributor"
198
+ def remove_contributor container, user, subreddit
199
+ unfriend_wrapper container: container, name: user, r: subreddit, type: "contributor"
200
200
  end
201
201
 
202
202
  # Unban a user from a subreddit
203
203
  #
204
204
  # @param (see #remove_moderator)
205
205
  # @return (see #clear_sessions)
206
- def unban_user id, container, user, subreddit
207
- unfriend_wrapper api_id = id, api_container = container, api_name = user, api_subreddit = subreddit, api_type = "banned"
206
+ def unban_user container, user, subreddit
207
+ unfriend_wrapper container: container, name: user, r: subreddit, type: "banned"
208
208
  end
209
209
 
210
210
  # List moderators of a subreddit
@@ -234,7 +234,7 @@ module Snoo
234
234
  end
235
235
 
236
236
  # Accept a moderatorship
237
- #
237
+ #
238
238
  # @param subreddit [String] The subreddit to accept in. You must have been invited
239
239
  def accept_moderator subreddit
240
240
  logged_in?
@@ -36,38 +36,32 @@ module Snoo
36
36
  end
37
37
 
38
38
  # Posts to '/api/friend'. This method exists because there are tons of things that use this
39
+ # See http://www.reddit.com/dev/api#POST_api_friend for details
39
40
  #
40
- # @param api_type [friend, moderator, contributor, banned] Type of action to use. All but friend target subreddits
41
- # @param api_container [String] Thing ID, either subreddit (t5_) or user adding friend (t2_)
42
- # @param api_name [String] Username to add
43
- # @param api_note [String] Note to leave. Requires reddit gold
44
- # @param api_subreddit [String] Subreddit name
41
+ # @param opts [Hash] an options hash
42
+ # @option opts [String] :type The type of action to add.
43
+ # @option opts [String] :container The id of the containing user/object/thing
44
+ # @options opt [String] :note The reddit gold user node
45
+ # @option opts [String] :name The name of a reddit user
45
46
  # @return [HTTParty::Response] The response object.
46
- def friend_wrapper api_type, api_container = nil, api_name = nil, api_note = nil, api_subreddit = nil
47
+ def friend_wrapper opts = {}
47
48
  logged_in?
48
- params = {type: api_type, uh: @modhash}
49
- params[:container] = api_container if api_container
50
- params[:name] = api_name if api_name
51
- params[:note] = api_note if api_note
52
- params[:r] = api_subreddit if api_subreddit
49
+ params = {uh: @modhash}
50
+ params.merge! opts
53
51
  post('/api/friend', body: params)
54
52
  end
55
53
 
56
54
  # Posts to '/api/unfriend'. This method exists because there are a ton of things that use this.
57
55
  #
58
- # @param api_type [friend, enemy, moderator, contributor, banned] Type of removal
59
- # @param api_container [String] Thing ID, either subreddit (t5_) or user adding friend (t2_)
60
- # @param api_name [String] User name
61
- # @param api_id [String] User ID of user being removed
62
- # @param api_subreddit [String] Subreddit name
56
+ # @param opts [Hash] an options hash
57
+ # @option opts [String] :type The type of action to add.
58
+ # @option opts [String] :container The id of the containing user/object/thing
59
+ # @option opts [String] :name The name of a reddit user
63
60
  # @return (see #friend_wrapper)
64
- def unfriend_wrapper api_type, api_container = nil, api_name = nil, api_id = nil, api_subreddit = nil
61
+ def unfriend_wrapper opts = {}
65
62
  logged_in?
66
- params = { type: api_type, uh: @modhash}
67
- params[:container] = api_container if api_container
68
- params[:name] = api_name if api_name
69
- params[:id] = api_id if api_id
70
- params[:r] = api_subreddit if api_subreddit
63
+ params = { uh: @modhash}
64
+ params.merge! opts
71
65
  post('/api/unfriend', body: params)
72
66
  end
73
67
  end
data/lib/snoo/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Snoo
2
2
  # The version string (duh)
3
- VERSION = "0.1.0.pre.2"
3
+ VERSION = "0.1.0.pre.3"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snoo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.2
4
+ version: 0.1.0.pre.3
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-25 00:00:00.000000000 Z
12
+ date: 2012-10-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  version: 1.3.1
118
118
  requirements: []
119
119
  rubyforge_project:
120
- rubygems_version: 1.8.24
120
+ rubygems_version: 1.8.23
121
121
  signing_key:
122
122
  specification_version: 3
123
123
  summary: A simple reddit api wrapper