lolcommits-tumblr 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +5 -5
- data/lib/lolcommits/plugin/tumblr.rb +24 -26
- data/lib/lolcommits/tumblr/version.rb +1 -1
- data/lolcommits-tumblr.gemspec +2 -2
- data/test/lolcommits/plugin/tumblr_test.rb +25 -45
- data/test/test_helper.rb +2 -5
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b0331ea42b461db76e0326cea99eb542c277669b20bbbbc919db870e389808cf
|
4
|
+
data.tar.gz: '08a5ec9ef7fccdb5155f5d67c925be97d1417c0e88c1663d2e61c02144310383'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: deca73dee9840f60a85ee2cd88331bda3adc76689091365e29e7ce56fe264d7addfcb283ef0f4b720596938992dd578bed66f682b4e554309bac4d79729a555a
|
7
|
+
data.tar.gz: 05ca09dd8385fe6ca4a66c068add9eb1fb7038642f5d62b121d938b3e3e01fc5d7586c524d360c7ceb2ee71fd1bb65736cebf4714b9223586d26b7ed140516f7
|
data/.travis.yml
CHANGED
@@ -2,15 +2,15 @@ sudo: false
|
|
2
2
|
language: ruby
|
3
3
|
cache: bundler
|
4
4
|
rvm:
|
5
|
-
- 2.0.0
|
6
5
|
- 2.1.10
|
7
|
-
- 2.2.
|
8
|
-
- 2.3.
|
9
|
-
- 2.4.
|
6
|
+
- 2.2.9
|
7
|
+
- 2.3.6
|
8
|
+
- 2.4.3
|
9
|
+
- 2.5.0
|
10
10
|
- ruby-head
|
11
11
|
|
12
12
|
before_install:
|
13
|
-
- gem
|
13
|
+
- gem update --system
|
14
14
|
- git --version
|
15
15
|
- git config --global user.email "lol@commits.org"
|
16
16
|
- git config --global user.name "Lolcommits"
|
@@ -13,15 +13,6 @@ module Lolcommits
|
|
13
13
|
TUMBLR_CONSUMER_KEY = '2FtMEDpEPkxjoUdkpHh42h9wqTu9IVS7Ra0QyNZGixdCvhllN2'.freeze
|
14
14
|
TUMBLR_CONSUMER_SECRET = 'qWuvxgFUR2YyWKtbWOkDTMAiBEbj7ZGaNLaNQPba0PI1N4JpBs'.freeze
|
15
15
|
|
16
|
-
##
|
17
|
-
# Returns the name of the plugin to identify the plugin to lolcommits.
|
18
|
-
#
|
19
|
-
# @return [String] the plugin name
|
20
|
-
#
|
21
|
-
def self.name
|
22
|
-
'tumblr'
|
23
|
-
end
|
24
|
-
|
25
16
|
##
|
26
17
|
# Returns position(s) of when this plugin should run during the capture
|
27
18
|
# process. Uploading happens when a new capture is ready.
|
@@ -50,11 +41,11 @@ module Lolcommits
|
|
50
41
|
#
|
51
42
|
def run_capture_ready
|
52
43
|
print "*** Posting to Tumblr ... "
|
53
|
-
post = client.photo(configuration[
|
44
|
+
post = client.photo(configuration[:tumblr_name], data: runner.main_image)
|
54
45
|
|
55
46
|
if post.key?('id')
|
56
47
|
post_url = tumblr_post_url(post)
|
57
|
-
open_url(post_url) if configuration[
|
48
|
+
open_url(post_url) if configuration[:open_url]
|
58
49
|
print "done! #{post_url}\n"
|
59
50
|
else
|
60
51
|
print "Post FAILED! #{post.inspect}"
|
@@ -64,15 +55,14 @@ module Lolcommits
|
|
64
55
|
end
|
65
56
|
|
66
57
|
##
|
67
|
-
# Returns true if the plugin has been configured
|
58
|
+
# Returns true if the plugin has been configured correctly
|
68
59
|
#
|
69
|
-
# @return [Boolean] true/false indicating if plugin
|
60
|
+
# @return [Boolean] true/false indicating if plugin has a valid config
|
70
61
|
#
|
71
|
-
def
|
72
|
-
!!(configuration[
|
73
|
-
configuration[
|
74
|
-
configuration[
|
75
|
-
configuration['tumblr_name'])
|
62
|
+
def valid_configuration?
|
63
|
+
!!(configuration[:access_token] &&
|
64
|
+
configuration[:secret] &&
|
65
|
+
configuration[:tumblr_name])
|
76
66
|
end
|
77
67
|
|
78
68
|
##
|
@@ -87,7 +77,7 @@ module Lolcommits
|
|
87
77
|
def configure_options!
|
88
78
|
options = super
|
89
79
|
# ask user to configure tokens if enabling
|
90
|
-
if options[
|
80
|
+
if options[:enabled]
|
91
81
|
auth_config = configure_auth!
|
92
82
|
return unless auth_config
|
93
83
|
options = options.merge(auth_config).merge(configure_tumblr)
|
@@ -131,8 +121,8 @@ module Lolcommits
|
|
131
121
|
puts '----------------------------------------'
|
132
122
|
|
133
123
|
{
|
134
|
-
|
135
|
-
|
124
|
+
access_token: access_token.token,
|
125
|
+
secret: access_token.secret
|
136
126
|
}
|
137
127
|
end
|
138
128
|
|
@@ -141,15 +131,15 @@ module Lolcommits
|
|
141
131
|
tumblr_name = parse_user_input(gets.strip)
|
142
132
|
print "\n* Automatically open Tumblr URL after posting (y/N): "
|
143
133
|
open_url = ask_yes_or_no?
|
144
|
-
{
|
134
|
+
{ tumblr_name: tumblr_name, open_url: open_url }
|
145
135
|
end
|
146
136
|
|
147
137
|
def client
|
148
138
|
@client ||= ::Tumblr.new(
|
149
139
|
consumer_key: TUMBLR_CONSUMER_KEY,
|
150
140
|
consumer_secret: TUMBLR_CONSUMER_SECRET,
|
151
|
-
oauth_token: configuration[
|
152
|
-
oauth_token_secret: configuration[
|
141
|
+
oauth_token: configuration[:access_token],
|
142
|
+
oauth_token_secret: configuration[:secret]
|
153
143
|
)
|
154
144
|
end
|
155
145
|
|
@@ -170,7 +160,7 @@ module Lolcommits
|
|
170
160
|
end
|
171
161
|
|
172
162
|
def tumblr_post_url(post)
|
173
|
-
"https://#{configuration[
|
163
|
+
"https://#{configuration[:tumblr_name]}.tumblr.com/post/#{post['id']}"
|
174
164
|
end
|
175
165
|
|
176
166
|
def open_url(url)
|
@@ -178,7 +168,15 @@ module Lolcommits
|
|
178
168
|
end
|
179
169
|
|
180
170
|
def local_server
|
181
|
-
@local_server ||= WEBrick::HTTPServer.new(
|
171
|
+
@local_server ||= WEBrick::HTTPServer.new(
|
172
|
+
Port: 3000,
|
173
|
+
Logger: null_logger,
|
174
|
+
AccessLog: null_logger
|
175
|
+
)
|
176
|
+
end
|
177
|
+
|
178
|
+
def null_logger
|
179
|
+
WEBrick::Log.new(nil, -1)
|
182
180
|
end
|
183
181
|
|
184
182
|
def oauth_response(heading, message)
|
data/lolcommits-tumblr.gemspec
CHANGED
@@ -32,13 +32,13 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.executables = []
|
33
33
|
spec.require_paths = ["lib"]
|
34
34
|
|
35
|
-
spec.required_ruby_version = ">= 2.
|
35
|
+
spec.required_ruby_version = ">= 2.1"
|
36
36
|
|
37
37
|
spec.add_runtime_dependency('tumblr_client')
|
38
38
|
spec.add_runtime_dependency('webrick')
|
39
39
|
spec.add_runtime_dependency('oauth')
|
40
40
|
|
41
|
-
spec.add_development_dependency "lolcommits", ">= 0.
|
41
|
+
spec.add_development_dependency "lolcommits", ">= 0.11.0"
|
42
42
|
spec.add_development_dependency "bundler"
|
43
43
|
spec.add_development_dependency "webmock"
|
44
44
|
spec.add_development_dependency "pry"
|
@@ -8,14 +8,6 @@ describe Lolcommits::Plugin::Tumblr do
|
|
8
8
|
include Lolcommits::TestHelpers::GitRepo
|
9
9
|
include Lolcommits::TestHelpers::FakeIO
|
10
10
|
|
11
|
-
def plugin_name
|
12
|
-
"tumblr"
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should have a name" do
|
16
|
-
::Lolcommits::Plugin::Tumblr.name.must_equal plugin_name
|
17
|
-
end
|
18
|
-
|
19
11
|
it "should run on capture ready" do
|
20
12
|
::Lolcommits::Plugin::Tumblr.runner_order.must_equal [:capture_ready]
|
21
13
|
end
|
@@ -24,11 +16,7 @@ describe Lolcommits::Plugin::Tumblr do
|
|
24
16
|
def runner
|
25
17
|
# a simple lolcommits runner with an empty configuration Hash
|
26
18
|
@runner ||= Lolcommits::Runner.new(
|
27
|
-
main_image: Tempfile.new("main_image.jpg").path
|
28
|
-
config: OpenStruct.new(
|
29
|
-
read_configuration: {},
|
30
|
-
loldir: File.expand_path("#{__dir__}../../../images")
|
31
|
-
)
|
19
|
+
main_image: Tempfile.new("main_image.jpg").path
|
32
20
|
)
|
33
21
|
end
|
34
22
|
|
@@ -37,17 +25,13 @@ describe Lolcommits::Plugin::Tumblr do
|
|
37
25
|
end
|
38
26
|
|
39
27
|
def valid_enabled_config
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
"open_url" => false
|
48
|
-
}
|
49
|
-
}
|
50
|
-
)
|
28
|
+
{
|
29
|
+
enabled: true,
|
30
|
+
access_token: "tumblr-access-token",
|
31
|
+
secret: "tumblr-secret",
|
32
|
+
tumblr_name: "my-tumblr",
|
33
|
+
open_url: false
|
34
|
+
}
|
51
35
|
end
|
52
36
|
|
53
37
|
describe "#enabled?" do
|
@@ -56,7 +40,7 @@ describe Lolcommits::Plugin::Tumblr do
|
|
56
40
|
end
|
57
41
|
|
58
42
|
it "is true when configured" do
|
59
|
-
plugin.
|
43
|
+
plugin.configuration = valid_enabled_config
|
60
44
|
plugin.enabled?.must_equal true
|
61
45
|
end
|
62
46
|
end
|
@@ -67,7 +51,7 @@ describe Lolcommits::Plugin::Tumblr do
|
|
67
51
|
|
68
52
|
it "posts lolcommit image to tumblr showing link to new photo post" do
|
69
53
|
in_repo do
|
70
|
-
plugin.
|
54
|
+
plugin.configuration = valid_enabled_config
|
71
55
|
|
72
56
|
stub_request(:post, "https://api.tumblr.com/v2/blog/my-tumblr.tumblr.com/post").to_return(
|
73
57
|
body: {
|
@@ -82,30 +66,26 @@ describe Lolcommits::Plugin::Tumblr do
|
|
82
66
|
output.must_match "done! https://my-tumblr.tumblr.com/post/123456789"
|
83
67
|
|
84
68
|
assert_requested :post, "https://api.tumblr.com/v2/blog/my-tumblr.tumblr.com/post", times: 1,
|
85
|
-
headers: {"Content-Type" => /multipart\/form-data/, "Accept" => "application/json" } do |req|
|
69
|
+
headers: { "Content-Type" => /multipart\/form-data/, "Accept" => "application/json" } do |req|
|
86
70
|
req.body.must_match 'filename="main_image.jpg'
|
87
71
|
end
|
88
72
|
end
|
89
73
|
end
|
90
74
|
end
|
91
75
|
|
92
|
-
describe "
|
93
|
-
it "returns
|
94
|
-
plugin.
|
95
|
-
|
96
|
-
|
97
|
-
it "returns false when partially configured" do
|
98
|
-
plugin.config = OpenStruct.new(read_configuration: {
|
99
|
-
plugin_name => { "enabled" => true, "tumblr_name" => "fire" }
|
100
|
-
})
|
101
|
-
plugin.configured?.must_equal false
|
76
|
+
describe "valid_configuration?" do
|
77
|
+
it "returns invalid config when partially configured" do
|
78
|
+
plugin.configuration = { tumblr_name: "fire" }
|
79
|
+
plugin.valid_configuration?.must_equal false
|
102
80
|
end
|
103
81
|
|
104
|
-
it "returns true
|
105
|
-
plugin.
|
106
|
-
plugin.
|
82
|
+
it "returns true with a valid configuration" do
|
83
|
+
plugin.configuration = valid_enabled_config
|
84
|
+
plugin.valid_configuration?.must_equal true
|
107
85
|
end
|
86
|
+
end
|
108
87
|
|
88
|
+
describe "configuration" do
|
109
89
|
it "allows plugin options to be configured" do
|
110
90
|
# allow requests to localhost for this test
|
111
91
|
WebMock.disable_net_connect!(allow_localhost: true)
|
@@ -141,11 +121,11 @@ describe Lolcommits::Plugin::Tumblr do
|
|
141
121
|
end
|
142
122
|
|
143
123
|
configured_plugin_options.must_equal({
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
124
|
+
enabled: true,
|
125
|
+
access_token: "tumblr-access-token",
|
126
|
+
secret: "tumblr-secret",
|
127
|
+
tumblr_name: "my-tumblr",
|
128
|
+
open_url: true
|
149
129
|
})
|
150
130
|
|
151
131
|
WebMock.disable_net_connect!
|
data/test/test_helper.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
2
|
|
3
|
-
#
|
4
|
-
require '
|
5
|
-
require 'lolcommits/runner'
|
6
|
-
require 'lolcommits/vcs_info'
|
7
|
-
require 'lolcommits/backends/git_info'
|
3
|
+
# lolcommits gem
|
4
|
+
require 'lolcommits'
|
8
5
|
|
9
6
|
# lolcommit test helpers
|
10
7
|
require 'lolcommits/test_helpers/git_repo'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lolcommits-tumblr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Hutchinson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tumblr_client
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.11.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.11.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -189,7 +189,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
189
189
|
requirements:
|
190
190
|
- - ">="
|
191
191
|
- !ruby/object:Gem::Version
|
192
|
-
version: 2.
|
192
|
+
version: '2.1'
|
193
193
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
194
|
requirements:
|
195
195
|
- - ">="
|
@@ -197,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
197
|
version: '0'
|
198
198
|
requirements: []
|
199
199
|
rubyforge_project:
|
200
|
-
rubygems_version: 2.
|
200
|
+
rubygems_version: 2.7.3
|
201
201
|
signing_key:
|
202
202
|
specification_version: 4
|
203
203
|
summary: Post lolcommits to Tumblr
|