tumblr-rb 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,6 +1,7 @@
1
1
  # A sample Gemfile
2
2
 
3
3
  gem 'weary','>= 0.7.1'
4
+ gem 'highline', '>= 1.5.2'
4
5
 
5
6
  group :test do
6
7
  gem 'rake'
data/Gemfile.lock CHANGED
@@ -8,6 +8,10 @@ dependencies:
8
8
  group:
9
9
  - :test
10
10
  version: ">= 0"
11
+ highline:
12
+ group:
13
+ - :default
14
+ version: ">= 1.5.2"
11
15
  weary:
12
16
  group:
13
17
  - :default
@@ -49,10 +53,12 @@ specs:
49
53
  version: 1.4.0
50
54
  - contest:
51
55
  version: 0.1.2
56
+ - highline:
57
+ version: 1.5.2
52
58
  - fakeweb:
53
59
  version: 1.2.8
54
60
  - vcr:
55
61
  version: 0.1.2
56
- hash: c4f81bd854c0ac103c3a0434d4d004dd192b9b45
62
+ hash: bb23bf752ce2daa339a799069ab0b6df9063a3a4
57
63
  sources: []
58
64
 
data/README.md CHANGED
@@ -8,6 +8,20 @@ Ruby wrapper and command line tool for the [Tumblr API](http://www.tumblr.com/do
8
8
 
9
9
  gem install tumblr-rb
10
10
 
11
+ ## Usage
12
+
13
+ $: tumblr path/to/a_post.markdown
14
+ Email Address: tumblr-user@foobarmail.com
15
+ Password:
16
+ Published to Tumblr. The ID for this post is: 123456789
17
+
18
+ You can pass `tumblr` something from standard input, but you have to set your email and password as arguments:
19
+
20
+ $: echo 'Hello world.' | tumblr -a user@tumblr.com:supers3cretp4ssw0rd
21
+ Published to Tumblr. The ID for this post is: 123456790
22
+
23
+ Try `tumblr --help` if you are in need of guidance. Read [tumblr(1)](http://mwunsch.github.com/tumblr/tumblr.1.html) for more information.
24
+
11
25
  ## Getting Started
12
26
 
13
27
  Like [Jekyll](http://tom.preston-werner.com/jekyll/), and [Mustache](http://defunkt.github.com/mustache/), Tumblr gem will transform documents preceded by a [YAML](http://www.yaml.org/) frontmatter block.
@@ -24,6 +38,8 @@ YAML frontmatter beings with `---` on a single line, followed by YAML, ending wi
24
38
 
25
39
  Understood YAML parameters are taken from the Tumblr API: http://www.tumblr.com/docs/en/api#api_write
26
40
 
41
+ Read [tumblr(5)](http://mwunsch.github.com/tumblr/tumblr.5.html) for more info.
42
+
27
43
  #### All Posts
28
44
 
29
45
  type regular, photo, link, quote, conversation, video, audio
@@ -86,8 +102,7 @@ To publish to Tumblr, do this:
86
102
  ## TODO:
87
103
 
88
104
  + Tumblr::Post needs methods for liking and unliking.
89
- + Make the CLI
90
- + Make the manpages for the CLI
105
+ + Add options to CLI for adding to queue, drafts, etc.
91
106
  + File-uploading for Photos, Videos, Audio (needs to get into Weary)
92
107
 
93
108
  ## Copyright
data/Rakefile CHANGED
@@ -22,6 +22,7 @@ begin
22
22
  gem.homepage = "http://github.com/mwunsch/tumblr"
23
23
  gem.authors = ["Mark Wunsch"]
24
24
  gem.add_dependency 'weary', '>= 0.7.1'
25
+ gem.add_dependency 'highline', '>= 1.5.2'
25
26
  gem.add_development_dependency "bundler", ">= 0.9.7"
26
27
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
27
28
  end
@@ -68,3 +69,13 @@ desc "Open an irb session preloaded with this library"
68
69
  task :console do
69
70
  sh "irb -rubygems -I lib -r tumblr"
70
71
  end
72
+
73
+ desc "Build the manual"
74
+ task :build_man do
75
+ sh "ronn -br5 --organization='Mark Wunsch' --manual='Tumblr Manual' man/*.ronn"
76
+ end
77
+
78
+ desc "Show the manual"
79
+ task :man => :build_man do
80
+ exec "man man/tumblr.1"
81
+ end
data/bin/tumblr ADDED
@@ -0,0 +1,119 @@
1
+ #!/usr/bin/env ruby
2
+ ## Tumblr is a command line interface for publishing to Tumblr.com
3
+ ##
4
+ ## Usage: tumblr [ OPTIONS ] [ FILE or URL ]
5
+ ##
6
+ ## Publish to Tumblr. If a URL is given, it will create a link post.
7
+ ## If URL is a YouTube or Vimeo URL, it will create a video post.
8
+ ## If a FILE is given, it will publish its contents.
9
+ ## See tumblr(5) for formatting instructions for FILE.
10
+ ## If a URL or FILE is not given, tumblr will read from the Standard Input.
11
+ ## If tumblr reads from the Standard Input, you must authenticate with -a.
12
+ ##
13
+ ##
14
+
15
+ require 'optparse'
16
+
17
+ def usage
18
+ File.readlines(__FILE__).
19
+ grep(/^##.*/).
20
+ map { |line| line.chomp[3..-1] }.
21
+ join("\n")
22
+ end
23
+
24
+ begin
25
+ require 'tumblr'
26
+ rescue LoadError
27
+ raise if $!.to_s !~ /tumblr/
28
+ libdir = File.expand_path("../../lib", __FILE__).sub(/^#{Dir.pwd}/, '.')
29
+ if !$:.include?(libdir)
30
+ $:.unshift libdir
31
+ require File.expand_path('../../.bundle/environment', __FILE__)
32
+ retry
33
+ end
34
+ raise
35
+ end
36
+
37
+ publisher = {}
38
+
39
+ ARGV.options do |option|
40
+ option.banner = usage
41
+ option.separator "Options"
42
+
43
+ auth_text = 'Email Address and Password, separated by a colon'
44
+ option.on('-a EMAIL:PASSWORD', '--auth EMAIL:PASSWORD', auth_text) do |auth|
45
+ credentials = auth.split(':')
46
+ publisher[:email] = credentials[0]
47
+ publisher[:password] = credentials[1]
48
+ end
49
+
50
+ address_text = 'Email Address (will prompt for password)'
51
+ option.on('-e EMAIL', '--email EMAIL', address_text) do |email|
52
+ publisher[:email] = email
53
+ end
54
+
55
+ option.separator ""
56
+
57
+ option.on('-h','--help', 'Show this help message') { puts option ; exit }
58
+ option.on('-v','--version', 'Show version number') do
59
+ puts Tumblr::VERSION
60
+ exit
61
+ end
62
+
63
+ option.separator ""
64
+
65
+ option.parse!
66
+ end
67
+
68
+ if ARGV.empty? && STDIN.tty?
69
+ puts usage
70
+ puts "See 'tumblr --help' for more information."
71
+ exit
72
+ end
73
+
74
+ input = if !ARGV.empty?
75
+ path = ARGV.first
76
+ (path =~ /^https?:\/\/\S+$/i) ? path : File.read(path)
77
+ else
78
+ STDIN.read.chomp!
79
+ end
80
+
81
+ if !STDIN.tty? && (!publisher[:email] || !publisher[:password])
82
+ bad_auth = %q(Error: An email address and password are required. Use 'tumblr -a' to authenticate. See 'tumblr --help' for details.)
83
+ abort bad_auth
84
+ end
85
+
86
+ if !publisher[:email] || !publisher[:password]
87
+ begin
88
+ require 'highline/import'
89
+ rescue LoadError
90
+ require 'rubygems'
91
+ retry
92
+ end
93
+
94
+ def get_email(pub)
95
+ pub[:email] = ask("Email Address: ")
96
+ get_email(pub) if pub[:email].empty?
97
+ end
98
+
99
+ def get_password(pub)
100
+ pub[:password] = ask("Password: ") { |q| q.echo = false }
101
+ get_password(pub) if pub[:password].empty?
102
+ end
103
+
104
+ if !publisher[:email]
105
+ get_email(publisher)
106
+ end
107
+
108
+ if !publisher[:password]
109
+ get_password(publisher)
110
+ end
111
+ end
112
+
113
+ response = Tumblr.execute(publisher, input)
114
+ if response.success?
115
+ puts "Published to Tumblr. The ID for this post is: #{response.body}"
116
+ exit
117
+ else
118
+ abort %Q(Oh no! Something went wrong. Tumblr says, "#{response.body}")
119
+ end
data/lib/tumblr.rb CHANGED
@@ -1,13 +1,14 @@
1
1
  require 'weary'
2
2
 
3
- require 'tumblr/post'
4
- require 'tumblr/reader'
5
- require 'tumblr/writer'
6
- require 'tumblr/authenticator'
7
-
8
3
  class Tumblr
9
- VERSION = "0.1.1"
4
+ VERSION = "1.0.0"
10
5
  GENERATOR = "The Tumblr Gem v#{VERSION}"
6
+ USER_AGENT = "TumblrGem/#{VERSION} (+http://github.com/mwunsch/tumblr)"
7
+
8
+ require 'tumblr/post'
9
+ require 'tumblr/reader'
10
+ require 'tumblr/writer'
11
+ require 'tumblr/authenticator'
11
12
 
12
13
  def initialize(*credentials)
13
14
  @credentials = {:email => credentials[0], :password => credentials[1]} unless credentials.blank?
@@ -53,6 +54,11 @@ class Tumblr
53
54
  Writer.new(@credentials[:email],@credentials[:password])
54
55
  end
55
56
 
57
+ def self.execute(credentials, input, state=nil)
58
+ request = new(credentials[:email],credentials[:password]).post(input)
59
+ request.perform
60
+ end
61
+
56
62
  # Parse a post out of a string
57
63
  def self.parse(doc)
58
64
  document = {}
@@ -1,6 +1,8 @@
1
1
  class Tumblr
2
2
  class Authenticator < Weary::Base
3
3
 
4
+ headers({"User-Agent" => Tumblr::USER_AGENT})
5
+
4
6
  def initialize(*credentials)
5
7
  @defaults = {:email => credentials[0], :password => credentials[1]} unless credentials.blank?
6
8
  end
data/lib/tumblr/reader.rb CHANGED
@@ -2,6 +2,8 @@
2
2
  class Tumblr
3
3
  class Reader < Weary::Base
4
4
 
5
+ headers({"User-Agent" => Tumblr::USER_AGENT})
6
+
5
7
  def initialize(*credentials)
6
8
  @defaults = {:email => credentials[0], :password => credentials[1]} unless credentials.blank?
7
9
  end
data/lib/tumblr/writer.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  class Tumblr
2
2
  class Writer < Weary::Base
3
3
 
4
+ headers({"User-Agent" => Tumblr::USER_AGENT})
5
+
4
6
  def initialize(*credentials)
5
7
  @defaults = {:generator => Tumblr::GENERATOR}
6
8
  @defaults.merge!({:email => credentials[0], :password => credentials[1]}) unless credentials.blank?
data/man/tumblr.1 ADDED
@@ -0,0 +1,112 @@
1
+ .\" generated with Ronn/v0.4.1
2
+ .\" http://github.com/rtomayko/ronn/
3
+ .
4
+ .TH "TUMBLR" "1" "March 2010" "Mark Wunsch" "Tumblr Manual"
5
+ .
6
+ .SH "NAME"
7
+ \fBtumblr\fR \-\- publish to tumblr.com
8
+ .
9
+ .SH "SYNOPSIS"
10
+ \fBtumblr\fR [\fIOPTIONS\fR] \fIFILE OR URL\fR
11
+ .
12
+ .SH "DESCRIPTION"
13
+ \fBtumblr\fR is a command line utility and Ruby library for working with Tumblr.com. It can read plain\-text files and publish them to Tumblr.
14
+ .
15
+ .P
16
+ The \fBtumblr\fR command will publish a named input \fIFILE\fR (or Standard Input if no file is given), or if a \fIURL\fR is given it will publish that URL as a Link post (or a Video post if the url is a YouTube or Vimeo post).
17
+ .
18
+ .P
19
+ If you preface your \fIFILE\fR with a bit of YAML (<yaml.org>) frontmatter, you can give \fBtumblr\fR more explicit instructions for publishing your post. See tumblr(5) for available YAML parameters.
20
+ .
21
+ .SH "OPTIONS"
22
+ .
23
+ .TP
24
+ \fB\-a\fR,\fB\-\-auth\fR [\fIEMAIL:PASSWORD\fR]
25
+ Provide Email Address and Password, to authenticate to Tumblr, separated by a colon.
26
+ If these are not provided, you will be prompted for them.
27
+ You \fBmust\fR provide this argument if the post comes from standard input.
28
+ .
29
+ .TP
30
+ \fB\-e\fR, \fB\-\-email\fR [\fIEMAIL\fR]
31
+ Email Address associated with your Tumblr account.
32
+ You will be prompted for a password.
33
+ .
34
+ .P
35
+ Other:
36
+ .
37
+ .TP
38
+ \fB\-h\fR, \fB\-\-help\fR
39
+ Print the help message and quit.
40
+ .
41
+ .TP
42
+ \fB\-v\fR, \fB\-\-version\fR
43
+ Print the \fBtumblr\fR version and quit.
44
+ .
45
+ .SH "EXAMPLES"
46
+ Publish a file to Tumblr.com:
47
+ .
48
+ .IP "" 4
49
+ .
50
+ .nf
51
+ $ tumblr my_post.txt
52
+ .
53
+ .fi
54
+ .
55
+ .IP "" 0
56
+ .
57
+ .P
58
+ Or from standard input:
59
+ .
60
+ .IP "" 4
61
+ .
62
+ .nf
63
+ $ cat data.yml my_post.txt | tumblr \-a tumblr_user@foobar.com:p4ssw0rd
64
+ .
65
+ .fi
66
+ .
67
+ .IP "" 0
68
+ .
69
+ .P
70
+ Make a Link post:
71
+ .
72
+ .IP "" 4
73
+ .
74
+ .nf
75
+ $ tumblr http://github.com/mwunsch/tumblr
76
+ .
77
+ .fi
78
+ .
79
+ .IP "" 0
80
+ .
81
+ .P
82
+ Or a Video post:
83
+ .
84
+ .IP "" 4
85
+ .
86
+ .nf
87
+ $ tumblr http://www.youtube.com/watch?v=CW0DUg63lqU
88
+ .
89
+ .fi
90
+ .
91
+ .IP "" 0
92
+ .
93
+ .SH "INSTALLATION"
94
+ If you have RubyGems installed:
95
+ .
96
+ .IP "" 4
97
+ .
98
+ .nf
99
+ gem install tumblr\-rb
100
+ .
101
+ .fi
102
+ .
103
+ .IP "" 0
104
+ .
105
+ .SH "COPYRIGHT"
106
+ Tumblr (the gem) is Copyright (C) 2010 Mark Wunsch
107
+ .
108
+ .P
109
+ Tumblr is Copyright (c) Tumblr, Inc. The Tumblr gem is NOT affiliated with Tumblr.
110
+ .
111
+ .SH "SEE ALSO"
112
+ tumblr(5), gem(1)
data/man/tumblr.1.html ADDED
@@ -0,0 +1,147 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv='content-type' value='text/html;charset=utf8'>
5
+ <meta name='generator' value='Ronn/v0.4.1'>
6
+ <title>tumblr(1) -- publish to tumblr.com</title>
7
+ <style type='text/css'>
8
+ body {margin:0}
9
+ #man, #man code, #man pre, #man tt, #man kbd, #man samp {
10
+ font-family:consolas,monospace;
11
+ font-size:16px;
12
+ line-height:1.3;
13
+ color:#343331;
14
+ background:#fff; }
15
+ #man { max-width:89ex; text-align:justify; margin:0 25px 25px 25px }
16
+ #man h1, #man h2, #man h3 { color:#232221;clear:left }
17
+ #man h1 { font-size:28px; margin:15px 0 30px 0; text-align:center }
18
+ #man h2 { font-size:18px; margin-bottom:0; margin-top:10px; line-height:1.3; }
19
+ #man h3 { font-size:16px; margin:0 0 0 4ex; }
20
+ #man p, #man ul, #man ol, #man dl, #man pre { margin:0 0 18px 0; }
21
+ #man pre {
22
+ color:#333231;
23
+ background:#edeceb;
24
+ padding:5px 7px;
25
+ margin:0px 0 20px 0;
26
+ border-left:2ex solid #ddd}
27
+ #man pre + h2, #man pre + h3 {
28
+ margin-top:22px;
29
+ }
30
+ #man h2 + pre, #man h3 + pre {
31
+ margin-top:5px;
32
+ }
33
+ #man > p, #man > ul, #man > ol, #man > dl, #man > pre { margin-left:8ex; }
34
+ #man dt { margin:0; clear:left }
35
+ #man dt.flush { float:left; width:8ex }
36
+ #man dd { margin:0 0 0 9ex }
37
+ #man code, #man strong, #man b { font-weight:bold; color:#131211; }
38
+ #man pre code { font-weight:normal; color:#232221; background:inherit }
39
+ #man em, var, u {
40
+ font-style:normal; color:#333231; border-bottom:1px solid #999; }
41
+ #man h1.man-title { display:none; }
42
+ #man ol.man, #man ol.man li { margin:2px 0 10px 0; padding:0;
43
+ float:left; width:33%; list-style-type:none;
44
+ text-transform:uppercase; font-size:18px; color:#999;
45
+ letter-spacing:1px;}
46
+ #man ol.man { width:100%; }
47
+ #man ol.man li.tl { text-align:left }
48
+ #man ol.man li.tc { text-align:center;letter-spacing:4px }
49
+ #man ol.man li.tr { text-align:right }
50
+ #man ol.man a { color:#999 }
51
+ #man ol.man a:hover { color:#333231 }
52
+ </style>
53
+ </head>
54
+ <body>
55
+ <div id='man'>
56
+
57
+ <h1 class='man-title'>tumblr(1)</h1>
58
+
59
+ <ol class='head man'>
60
+ <li class='tl'>tumblr(1)</li>
61
+ <li class='tc'>Tumblr Manual</li>
62
+ <li class='tr'>tumblr(1)</li>
63
+ </ol>
64
+
65
+ <h2 id='NAME'>NAME</h2>
66
+ <p><code>tumblr</code> -- publish to tumblr.com</p>
67
+
68
+ <h2>SYNOPSIS</h2>
69
+
70
+ <p><code>tumblr</code> [<var>OPTIONS</var>] <var>FILE OR URL</var></p>
71
+
72
+ <h2>DESCRIPTION</h2>
73
+
74
+ <p><code>tumblr</code> is a command line utility and Ruby library for working with Tumblr.com. It can read plain-text files and publish them to Tumblr.</p>
75
+
76
+ <p>The <code>tumblr</code> command will publish a named input <var>FILE</var> (or Standard Input if no file is given), or if a <var>URL</var> is given it will publish that URL as a Link post (or a Video post if the url is a YouTube or Vimeo post).</p>
77
+
78
+ <p>If you preface your <var>FILE</var> with a bit of YAML (&lt;yaml.org>) frontmatter, you can give <code>tumblr</code> more explicit instructions for publishing your post. See tumblr(5) for available YAML parameters.</p>
79
+
80
+ <h2>OPTIONS</h2>
81
+
82
+ <dl>
83
+ <dt><code>-a</code>,<code>--auth</code> [<em>EMAIL:PASSWORD</em>]</dt><dd><p> Provide Email Address and Password, to authenticate to Tumblr, separated by a colon.
84
+ If these are not provided, you will be prompted for them.
85
+ You <b>must</b> provide this argument if the post comes from standard input.</p></dd>
86
+ <dt><code>-e</code>, <code>--email</code> [<em>EMAIL</em>]</dt><dd><p> Email Address associated with your Tumblr account.
87
+ You will be prompted for a password.</p></dd>
88
+ </dl>
89
+
90
+
91
+ <p>Other:</p>
92
+
93
+ <dl>
94
+ <dt><code>-h</code>, <code>--help</code></dt><dd><p> Print the help message and quit.</p></dd>
95
+ <dt><code>-v</code>, <code>--version</code></dt><dd><p> Print the <code>tumblr</code> version and quit.</p></dd>
96
+ </dl>
97
+
98
+
99
+ <h2>EXAMPLES</h2>
100
+
101
+ <p>Publish a file to Tumblr.com:</p>
102
+
103
+ <pre><code>$ tumblr my_post.txt
104
+ </code></pre>
105
+
106
+ <p>Or from standard input:</p>
107
+
108
+ <pre><code>$ cat data.yml my_post.txt | tumblr -a tumblr_user@foobar.com:p4ssw0rd
109
+ </code></pre>
110
+
111
+ <p>Make a Link post:</p>
112
+
113
+ <pre><code>$ tumblr http://github.com/mwunsch/tumblr
114
+ </code></pre>
115
+
116
+ <p>Or a Video post:</p>
117
+
118
+ <pre><code>$ tumblr http://www.youtube.com/watch?v=CW0DUg63lqU
119
+ </code></pre>
120
+
121
+ <h2>INSTALLATION</h2>
122
+
123
+ <p>If you have RubyGems installed:</p>
124
+
125
+ <pre><code>gem install tumblr-rb
126
+ </code></pre>
127
+
128
+ <h2>COPYRIGHT</h2>
129
+
130
+ <p>Tumblr (the gem) is Copyright (C) 2010 Mark Wunsch</p>
131
+
132
+ <p>Tumblr is Copyright (c) Tumblr, Inc. The Tumblr gem is NOT affiliated with Tumblr.</p>
133
+
134
+ <h2>SEE ALSO</h2>
135
+
136
+ <p>tumblr(5), gem(1)</p>
137
+
138
+
139
+ <ol class='foot man'>
140
+ <li class='tl'>Mark Wunsch</li>
141
+ <li class='tc'>March 2010</li>
142
+ <li class='tr'>tumblr(1)</li>
143
+ </ol>
144
+
145
+ </div>
146
+ </body>
147
+ </html>
data/man/tumblr.1.ronn ADDED
@@ -0,0 +1,67 @@
1
+ tumblr(1) -- publish to tumblr.com
2
+ ===================================
3
+
4
+ ## SYNOPSIS
5
+
6
+ `tumblr` [<OPTIONS>] <FILE OR URL>
7
+
8
+ ## DESCRIPTION
9
+
10
+ `tumblr` is a command line utility and Ruby library for working with Tumblr.com. It can read plain-text files and publish them to Tumblr.
11
+
12
+ The `tumblr` command will publish a named input <FILE> (or Standard Input if no file is given), or if a <URL> is given it will publish that URL as a Link post (or a Video post if the url is a YouTube or Vimeo post).
13
+
14
+ If you preface your <FILE> with a bit of YAML (<yaml.org>) frontmatter, you can give `tumblr` more explicit instructions for publishing your post. See tumblr(5) for available YAML parameters.
15
+
16
+ ## OPTIONS
17
+
18
+ * `-a`,`--auth` [_EMAIL:PASSWORD_]:
19
+ Provide Email Address and Password, to authenticate to Tumblr, separated by a colon.
20
+ If these are not provided, you will be prompted for them.
21
+ You <b>must</b> provide this argument if the post comes from standard input.
22
+
23
+ * `-e`, `--email` [_EMAIL_]:
24
+ Email Address associated with your Tumblr account.
25
+ You will be prompted for a password.
26
+
27
+ Other:
28
+
29
+ * `-h`, `--help`:
30
+ Print the help message and quit.
31
+
32
+ * `-v`, `--version`:
33
+ Print the `tumblr` version and quit.
34
+
35
+ ## EXAMPLES
36
+
37
+ Publish a file to Tumblr.com:
38
+
39
+ $ tumblr my_post.txt
40
+
41
+ Or from standard input:
42
+
43
+ $ cat data.yml my_post.txt | tumblr -a tumblr_user@foobar.com:p4ssw0rd
44
+
45
+ Make a Link post:
46
+
47
+ $ tumblr http://github.com/mwunsch/tumblr
48
+
49
+ Or a Video post:
50
+
51
+ $ tumblr http://www.youtube.com/watch?v=CW0DUg63lqU
52
+
53
+ ## INSTALLATION
54
+
55
+ If you have RubyGems installed:
56
+
57
+ gem install tumblr-rb
58
+
59
+ ## COPYRIGHT
60
+
61
+ Tumblr (the gem) is Copyright (C) 2010 Mark Wunsch
62
+
63
+ Tumblr is Copyright (c) Tumblr, Inc. The Tumblr gem is NOT affiliated with Tumblr.
64
+
65
+ ## SEE ALSO
66
+
67
+ tumblr(5), gem(1)
data/man/tumblr.5 ADDED
@@ -0,0 +1,137 @@
1
+ .\" generated with Ronn/v0.4.1
2
+ .\" http://github.com/rtomayko/ronn/
3
+ .
4
+ .TH "TUMBLR" "5" "March 2010" "Mark Wunsch" "Tumblr Manual"
5
+ .
6
+ .SH "NAME"
7
+ \fBtumblr\fR \-\- tumblr posts in plaintext
8
+ .
9
+ .SH "SYNOPSIS"
10
+ .
11
+ .nf
12
+ \-\-\-
13
+ title: A typical Tumblr post
14
+ state: queue
15
+ publish\-on: next tuesday
16
+ tags: unix, manpages
17
+ format: markdown
18
+ \-\-\-
19
+ This will create a *Regular* type of post on Tumblr.com. It's so easy.
20
+ That bit up at the top is called YAML frontmatter, and it just gives the
21
+ post a bit of metadata, so publishing options are more flexible.
22
+ They correspond to the Tumblr API. This post will be added to your Tumblr
23
+ queue, to be published next Tuesday, tagged with "unix" and "manpages",
24
+ and formatted in markdown.
25
+ .
26
+ .fi
27
+ .
28
+ .SH "DESCRIPTION"
29
+ Any file can be published to Tumblr.com as a \fIRegular\fR post, but if you add a bit of YAML frontmatter (<yaml.org>) to the file, you can tell Tumblr exactly what you want to do.
30
+ .
31
+ .P
32
+ YAML frontmatter beings with \fB\-\-\-\fR on a single line, followed by YAML, ending with another \fB\-\-\-\fR on a single line, e.g.
33
+ .
34
+ .IP "" 4
35
+ .
36
+ .nf
37
+ \-\-\-
38
+ type: quote
39
+ source: Billy Shakespeare
40
+ state: draft
41
+ tags: hamlet, shakespeare
42
+ \-\-\-
43
+ "To be or not to be."
44
+ .
45
+ .fi
46
+ .
47
+ .IP "" 0
48
+ .
49
+ .P
50
+ Understood YAML parameters are documented and taken from the Tumblr API: http://www.tumblr.com/docs/en/api#api_write
51
+ .
52
+ .SH "BASIC PARAMETERS"
53
+ These YAML parameters are available for all posts
54
+ .
55
+ .IP "\(bu" 4
56
+ \fBtype\fR:
57
+ \fBregular\fR, \fBphoto\fR, \fBlink\fR, \fBquote\fR, \fBconversation\fR, \fBvideo\fR, \fBaudio\fR
58
+ Will take a guess if omitted.
59
+ See \fIPOST\-TYPE SPECIFIC PARAMETERS\fR below.
60
+ .
61
+ .IP "\(bu" 4
62
+ \fBstate\fR:
63
+ \fBpublished\fR, \fBdraft\fR, \fBqueue\fR, \fBsubmission\fR
64
+ .
65
+ .IP "\(bu" 4
66
+ \fBformat\fR:
67
+ \fBhtml\fR or \fBmarkdown\fR
68
+ .
69
+ .IP "\(bu" 4
70
+ \fBtags\fR:
71
+ .
72
+ .br
73
+ Comma\-separated list of tags.
74
+ .
75
+ .IP "\(bu" 4
76
+ \fBdate\fR:
77
+ Post date.
78
+ .
79
+ .IP "\(bu" 4
80
+ \fBprivate\fR:
81
+ If the post should be marked private.
82
+ .
83
+ .IP "\(bu" 4
84
+ \fBslug\fR:
85
+ A custom string to appear in the post's url.
86
+ .
87
+ .IP "\(bu" 4
88
+ \fBgroup\fR:
89
+ ID for a secondary blog.
90
+ .
91
+ .IP "\(bu" 4
92
+ \fBgenerator\fR:
93
+ Short description of the publishing application.
94
+ .
95
+ .IP "\(bu" 4
96
+ \fBsend\-to\-twitter\fR:
97
+ Twitter status update to make if the tumblelog has enabled it.
98
+ .
99
+ .IP "\(bu" 4
100
+ \fBpublish\-on\fR:
101
+ If the post state is 'queue', publish on this date
102
+ .
103
+ .IP "" 0
104
+ .
105
+ .SH "POST\-TYPE SPECIFIC PARAMETERS"
106
+ These are parameters that are available for specific types of posts.
107
+ .
108
+ .TP
109
+ \fBregular\fR
110
+ \fBtitle\fR
111
+ .
112
+ .TP
113
+ \fBphoto\fR
114
+ \fBcaption\fR, \fBclick\-through\-url\fR
115
+ .
116
+ .TP
117
+ \fBquote\fR
118
+ \fBsource\fR
119
+ .
120
+ .TP
121
+ \fBlink\fR
122
+ \fBname\fR, \fBdescription\fR
123
+ .
124
+ .TP
125
+ \fBconversation\fR
126
+ \fBtitle\fR
127
+ .
128
+ .TP
129
+ \fBvideo\fR
130
+ \fBtitle\fR,\fBcaption\fR
131
+ .
132
+ .TP
133
+ \fBaudio\fR
134
+ \fBcaption\fR
135
+ .
136
+ .SH "SEE ALSO"
137
+ tumblr(1), markdown(5)
data/man/tumblr.5.html ADDED
@@ -0,0 +1,163 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv='content-type' value='text/html;charset=utf8'>
5
+ <meta name='generator' value='Ronn/v0.4.1'>
6
+ <title>tumblr(5) -- tumblr posts in plaintext</title>
7
+ <style type='text/css'>
8
+ body {margin:0}
9
+ #man, #man code, #man pre, #man tt, #man kbd, #man samp {
10
+ font-family:consolas,monospace;
11
+ font-size:16px;
12
+ line-height:1.3;
13
+ color:#343331;
14
+ background:#fff; }
15
+ #man { max-width:89ex; text-align:justify; margin:0 25px 25px 25px }
16
+ #man h1, #man h2, #man h3 { color:#232221;clear:left }
17
+ #man h1 { font-size:28px; margin:15px 0 30px 0; text-align:center }
18
+ #man h2 { font-size:18px; margin-bottom:0; margin-top:10px; line-height:1.3; }
19
+ #man h3 { font-size:16px; margin:0 0 0 4ex; }
20
+ #man p, #man ul, #man ol, #man dl, #man pre { margin:0 0 18px 0; }
21
+ #man pre {
22
+ color:#333231;
23
+ background:#edeceb;
24
+ padding:5px 7px;
25
+ margin:0px 0 20px 0;
26
+ border-left:2ex solid #ddd}
27
+ #man pre + h2, #man pre + h3 {
28
+ margin-top:22px;
29
+ }
30
+ #man h2 + pre, #man h3 + pre {
31
+ margin-top:5px;
32
+ }
33
+ #man > p, #man > ul, #man > ol, #man > dl, #man > pre { margin-left:8ex; }
34
+ #man dt { margin:0; clear:left }
35
+ #man dt.flush { float:left; width:8ex }
36
+ #man dd { margin:0 0 0 9ex }
37
+ #man code, #man strong, #man b { font-weight:bold; color:#131211; }
38
+ #man pre code { font-weight:normal; color:#232221; background:inherit }
39
+ #man em, var, u {
40
+ font-style:normal; color:#333231; border-bottom:1px solid #999; }
41
+ #man h1.man-title { display:none; }
42
+ #man ol.man, #man ol.man li { margin:2px 0 10px 0; padding:0;
43
+ float:left; width:33%; list-style-type:none;
44
+ text-transform:uppercase; font-size:18px; color:#999;
45
+ letter-spacing:1px;}
46
+ #man ol.man { width:100%; }
47
+ #man ol.man li.tl { text-align:left }
48
+ #man ol.man li.tc { text-align:center;letter-spacing:4px }
49
+ #man ol.man li.tr { text-align:right }
50
+ #man ol.man a { color:#999 }
51
+ #man ol.man a:hover { color:#333231 }
52
+ </style>
53
+ </head>
54
+ <body>
55
+ <div id='man'>
56
+
57
+ <h1 class='man-title'>tumblr(5)</h1>
58
+
59
+ <ol class='head man'>
60
+ <li class='tl'>tumblr(5)</li>
61
+ <li class='tc'>Tumblr Manual</li>
62
+ <li class='tr'>tumblr(5)</li>
63
+ </ol>
64
+
65
+ <h2 id='NAME'>NAME</h2>
66
+ <p><code>tumblr</code> -- tumblr posts in plaintext</p>
67
+
68
+ <h2>SYNOPSIS</h2>
69
+
70
+ <pre><code>---
71
+ title: A typical Tumblr post
72
+ state: queue
73
+ publish-on: next tuesday
74
+ tags: unix, manpages
75
+ format: markdown
76
+ ---
77
+
78
+ This will create a *Regular* type of post on Tumblr.com. It's so easy.
79
+ That bit up at the top is called YAML frontmatter, and it just gives the
80
+ post a bit of metadata, so publishing options are more flexible.
81
+ They correspond to the Tumblr API. This post will be added to your Tumblr
82
+ queue, to be published next Tuesday, tagged with "unix" and "manpages",
83
+ and formatted in markdown.
84
+ </code></pre>
85
+
86
+ <h2>DESCRIPTION</h2>
87
+
88
+ <p>Any file can be published to Tumblr.com as a <i>Regular</i> post, but if you add a bit of YAML frontmatter (&lt;yaml.org>) to the file, you can tell Tumblr exactly what you want to do.</p>
89
+
90
+ <p>YAML frontmatter beings with <code>---</code> on a single line, followed by YAML, ending with another <code>---</code> on a single line, e.g.</p>
91
+
92
+ <pre><code>---
93
+ type: quote
94
+ source: Billy Shakespeare
95
+ state: draft
96
+ tags: hamlet, shakespeare
97
+ ---
98
+ "To be or not to be."
99
+ </code></pre>
100
+
101
+ <p>Understood YAML parameters are documented and taken from the Tumblr API: http://www.tumblr.com/docs/en/api#api_write</p>
102
+
103
+ <h2>BASIC PARAMETERS</h2>
104
+
105
+ <p>These YAML parameters are available for all posts</p>
106
+
107
+ <ul>
108
+ <li><p><code>type</code>:
109
+ <code>regular</code>, <code>photo</code>, <code>link</code>, <code>quote</code>, <code>conversation</code>, <code>video</code>, <code>audio</code>
110
+ Will take a guess if omitted.
111
+ See <em>POST-TYPE SPECIFIC PARAMETERS</em> below.</p></li>
112
+ <li><p><code>state</code>:
113
+ <code>published</code>, <code>draft</code>, <code>queue</code>, <code>submission</code></p></li>
114
+ <li><p><code>format</code>:
115
+ <code>html</code> or <code>markdown</code></p></li>
116
+ <li><p><code>tags</code>: <br />
117
+ Comma-separated list of tags.</p></li>
118
+ <li><p><code>date</code>:
119
+ Post date.</p></li>
120
+ <li><p><code>private</code>:
121
+ If the post should be marked private.</p></li>
122
+ <li><p><code>slug</code>:
123
+ A custom string to appear in the post's url.</p></li>
124
+ <li><p><code>group</code>:
125
+ ID for a secondary blog.</p></li>
126
+ <li><p><code>generator</code>:
127
+ Short description of the publishing application.</p></li>
128
+ <li><p><code>send-to-twitter</code>:
129
+ Twitter status update to make if the tumblelog has enabled it.</p></li>
130
+ <li><p><code>publish-on</code>:
131
+ If the post state is 'queue', publish on this date</p></li>
132
+ </ul>
133
+
134
+
135
+ <h2>POST-TYPE SPECIFIC PARAMETERS</h2>
136
+
137
+ <p>These are parameters that are available for specific types of posts.</p>
138
+
139
+ <dl>
140
+ <dt class="flush"><code>regular</code></dt><dd><p> <code>title</code></p></dd>
141
+ <dt class="flush"><code>photo</code></dt><dd><p> <code>caption</code>, <code>click-through-url</code></p></dd>
142
+ <dt class="flush"><code>quote</code></dt><dd><p> <code>source</code></p></dd>
143
+ <dt class="flush"><code>link</code></dt><dd><p> <code>name</code>, <code>description</code></p></dd>
144
+ <dt><code>conversation</code></dt><dd><p> <code>title</code></p></dd>
145
+ <dt class="flush"><code>video</code></dt><dd><p> <code>title</code>,<code>caption</code></p></dd>
146
+ <dt class="flush"><code>audio</code></dt><dd><p> <code>caption</code></p></dd>
147
+ </dl>
148
+
149
+
150
+ <h2>SEE ALSO</h2>
151
+
152
+ <p>tumblr(1), markdown(5)</p>
153
+
154
+
155
+ <ol class='foot man'>
156
+ <li class='tl'>Mark Wunsch</li>
157
+ <li class='tc'>March 2010</li>
158
+ <li class='tr'>tumblr(5)</li>
159
+ </ol>
160
+
161
+ </div>
162
+ </body>
163
+ </html>
data/man/tumblr.5.ronn ADDED
@@ -0,0 +1,104 @@
1
+ tumblr(5) -- tumblr posts in plaintext
2
+ ======================================
3
+
4
+ ## SYNOPSIS
5
+
6
+ ---
7
+ title: A typical Tumblr post
8
+ state: queue
9
+ publish-on: next tuesday
10
+ tags: unix, manpages
11
+ format: markdown
12
+ ---
13
+
14
+ This will create a *Regular* type of post on Tumblr.com. It's so easy.
15
+ That bit up at the top is called YAML frontmatter, and it just gives the
16
+ post a bit of metadata, so publishing options are more flexible.
17
+ They correspond to the Tumblr API. This post will be added to your Tumblr
18
+ queue, to be published next Tuesday, tagged with "unix" and "manpages",
19
+ and formatted in markdown.
20
+
21
+ ## DESCRIPTION
22
+
23
+ Any file can be published to Tumblr.com as a <i>Regular</i> post, but if you add a bit of YAML frontmatter (<yaml.org>) to the file, you can tell Tumblr exactly what you want to do.
24
+
25
+ YAML frontmatter beings with `---` on a single line, followed by YAML, ending with another `---` on a single line, e.g.
26
+
27
+ ---
28
+ type: quote
29
+ source: Billy Shakespeare
30
+ state: draft
31
+ tags: hamlet, shakespeare
32
+ ---
33
+ "To be or not to be."
34
+
35
+ Understood YAML parameters are documented and taken from the Tumblr API: http://www.tumblr.com/docs/en/api#api_write
36
+
37
+ ## BASIC PARAMETERS
38
+
39
+ These YAML parameters are available for all posts
40
+
41
+ * `type`:
42
+ `regular`, `photo`, `link`, `quote`, `conversation`, `video`, `audio`
43
+ Will take a guess if omitted.
44
+ See _POST-TYPE SPECIFIC PARAMETERS_ below.
45
+
46
+ * `state`:
47
+ `published`, `draft`, `queue`, `submission`
48
+
49
+ * `format`:
50
+ `html` or `markdown`
51
+
52
+ * `tags`:
53
+ Comma-separated list of tags.
54
+
55
+ * `date`:
56
+ Post date.
57
+
58
+ * `private`:
59
+ If the post should be marked private.
60
+
61
+ * `slug`:
62
+ A custom string to appear in the post's url.
63
+
64
+ * `group`:
65
+ ID for a secondary blog.
66
+
67
+ * `generator`:
68
+ Short description of the publishing application.
69
+
70
+ * `send-to-twitter`:
71
+ Twitter status update to make if the tumblelog has enabled it.
72
+
73
+ * `publish-on`:
74
+ If the post state is 'queue', publish on this date
75
+
76
+ ## POST-TYPE SPECIFIC PARAMETERS
77
+
78
+ These are parameters that are available for specific types of posts.
79
+
80
+ * `regular`:
81
+ `title`
82
+
83
+ * `photo`:
84
+ `caption`, `click-through-url`
85
+
86
+ * `quote`:
87
+ `source`
88
+
89
+ * `link`:
90
+ `name`, `description`
91
+
92
+ * `conversation`:
93
+ `title`
94
+
95
+ * `video`:
96
+ `title`,`caption`
97
+
98
+ * `audio`:
99
+ `caption`
100
+
101
+ ## SEE ALSO
102
+
103
+ tumblr(1), markdown(5)
104
+
data/test/test_tumblr.rb CHANGED
@@ -109,6 +109,15 @@ link
109
109
  assert tumbl.authenticate.is_a? Weary::Request
