Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Modularized everything

  • Loading branch information...
commit acfd7683dc89b5edd999ddf5f64813c965312961 1 parent 4d5de57
@paradox460 authored
View
21 lib/snoo.rb
@@ -1,25 +1,21 @@
require 'httparty'
-require "snoo/version"
-require "snoo/utilities"
-require "snoo/account"
-require "snoo/flair"
-require "snoo/links_comments"
-require "snoo/listings"
-require "snoo/moderation"
-require "snoo/pms"
-require "snoo/subreddits"
-require "snoo/users"
-
+%w{version utilities account flair links_comments listings moderation pms subreddits users}.each do |local|
+ require "snoo/#{local}"
+end
# Snoo reddit API wrapper
#
# @author Jeff Sandberg <paradox460@gmail.com>
module Snoo
# Snoo reddit API wrapper
#
- # @author Jeff Sandberg <paradox460@gmail.com>
+ # @author (see Snoo)
class Client
include HTTParty
+ [Account, Flair, LinksComments, Listings, Moderation, PM, Utilities, User, Subreddit].each do |inc|
+ include inc
+ end
+
# Creates a new instance of Snoo
#
@@ -33,3 +29,4 @@ def initialize( url = "http://www.reddit.com", useragent = "Snoo ruby reddit api
end
end
end
+
View
6 lib/snoo/account.rb
@@ -1,6 +1,8 @@
module Snoo
- class Client
- # @!group Account
+ # Account related methods, such as logging in, deleting the current user, changing passwords, etc
+ #
+ # @author (see Snoo)
+ module Account
# Log into a reddit account. You need to do this to use any restricted or write APIs
#
View
7 lib/snoo/flair.rb
@@ -1,6 +1,9 @@
module Snoo
- class Client
- # @!group Flair
+ # Flair related methods.
+ # These are used for interacting with flair in reddit. Things like giving flair, setting templates, and whatnot.
+ #
+ # @author (see Snoo)
+ module Flair
# Clear all the flair templates of a particular type
#
View
17 lib/snoo/links_comments.rb
@@ -1,6 +1,8 @@
module Snoo
- class Client
- # @!group Links and Comments
+ # Methods for interacting with links and comments, such as leaving a comment, voting, etc
+ #
+ # @author (see Snoo)
+ module LinksComments
# Posts a comment to the site
#
@@ -134,6 +136,17 @@ def vote direction, id
self.class.post('/api/vote', body: {id: id, dir: direction, uh: @modhash})
end
+ # Upvote
+ # An alias for `vote 1, id`
+ #
+
+ # Downvote
+ # An alias for `vote -1, id`
+ #
+
+ # Sidevote (clear your vote)
+ # An alias for `vote 0, id`
+ #
end
end
View
6 lib/snoo/listings.rb
@@ -1,6 +1,8 @@
module Snoo
- class Client
- # @!group Page listings
+ # Methods for getting thing listings. Comments, links, etc
+ #
+ # @author (see Snoo)
+ module Listings
# Get a comment listing from the site
#
View
6 lib/snoo/moderation.rb
@@ -1,6 +1,8 @@
module Snoo
- class Client
- # @!group Moderation
+ # Methods for moderating on reddit, including tasks such as removing, approving, and distinguishing
+ #
+ # @author (see Snoo)
+ module Moderation
# Approve a thing
#
View
6 lib/snoo/pms.rb
@@ -1,6 +1,8 @@
module Snoo
- class Client
- # @!group Private Messages
+ # Methods for interacting with private messages
+ #
+ # @author (see Snoo)
+ module PM
# Block a user from sending you messages
#
View
6 lib/snoo/subreddits.rb
@@ -1,6 +1,8 @@
module Snoo
- class Client
- # @!group Subreddits
+ # Methods for administering a subreddit, as well as looking up subreddits (subreddit search)
+ #
+ # @author (see Snoo)
+ module Subreddit
# Deletes the header image of a subreddit
#
View
6 lib/snoo/users.rb
@@ -1,6 +1,8 @@
module Snoo
- class Client
- # @!group Users
+ # Methods for interacting with users, such as adding and removing friends, getting user info, etc
+ #
+ # @author (see Snoo)
+ module User
# Friend a user
#
View
6 lib/snoo/utilities.rb
@@ -1,5 +1,9 @@
module Snoo
- class Client
+ # Utility functions.
+ # These are all private
+ #
+ # @author (see Snoo)
+ module Utilities
private
# Set the cookie header and instance variable
#
Please sign in to comment.
Something went wrong with that request. Please try again.