lolcommits-tumblr 0.2.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -9
- data/CHANGELOG.md +37 -3
- data/README.md +23 -8
- data/lib/lolcommits/plugin/tumblr.rb +102 -48
- data/lib/lolcommits/tumblr.rb +2 -0
- data/lib/lolcommits/tumblr/version.rb +3 -1
- data/lolcommits-tumblr.gemspec +26 -33
- data/test/lolcommits/plugin/tumblr_test.rb +17 -14
- data/test/test_helper.rb +2 -0
- metadata +44 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3a707d534f095ce7fab54dc773c1b8897dd75e2dcf58dfe700d2290f76d2377
|
4
|
+
data.tar.gz: cccfb490b45d0bc65a2eb2cc0b906cf55dee263f306ca732c5e11b4525f9c2d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5d907e02eb2fdf7735b2e928441de5758fdaa922da75d0ba2803c6ffb39060850ceb54c502cd18e859a412905f2380ff06217a883252ae9904f990d7986672a
|
7
|
+
data.tar.gz: e039e75a37569b641b03481076e3e18e4bf9c6344685ba0f14aa2c165e2a4ebdbec93012e827ec5b5b2905a0bb958367267d0820798fa2f05e5d66f4e682d0d6
|
data/.travis.yml
CHANGED
@@ -2,17 +2,16 @@ sudo: false
|
|
2
2
|
language: ruby
|
3
3
|
cache: bundler
|
4
4
|
rvm:
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
- 2.5.8
|
6
|
+
- 2.6.6
|
7
|
+
- 2.7.2
|
8
|
+
- 3.0.0
|
9
|
+
- ruby-head
|
9
10
|
|
10
11
|
before_install:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
- git config --global user.email "lol@commits.org"
|
15
|
-
- git config --global user.name "Lolcommits"
|
12
|
+
- git --version
|
13
|
+
- git config --global user.email "lol@commits.org"
|
14
|
+
- git config --global user.name "Lolcommits"
|
16
15
|
|
17
16
|
matrix:
|
18
17
|
allow_failures:
|
data/CHANGELOG.md
CHANGED
@@ -2,13 +2,42 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
-
The format is based on [Keep a Changelog]
|
6
|
-
adheres to [Semantic Versioning]
|
5
|
+
The format is based on [Keep a Changelog][KeepAChangelog] and this
|
6
|
+
project adheres to [Semantic Versioning][Semver].
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
10
|
- Your contribution here!
|
11
11
|
|
12
|
+
## [0.5.1] - 2021-02-06
|
13
|
+
## Added
|
14
|
+
- Support for Ruby 3.0 (ditch tumblr_client gem, use faraday with simple_oauth)
|
15
|
+
|
16
|
+
## [0.5.0] - 2020-01-24
|
17
|
+
### Removed
|
18
|
+
- Support for Ruby < 2.4 (older rubies no longer supported)
|
19
|
+
|
20
|
+
## [0.4.1] - 2019-08-16
|
21
|
+
### Added
|
22
|
+
- allow erb captions, thanks to @xurizaemon
|
23
|
+
|
24
|
+
## [0.4.0] - 2019-05-20
|
25
|
+
### Changed
|
26
|
+
- lolcommits gem is a runtime dependency
|
27
|
+
- Use `lolcommit_path` (instead of `main_image`)
|
28
|
+
- Requires at least lolcommits >= `0.14.2`
|
29
|
+
- Updated README and gemspec
|
30
|
+
|
31
|
+
### Removed
|
32
|
+
- Support for lolcommits < `0.14.2`
|
33
|
+
|
34
|
+
## [0.3.0] - 2019-04-24
|
35
|
+
### Removed
|
36
|
+
- Support for Ruby < 2.3 (older rubies no longer supported)
|
37
|
+
|
38
|
+
### Added
|
39
|
+
- `frozen_string_literal: true` to all ruby files
|
40
|
+
|
12
41
|
## [0.2.0] - 2018-17-06
|
13
42
|
### Changed
|
14
43
|
- Require at least Ruby 2.3 (webrick requires it)
|
@@ -46,7 +75,12 @@ adheres to [Semantic Versioning](Semver).
|
|
46
75
|
### Changed
|
47
76
|
- Initial release
|
48
77
|
|
49
|
-
[Unreleased]: https://github.com/lolcommits/lolcommits-tumblr/compare/v0.
|
78
|
+
[Unreleased]: https://github.com/lolcommits/lolcommits-tumblr/compare/v0.5.1...HEAD
|
79
|
+
[0.5.1]: https://github.com/lolcommits/lolcommits-tumblr/compare/v0.5.0...v0.5.1
|
80
|
+
[0.5.0]: https://github.com/lolcommits/lolcommits-tumblr/compare/v0.4.1...v0.5.0
|
81
|
+
[0.4.1]: https://github.com/lolcommits/lolcommits-tumblr/compare/v0.4.0...v0.4.1
|
82
|
+
[0.4.0]: https://github.com/lolcommits/lolcommits-tumblr/compare/v0.3.0...v0.4.0
|
83
|
+
[0.3.0]: https://github.com/lolcommits/lolcommits-tumblr/compare/v0.2.0...v0.3.0
|
50
84
|
[0.2.0]: https://github.com/lolcommits/lolcommits-tumblr/compare/v0.1.1...v0.2.0
|
51
85
|
[0.1.1]: https://github.com/lolcommits/lolcommits-tumblr/compare/v0.1.0...v0.1.1
|
52
86
|
[0.1.0]: https://github.com/lolcommits/lolcommits-tumblr/compare/v0.0.5...v0.1.0
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Lolcommits Tumblr
|
2
2
|
|
3
3
|
[![Gem](https://img.shields.io/gem/v/lolcommits-tumblr.svg?style=flat)](http://rubygems.org/gems/lolcommits-tumblr)
|
4
|
-
[![Travis](https://
|
4
|
+
[![Travis](https://img.shields.io/travis/com/lolcommits/lolcommits-tumblr/master.svg?style=flat)](https://travis-ci.com/lolcommits/lolcommits-tumblr)
|
5
5
|
[![Depfu](https://img.shields.io/depfu/lolcommits/lolcommits-tumblr.svg?style=flat)](https://depfu.com/github/lolcommits/lolcommits-tumblr)
|
6
6
|
[![Maintainability](https://api.codeclimate.com/v1/badges/0c289196d8504223c31a/maintainability)](https://codeclimate.com/github/lolcommits/lolcommits-tumblr/maintainability)
|
7
7
|
[![Test Coverage](https://api.codeclimate.com/v1/badges/0c289196d8504223c31a/test_coverage)](https://codeclimate.com/github/lolcommits/lolcommits-tumblr/test_coverage)
|
@@ -15,7 +15,7 @@ Tumblr access token and secret (the plugin will guide you through this process).
|
|
15
15
|
|
16
16
|
## Requirements
|
17
17
|
|
18
|
-
* Ruby >= 2.
|
18
|
+
* Ruby >= 2.4
|
19
19
|
* A webcam
|
20
20
|
* [ImageMagick](http://www.imagemagick.org)
|
21
21
|
* [ffmpeg](https://www.ffmpeg.org) (optional) for animated gif capturing
|
@@ -34,6 +34,7 @@ to visit Tumblr to authenticate and allow access.
|
|
34
34
|
# set enabled to `true`
|
35
35
|
# confirm access for this plugin at tumblr.com (link opens automatically)
|
36
36
|
# click 'allow' then return to the console to set your Tumblr name
|
37
|
+
# optionally set a caption for each post (ERB friendly, see below)
|
37
38
|
# optionally set the plugin to auto-open each created Tumblr post
|
38
39
|
|
39
40
|
That's it! Your next lolcommit will automatically be posted to your Tumblr blog.
|
@@ -42,6 +43,21 @@ To disable use:
|
|
42
43
|
$ lolcommits --config -p tumblr
|
43
44
|
# and set enabled to `false`
|
44
45
|
|
46
|
+
### ERB friendly captions
|
47
|
+
|
48
|
+
You can optionally configure a caption string for each Tumblr post
|
49
|
+
`caption_erb`. The ERB bind has these variables available:
|
50
|
+
|
51
|
+
* `message` - commit message string
|
52
|
+
* `sha` - commit sha (shortened)
|
53
|
+
* `branch` - commit branch name
|
54
|
+
* `repo` - vcs respository name
|
55
|
+
* `vcs_info` - [vcs_info](https://github.com/lolcommits/lolcommits/blob/master/lib/lolcommits/vcs_info.rb) instance (from lolcommits)
|
56
|
+
|
57
|
+
This allows you to set caption strings like this:
|
58
|
+
|
59
|
+
Committed <%= sha %> in <%= repo %> on <%= branch %> - <%= message %>
|
60
|
+
|
45
61
|
## Development
|
46
62
|
|
47
63
|
Check out this repo and run `bin/setup`, this will install all dependencies and
|
@@ -72,8 +88,8 @@ Generate docs for this gem with:
|
|
72
88
|
## Troubles?
|
73
89
|
|
74
90
|
If you think something is broken or missing, please raise a new
|
75
|
-
[issue](https://github.com/lolcommits/lolcommits-tumblr/issues). Take
|
76
|
-
|
91
|
+
[issue](https://github.com/lolcommits/lolcommits-tumblr/issues). Take a moment
|
92
|
+
to check it hasn't been raised in the past (and possibly closed).
|
77
93
|
|
78
94
|
## Contributing
|
79
95
|
|
@@ -83,14 +99,13 @@ GitHub.
|
|
83
99
|
|
84
100
|
When submitting pull requests, remember to add tests covering any new behaviour,
|
85
101
|
and ensure all tests are passing on [Travis
|
86
|
-
CI](https://travis-ci.
|
87
|
-
[contributing
|
102
|
+
CI](https://travis-ci.com/lolcommits/lolcommits-tumblr). Read the [contributing
|
88
103
|
guidelines](https://github.com/lolcommits/lolcommits-tumblr/blob/master/CONTRIBUTING.md)
|
89
104
|
for more details.
|
90
105
|
|
91
106
|
This project is intended to be a safe, welcoming space for collaboration, and
|
92
107
|
contributors are expected to adhere to the [Contributor
|
93
|
-
Covenant](http://contributor-covenant.org) code of conduct.
|
108
|
+
Covenant](http://contributor-covenant.org) code of conduct. See
|
94
109
|
[here](https://github.com/lolcommits/lolcommits-tumblr/blob/master/CODE_OF_CONDUCT.md)
|
95
110
|
for more details.
|
96
111
|
|
@@ -101,7 +116,7 @@ The gem is available as open source under the terms of
|
|
101
116
|
|
102
117
|
## Links
|
103
118
|
|
104
|
-
* [Travis CI](https://travis-ci.
|
119
|
+
* [Travis CI](https://travis-ci.com/lolcommits/lolcommits-tumblr)
|
105
120
|
* [Code Climate](https://codeclimate.com/github/lolcommits/lolcommits-tumblr)
|
106
121
|
* [Test Coverage](https://codeclimate.com/github/lolcommits/lolcommits-tumblr/coverage)
|
107
122
|
* [RDoc](http://rdoc.info/projects/lolcommits/lolcommits-tumblr)
|
@@ -1,44 +1,53 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "lolcommits/plugin/base"
|
4
|
+
require "lolcommits/cli/launcher"
|
5
|
+
require "oauth"
|
6
|
+
require "webrick"
|
7
|
+
require "cgi"
|
8
|
+
require "erb"
|
9
|
+
require "faraday"
|
10
|
+
require "faraday_middleware"
|
7
11
|
|
8
12
|
module Lolcommits
|
9
13
|
module Plugin
|
10
14
|
class Tumblr < Base
|
11
15
|
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
TUMBLR_API_HOST = "api.tumblr.com".freeze
|
17
|
+
TUMBLR_API_ENDPOINT = "https://www.tumblr.com".freeze
|
18
|
+
TUMBLR_CONSUMER_KEY = "2FtMEDpEPkxjoUdkpHh42h9wqTu9IVS7Ra0QyNZGixdCvhllN2".freeze
|
19
|
+
TUMBLR_CONSUMER_SECRET = "qWuvxgFUR2YyWKtbWOkDTMAiBEbj7ZGaNLaNQPba0PI1N4JpBs".freeze
|
15
20
|
|
16
21
|
##
|
17
|
-
# Post-capture hook, runs after lolcommits captures a snapshot.
|
18
|
-
# the lolcommit image to the remote server with an optional Authorization
|
19
|
-
# header and the following request params.
|
20
|
-
#
|
21
|
-
# `file` - captured lolcommit image file
|
22
|
-
# `message` - the commit message
|
23
|
-
# `repo` - repository name e.g. mroth/lolcommits
|
24
|
-
# `sha` - commit SHA
|
25
|
-
# `key` - key (string) from plugin configuration (optional)
|
26
|
-
# `author_name` - the commit author name
|
27
|
-
# `author_email` - the commit author email address
|
22
|
+
# Post-capture hook, runs after lolcommits captures a snapshot.
|
28
23
|
#
|
29
|
-
#
|
30
|
-
#
|
24
|
+
# Posts the lolcommit main image to Tumblr, printing success or
|
25
|
+
# failure message to stdout.
|
31
26
|
#
|
32
27
|
def run_capture_ready
|
28
|
+
if runner.capture_video && !runner.capture_gif
|
29
|
+
debug "unable to post videos, (Tumblr API only supports images)"
|
30
|
+
return
|
31
|
+
end
|
32
|
+
|
33
33
|
print "*** Posting to Tumblr ... "
|
34
|
-
|
34
|
+
response = tumblr_api.post do |req|
|
35
|
+
req.url "v2/blog/#{configuration[:tumblr_name]}/post"
|
36
|
+
req.body = {
|
37
|
+
caption: tumblr_caption,
|
38
|
+
type: "photo",
|
39
|
+
data: Faraday::FilePart.new(lolcommit_path, lolcommit_mime_type)
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
post = response.body["response"] || {}
|
35
44
|
|
36
45
|
if post.key?('id')
|
37
46
|
post_url = tumblr_post_url(post)
|
38
47
|
open_url(post_url) if configuration[:open_url]
|
39
48
|
print "done! #{post_url}\n"
|
40
49
|
else
|
41
|
-
print "Post FAILED! #{
|
50
|
+
print "Post FAILED! #{response.inspect}"
|
42
51
|
end
|
43
52
|
rescue Faraday::Error => e
|
44
53
|
print "Post FAILED! #{e.message}"
|
@@ -78,11 +87,47 @@ module Lolcommits
|
|
78
87
|
|
79
88
|
private
|
80
89
|
|
90
|
+
def lolcommit_path
|
91
|
+
runner.capture_image? ? runner.lolcommit_path : runner.lolcommit_gif_path
|
92
|
+
end
|
93
|
+
|
94
|
+
def lolcommit_mime_type
|
95
|
+
runner.capture_image? ? "image/jpeg" : "image/gif"
|
96
|
+
end
|
97
|
+
|
98
|
+
def tumblr_api
|
99
|
+
# TODO: maybe remove faraday, just use Net::HTTP and simpler code for
|
100
|
+
# Oauth1.0 auth (so we can remove a few runtime deps)
|
101
|
+
@tumblr_api ||= Faraday.new(url: "https://#{TUMBLR_API_HOST}/", headers: api_headers) do |conn|
|
102
|
+
conn.request :oauth, api_oauth
|
103
|
+
conn.request :multipart
|
104
|
+
conn.request :url_encoded
|
105
|
+
conn.response :json, :content_type => /\bjson$/
|
106
|
+
conn.adapter Faraday.default_adapter
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def api_headers
|
111
|
+
{
|
112
|
+
accept: "application/json",
|
113
|
+
user_agent: "lolcommits-tumblr/#{Lolcommits::Tumblr::VERSION}"
|
114
|
+
}
|
115
|
+
end
|
116
|
+
|
117
|
+
def api_oauth
|
118
|
+
{
|
119
|
+
consumer_key: TUMBLR_CONSUMER_KEY,
|
120
|
+
consumer_secret: TUMBLR_CONSUMER_SECRET,
|
121
|
+
token: configuration[:access_token],
|
122
|
+
token_secret: configuration[:secret]
|
123
|
+
}
|
124
|
+
end
|
125
|
+
|
81
126
|
def configure_auth!
|
82
|
-
puts
|
83
|
-
puts
|
84
|
-
puts
|
85
|
-
puts
|
127
|
+
puts ""
|
128
|
+
puts "----------------------------------------"
|
129
|
+
puts " Need to grab Tumblr Oauth token "
|
130
|
+
puts "----------------------------------------"
|
86
131
|
|
87
132
|
request_token = oauth_consumer.get_request_token(exclude_callback: true)
|
88
133
|
puts "\nOpening this url to authorize lolcommits:"
|
@@ -90,9 +135,9 @@ module Lolcommits
|
|
90
135
|
open_url(request_token.authorize_url)
|
91
136
|
puts "\nLaunching local webbrick server to complete the OAuth process ...\n"
|
92
137
|
begin
|
93
|
-
trap(
|
94
|
-
trap(
|
95
|
-
local_server.mount_proc
|
138
|
+
trap("INT") { local_server.shutdown }
|
139
|
+
trap("SIGTERM") { local_server.shutdown }
|
140
|
+
local_server.mount_proc "/", server_callback
|
96
141
|
local_server.start
|
97
142
|
debug "Requesting Tumblr OAuth Token with verifier: #{@verifier}"
|
98
143
|
access_token = request_token.get_access_token(oauth_verifier: @verifier)
|
@@ -105,10 +150,10 @@ module Lolcommits
|
|
105
150
|
end
|
106
151
|
return unless access_token.token && access_token.secret
|
107
152
|
|
108
|
-
puts
|
109
|
-
puts
|
110
|
-
puts
|
111
|
-
puts
|
153
|
+
puts ""
|
154
|
+
puts "----------------------------------------"
|
155
|
+
puts "Thanks! Lolcommits Tumblr Auth Succeeded"
|
156
|
+
puts "----------------------------------------"
|
112
157
|
|
113
158
|
{
|
114
159
|
access_token: access_token.token,
|
@@ -119,18 +164,12 @@ module Lolcommits
|
|
119
164
|
def configure_tumblr
|
120
165
|
print "\n* What's your Tumblr name? (i.e. 'http://[THIS PART HERE].tumblr.com'): "
|
121
166
|
tumblr_name = parse_user_input(gets.strip)
|
167
|
+
print "\n* Optional caption (ERB friendly with vars message, sha, repo, branch, vcs_info)"
|
168
|
+
print "\n e.g. Committed <%= sha %> in <%= repo %> on <%= branch %> - <%= message %>\n\n"
|
169
|
+
caption_erb = parse_user_input(gets.strip)
|
122
170
|
print "\n* Automatically open Tumblr URL after posting (y/N): "
|
123
171
|
open_url = ask_yes_or_no?
|
124
|
-
{ tumblr_name: tumblr_name, open_url: open_url }
|
125
|
-
end
|
126
|
-
|
127
|
-
def client
|
128
|
-
@client ||= ::Tumblr.new(
|
129
|
-
consumer_key: TUMBLR_CONSUMER_KEY,
|
130
|
-
consumer_secret: TUMBLR_CONSUMER_SECRET,
|
131
|
-
oauth_token: configuration[:access_token],
|
132
|
-
oauth_token_secret: configuration[:secret]
|
133
|
-
)
|
172
|
+
{ tumblr_name: tumblr_name, open_url: open_url, caption_erb: caption_erb }
|
134
173
|
end
|
135
174
|
|
136
175
|
def oauth_consumer
|
@@ -150,7 +189,22 @@ module Lolcommits
|
|
150
189
|
end
|
151
190
|
|
152
191
|
def tumblr_post_url(post)
|
153
|
-
"https://#{configuration[:tumblr_name]}.tumblr.com/post/#{post[
|
192
|
+
"https://#{configuration[:tumblr_name]}.tumblr.com/post/#{post["id"]}"
|
193
|
+
end
|
194
|
+
|
195
|
+
def tumblr_caption
|
196
|
+
return if configuration[:caption_erb].to_s.strip.empty?
|
197
|
+
|
198
|
+
ERB.new(configuration[:caption_erb]).result(
|
199
|
+
binding.tap do |bind|
|
200
|
+
vcs_info = runner.vcs_info
|
201
|
+
bind.local_variable_set(:message, vcs_info.message)
|
202
|
+
bind.local_variable_set(:sha, vcs_info.sha)
|
203
|
+
bind.local_variable_set(:repo, vcs_info.repo)
|
204
|
+
bind.local_variable_set(:branch, vcs_info.branch)
|
205
|
+
bind.local_variable_set(:vcs_info, vcs_info)
|
206
|
+
end
|
207
|
+
)
|
154
208
|
end
|
155
209
|
|
156
210
|
def open_url(url)
|
@@ -223,8 +277,8 @@ module Lolcommits
|
|
223
277
|
query = req.request_uri.query
|
224
278
|
query = CGI.parse(req.request_uri.query) if query
|
225
279
|
|
226
|
-
if query && query[
|
227
|
-
@verifier = query[
|
280
|
+
if query && query["oauth_verifier"]
|
281
|
+
@verifier = query["oauth_verifier"][0]
|
228
282
|
res.body = oauth_response(
|
229
283
|
"Lolcommits Authorization Complete",
|
230
284
|
"Please return to your console to complete the <a href=\"https://github.com/lolcommits/lolcommits-tumblr\">lolcommits-tumblr</a> plugin setup"
|
data/lib/lolcommits/tumblr.rb
CHANGED
data/lolcommits-tumblr.gemspec
CHANGED
@@ -1,51 +1,44 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
3
|
+
require "lolcommits/tumblr/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
9
|
-
spec.authors
|
10
|
-
spec.email
|
11
|
-
spec.summary
|
12
|
-
spec.homepage
|
13
|
-
spec.license
|
14
|
-
|
15
|
-
spec.description = <<-
|
16
|
-
A simple plugin to post lolcommits to your Tumblr. Configure it with a
|
17
|
-
access token and secret.
|
18
|
-
|
6
|
+
spec.name = "lolcommits-tumblr"
|
7
|
+
spec.version = Lolcommits::Tumblr::VERSION
|
8
|
+
spec.authors = ["Matthew Hutchinson"]
|
9
|
+
spec.email = ["matt@hiddenloop.com"]
|
10
|
+
spec.summary = %q{Post lolcommits to Tumblr}
|
11
|
+
spec.homepage = "https://github.com/lolcommits/lolcommits-tumblr"
|
12
|
+
spec.license = "LGPL-3.0"
|
13
|
+
|
14
|
+
spec.description = <<-DESC
|
15
|
+
A simple plugin to post lolcommits to your Tumblr. Configure it with a
|
16
|
+
Tumblr access token and secret.
|
17
|
+
DESC
|
19
18
|
|
20
19
|
spec.metadata = {
|
21
|
-
"homepage_uri"
|
22
|
-
"changelog_uri"
|
23
|
-
"source_code_uri"
|
24
|
-
"bug_tracker_uri"
|
20
|
+
"homepage_uri" => "https://github.com/lolcommits/lolcommits-tumblr",
|
21
|
+
"changelog_uri" => "https://github.com/lolcommits/lolcommits-tumblr/blob/master/CHANGELOG.md",
|
22
|
+
"source_code_uri" => "https://github.com/lolcommits/lolcommits-tumblr",
|
23
|
+
"bug_tracker_uri" => "https://github.com/lolcommits/lolcommits-tumblr/issues",
|
24
|
+
"allowed_push_host" => "https://rubygems.org"
|
25
25
|
}
|
26
26
|
|
27
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
28
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
29
|
-
if spec.respond_to?(:metadata)
|
30
|
-
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
31
|
-
else
|
32
|
-
raise "RubyGems 2.0 or newer is required to protect against " \
|
33
|
-
"public gem pushes."
|
34
|
-
end
|
35
|
-
|
36
27
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(assets|test|features)/}) }
|
37
28
|
spec.test_files = `git ls-files -- {test,features}/*`.split("\n")
|
38
29
|
spec.bindir = "bin"
|
39
30
|
spec.executables = []
|
40
31
|
spec.require_paths = ["lib"]
|
41
32
|
|
42
|
-
spec.required_ruby_version = ">= 2.
|
33
|
+
spec.required_ruby_version = ">= 2.4"
|
43
34
|
|
44
|
-
spec.add_runtime_dependency
|
45
|
-
spec.add_runtime_dependency(
|
46
|
-
spec.add_runtime_dependency(
|
35
|
+
spec.add_runtime_dependency "lolcommits", ">= 0.14.2"
|
36
|
+
spec.add_runtime_dependency("faraday")
|
37
|
+
spec.add_runtime_dependency("faraday_middleware")
|
38
|
+
spec.add_runtime_dependency("simple_oauth")
|
39
|
+
spec.add_runtime_dependency("oauth")
|
40
|
+
spec.add_runtime_dependency("webrick")
|
47
41
|
|
48
|
-
spec.add_development_dependency "lolcommits", ">= 0.12.0"
|
49
42
|
spec.add_development_dependency "bundler"
|
50
43
|
spec.add_development_dependency "webmock"
|
51
44
|
spec.add_development_dependency "pry"
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "json"
|
2
4
|
require 'net/http'
|
3
5
|
require "test_helper"
|
@@ -12,7 +14,7 @@ describe Lolcommits::Plugin::Tumblr do
|
|
12
14
|
def runner
|
13
15
|
# a simple lolcommits runner with an empty configuration Hash
|
14
16
|
@runner ||= Lolcommits::Runner.new(
|
15
|
-
|
17
|
+
lolcommit_path: Tempfile.new("lolcommit.jpg").path
|
16
18
|
)
|
17
19
|
end
|
18
20
|
|
@@ -32,12 +34,12 @@ describe Lolcommits::Plugin::Tumblr do
|
|
32
34
|
|
33
35
|
describe "#enabled?" do
|
34
36
|
it "is false by default" do
|
35
|
-
plugin.enabled
|
37
|
+
_(plugin.enabled?).must_equal false
|
36
38
|
end
|
37
39
|
|
38
40
|
it "is true when configured" do
|
39
41
|
plugin.configuration = valid_enabled_config
|
40
|
-
plugin.enabled
|
42
|
+
_(plugin.enabled?).must_equal true
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
@@ -45,11 +47,11 @@ describe Lolcommits::Plugin::Tumblr do
|
|
45
47
|
before { commit_repo_with_message("first commit!") }
|
46
48
|
after { teardown_repo }
|
47
49
|
|
48
|
-
it "posts lolcommit
|
50
|
+
it "posts lolcommit to tumblr showing link to new photo post" do
|
49
51
|
in_repo do
|
50
52
|
plugin.configuration = valid_enabled_config
|
51
53
|
|
52
|
-
stub_request(:post, "https://api.tumblr.com/v2/blog/my-tumblr
|
54
|
+
stub_request(:post, "https://api.tumblr.com/v2/blog/my-tumblr/post").to_return(
|
53
55
|
body: {
|
54
56
|
"meta" => { "status" => 201, "msg" => "Created"},
|
55
57
|
"response" => { "id" => 123456789 }
|
@@ -59,11 +61,11 @@ describe Lolcommits::Plugin::Tumblr do
|
|
59
61
|
)
|
60
62
|
|
61
63
|
output = fake_io_capture { plugin.run_capture_ready }
|
62
|
-
output.must_match "done! https://my-tumblr.tumblr.com/post/123456789"
|
64
|
+
_(output).must_match "done! https://my-tumblr.tumblr.com/post/123456789"
|
63
65
|
|
64
|
-
assert_requested :post, "https://api.tumblr.com/v2/blog/my-tumblr
|
66
|
+
assert_requested :post, "https://api.tumblr.com/v2/blog/my-tumblr/post", times: 1,
|
65
67
|
headers: { "Content-Type" => /multipart\/form-data/, "Accept" => "application/json" } do |req|
|
66
|
-
req.body.must_match 'filename="
|
68
|
+
_(req.body).must_match 'filename="lolcommit.jpg'
|
67
69
|
end
|
68
70
|
end
|
69
71
|
end
|
@@ -72,12 +74,12 @@ describe Lolcommits::Plugin::Tumblr do
|
|
72
74
|
describe "valid_configuration?" do
|
73
75
|
it "returns invalid config when partially configured" do
|
74
76
|
plugin.configuration = { tumblr_name: "fire" }
|
75
|
-
plugin.valid_configuration
|
77
|
+
_(plugin.valid_configuration?).must_equal false
|
76
78
|
end
|
77
79
|
|
78
80
|
it "returns true with a valid configuration" do
|
79
81
|
plugin.configuration = valid_enabled_config
|
80
|
-
plugin.valid_configuration
|
82
|
+
_(plugin.valid_configuration?).must_equal true
|
81
83
|
end
|
82
84
|
end
|
83
85
|
|
@@ -86,8 +88,8 @@ describe Lolcommits::Plugin::Tumblr do
|
|
86
88
|
# allow requests to localhost for this test
|
87
89
|
WebMock.disable_net_connect!(allow_localhost: true)
|
88
90
|
|
89
|
-
# enabled tumblr_name open_url
|
90
|
-
inputs =
|
91
|
+
# enabled tumblr_name caption_erb open_url
|
92
|
+
inputs = [true, 'my-tumblr', ' ', 'Y']
|
91
93
|
configured_plugin_options = {}
|
92
94
|
|
93
95
|
# stub Oauth token request flow
|
@@ -116,12 +118,13 @@ describe Lolcommits::Plugin::Tumblr do
|
|
116
118
|
configured_plugin_options = plugin.configure_options!
|
117
119
|
end
|
118
120
|
|
119
|
-
configured_plugin_options.must_equal({
|
121
|
+
_(configured_plugin_options).must_equal({
|
120
122
|
enabled: true,
|
121
123
|
access_token: "tumblr-access-token",
|
122
124
|
secret: "tumblr-secret",
|
123
125
|
tumblr_name: "my-tumblr",
|
124
|
-
open_url: true
|
126
|
+
open_url: true,
|
127
|
+
caption_erb: nil
|
125
128
|
})
|
126
129
|
|
127
130
|
WebMock.disable_net_connect!
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lolcommits-tumblr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Hutchinson
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: lolcommits
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.14.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.14.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - ">="
|
@@ -25,7 +39,21 @@ dependencies:
|
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
42
|
+
name: faraday_middleware
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simple_oauth
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
30
58
|
requirements:
|
31
59
|
- - ">="
|
@@ -53,19 +81,19 @@ dependencies:
|
|
53
81
|
- !ruby/object:Gem::Version
|
54
82
|
version: '0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
84
|
+
name: webrick
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
58
86
|
requirements:
|
59
87
|
- - ">="
|
60
88
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0
|
62
|
-
type: :
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
63
91
|
prerelease: false
|
64
92
|
version_requirements: !ruby/object:Gem::Requirement
|
65
93
|
requirements:
|
66
94
|
- - ">="
|
67
95
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0
|
96
|
+
version: '0'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: bundler
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,8 +179,8 @@ dependencies:
|
|
151
179
|
- !ruby/object:Gem::Version
|
152
180
|
version: '0'
|
153
181
|
description: |2
|
154
|
-
A simple plugin to post lolcommits to your Tumblr. Configure it with a
|
155
|
-
access token and secret.
|
182
|
+
A simple plugin to post lolcommits to your Tumblr. Configure it with a
|
183
|
+
Tumblr access token and secret.
|
156
184
|
email:
|
157
185
|
- matt@hiddenloop.com
|
158
186
|
executables: []
|
@@ -180,14 +208,14 @@ files:
|
|
180
208
|
- test/test_helper.rb
|
181
209
|
homepage: https://github.com/lolcommits/lolcommits-tumblr
|
182
210
|
licenses:
|
183
|
-
- LGPL-3
|
211
|
+
- LGPL-3.0
|
184
212
|
metadata:
|
185
213
|
homepage_uri: https://github.com/lolcommits/lolcommits-tumblr
|
186
214
|
changelog_uri: https://github.com/lolcommits/lolcommits-tumblr/blob/master/CHANGELOG.md
|
187
215
|
source_code_uri: https://github.com/lolcommits/lolcommits-tumblr
|
188
216
|
bug_tracker_uri: https://github.com/lolcommits/lolcommits-tumblr/issues
|
189
217
|
allowed_push_host: https://rubygems.org
|
190
|
-
post_install_message:
|
218
|
+
post_install_message:
|
191
219
|
rdoc_options: []
|
192
220
|
require_paths:
|
193
221
|
- lib
|
@@ -195,16 +223,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
195
223
|
requirements:
|
196
224
|
- - ">="
|
197
225
|
- !ruby/object:Gem::Version
|
198
|
-
version: '2.
|
226
|
+
version: '2.4'
|
199
227
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
200
228
|
requirements:
|
201
229
|
- - ">="
|
202
230
|
- !ruby/object:Gem::Version
|
203
231
|
version: '0'
|
204
232
|
requirements: []
|
205
|
-
|
206
|
-
|
207
|
-
signing_key:
|
233
|
+
rubygems_version: 3.2.3
|
234
|
+
signing_key:
|
208
235
|
specification_version: 4
|
209
236
|
summary: Post lolcommits to Tumblr
|
210
237
|
test_files:
|