tumblr-rb 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/tumblr.rb +24 -4
- data/test/test_tumblr.rb +21 -0
- data/tumblr-rb.gemspec +2 -2
- metadata +3 -3
data/README.md
CHANGED
@@ -85,9 +85,9 @@ To publish to Tumblr, do this:
|
|
85
85
|
|
86
86
|
## TODO:
|
87
87
|
|
88
|
+
+ Tumblr::Post needs methods for liking and unliking.
|
88
89
|
+ Make the CLI
|
89
90
|
+ Make the manpages for the CLI
|
90
|
-
+ More convenience methods for the Tumblr class.
|
91
91
|
+ File-uploading for Photos, Videos, Audio (needs to get into Weary)
|
92
92
|
|
93
93
|
## Copyright
|
data/lib/tumblr.rb
CHANGED
@@ -6,7 +6,7 @@ require 'tumblr/writer'
|
|
6
6
|
require 'tumblr/authenticator'
|
7
7
|
|
8
8
|
class Tumblr
|
9
|
-
VERSION = "0.1.
|
9
|
+
VERSION = "0.1.1"
|
10
10
|
GENERATOR = "The Tumblr Gem v#{VERSION}"
|
11
11
|
|
12
12
|
def initialize(*credentials)
|
@@ -15,13 +15,11 @@ class Tumblr
|
|
15
15
|
|
16
16
|
# Convenience method for Reader#read
|
17
17
|
def read(username, parameters={})
|
18
|
-
reader = !@credentials.blank? ? Reader.new(@credentials[:email],@credentials[:password]) : Reader.new
|
19
18
|
reader.read(username, parameters)
|
20
19
|
end
|
21
20
|
|
22
21
|
# Post a document to Tumblr. If the document has a post-id, it will be edited.
|
23
22
|
def post(doc)
|
24
|
-
raise 'Requires an e-mail address and password' unless @credentials
|
25
23
|
tumblr_post = if doc.is_a?(Tumblr::Post)
|
26
24
|
doc.to_h
|
27
25
|
elsif doc.respond_to?(:keys)
|
@@ -29,10 +27,32 @@ class Tumblr
|
|
29
27
|
else
|
30
28
|
Tumblr.parse(doc).to_h
|
31
29
|
end
|
32
|
-
writer = Writer.new(@credentials[:email],@credentials[:password])
|
33
30
|
tumblr_post.has_key?(:'post-id') ? writer.edit(tumblr_post) : writer.write(tumblr_post)
|
34
31
|
end
|
35
32
|
|
33
|
+
def dashboard(parameters={})
|
34
|
+
raise 'Requires an e-mail address and password' unless @credentials
|
35
|
+
reader.dashboard(parameters)
|
36
|
+
end
|
37
|
+
|
38
|
+
def authenticate
|
39
|
+
raise 'Requires an e-mail address and password' unless @credentials
|
40
|
+
Authenticator.new(@credentials[:email],@credentials[:password]).authenticate
|
41
|
+
end
|
42
|
+
|
43
|
+
def reader
|
44
|
+
if @credentials.blank?
|
45
|
+
Reader.new
|
46
|
+
else
|
47
|
+
Reader.new(@credentials[:email],@credentials[:password])
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def writer
|
52
|
+
raise 'Requires an e-mail address and password' unless @credentials
|
53
|
+
Writer.new(@credentials[:email],@credentials[:password])
|
54
|
+
end
|
55
|
+
|
36
56
|
# Parse a post out of a string
|
37
57
|
def self.parse(doc)
|
38
58
|
document = {}
|
data/test/test_tumblr.rb
CHANGED
@@ -88,6 +88,27 @@ link
|
|
88
88
|
write = tumbl.post('Hello world')
|
89
89
|
assert write.is_a? Weary::Request
|
90
90
|
end
|
91
|
+
|
92
|
+
test 'can read the dashboard' do
|
93
|
+
dashboard = Tumblr.new('test@testermcgee.com','dontrevealmysecrets').dashboard
|
94
|
+
reader = Tumblr::Reader.new('test@testermcgee.com','dontrevealmysecrets').dashboard
|
95
|
+
assert dashboard.is_a? Weary::Request
|
96
|
+
assert_equal reader.uri, dashboard.uri
|
97
|
+
end
|
98
|
+
|
99
|
+
test 'provides a convenience method for reader and writer' do
|
100
|
+
tumbl = Tumblr.new('test@testermcgee.com','dontrevealmysecrets')
|
101
|
+
assert tumbl.reader.is_a? Tumblr::Reader
|
102
|
+
assert tumbl.writer.is_a? Tumblr::Writer
|
103
|
+
end
|
104
|
+
|
105
|
+
test 'authenticates to get user information' do
|
106
|
+
tumbl = Tumblr.new('test@testermcgee.com','dontrevealmysecrets')
|
107
|
+
auth = Tumblr::Authenticator.new('test@testermcgee.com','dontrevealmysecrets').authenticate
|
108
|
+
assert_respond_to tumbl, :authenticate
|
109
|
+
assert tumbl.authenticate.is_a? Weary::Request
|
110
|
+
assert_equal auth.uri, tumbl.authenticate.uri
|
111
|
+
end
|
91
112
|
end
|
92
113
|
|
93
114
|
describe 'Reader' do
|
data/tumblr-rb.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{tumblr-rb}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Mark Wunsch"]
|
12
|
-
s.date = %q{2010-03-
|
12
|
+
s.date = %q{2010-03-09}
|
13
13
|
s.description = %q{Ruby library and command line utility to work with the Tumblr Blogging Platform, powered by Weary.}
|
14
14
|
s.email = %q{mark@markwunsch.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Mark Wunsch
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-09 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|