lolcommits-twitter 0.0.4 → 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: c2e6ca5a48db6a374a75549ac5c71511ad261da1
4
- data.tar.gz: bd3cf98cbb1c1e54cfbb3aa0a3ee84d541ad1beb
2
+ SHA256:
3
+ metadata.gz: dda1729a3916ac1f7b263e100d3cfa6fe44b77059b0f0a06233bd392b57d9b4c
4
+ data.tar.gz: ea083a54e32198bf114c652442055e1b9377822ee9fcc08c7c035e6ea43ceb01
5
5
  SHA512:
6
- metadata.gz: 045f56f6322053db7d13f2f1b0973fc87aed5b0628fab3e749a0c60b6a39ae89b3dc8038f4c6ffc2a8ac1a464752b3867b915d21d2954e245f766e49d0f43d17
7
- data.tar.gz: f9a762e2c0c8a917600b72e811472600aec9b94d17f79d5189bbc91db3cb6560aa7e1f7fe43ba113fdcdb75f7a8f6f48aefd004ab4936906766695ae0577ff58
6
+ metadata.gz: abfce6434ffe7c021a432ef3575c72fa56941e23f830ccac62bf0c164627eced124a1f6ffccedfb565d8e4931392c30449afa559aa3f3a68cf3962e143b1be1d
7
+ data.tar.gz: e8e23a6cf2ae6d80e411bc7ab829cfbef8a006ef0873c906acfe6b88a95c9a3a2a8942368a9325046caba04ff90ae94fdc50dafd92338d98157f32a2fd7b8cba
data/.travis.yml CHANGED
@@ -2,18 +2,19 @@ sudo: false
2
2
  language: ruby
3
3
  cache: bundler
4
4
  rvm:
5
- - 2.0.0
6
- - 2.1.10
7
- - 2.2.8
8
- - 2.3.5
9
- - 2.4.2
10
- - ruby-head
5
+ - 2.0.0
6
+ - 2.1.10
7
+ - 2.2.9
8
+ - 2.3.6
9
+ - 2.4.3
10
+ - 2.5.0
11
+ - ruby-head
11
12
 
12
13
  before_install:
13
- - gem install bundler -v 1.13.7
14
- - git --version
15
- - git config --global user.email "lol@commits.org"
16
- - git config --global user.name "Lolcommits"
14
+ - gem update --system
15
+ - git --version
16
+ - git config --global user.email "lol@commits.org"
17
+ - git config --global user.name "Lolcommits"
17
18
 
18
19
  matrix:
19
20
  allow_failures:
@@ -8,15 +8,6 @@ module Lolcommits
8
8
 
9
9
  DEFAULT_SUFFIX = '#lolcommits'.freeze
10
10
 
11
- ##
12
- # Returns the name of the plugin. Identifies the plugin to lolcommits.
13
- #
14
- # @return [String] the plugin name
15
- #
16
- def self.name
17
- 'twitter'
18
- end
19
-
20
11
  ##
21
12
  # Returns position(s) of when this plugin should run during the capture
22
13
  # process. We want to post to Twitter when the capture is ready (after all
@@ -29,12 +20,12 @@ module Lolcommits
29
20
  end
30
21
 
31
22
  ##
32
- # Plugin is configured when a token and token secret exist
23
+ # Indicate if the plugin is configured correctly.
33
24
  #
34
- # @return [Boolean] true/false if the plugin has been configured
25
+ # @return [Boolean] true/false
35
26
  #
36
- def configured?
37
- !!(configuration['token'] && configuration['token_secret'])
27
+ def valid_configuration?
28
+ !!(configuration[:token] && configuration[:token_secret])
38
29
  end
39
30
 
40
31
  ##
@@ -46,7 +37,7 @@ module Lolcommits
46
37
  def configure_options!
47
38
  options = super
48
39
  # ask user to configure all options (if enabling)
49
- if options['enabled']
40
+ if options[:enabled]
50
41
  auth_config = configure_auth!
51
42
  return unless auth_config
52
43
  options = options.merge(auth_config).
@@ -74,8 +65,8 @@ module Lolcommits
74
65
 
75
66
  begin
