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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 399ba5d629f2b57d53ac4b497a14685fc9b0ca49
4
- data.tar.gz: ebdf68212ed25c7db36c0865b1445c02aec7a887
2
+ SHA256:
3
+ metadata.gz: b0331ea42b461db76e0326cea99eb542c277669b20bbbbc919db870e389808cf
4
+ data.tar.gz: '08a5ec9ef7fccdb5155f5d67c925be97d1417c0e88c1663d2e61c02144310383'
5
5
  SHA512:
6
- metadata.gz: de3b42bf3a568539f16a2b3459d4793749463ed9e324f3d05945a928608b05aaa7b1bf538d3e4ec98887c14058177c2876b77675eeaa2b44382618ba30f584b9
7
- data.tar.gz: d5acb2dd96a3aa81f67a854971e3f377d7e9ff6203de7cc6a872b0cfd6238442d624cfcb9e1c33ed6236a0a5fbc7f1c23141725e7a3f9978baf19b85fcebe475
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
8
- - 2.3.5
9
- - 2.4.2
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 install bundler -v 1.13.7
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['tumblr_name'], data: runner.main_image)
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['open_url']
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 is configured
60
+ # @return [Boolean] true/false indicating if plugin has a valid config
70
61
  #
71
- def configured?
72
- !!(configuration['enabled'] &&
73
- configuration['access_token'] &&
74
- configuration['secret'] &&
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['enabled']
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
- 'access_token' => access_token.token,
135
- 'secret' => access_token.secret
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
- { 'tumblr_name' => tumblr_name, 'open_url' => open_url }
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['access_token'],
152
- oauth_token_secret: configuration['secret']
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['tumblr_name']}.tumblr.com/post/#{post['id']}"
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(Port: 3000)
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)
@@ -1,5 +1,5 @@
1
1
  module Lolcommits
2
2
  module Tumblr
3
- VERSION = "0.0.3".freeze
3
+ VERSION = "0.0.5".freeze
4
4
  end
5
5
  end
@@ -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.0.0"
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.9.5"
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
- @config ||= OpenStruct.new(
41
- read_configuration: {
42
- plugin_name => {
43
- "enabled" => true,
44
- "access_token" => "tumblr-access-token",
45
- "secret" => "tumblr-secret",
46
- "tumblr_name" => "my-tumblr",
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.config = valid_enabled_config
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.config = valid_enabled_config
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 "configuration" do
93
- it "returns false when not configured" do
94
- plugin.configured?.must_equal false
95
- end
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 when configured" do
105
- plugin.config = valid_enabled_config
106
- plugin.configured?.must_equal true
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
- "enabled" => true,
145
- "access_token" => "tumblr-access-token",
146
- "secret" => "tumblr-secret",
147
- "tumblr_name" => "my-tumblr",
148
- "open_url" => true
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
- # necessary libs from lolcommits (allowing plugin to run)
4
- require 'git'
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.3
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: 2017-12-09 00:00:00.000000000 Z
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.9.5
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.9.5
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.0.0
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.6.13
200
+ rubygems_version: 2.7.3
201
201
  signing_key:
202
202
  specification_version: 4
203
203
  summary: Post lolcommits to Tumblr