snoo 0.1.0.pre.3 → 0.1.0.pre.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/snoo.rb +20 -7
- data/lib/snoo/version.rb +1 -1
- metadata +2 -2
data/lib/snoo.rb
CHANGED
@@ -22,17 +22,30 @@ module Snoo
|
|
22
22
|
|
23
23
|
# Creates a new instance of Snoo.
|
24
24
|
#
|
25
|
-
#
|
25
|
+
# As of 0.1.0.pre.4, you can auth or log-in via initializers, saving you from having to run the log-in or auth command seperately.
|
26
|
+
# Simply pass username-password options, OR modhash-cookie options (you cannot do both)
|
26
27
|
#
|
27
|
-
# @param
|
28
|
-
# @
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
# @param opts [Hash] A hash of options
|
29
|
+
# @option opts [String] :url The base url of the reddit instance to use. Only change this if you have a private reddit
|
30
|
+
# @option opts [String] :useragent The useragent the bot uses. Please change this if you write your own complex bot
|
31
|
+
# @option opts [String] :username The username the bot will log in as
|
32
|
+
# @option opts [String] :password The password the bot will log in with
|
33
|
+
# @option opts [String] :modhash The modhash the bot will auth with
|
34
|
+
# @option opts [String] :cookies The cookie string the bot will auth with
|
35
|
+
def initialize( opts = {} )
|
36
|
+
options = {url: "http://www.reddit.com", useragent: "Snoo ruby reddit api wrapper v#{VERSION}" }.merge opts
|
37
|
+
@baseurl = options[:url]
|
38
|
+
self.class.base_uri options[:url]
|
39
|
+
@headers = {'User-Agent' => options[:useragent] }
|
33
40
|
self.class.headers @headers
|
34
41
|
@cookies = nil
|
35
42
|
@modhash = nil
|
43
|
+
|
44
|
+
if !(options[:username].nil? && options[:password].nil?)
|
45
|
+
self.log_in options[:username], options[:password]
|
46
|
+
elsif !(options[:modhash].nil? && options[:cookies].nil?)
|
47
|
+
self.auth options[:modhash], options[:cookies]
|
48
|
+
end
|
36
49
|
end
|
37
50
|
end
|
38
51
|
end
|
data/lib/snoo/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.0.pre.4
|
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-
|
12
|
+
date: 2012-11-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|