76
67
  client = twitter_client.new(
77
- configuration['token'],
78
- configuration['token_secret']
68
+ configuration[:token],
69
+ configuration[:token_secret]
79
70
  )
80
71
 
81
72
  debug "--> Uploading media (#{file.size} bytes)"
@@ -85,7 +76,7 @@ module Lolcommits
85
76
 
86
77
  tweet_url = status_response['entities']['media'][0]['url']
87
78
  print "#{tweet_url}\n"
88
- open_url(tweet_url) if configuration['open_tweet_url']
79
+ open_url(tweet_url) if configuration[:open_tweet_url]
89
80
  rescue StandardError => e
90
81
  puts "ERROR: Tweeting FAILED! - #{e.message}"
91
82
  end
@@ -98,10 +89,10 @@ module Lolcommits
98
89
  end
99
90
 
100
91
  def build_tweet(commit_message)
101
- prefix = configuration['prefix'].to_s
102
- suffix = configuration['suffix'].to_s
103
- prefix = "#{configuration['prefix']} " unless prefix.empty?
104
- suffix = " #{configuration['suffix']}" unless suffix.empty?
92
+ prefix = configuration[:prefix].to_s
93
+ suffix = configuration[:suffix].to_s
94
+ prefix = "#{configuration[:prefix]} " unless prefix.empty?
95
+ suffix = " #{configuration[:suffix]}" unless suffix.empty?
105
96
 
106
97
  available_commit_msg_size = twitter_client::MAX_TWEET_CHARS - (prefix.length + suffix.length)
107
98
  if commit_message.length > available_commit_msg_size
@@ -118,9 +109,9 @@ module Lolcommits
118
109
  end
119
110
 
120
111
  def configure_auth!
121
- if configured?
112
+ if valid_configuration?
122
113
  print "\n* Reset Twitter Auth ? (y/N): "
123
- return configuration.select {|k,v| k =~ /^token/ } if !ask_yes_or_no?
114
+ return configuration.select {|k,v| k.to_s =~ /^token/ } if !ask_yes_or_no?
124
115
  end
125
116
 
126
117
  puts ''
@@ -129,8 +120,6 @@ module Lolcommits
129
120
  puts '-----------------------------------'
130
121
 
131
122
  request_token = twitter_client.oauth_consumer.get_request_token
132
- rtoken = request_token.token
133
- rsecret = request_token.secret
134
123
  authorize_url = request_token.authorize_url
135
124
 
136
125
  open_url(authorize_url)
@@ -156,8 +145,8 @@ module Lolcommits
156
145
  puts '-----------------------------------'
157
146
 
158
147
  {
159
- 'token' => access_token.token,
160
- 'token_secret' => access_token.secret
148
+ token: access_token.token,
149
+ token_secret: access_token.secret
161
150
  }
162
151
  end
163
152
 
@@ -168,14 +157,14 @@ module Lolcommits
168
157
  suffix = gets.strip
169
158
 
170
159
  config = {}
171
- config['prefix'] = prefix.empty? ? '' : prefix
172
- config['suffix'] = suffix.empty? ? DEFAULT_SUFFIX : suffix
160
+ config[:prefix] = prefix.empty? ? '' : prefix
161
+ config[:suffix] = suffix.empty? ? DEFAULT_SUFFIX : suffix
173
162
  config
174
163
  end
175
164
 
176
165
  def configure_open_tweet_url
177
166
  print "\n* Automatically open Tweet URL after posting (y/N): "
178
- { 'open_tweet_url' => ask_yes_or_no? }
167
+ { open_tweet_url: ask_yes_or_no? }
179
168
  end
180
169
 
181
170
  def open_url(url)
@@ -1,5 +1,5 @@
1
1
  module Lolcommits
2
2
  module Twitter
3
- VERSION = "0.0.4".freeze
3
+ VERSION = "0.0.5".freeze
4
4
  end
5
5
  end
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_runtime_dependency "simple_oauth"
37
37
  spec.add_runtime_dependency "addressable"
38
38
 
39
- spec.add_development_dependency "lolcommits", ">= 0.9.5"
39
+ spec.add_development_dependency "lolcommits", ">= 0.10.0"
40
40
  spec.add_development_dependency "bundler"
41
41
  spec.add_development_dependency "rake"
