snoo 0.1.0.pre.8 → 0.1.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.
data/README.md CHANGED
@@ -53,11 +53,6 @@ See the [docs](http://rubydoc.info/github/paradox460/snoo/) for more info.
53
53
  4. Push to the branch (`git push origin my-new-feature`)
54
54
  5. Create new Pull Request
55
55
 
56
- ## Testing
57
-
58
- 1. Edit `spec/auth.rb` and fill out all the globals with a test user account and test reddit
59
- 2. Run rspec
60
-
61
56
  ## License
62
57
 
63
58
  ```
@@ -49,7 +49,7 @@ module Snoo
49
49
  # @return (see #log_in)
50
50
  def clear_sessions password
51
51
  logged_in?
52
- clear = post('/api/clear_sessions', body: { curpass: password, dest: @baseurl, uh: @modhash })
52
+ clear = post('/api/clear_sessions', body: { curpass: password, dest: @baseurl, uh: @modhash, api_type: 'json' })
53
53
  set_cookies clear.headers['set-cookie']
54
54
  return clear
55
55
  end
@@ -67,7 +67,8 @@ module Snoo
67
67
  delete_message: reason,
68
68
  passwd: password,
69
69
  uh: @modhash,
70
- user: @username
70
+ user: @username,
71
+ api_type: 'json'
71
72
  })
72
73
  return delete
73
74
  end
@@ -93,7 +94,8 @@ module Snoo
93
94
  newpass: newPass,
94
95
  uh: @modhash,
95
96
  verify: true,
96
- verpass: newPass
97
+ verpass: newPass,
98
+ api_type: 'json'
97
99
  }
98
100
  params[:email] = email if email
99
101
  update = post('/api/update', body: params )
@@ -12,7 +12,7 @@ module Snoo
12
12
  # @return (see #clear_sessions)
13
13
  def clear_flair_templates type, subreddit
14
14
  logged_in?
15
- post('/api/clearflairtemplates', body: { flair_type: type, r: subreddit, uh: @modhash})
15
+ post('/api/clearflairtemplates', body: { flair_type: type, r: subreddit, uh: @modhash, api_type: 'json'})
16
16
  end
17
17
 
18
18
  # Deletes a user's flair
@@ -22,16 +22,16 @@ module Snoo
22
22
  # @return (see #clear_sessions)
23
23
  def delete_user_flair user, subreddit
24
24
  logged_in?
25
- post('/api/deleteflair', body: {name: user, r: subreddit, uh: @modhash})
25
+ post('/api/deleteflair', body: {name: user, r: subreddit, uh: @modhash, api_type: 'json'})
26
26
  end
27
27
 
28
28
  # Deletes a flair template by ID.
29
29
  #
30
- # @param id [String] The flair template's ID to delete. Get this from {#flair_template_list}
30
+ # @param id [String] The flair template's ID to delete.
31
31
  # @param subreddit [String] The subreddit targeted.
32
32
  def delete_flair_template id, subreddit
33
33
  logged_in?
34
- post('/api/deleteflairtemplate', body: {flair_template_id: id, r: subreddit, uh: @modhash})
34
+ post('/api/deleteflairtemplate', body: {flair_template_id: id, r: subreddit, uh: @modhash, api_type: 'json'})
35
35
  end
36
36
 
37
37
  # Sets flair on a thing, currently supports links and users. Must specify **either** link *or* user, **not** both
@@ -48,6 +48,7 @@ module Snoo
48
48
  params = {
49
49
  r: subreddit,
50
50
  uh: @modhash,
51
+ api_type: 'json'
51
52
  }
52
53
  params.merge! opts
53
54
 
@@ -73,7 +74,8 @@ module Snoo
73
74
  link_flair_position: 'right',
74
75
  link_flair_self_assign_enabled: false,
75
76
  uh: @modhash,
76
- r: subreddit
77
+ r: subreddit,
78
+ api_type: 'json'
77
79
  }
78
80
  options.merge! opts
79
81
 
@@ -124,7 +126,8 @@ module Snoo
124
126
  flair_type: 'USER_FLAIR',
125
127
  text_editable: false,
126
128
  uh: @modhash,
127
- r: subreddit
129
+ r: subreddit,
130
+ api_type: 'json'
128
131
  }
129
132
  params.merge! opts
130
133
 
@@ -133,7 +136,7 @@ module Snoo
133
136
 
134
137
  # Select a flair template and apply it to a user or link
135
138
  #
136
- # @param template_id [String] The template id to apply. Get this from {#flair_template_list}
139
+ # @param template_id [String] The template id to apply.
137
140
  # @param subreddit [String] The subreddit targeted.
138
141
  # @param (see LinksComments#info)
139
142
  # @option opts [String] :link The link id to apply to
@@ -145,7 +148,8 @@ module Snoo
145
148
  params = {
146
149
  flair_template_id: template_id,
147
150
  uh: @modhash,
148
- r: subreddit
151
+ r: subreddit,
152
+ api_type: 'json'
149
153
  }
150
154
  params.merge! opts
151
155
  post('/api/selectflair', body: params)
@@ -158,12 +162,12 @@ module Snoo
158
162
  # @return (see #clear_sessions)
159
163
  def flair_toggle enabled, subreddit
160
164
  logged_in?
161
- post('/api/setflairenabled', body: {flair_enabled: enabled, uh: @modhash, r: subreddit})
165
+ post('/api/setflairenabled', body: {flair_enabled: enabled, uh: @modhash, r: subreddit, api_type: 'json'})
162
166
  end
163
167
 
164
168
  # @todo implement this.
165
169
  # it will probably require nokogiri and some trickery.
166
- def flair_template_list
167
- end
170
+ # def flair_template_list
171
+ # end
168
172
  end
169
173
  end
@@ -11,7 +11,7 @@ module Snoo
11
11
  # @return (see #clear_sessions)
12
12
  def comment text, id
13
13
  logged_in?
14
- post('/api/comment', body: { text: text, thing_id: id, uh: @modhash})
14
+ post('/api/comment', body: { text: text, thing_id: id, uh: @modhash, api_type: 'json'})
15
15
  end
16
16
 
17
17
  # Deletes a thing from the site
@@ -20,7 +20,7 @@ module Snoo
20
20
  # @return (see #clear_sessions)
21
21
  def delete id
22
22
  logged_in?
23
- post('/api/del', body: { id: id, uh: @modhash })
23
+ post('/api/del', body: { id: id, uh: @modhash, api_type: 'json' })
24
24
  end
25
25
 
26
26
  # Edits a thing.
@@ -30,7 +30,7 @@ module Snoo
30
30
  # @return (see #clear_sessions)
31
31
  def edit text, id
32
32
  logged_in?
33
- post('/api/editusertext', body: {text: text, thing_id: id, uh: @modhash})
33
+ post('/api/editusertext', body: {text: text, thing_id: id, uh: @modhash, api_type: 'json'})
34
34
  end
35
35
 
36
36
  # Hides a thing
@@ -39,7 +39,7 @@ module Snoo
39
39
  # @return (see #clear_sessions)
40
40
  def hide id
41
41
  logged_in?
42
- post('/api/hide', body: {id: id, uh: @modhash})
42
+ post('/api/hide', body: {id: id, uh: @modhash, api_type: 'json'})
43
43
  end
44
44
 
45
45
  # Get a listing of things which have the provided URL.
@@ -63,7 +63,7 @@ module Snoo
63
63
  # @return (see #clear_sessions)
64
64
  def mark_nsfw id
65
65
  logged_in?
66
- post('/api/marknsfw', body: {id: id, uh: @modhash})
66
+ post('/api/marknsfw', body: {id: id, uh: @modhash, api_type: 'json'})
67
67
  end
68
68
 
69
69
  # Reports a comment or link
@@ -72,7 +72,7 @@ module Snoo
72
72
  # @reutrn (see #comment)
73
73
  def report id
74
74
  logged_in?
75
- post('/api/report', body: {id: id, uh: @modhash})
75
+ post('/api/report', body: {id: id, uh: @modhash, api_type: 'json'})
76
76
  end
77
77
 
78
78
  # Saves a link
@@ -81,7 +81,7 @@ module Snoo
81
81
  # @return (see #clear_sessions)
82
82
  def save id
83
83
  logged_in?
84
- post('/api/save', body: { id: id, uh: @modhash})
84
+ post('/api/save', body: { id: id, uh: @modhash, api_type: 'json'})
85
85
  end
86
86
 
87
87
  # Submit a link or self post
@@ -98,7 +98,8 @@ module Snoo
98
98
  title: title,
99
99
  sr: subreddit,
100
100
  uh: @modhash,
101
- kind: (opts[:url] ? "link" : "self")
101
+ kind: (opts[:url] ? "link" : "self"),
102
+ api_type: 'json'
102
103
  }
103
104
  post.merge! opts
104
105
  post('/api/submit', body: post)
@@ -110,7 +111,7 @@ module Snoo
110
111
  # @return (see #clear_sessions)
111
112
  def unhide id
112
113
  logged_in?
113
- post('/api/unhide', body: {id: id, uh: @modhash})
114
+ post('/api/unhide', body: {id: id, uh: @modhash, api_type: 'json'})
114
115
  end
115
116
 
116
117
  # Un-mark NSFW a thing.
@@ -119,7 +120,7 @@ module Snoo
119
120
  # @return (see #clear_sessions)
120
121
  def unmark_nsfw id
121
122
  logged_in?
122
- post('/api/unmarknsfw', body: {id: id, uh: @modhash})
123
+ post('/api/unmarknsfw', body: {id: id, uh: @modhash, api_type: 'json'})
123
124
  end
124
125
  alias_method :mark_sfw, :unmark_nsfw
125
126
 
@@ -130,7 +131,7 @@ module Snoo
130
131
  # @return (see #clear_sessions)
131
132
  def vote direction, id
132
133
  logged_in?
133
- post('/api/vote', body: {id: id, dir: direction, uh: @modhash})
134
+ post('/api/vote', body: {id: id, dir: direction, uh: @modhash, api_type: 'json'})
134
135
  end
135
136
 
136
137
  # Upvote
@@ -6,7 +6,6 @@ module Snoo
6
6
 
7
7
  # Get a comment listing from the site
8
8
  #
9
- # @param link_id [String] The link id of the comment thread. Must always be present
10
9
  # @param (see LinksComments#info)
11
10
  # @option opts [String] :subreddit The subreddit to fetch the comments of
12
11
  # @option opts [String] :link_id The link to get the comments of
@@ -57,11 +56,6 @@ module Snoo
57
56
  # @option opts [cloudsearch, lucene] :syntax The search syntax.
58
57
  # @return (see #clear_sessions)
59
58
  def search query, opts = {}
60
- raise ArgumentError, 'restrict_subreddit needs to be boolean' unless [true, false].include?(opts[:restrict_sr]) or opts[:restrict_sr].nil?
61
- raise ArgumentError, "limit needs to be 1..100, is #{opts[:limit]}" unless (1..100).include?(opts[:limit]) or opts[:limit].nil?
62
- raise ArgumentError, "sort needs to be one of relevance, new, top, is #{opts[:sort]}" unless %w{relevance new top}.include?(opts[:sort]) or opts[:sort].nil?
63
- raise ArgumentError, "syntax needs to be one of cloudsearch, lucene; is #{opts[:syntax]}" if %w{cloudsearch lucene}.include?(opts[:syntax])
64
-
65
59
  # This supports searches with and without a subreddit
66
60
  url = "%s/search.json" % ('/r/' + opts[:subreddit] if opts[:subreddit])
67
61
 
@@ -10,7 +10,7 @@ module Snoo
10
10
  # @return (see #clear_sessions)
11
11
  def approve id
12
12
  logged_in?
13
- post('/api/approve', body: {id: id, uh: @modhash})
13
+ post('/api/approve', body: {id: id, uh: @modhash, api_type: 'json'})
14
14
  end
15
15
 
16
16
  # Distinguish a thing
@@ -21,7 +21,7 @@ module Snoo
21
21
  def distinguish id, how = "yes"
22
22
  logged_in?
23
23
  hows = %w{yes no admin special}
24
- post('/api/distinguish', body: {id: id, how: how, uh: @modhash})
24
+ post('/api/distinguish', body: {id: id, how: how, uh: @modhash, api_type: 'json'})
25
25
  end
26
26
 
27
27
  # Removes you from a subreddits list of contributors
@@ -31,7 +31,7 @@ module Snoo
31
31
  # @return (see #clear_sessions)
32
32
  def leave_contributor id
33
33
  logged_in?
34
- post('/api/leavecontributor', body: {id: id, uh: @modhash})
34
+ post('/api/leavecontributor', body: {id: id, uh: @modhash, api_type: 'json'})
35
35
  end
36
36
 
37
37
  # Removes you from a subreddits moderators
@@ -41,7 +41,7 @@ module Snoo
41
41
  # @return (see #clear_sessions)
42
42
  def leave_moderator id
43
43
  logged_in?
44
- post('/api/leavemoderator', body: {id: id, uh: @modhash})
44
+ post('/api/leavemoderator', body: {id: id, uh: @modhash, api_type: 'json'})
45
45
  end
46
46
 
47
47
  # Removes a thing
@@ -51,7 +51,7 @@ module Snoo
51
51
  # @return (see #clear_sessions)
52
52
  def remove id, spam = false
53
53
  logged_in?
54
- post('/api/remove', body: {id: id, spam: spam, uh: @modhash})
54
+ post('/api/remove', body: {id: id, spam: spam, uh: @modhash, api_type: 'json'})
55
55
  end
56
56
 
57
57
  # Gets a moderation log
@@ -10,7 +10,7 @@ module Snoo
10
10
  # @return (see #clear_sessions)
11
11
  def block_pm id
12
12
  logged_in?
13
- post('/api/block', body: {id: id, uh: @modhash})
13
+ post('/api/block', body: {id: id, uh: @modhash, api_type: 'json'})
14
14
  end
15
15
 
16
16
  # Send a private message
@@ -22,7 +22,7 @@ module Snoo
22
22
  # @return (see #clear_sessions)
23
23
  def send_pm to, subject, text
24
24
  logged_in?
25
- post('/api/compose.json', body: {to: to, subject: subject, text: text, uh: @modhash})
25
+ post('/api/compose.json', body: {to: to, subject: subject, text: text, uh: @modhash, api_type: 'json'})
26
26
  end
27
27
 
28
28
  # Mark a PM as read
@@ -31,7 +31,7 @@ module Snoo
31
31
  # @return (see #clear_sessions)
32
32
  def mark_read id
33
33
  logged_in?
34
- post('/api/read_message', body: {id: id, uh: @modhash})
34
+ post('/api/read_message', body: {id: id, uh: @modhash, api_type: 'json'})
35
35
  end
36
36
 
37
37
  # Mark a PM as unread
@@ -40,7 +40,7 @@ module Snoo
40
40
  # @return (see #clear_sessions)
41
41
  def mark_unread id
42
42
  logged_in?
43
- post('/api/unread_message', body: {id: id, uh: @modhash})
43
+ post('/api/unread_message', body: {id: id, uh: @modhash, api_type: 'json'})
44
44
  end
45
45
 
46
46
  # Gets a listing of PMs
@@ -10,7 +10,7 @@ module Snoo
10
10
  # @return (see #clear_sessions)
11
11
  def delete_header subreddit
12
12
  logged_in?
13
- post('/api/delete_sr_header', body: {r: subreddit, uh: @modhash})
13
+ post('/api/delete_sr_header', body: {r: subreddit, uh: @modhash, api_type: 'json'})
14
14
  end
15
15
 
16
16
  # Deletes an image from a subreddit. This is for css, not removing posts
@@ -20,7 +20,7 @@ module Snoo
20
20
  # @return (see #clear_sessions)
21
21
  def delete_image subreddit, image_name
22
22
  logged_in?
23
- post('/api/delete_sr_image', body: {r: subreddit, img_name: image_name, uh: @modhash})
23
+ post('/api/delete_sr_image', body: {r: subreddit, img_name: image_name, uh: @modhash, api_type: 'json'})
24
24
  end
25
25
 
26
26
  # Gets a hash of the subreddit settings
@@ -58,6 +58,7 @@ module Snoo
58
58
  allow_top: true,
59
59
  show_media: true,
60
60
  over_18: false,
61
+ api_type: 'json'
61
62
  }
62
63
  params.merge! opts
63
64
  post('/api/site_admin', body: params)
@@ -70,7 +71,7 @@ module Snoo
70
71
  # @return (see #clear_sessions)
71
72
  def set_stylesheet stylesheet, subreddit
72
73
  logged_in?
73
- post('/api/subreddit_stylesheet', body: {op: 'save', r: subreddit, stylesheet_contents: stylesheet, uh: @modhash})
74
+ post('/api/subreddit_stylesheet', body: {op: 'save', r: subreddit, stylesheet_contents: stylesheet, uh: @modhash, api_type: 'json'})
74
75
  end
75
76
 
76
77
  # Subscribe to a subreddit
@@ -80,7 +81,7 @@ module Snoo
80
81
  # @return (see #clear_sessions)
81
82
  def subscribe subreddit, action = "sub"
82
83
  logged_in?
83
- post('/api/subscribe', body: {action: action, sr: subreddit, uh: @modhash})
84
+ post('/api/subscribe', body: {action: action, sr: subreddit, uh: @modhash, api_type: 'json'})
84
85
  end
85
86
 
86
87
  # Unsubscribe from a subreddit
@@ -184,7 +185,6 @@ module Snoo
184
185
 
185
186
  # Remove a moderator from a subreddit
186
187
  #
187
- # @param id [String] The user id
188
188
  # @param (see #add_moderator)
189
189
  # @return (see #clear_sessions)
190
190
  def remove_moderator container, user, subreddit
@@ -238,7 +238,7 @@ module Snoo
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?
241
- post('/api/accept_moderator_invite', body: {r: subreddit, uh: @modhash})
241
+ post('/api/accept_moderator_invite', body: {r: subreddit, uh: @modhash, api_type: 'json'})
242
242
  end
243
243
  end
244
244
  end
@@ -41,12 +41,12 @@ module Snoo
41
41
  # @param opts [Hash] an options hash
42
42
  # @option opts [String] :type The type of action to add.
43
43
  # @option opts [String] :container The id of the containing user/object/thing
44
- # @options opt [String] :note The reddit gold user node
44
+ # @option opt [String] :note The reddit gold user node
45
45
  # @option opts [String] :name The name of a reddit user
46
46
  # @return [HTTParty::Response] The response object.
47
47
  def friend_wrapper opts = {}
48
48
  logged_in?
49
- params = {uh: @modhash}
49
+ params = {uh: @modhash, api_type: 'json'}
50
50
  params.merge! opts
51
51
  post('/api/friend', body: params)
52
52
  end
@@ -60,7 +60,7 @@ module Snoo
60
60
  # @return (see #friend_wrapper)
61
61
  def unfriend_wrapper opts = {}
62
62
  logged_in?
63
- params = { uh: @modhash}
63
+ params = { uh: @modhash, api_type: 'json'}
64
64
  params.merge! opts
65
65
  post('/api/unfriend', body: params)
66
66
  end
@@ -1,4 +1,4 @@
1
1
  module Snoo
2
2
  # The version string (duh)
3
- VERSION = "0.1.0.pre.8"
3
+ VERSION = "0.1.0"
4
4
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snoo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.8
5
- prerelease: 6
4
+ version: 0.1.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jeff Sandberg
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-06 00:00:00.000000000 Z
12
+ date: 2012-12-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -112,9 +112,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
112
  required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  none: false
114
114
  requirements:
115
- - - ! '>'
115
+ - - ! '>='
116
116
  - !ruby/object:Gem::Version
117
- version: 1.3.1
117
+ version: '0'
118
118
  requirements: []
119
119
  rubyforge_project:
120
120
  rubygems_version: 1.8.23