110
110
  assert_equal auth.uri, tumbl.authenticate.uri
111
111
  end
112
+
113
+ test 'executes' do
114
+ cred = {:email => 'test@testermcgee.com', :password => 'dontrevealmysecrets'}
115
+ response = VCR.with_cassette('write/write') do
116
+ Tumblr.execute(cred, 'Hello World.')
117
+ end
118
+ assert response.is_a? Weary::Response
119
+ assert response.success?
120
+ end
112
121
  end
113
122
 
114
123
  describe 'Reader' do
data/tumblr-rb.gemspec CHANGED
@@ -5,13 +5,15 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{tumblr-rb}
8
- s.version = "0.1.1"
8
+ s.version = "1.0.0"
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-09}
12
+ s.date = %q{2010-03-10}
13
+ s.default_executable = %q{tumblr}
13
14
  s.description = %q{Ruby library and command line utility to work with the Tumblr Blogging Platform, powered by Weary.}
14
15
  s.email = %q{mark@markwunsch.com}
16
+ s.executables = ["tumblr"]
15
17
  s.extra_rdoc_files = [
16
18
  "LICENSE",
17
19
  "README.md"
@@ -23,6 +25,7 @@ Gem::Specification.new do |s|
23
25
  "LICENSE",
24
26
  "README.md",
25
27
  "Rakefile",
28
+ "bin/tumblr",
26
29
  "lib/tumblr.rb",
27
30
  "lib/tumblr/authenticator.rb",
28
31
  "lib/tumblr/post.rb",
@@ -35,6 +38,12 @@ Gem::Specification.new do |s|
35
38
  "lib/tumblr/post/video.rb",
36
39
  "lib/tumblr/reader.rb",
37
40
  "lib/tumblr/writer.rb",
41
+ "man/tumblr.1",
42
+ "man/tumblr.1.html",
43
+ "man/tumblr.1.ronn",
44
+ "man/tumblr.5",
45
+ "man/tumblr.5.html",
46
+ "man/tumblr.5.ronn",
38
47
  "test/fixtures/vcr_cassettes/authenticate/authenticate.yml",
39
48
  "test/fixtures/vcr_cassettes/read/authenticated.yml",
40
49
  "test/fixtures/vcr_cassettes/read/authentication_failure.yml",
@@ -63,13 +72,16 @@ Gem::Specification.new do |s|
63
72
 
64
73
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
65
74
  s.add_runtime_dependency(%q<weary>, [">= 0.7.1"])
75
+ s.add_runtime_dependency(%q<highline>, [">= 1.5.2"])
66
76
  s.add_development_dependency(%q<bundler>, [">= 0.9.7"])
67
77
  else
68
78
  s.add_dependency(%q<weary>, [">= 0.7.1"])
79
+ s.add_dependency(%q<highline>, [">= 1.5.2"])
69
80
  s.add_dependency(%q<bundler>, [">= 0.9.7"])
70
81
  end
71
82
  else
72
83
  s.add_dependency(%q<weary>, [">= 0.7.1"])
84
+ s.add_dependency(%q<highline>, [">= 1.5.2"])
73
85
  s.add_dependency(%q<bundler>, [">= 0.9.7"])
74
86
  end
75
87
  end
metadata CHANGED
@@ -3,10 +3,10 @@ name: tumblr-rb
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
- - 0
7
- - 1
8
6
  - 1
9
- version: 0.1.1
7
+ - 0
8
+ - 0
9
+ version: 1.0.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mark Wunsch
@@ -14,8 +14,8 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-09 00:00:00 -05:00
18
- default_executable:
17
+ date: 2010-03-10 00:00:00 -05:00
18
+ default_executable: tumblr
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: weary
@@ -32,9 +32,23 @@ dependencies:
32
32
  type: :runtime
33
33
  version_requirements: *id001
34
34
  - !ruby/object:Gem::Dependency
35
- name: bundler
35
+ name: highline
36
36
  prerelease: false
37
37
  requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 1
43
+ - 5
44
+ - 2
45
+ version: 1.5.2
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: bundler
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
38
52
  requirements:
39
53
  - - ">="
40
54
  - !ruby/object:Gem::Version
@@ -44,11 +58,11 @@ dependencies:
44
58
  - 7
45
59
  version: 0.9.7
46
60
  type: :development
47
- version_requirements: *id002
61
+ version_requirements: *id003
48
62
  description: Ruby library and command line utility to work with the Tumblr Blogging Platform, powered by Weary.
49
63
  email: mark@markwunsch.com
50
- executables: []
51
-
64
+ executables:
65
+ - tumblr
52
66
  extensions: []
53
67
 
54
68
  extra_rdoc_files:
@@ -61,6 +75,7 @@ files:
61
75
  - LICENSE
62
76
  - README.md
63
77
  - Rakefile
78
+ - bin/tumblr
64
79
  - lib/tumblr.rb
65
80
  - lib/tumblr/authenticator.rb
66
81
  - lib/tumblr/post.rb
@@ -73,6 +88,12 @@ files:
73
88
  - lib/tumblr/post/video.rb
74
89
  - lib/tumblr/reader.rb
75
90
  - lib/tumblr/writer.rb
91
+ - man/tumblr.1
92
+ - man/tumblr.1.html
93
+ - man/tumblr.1.ronn
94
+ - man/tumblr.5
95
+ - man/tumblr.5.html
96
+ - man/tumblr.5.ronn
76
97
  - test/fixtures/vcr_cassettes/authenticate/authenticate.yml
77
98
  - test/fixtures/vcr_cassettes/read/authenticated.yml
78
99
  - test/fixtures/vcr_cassettes/read/authentication_failure.yml