42
42
  spec.add_development_dependency "minitest"
@@ -4,36 +4,21 @@ describe Lolcommits::Plugin::Twitter do
4
4
 
5
5
  include Lolcommits::TestHelpers::FakeIO
6
6
 
7
- def plugin_name
8
- 'twitter'
9
- end
10
-
11
- it 'should have a name' do
12
- ::Lolcommits::Plugin::Twitter.name.must_equal plugin_name
13
- end
14
-
15
7
  it 'should run on post capturing' do
16
8
  ::Lolcommits::Plugin::Twitter.runner_order.must_equal [:capture_ready]
17
9
  end
18
10
 
19
11
  describe 'with a runner' do
20
12
  def runner
21
- # a simple lolcommits runner with an empty configuration Hash
22
- @_runner ||= Lolcommits::Runner.new(
23
- config: OpenStruct.new(read_configuration: {})
24
- )
13
+ @_runner ||= Lolcommits::Runner.new
25
14
  end
26
15
 
27
16
  def valid_enabled_config
28
- @_valid_enabled_config ||= OpenStruct.new(
29
- read_configuration: {
30
- plugin.class.name => {
31
- 'enabled' => true,
32
- 'token' => 'abc-xyz',
33
- 'token_secret' => '123XYZ'
34
- }
35
- }
36
- )
17
+ {
18
+ enabled: true,
19
+ token: 'abc-xyz',
20
+ token_secret: '123XYZ'
21
+ }
37
22
  end
38
23
 
39
24
  def plugin
@@ -44,32 +29,25 @@ describe Lolcommits::Plugin::Twitter do
44
29
  Lolcommits::Twitter::Client
45
30
  end
46
31
 
47
- describe 'initalizing' do
48
- it 'should assign runner and an enabled option' do
49
- plugin.runner.must_equal runner
50
- plugin.options.must_equal ['enabled']
51
- end
52
- end
53
-
54
32
  describe '#enabled?' do
55
33
  it 'should be false by default' do
56
- plugin.enabled?.must_equal false
34
+ assert_nil plugin.enabled?
57
35
  end
58
36
 
59
37
  it 'should true when configured' do
60
- plugin.config = valid_enabled_config
38
+ plugin.configuration = valid_enabled_config
61
39
  plugin.enabled?.must_equal true
62
40
  end
63
41
  end
64
42
 
65
43
  describe 'configuration' do
66
- it 'should not be configured by default' do
67
- plugin.configured?.must_equal false
44
+ it 'should not have a valid config by default' do
45
+ plugin.valid_configuration?.must_equal false
68
46
  end
69
47
 
70
- it 'should indicate when configured' do
71
- plugin.config = valid_enabled_config
72
- plugin.configured?.must_equal true
48
+ it 'should indicate when configured correctly' do
49
+ plugin.configuration = valid_enabled_config
50
+ plugin.valid_configuration?.must_equal true
73
51
  end
74
52
 
75
53
  it 'should allow plugin options to be configured' do
@@ -88,12 +66,12 @@ describe Lolcommits::Plugin::Twitter do
88
66
  end
89
67
 
90
68
  configured_plugin_options.must_equal({
91
- 'enabled' => true,
92
- 'token' => 'oauthtoken',
93
- 'token_secret' => 'oauthtokensecret',
94
- 'prefix' => 'LOL-prefix',
95
- 'suffix' => 'LOL-suffix',
96
- 'open_tweet_url' => true
69
+ enabled: true,
70
+ token: 'oauthtoken',
71
+ token_secret: 'oauthtokensecret',
72
+ prefix: 'LOL-prefix',
73
+ suffix: 'LOL-suffix',
74
+ open_tweet_url: true
97
75
  })
98
76
  end
99
77
  end
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-twitter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
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-06 00:00:00.000000000 Z
11
+ date: 2018-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 0.9.5
75
+ version: 0.10.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 0.9.5
82
+ version: 0.10.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -210,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
210
  version: '0'
211
211
  requirements: []
212
212
  rubyforge_project:
213
- rubygems_version: 2.6.13
213
+ rubygems_version: 2.7.3
214
214
  signing_key:
215
215
  specification_version: 4
216
216
  summary: Post lolcommits to Twitter