tumblr-rb 1.3.0 → 2.0.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +7 -0
- data/Gemfile +15 -8
- data/Gemfile.lock +65 -65
- data/LICENSE +4 -2
- data/README.md +31 -84
- data/Rakefile +8 -68
- data/bin/tumblr +3 -133
- data/lib/tumblr.rb +7 -184
- data/lib/tumblr/authentication.rb +71 -0
- data/lib/tumblr/client.rb +148 -0
- data/lib/tumblr/command_line_interface.rb +222 -0
- data/lib/tumblr/credentials.rb +31 -0
- data/lib/tumblr/post.rb +253 -171
- data/lib/tumblr/post/answer.rb +17 -0
- data/lib/tumblr/post/audio.rb +22 -10
- data/lib/tumblr/post/chat.rb +25 -0
- data/lib/tumblr/post/link.rb +22 -9
- data/lib/tumblr/post/photo.rb +29 -10
- data/lib/tumblr/post/quote.rb +17 -10
- data/lib/tumblr/post/text.rb +18 -0
- data/lib/tumblr/post/video.rb +26 -11
- data/lib/tumblr/version.rb +3 -0
- data/lib/tumblr/views/error.erb +6 -0
- data/lib/tumblr/views/form.erb +11 -0
- data/lib/tumblr/views/layout.erb +41 -0
- data/lib/tumblr/views/success.erb +6 -0
- data/man/tumblr.1 +67 -65
- data/man/tumblr.1.html +131 -108
- data/man/tumblr.1.ronn +76 -57
- data/man/tumblr.5 +48 -68
- data/man/tumblr.5.html +106 -114
- data/man/tumblr.5.ronn +38 -51
- data/spec/fixtures/posts.json +10 -0
- data/spec/fixtures/typical_animated_gif.gif +0 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/tumblr/authentication_spec.rb +57 -0
- data/spec/tumblr/client_spec.rb +223 -0
- data/spec/tumblr/credentials_spec.rb +63 -0
- data/spec/tumblr/post_spec.rb +125 -0
- data/tumblr-rb.gemspec +16 -89
- metadata +101 -102
- data/lib/tumblr/authenticator.rb +0 -18
- data/lib/tumblr/post/conversation.rb +0 -15
- data/lib/tumblr/post/regular.rb +0 -14
- data/lib/tumblr/reader.rb +0 -191
- data/lib/tumblr/writer.rb +0 -39
- data/test/fixtures/vcr_cassettes/authenticate/authenticate.yml +0 -39
- data/test/fixtures/vcr_cassettes/read/all_pages.yml +0 -34
- data/test/fixtures/vcr_cassettes/read/authenticated.yml +0 -40
- data/test/fixtures/vcr_cassettes/read/authentication_failure.yml +0 -33
- data/test/fixtures/vcr_cassettes/read/like.yml +0 -31
- data/test/fixtures/vcr_cassettes/read/mwunsch.yml +0 -101
- data/test/fixtures/vcr_cassettes/read/optional.yml +0 -48
- data/test/fixtures/vcr_cassettes/read/pages.yml +0 -36
- data/test/fixtures/vcr_cassettes/read/tumblrgemtest.yml +0 -42
- data/test/fixtures/vcr_cassettes/read/unlike.yml +0 -31
- data/test/fixtures/vcr_cassettes/write/delete.yml +0 -31
- data/test/fixtures/vcr_cassettes/write/edit.yml +0 -31
- data/test/fixtures/vcr_cassettes/write/reblog.yml +0 -31
- data/test/fixtures/vcr_cassettes/write/write.yml +0 -31
- data/test/helper.rb +0 -44
- data/test/test_tumblr.rb +0 -710
data/lib/tumblr/post/audio.rb
CHANGED
@@ -1,16 +1,28 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class Tumblr
|
1
|
+
module Tumblr
|
4
2
|
class Post
|
5
3
|
class Audio < Post
|
6
|
-
|
7
|
-
|
8
|
-
super post_id
|
4
|
+
def initialize(post_data = {})
|
5
|
+
super(post_data)
|
9
6
|
@type = :audio
|
10
7
|
end
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
|
9
|
+
def caption
|
10
|
+
@caption
|
11
|
+
end
|
12
|
+
|
13
|
+
def external_url
|
14
|
+
@external_url
|
15
|
+
end
|
16
|
+
|
17
|
+
def data
|
18
|
+
@data
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.post_body_keys
|
22
|
+
[:external_url, :caption]
|
23
|
+
end
|
14
24
|
end
|
15
25
|
end
|
16
|
-
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Tumblr
|
2
|
+
class Post
|
3
|
+
class Chat < Post
|
4
|
+
def initialize(post_data = {})
|
5
|
+
super(post_data)
|
6
|
+
@type = :chat
|
7
|
+
end
|
8
|
+
|
9
|
+
def title
|
10
|
+
@title
|
11
|
+
end
|
12
|
+
|
13
|
+
def conversation
|
14
|
+
@conversation
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.post_body_keys
|
18
|
+
[:conversation]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
|
data/lib/tumblr/post/link.rb
CHANGED
@@ -1,15 +1,28 @@
|
|
1
|
-
|
1
|
+
module Tumblr
|
2
2
|
class Post
|
3
3
|
class Link < Post
|
4
|
-
|
5
|
-
|
6
|
-
super post_id
|
7
|
-
self.url = url
|
4
|
+
def initialize(post_data = {})
|
5
|
+
super(post_data)
|
8
6
|
@type = :link
|
9
7
|
end
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
|
9
|
+
def title
|
10
|
+
@title
|
11
|
+
end
|
12
|
+
|
13
|
+
def url
|
14
|
+
@url
|
15
|
+
end
|
16
|
+
|
17
|
+
def description
|
18
|
+
@description
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.post_body_keys
|
22
|
+
[:url, :description]
|
23
|
+
end
|
13
24
|
end
|
14
25
|
end
|
15
|
-
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
data/lib/tumblr/post/photo.rb
CHANGED
@@ -1,16 +1,35 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class Tumblr
|
1
|
+
module Tumblr
|
4
2
|
class Post
|
5
3
|
class Photo < Post
|
6
|
-
|
7
|
-
|
8
|
-
super post_id
|
4
|
+
def initialize(post_data = {})
|
5
|
+
super(post_data)
|
9
6
|
@type = :photo
|
7
|
+
@source ||= first_photo_url_from_response
|
8
|
+
end
|
9
|
+
|
10
|
+
def caption
|
11
|
+
@caption
|
12
|
+
end
|
13
|
+
|
14
|
+
def link
|
15
|
+
@link
|
16
|
+
end
|
17
|
+
|
18
|
+
def source
|
19
|
+
@source
|
20
|
+
end
|
21
|
+
|
22
|
+
def data
|
23
|
+
@data
|
24
|
+
end
|
25
|
+
|
26
|
+
def first_photo_url_from_response
|
27
|
+
@photos.first["original_size"]["url"] if @photos and !@photos.empty?
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.post_body_keys
|
31
|
+
[:source, :caption]
|
10
32
|
end
|
11
|
-
|
12
|
-
parameters :source, :caption, :click_through_url
|
13
|
-
|
14
33
|
end
|
15
34
|
end
|
16
|
-
end
|
35
|
+
end
|
data/lib/tumblr/post/quote.rb
CHANGED
@@ -1,16 +1,23 @@
|
|
1
|
-
|
1
|
+
module Tumblr
|
2
2
|
class Post
|
3
3
|
class Quote < Post
|
4
|
-
|
5
|
-
|
6
|
-
super post_id
|
7
|
-
self.quote = quotation
|
4
|
+
def initialize(post_data = {})
|
5
|
+
super(post_data)
|
8
6
|
@type = :quote
|
9
7
|
end
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
|
9
|
+
def quote
|
10
|
+
@quote
|
11
|
+
end
|
12
|
+
|
13
|
+
def source
|
14
|
+
@source
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.post_body_keys
|
18
|
+
[:quote]
|
19
|
+
end
|
14
20
|
end
|
15
21
|
end
|
16
|
-
end
|
22
|
+
end
|
23
|
+
|
data/lib/tumblr/post/video.rb
CHANGED
@@ -1,17 +1,32 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class Tumblr
|
1
|
+
module Tumblr
|
4
2
|
class Post
|
5
3
|
class Video < Post
|
6
|
-
|
7
|
-
|
8
|
-
super post_id
|
9
|
-
self.embed = video
|
4
|
+
def initialize(post_data = {})
|
5
|
+
super(post_data)
|
10
6
|
@type = :video
|
7
|
+
@embed ||= get_embed_code_from_response
|
8
|
+
end
|
9
|
+
|
10
|
+
def caption
|
11
|
+
@caption
|
12
|
+
end
|
13
|
+
|
14
|
+
def embed
|
15
|
+
@embed
|
16
|
+
end
|
17
|
+
|
18
|
+
def data
|
19
|
+
@data
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_embed_code_from_response
|
23
|
+
@player.last["embed_code"] if @player and !@player.empty?
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.post_body_keys
|
27
|
+
[:embed, :caption]
|
11
28
|
end
|
12
|
-
|
13
|
-
parameters :caption, :embed
|
14
|
-
|
15
29
|
end
|
16
30
|
end
|
17
|
-
end
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<form class="auth" action="/">
|
2
|
+
<label class="key">Consumer Key: <input name="key" /></label>
|
3
|
+
<label class="secret">Consumer Secret: <input name="secret" /></label>
|
4
|
+
<input type="submit" />
|
5
|
+
</form>
|
6
|
+
<p>
|
7
|
+
You need to <a href="http://www.tumblr.com/oauth/apps" target="_blank">register for an application on Tumblr</a>, then put your <em>consumer</em> key and secret here.
|
8
|
+
</p>
|
9
|
+
<p>
|
10
|
+
You will then be redirected to Tumblr to authenticate and authorize.
|
11
|
+
</p>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Authenticate and Authorize</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body {
|
7
|
+
color: rgb(40, 254, 20);
|
8
|
+
font-size: 14px;
|
9
|
+
font-family: Consolas, Menlo, Monaco, monospace;
|
10
|
+
background: #191919;
|
11
|
+
}
|
12
|
+
.main {
|
13
|
+
width: 640px;
|
14
|
+
margin: 0 auto;
|
15
|
+
}
|
16
|
+
.tumblr-logo {
|
17
|
+
font-family: Consolas, Menlo, Monaco, monospace;
|
18
|
+
}
|
19
|
+
a, .command {
|
20
|
+
color: #94ff8a;
|
21
|
+
}
|
22
|
+
.command {
|
23
|
+
font-weight: bold;
|
24
|
+
}
|
25
|
+
</style>
|
26
|
+
</head>
|
27
|
+
<body>
|
28
|
+
<div class="main">
|
29
|
+
<pre class="tumblr-logo">
|
30
|
+
. .o8 oooo
|
31
|
+
.o8 "888 `888
|
32
|
+
.o888oo oooo oooo ooo. .oo. .oo. 888oooo. 888 oooo d8b
|
33
|
+
888 `888 `888 `888P"Y88bP"Y88b d88' `88b 888 `888""8P
|
34
|
+
888 888 888 888 888 888 888 888 888 888
|
35
|
+
888 . 888 888 888 888 888 888 888 888 888 .o.
|
36
|
+
"888" `V88V"V8P' o888o o888o o888o `Y8bod8P' o888o d888b Y8P
|
37
|
+
</pre>
|
38
|
+
<%= yield %>
|
39
|
+
</div>
|
40
|
+
</body>
|
41
|
+
</html>
|
data/man/tumblr.1
CHANGED
@@ -1,159 +1,161 @@
|
|
1
|
-
.\" generated with Ronn/v0.
|
2
|
-
.\" http://github.com/rtomayko/ronn/
|
1
|
+
.\" generated with Ronn/v0.7.3
|
2
|
+
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
3
|
.
|
4
|
-
.TH "TUMBLR" "1" "
|
4
|
+
.TH "TUMBLR" "1" "October 2012" "Mark Wunsch" "Tumblr Manual"
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
|
-
\fBtumblr\fR
|
7
|
+
\fBtumblr\fR \- publish to tumblr\.com
|
8
8
|
.
|
9
9
|
.SH "SYNOPSIS"
|
10
|
-
\fBtumblr\fR [
|
10
|
+
\fBtumblr\fR COMMAND [ARGS]
|
11
11
|
.
|
12
12
|
.SH "DESCRIPTION"
|
13
|
-
\fBtumblr\fR is a command line utility and Ruby library for working with Tumblr
|
13
|
+
\fBtumblr\fR is a command line utility and Ruby library for working with Tumblr\.com\. It can read plain\-text and binary files and publish them to Tumblr\.
|
14
14
|
.
|
15
15
|
.P
|
16
|
-
|
16
|
+
\fBtumblr\fR is driven through a group of \fICOMMANDS\fR (similar to \fBgit\fR or \fBrbenv\fR)\.
|
17
17
|
.
|
18
18
|
.P
|
19
|
-
If you preface your
|
19
|
+
If you preface your plaintext file with a bit of YAML (<yaml\.org>) frontmatter, you can give \fBtumblr\fR more explicit instructions for how to publish your post\. See tumblr(5) for available YAML parameters\.
|
20
20
|
.
|
21
|
-
.SH "
|
21
|
+
.SH "COMMANDS"
|
22
22
|
.
|
23
23
|
.TP
|
24
|
-
\
|
25
|
-
|
26
|
-
If these are not provided, you will be prompted for them.
|
27
|
-
You \fBmust\fR provide this or the \fB\-\-credentials\fR argument if the post comes from standard input.
|
24
|
+
\fBtumblr post\fR \fIPOST\fR | \fIFILE\fR | \fIURL\fR
|
25
|
+
Post to tumblr\. A \fIPOST\fR is a piece of plaintext, assumed to be formatted as \fBtumblr(5)\fR\. \fIFILE\fR is a path to a \fIPOST\fR\. If \fIFILE\fR has a binary extension, that file will be uploaded as an image, audio, or video post\. \fIURL\fR will create a link\-type post, or a video or audio post, depending on the location of the url\.
|
28
26
|
.
|
29
27
|
.TP
|
30
|
-
\
|
31
|
-
|
32
|
-
You will be prompted for a password.
|
28
|
+
\fBtumblr pipe\fR
|
29
|
+
Read from STDIN and post to tumblr\.
|
33
30
|
.
|
34
31
|
.TP
|
35
|
-
\
|
36
|
-
|
32
|
+
\fBtumblr edit\fR \fIPOST_ID\fR
|
33
|
+
Edit \fIPOST_ID\fR on tumblr\. Will open the serialized post in the foreground with $TUMBLREDITOR then $EDITOR\.
|
37
34
|
.
|
38
35
|
.TP
|
39
|
-
\
|
40
|
-
|
36
|
+
\fBtumblr fetch\fR \fIPOST_ID\fR
|
37
|
+
Fetch \fIPOST_ID\fR from tumblr and write out its serialized form\.
|
41
38
|
.
|
42
39
|
.TP
|
43
|
-
\
|
44
|
-
|
40
|
+
\fBtumblr delete\fR \fIPOST_ID\fR
|
41
|
+
Delete \fIPOST_ID\fR from tumblr\.
|
45
42
|
.
|
46
43
|
.TP
|
47
|
-
\
|
48
|
-
|
44
|
+
\fBtumblr help\fR [\fITASK\fR]
|
45
|
+
Print the help message and the description for \fITASK\fR\.
|
49
46
|
.
|
50
47
|
.TP
|
51
|
-
\
|
52
|
-
|
48
|
+
\fBtumblr authorize\fR
|
49
|
+
Start a web server and application to authenticate to tumblr and authorize the cli\. See \fIAUTHORIZATION\fR
|
53
50
|
.
|
54
|
-
.
|
55
|
-
|
51
|
+
.TP
|
52
|
+
\fBtumblr version\fR
|
53
|
+
Print the \fBtumblr\fR version and quit\.
|
54
|
+
.
|
55
|
+
.SH "POSTING OPTIONS"
|
56
|
+
These options are used when posting to tumblr, i\.e\. when using \fBtumblr post\fR or \fBtumblr pipe\fR\.
|
56
57
|
.
|
57
58
|
.TP
|
58
|
-
\fB\-
|
59
|
-
|
59
|
+
\fB\-p\fR,\fB\-\-publish\fR
|
60
|
+
Publish this post (ignoring the \fBstate\fR parameter set in the post)\.
|
60
61
|
.
|
61
62
|
.TP
|
62
|
-
\fB\-
|
63
|
-
|
63
|
+
\fB\-q\fR,\fB\-\-queue\fR
|
64
|
+
Add this post to the queue\.
|
64
65
|
.
|
65
|
-
.
|
66
|
-
|
66
|
+
.TP
|
67
|
+
\fB\-d\fR,\fB\-\-draft\fR
|
68
|
+
Save this post as a draft\.
|
67
69
|
.
|
68
|
-
.
|
70
|
+
.SH "COMMON OPTIONS"
|
69
71
|
.
|
70
|
-
.
|
71
|
-
|
72
|
+
.TP
|
73
|
+
\fB\-\-credentials\fR=\fIPATH\fR
|
74
|
+
The file where your OAuth keys are stored\. When authenticating, this path is where the keys should be stored\.
|
72
75
|
.
|
73
|
-
.
|
76
|
+
.TP
|
77
|
+
\fB\-\-host\fR=\fIHOST\fR
|
78
|
+
The hostname of the Tumblr account your posting to\. Posting and fetching posts require the hostname\.
|
74
79
|
.
|
75
|
-
.
|
80
|
+
.SH "AUTHORIZATION"
|
81
|
+
Most actions of the cli require authorization to Tumblr\. \fBtumblr authorize\fR provides a mechanism to authenticate and authorize the cli\.
|
76
82
|
.
|
77
83
|
.P
|
78
|
-
|
79
|
-
.
|
80
|
-
.IP "" 4
|
81
|
-
.
|
82
|
-
.nf
|
83
|
-
$ cat data.yml my_post.txt | tumblr \-a tumblr_user@foobar.com:p4ssw0rd
|
84
|
-
.
|
85
|
-
.fi
|
86
|
-
.
|
87
|
-
.IP "" 0
|
84
|
+
In order to use \fBtumblr\fR, you first need to register \fIhttp://www\.tumblr\.com/oauth/apps\fR an OAuth application with tumblr\.
|
88
85
|
.
|
89
86
|
.P
|
90
|
-
|
87
|
+
Run \fBtumblr authorize\fR to start up server, and type in the consumer key and secret\. You\'ll then be asked to authorize the app\. These keys are saved to the file noted in \fB\-\-credentials\fR, defaulting to \fB~/\.tumblr\fR\. If you choose not to use this default, you will need to enter the \fB\-\-credentials\fR option every time you post\. Alternatively, use the \fB$TUMBLRCRED\fR environment variable\.
|
88
|
+
.
|
89
|
+
.SH "EXAMPLES"
|
90
|
+
Publish a file to Tumblr\.com:
|
91
91
|
.
|
92
92
|
.IP "" 4
|
93
93
|
.
|
94
94
|
.nf
|
95
|
-
|
95
|
+
|
96
|
+
$ tumblr post my_post\.txt
|
96
97
|
.
|
97
98
|
.fi
|
98
99
|
.
|
99
100
|
.IP "" 0
|
100
101
|
.
|
101
102
|
.P
|
102
|
-
Or
|
103
|
+
Or from standard input:
|
103
104
|
.
|
104
105
|
.IP "" 4
|
105
106
|
.
|
106
107
|
.nf
|
107
|
-
|
108
|
+
|
109
|
+
$ cat data\.yml my_post\.txt | tumblr \-\-host=mwunsch\.tumblr\.com
|
108
110
|
.
|
109
111
|
.fi
|
110
112
|
.
|
111
113
|
.IP "" 0
|
112
114
|
.
|
113
115
|
.P
|
114
|
-
|
116
|
+
Make a Link post:
|
115
117
|
.
|
116
118
|
.IP "" 4
|
117
119
|
.
|
118
120
|
.nf
|
119
|
-
|
121
|
+
|
122
|
+
$ tumblr post http://github\.com/mwunsch/tumblr
|
120
123
|
.
|
121
124
|
.fi
|
122
125
|
.
|
123
126
|
.IP "" 0
|
124
127
|
.
|
125
128
|
.P
|
126
|
-
|
129
|
+
Or a Video post:
|
127
130
|
.
|
128
131
|
.IP "" 4
|
129
132
|
.
|
130
133
|
.nf
|
131
|
-
|
132
|
-
|
133
|
-
password: myvoiceismypassport
|
134
|
-
$ cat data.yml my_post.txt | tumblr \-\-credentials ~/.tumblrlogin
|
134
|
+
|
135
|
+
$ tumblr post http://www\.youtube\.com/watch?v=CW0DUg63lqU
|
135
136
|
.
|
136
137
|
.fi
|
137
138
|
.
|
138
139
|
.IP "" 0
|
139
140
|
.
|
140
|
-
.
|
141
|
-
|
141
|
+
.P
|
142
|
+
Save it as a draft:
|
142
143
|
.
|
143
144
|
.IP "" 4
|
144
145
|
.
|
145
146
|
.nf
|
146
|
-
|
147
|
+
|
148
|
+
$ tumblr post \-d http://www\.youtube\.com/watch?v=CW0DUg63lqU
|
147
149
|
.
|
148
150
|
.fi
|
149
151
|
.
|
150
152
|
.IP "" 0
|
151
153
|
.
|
152
154
|
.SH "COPYRIGHT"
|
153
|
-
Tumblr (the gem) is Copyright (C) 2010 Mark Wunsch
|
155
|
+
Tumblr (the gem) is Copyright (C) 2010 \- 2012 Mark Wunsch
|
154
156
|
.
|
155
157
|
.P
|
156
|
-
Tumblr is Copyright (c) Tumblr, Inc
|
158
|
+
Tumblr is Copyright (c) Tumblr, Inc\. The Tumblr gem is NOT affiliated with Tumblr, Inc\.
|
157
159
|
.
|
158
160
|
.SH "SEE ALSO"
|
159
161
|
tumblr(5), gem(1)
|