lolcommits 0.9.4 → 0.9.5.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +3 -3
- data/CHANGELOG.md +6 -1
- data/Gemfile +0 -2
- data/README.md +1 -1
- data/lib/lolcommits.rb +0 -1
- data/lib/lolcommits/cli/launcher.rb +4 -0
- data/lib/lolcommits/configuration.rb +1 -1
- data/lib/lolcommits/plugin/base.rb +37 -21
- data/lib/lolcommits/plugin/dot_com.rb +3 -3
- data/lib/lolcommits/plugin/lol_flowdock.rb +2 -2
- data/lib/lolcommits/plugin/lol_hipchat.rb +3 -3
- data/lib/lolcommits/plugin/lol_protonet.rb +3 -3
- data/lib/lolcommits/plugin/lol_slack.rb +2 -2
- data/lib/lolcommits/plugin/lol_tumblr.rb +2 -2
- data/lib/lolcommits/plugin/lol_yammer.rb +2 -2
- data/lib/lolcommits/plugin/lolsrv.rb +3 -3
- data/lib/lolcommits/plugin/term_output.rb +2 -2
- data/lib/lolcommits/plugin/uploldz.rb +3 -3
- data/lib/lolcommits/plugin_manager.rb +5 -1
- data/lib/lolcommits/runner.rb +8 -8
- data/lib/lolcommits/version.rb +1 -1
- data/lolcommits.gemspec +21 -1
- metadata +22 -7
- data/lib/lolcommits/plugin/lol_twitter.rb +0 -176
- data/test/plugins_test.rb +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd13587e4a453dcd73506653bba23b9fe19c6903
|
4
|
+
data.tar.gz: beacc833f4169a2309e0fc0927f5dc3c639fda1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa7c9e5065643d109fec9fbcdcf9e75d9f349809bc4e95e43717c3f93b1ec9f203c0a052cf70d72593d3432172170c66fe7345aae2be7c003fc18af6f27518e1
|
7
|
+
data.tar.gz: 41035783d256a3d9929016e898107f51040e2ee03a561c145aab1b227dfe91ef490c9558769afeb58130ecf391ed065a623f078a82db4ef3099c77f08eab49f3
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -18,7 +18,7 @@ Metrics/AbcSize:
|
|
18
18
|
# Offense count: 2
|
19
19
|
# Configuration parameters: CountComments, ExcludedMethods.
|
20
20
|
Metrics/BlockLength:
|
21
|
-
Max:
|
21
|
+
Max: 60
|
22
22
|
|
23
23
|
# Offense count: 5
|
24
24
|
# Configuration parameters: CountComments.
|
@@ -56,7 +56,7 @@ Style/Documentation:
|
|
56
56
|
|
57
57
|
# Offense count: 2
|
58
58
|
# Cop supports --auto-correct.
|
59
|
-
|
59
|
+
Layout/EmptyLinesAroundBeginBody:
|
60
60
|
Exclude:
|
61
61
|
- 'lib/lolcommits/plugin/lol_flowdock.rb'
|
62
62
|
- 'lib/lolcommits/plugin/lol_slack.rb'
|
@@ -65,7 +65,7 @@ Style/EmptyLinesAroundBeginBody:
|
|
65
65
|
# Cop supports --auto-correct.
|
66
66
|
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
67
67
|
# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
|
68
|
-
|
68
|
+
Layout/IndentHeredoc:
|
69
69
|
Exclude:
|
70
70
|
- 'lib/lolcommits/backends/installation_git.rb'
|
71
71
|
|
data/CHANGELOG.md
CHANGED
@@ -8,6 +8,9 @@ project adheres to [Semantic Versioning][Semver].
|
|
8
8
|
* WIP - extract more plugins to gems ...
|
9
9
|
* Your contribution here!
|
10
10
|
|
11
|
+
## [0.9.5][] (21 July 2017)
|
12
|
+
* Extract Twitter Plugin / refactor Plugin::Base (@matthutchinson [#347][])
|
13
|
+
|
11
14
|
## [0.9.4][] (17 April 2017)
|
12
15
|
* Add captureready plugin hook (@matthutchinson [#342][])
|
13
16
|
* README changes (@mroth [#341][])
|
@@ -279,7 +282,8 @@ project adheres to [Semantic Versioning][Semver].
|
|
279
282
|
instead of compositing multiply image Caption objects (this seems to be more
|
280
283
|
reliable to not glitch.)
|
281
284
|
|
282
|
-
[Unreleased]: https://github.com/mroth/lolcommits/compare/v0.9.
|
285
|
+
[Unreleased]: https://github.com/mroth/lolcommits/compare/v0.9.5...HEAD
|
286
|
+
[0.9.5]: https://github.com/mroth/lolcommits/compare/v0.9.4...v0.9.5
|
283
287
|
[0.9.4]: https://github.com/mroth/lolcommits/compare/v0.9.3...v0.9.4
|
284
288
|
[0.9.3]: https://github.com/mroth/lolcommits/compare/v0.9.2...v0.9.3
|
285
289
|
[0.9.2]: https://github.com/mroth/lolcommits/compare/v0.9.1...v0.9.2
|
@@ -443,3 +447,4 @@ project adheres to [Semantic Versioning][Semver].
|
|
443
447
|
[#340]: https://github.com/mroth/lolcommits/pull/340
|
444
448
|
[#341]: https://github.com/mroth/lolcommits/pull/341
|
445
449
|
[#342]: https://github.com/mroth/lolcommits/pull/342
|
450
|
+
[#347]: https://github.com/mroth/lolcommits/pull/347
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -209,7 +209,7 @@ Installed plugins can be easily enabled, configured or disabled with the
|
|
209
209
|
lolcommits --config -p loltext
|
210
210
|
|
211
211
|
Interested in developing your own plugin? Follow [this simple
|
212
|
-
guide](https://github.com/lolcommits/lolcommits-plugin-sample) at the
|
212
|
+
guide](https://github.com/lolcommits/lolcommits-plugin-sample#developing-your-own-plugin) at the
|
213
213
|
Lolcommits Plugin Sample README.
|
214
214
|
|
215
215
|
|
data/lib/lolcommits.rb
CHANGED
@@ -30,7 +30,6 @@ require 'lolcommits/backends/mercurial_info'
|
|
30
30
|
|
31
31
|
require 'lolcommits/plugin/base'
|
32
32
|
require 'lolcommits/plugin/dot_com'
|
33
|
-
require 'lolcommits/plugin/lol_twitter'
|
34
33
|
require 'lolcommits/plugin/uploldz'
|
35
34
|
require 'lolcommits/plugin/term_output'
|
36
35
|
require 'lolcommits/plugin/lolsrv'
|
@@ -71,7 +71,7 @@ module Lolcommits
|
|
71
71
|
return if plugin_name.empty?
|
72
72
|
|
73
73
|
plugin_klass = plugin_manager.find_by_name(plugin_name)
|
74
|
-
return plugin_klass.new(
|
74
|
+
return plugin_klass.new(config: self) if plugin_klass
|
75
75
|
|
76
76
|
puts "Unable to find plugin: '#{plugin_name}'"
|
77
77
|
return if plugin_name_option.empty?
|
@@ -1,41 +1,45 @@
|
|
1
1
|
module Lolcommits
|
2
2
|
module Plugin
|
3
3
|
class Base
|
4
|
-
attr_accessor :runner, :options
|
4
|
+
attr_accessor :runner, :config, :options
|
5
5
|
|
6
|
-
def initialize(runner)
|
6
|
+
def initialize(runner: nil, config: nil)
|
7
7
|
self.runner = runner
|
8
|
+
self.config = config || runner.config
|
8
9
|
self.options = ['enabled']
|
9
10
|
end
|
10
11
|
|
11
|
-
def
|
12
|
+
def execute_pre_capture
|
12
13
|
return unless configured_and_enabled?
|
13
|
-
debug 'I am enabled, about to run
|
14
|
-
run_precapture
|
14
|
+
debug 'I am enabled, about to run pre capture'
|
15
|
+
run_precapture # TODO: remove me (legacy method)
|
16
|
+
run_pre_capture
|
15
17
|
end
|
16
18
|
|
17
|
-
def
|
19
|
+
def execute_post_capture
|
18
20
|
return unless configured_and_enabled?
|
19
|
-
debug 'I am enabled, about to run
|
20
|
-
run_postcapture
|
21
|
+
debug 'I am enabled, about to run post capture'
|
22
|
+
run_postcapture # TODO: remove me (legacy method)
|
23
|
+
run_post_capture
|
21
24
|
end
|
22
25
|
|
23
|
-
def
|
26
|
+
def execute_capture_ready
|
24
27
|
return unless configured_and_enabled?
|
25
|
-
debug 'I am enabled, about to run
|
26
|
-
run_captureready
|
28
|
+
debug 'I am enabled, about to run capture ready'
|
29
|
+
run_captureready # TODO: remove me (legacy method)
|
30
|
+
run_capture_ready
|
27
31
|
end
|
28
32
|
|
29
|
-
def
|
33
|
+
def run_pre_capture; end
|
30
34
|
|
31
|
-
def
|
35
|
+
def run_post_capture; end
|
32
36
|
|
33
|
-
def
|
37
|
+
def run_capture_ready; end
|
34
38
|
|
35
39
|
def configuration
|
36
|
-
|
37
|
-
return {} unless
|
38
|
-
|
40
|
+
saved_config = config.read_configuration
|
41
|
+
return {} unless saved_config
|
42
|
+
saved_config[self.class.name] || {}
|
39
43
|
end
|
40
44
|
|
41
45
|
# ask for plugin options
|
@@ -87,13 +91,18 @@ module Lolcommits
|
|
87
91
|
!configuration.empty?
|
88
92
|
end
|
89
93
|
|
90
|
-
# uniform puts for plugins
|
91
|
-
# dont puts if the runner wants to be silent (stealth mode)
|
94
|
+
# uniform puts and print for plugins
|
95
|
+
# dont puts or print if the runner wants to be silent (stealth mode)
|
92
96
|
def puts(*args)
|
93
97
|
return if runner && runner.capture_stealth
|
94
98
|
super(args)
|
95
99
|
end
|
96
100
|
|
101
|
+
def print(args)
|
102
|
+
return if runner && runner.capture_stealth
|
103
|
+
super(args)
|
104
|
+
end
|
105
|
+
|
97
106
|
# helper to log errors with a message via debug
|
98
107
|
def log_error(e, message)
|
99
108
|
debug message
|
@@ -118,12 +127,19 @@ module Lolcommits
|
|
118
127
|
# Three hook positions exist, your plugin code can execute in one or more
|
119
128
|
# of these.
|
120
129
|
#
|
121
|
-
# @return [Array] the position(s) (:
|
122
|
-
# :
|
130
|
+
# @return [Array] the position(s) (:pre_capture, :post_capture,
|
131
|
+
# :capture_ready)
|
123
132
|
#
|
124
133
|
def self.runner_order
|
125
134
|
[]
|
126
135
|
end
|
136
|
+
|
137
|
+
# TODO: remove these legacy methods
|
138
|
+
def run_precapture; end
|
139
|
+
|
140
|
+
def run_postcapture; end
|
141
|
+
|
142
|
+
def run_captureready; end
|
127
143
|
end
|
128
144
|
end
|
129
145
|
end
|
@@ -5,12 +5,12 @@ module Lolcommits
|
|
5
5
|
class DotCom < Base
|
6
6
|
BASE_URL = 'http://lolcommits-dot-com.herokuapp.com'.freeze
|
7
7
|
|
8
|
-
def initialize(runner)
|
8
|
+
def initialize(runner: nil, config: nil)
|
9
9
|
super
|
10
10
|
options.concat(%w(api_key api_secret repo_id))
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
13
|
+
def run_capture_ready
|
14
14
|
t = Time.now.to_i.to_s
|
15
15
|
HTTMultiParty.post(
|
16
16
|
"#{BASE_URL}/git_commits.json",
|
@@ -43,7 +43,7 @@ module Lolcommits
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def self.runner_order
|
46
|
-
:
|
46
|
+
:capture_ready
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -11,7 +11,7 @@ module Lolcommits
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.runner_order
|
14
|
-
:
|
14
|
+
:capture_ready
|
15
15
|
end
|
16
16
|
|
17
17
|
def configured?
|
@@ -45,7 +45,7 @@ module Lolcommits
|
|
45
45
|
options
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
48
|
+
def run_capture_ready
|
49
49
|
retries = RETRY_COUNT
|
50
50
|
begin
|
51
51
|
|
@@ -32,7 +32,7 @@ module Lolcommits
|
|
32
32
|
}
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
35
|
+
def run_capture_ready
|
36
36
|
http = Net::HTTP.new(api_url.host, api_url.port)
|
37
37
|
# http.set_debug_output $stderr # nice for debugging, never ever release with it
|
38
38
|
http.start do |connection|
|
@@ -74,7 +74,7 @@ module Lolcommits
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def api_url
|
77
|
-
URI(format('http
|
77
|
+
URI(format('http://%<api_team>.hipchat.com/v2/room/%<api_room>/share/file?auth_token=%<api_token>', symbolized_configuration))
|
78
78
|
end
|
79
79
|
|
80
80
|
def symbolized_configuration
|
@@ -117,7 +117,7 @@ module Lolcommits
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def self.runner_order
|
120
|
-
:
|
120
|
+
:capture_ready
|
121
121
|
end
|
122
122
|
end
|
123
123
|
end
|
@@ -3,12 +3,12 @@ require 'rest_client'
|
|
3
3
|
module Lolcommits
|
4
4
|
module Plugin
|
5
5
|
class LolProtonet < Base
|
6
|
-
def initialize(runner)
|
6
|
+
def initialize(runner: nil, config: nil)
|
7
7
|
super
|
8
8
|
options.concat(%w(api_token api_endpoint))
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
11
|
+
def run_capture_ready
|
12
12
|
debug "Posting capture to #{configuration['endpoint']}"
|
13
13
|
RestClient.post(
|
14
14
|
api_url,
|
@@ -61,7 +61,7 @@ module Lolcommits
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def self.runner_order
|
64
|
-
:
|
64
|
+
:capture_ready
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -11,7 +11,7 @@ module Lolcommits
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.runner_order
|
14
|
-
:
|
14
|
+
:capture_ready
|
15
15
|
end
|
16
16
|
|
17
17
|
def configured?
|
@@ -40,7 +40,7 @@ module Lolcommits
|
|
40
40
|
options
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
43
|
+
def run_capture_ready
|
44
44
|
retries = RETRY_COUNT
|
45
45
|
begin
|
46
46
|
|
@@ -11,7 +11,7 @@ module Lolcommits
|
|
11
11
|
TUMBLR_CONSUMER_KEY = '2FtMEDpEPkxjoUdkpHh42h9wqTu9IVS7Ra0QyNZGixdCvhllN2'.freeze
|
12
12
|
TUMBLR_CONSUMER_SECRET = 'qWuvxgFUR2YyWKtbWOkDTMAiBEbj7ZGaNLaNQPba0PI1N4JpBs'.freeze
|
13
13
|
|
14
|
-
def
|
14
|
+
def run_capture_ready
|
15
15
|
puts 'Posting to Tumblr'
|
16
16
|
r = client.photo(configuration['tumblr_name'], data: runner.main_image)
|
17
17
|
if r.key?('id')
|
@@ -111,7 +111,7 @@ module Lolcommits
|
|
111
111
|
end
|
112
112
|
|
113
113
|
def self.runner_order
|
114
|
-
:
|
114
|
+
:capture_ready
|
115
115
|
end
|
116
116
|
|
117
117
|
protected
|
@@ -15,7 +15,7 @@ module Lolcommits
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.runner_order
|
18
|
-
:
|
18
|
+
:capture_ready
|
19
19
|
end
|
20
20
|
|
21
21
|
def configured?
|
@@ -53,7 +53,7 @@ module Lolcommits
|
|
53
53
|
options
|
54
54
|
end
|
55
55
|
|
56
|
-
def
|
56
|
+
def run_capture_ready
|
57
57
|
commit_msg = runner.message
|
58
58
|
post = "#{commit_msg} #lolcommits"
|
59
59
|
puts "Yammer post: #{post}" unless runner.capture_stealth
|
@@ -5,12 +5,12 @@ require 'json'
|
|
5
5
|
module Lolcommits
|
6
6
|
module Plugin
|
7
7
|
class Lolsrv < Base
|
8
|
-
def initialize(runner)
|
8
|
+
def initialize(runner: nil, config: nil)
|
9
9
|
super
|
10
10
|
options << 'server'
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
13
|
+
def run_capture_ready
|
14
14
|
fork { sync }
|
15
15
|
end
|
16
16
|
|
@@ -51,7 +51,7 @@ module Lolcommits
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def self.runner_order
|
54
|
-
:
|
54
|
+
:capture_ready
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -3,7 +3,7 @@ require 'base64'
|
|
3
3
|
module Lolcommits
|
4
4
|
module Plugin
|
5
5
|
class TermOutput < Base
|
6
|
-
def
|
6
|
+
def run_capture_ready
|
7
7
|
if terminal_supported?
|
8
8
|
if !runner.vcs_info || runner.vcs_info.repo.empty?
|
9
9
|
debug 'repo is empty, skipping term output'
|
@@ -21,7 +21,7 @@ module Lolcommits
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.runner_order
|
24
|
-
:
|
24
|
+
:capture_ready
|
25
25
|
end
|
26
26
|
|
27
27
|
def configure_options!
|
@@ -6,7 +6,7 @@ module Lolcommits
|
|
6
6
|
class Uploldz < Base
|
7
7
|
attr_accessor :endpoint
|
8
8
|
|
9
|
-
def initialize(runner)
|
9
|
+
def initialize(runner: nil, config: nil)
|
10
10
|
super
|
11
11
|
options.concat(
|
12
12
|
%w(
|
@@ -18,7 +18,7 @@ module Lolcommits
|
|
18
18
|
)
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
21
|
+
def run_capture_ready
|
22
22
|
if !runner.vcs_info || runner.vcs_info.repo.empty?
|
23
23
|
puts 'Repo is empty, skipping upload'
|
24
24
|
else
|
@@ -58,7 +58,7 @@ module Lolcommits
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def self.runner_order
|
61
|
-
:
|
61
|
+
:capture_ready
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
@@ -19,7 +19,11 @@ module Lolcommits
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def plugins_for(position)
|
22
|
-
plugin_klasses.select
|
22
|
+
plugin_klasses.select do |p|
|
23
|
+
# TODO: remove (legacy support) position munging after 0.9.5 release
|
24
|
+
Array(p.runner_order).include?(position) ||
|
25
|
+
Array(p.runner_order).include?(position.to_s.delete('_').to_sym)
|
26
|
+
end
|
23
27
|
end
|
24
28
|
|
25
29
|
# @return [Lolcommits::Plugin] find first plugin matching name
|
data/lib/lolcommits/runner.rb
CHANGED
@@ -29,8 +29,8 @@ module Lolcommits
|
|
29
29
|
# now we're just using a simple procedural list
|
30
30
|
def run
|
31
31
|
# do plugins that need to happen before capture
|
32
|
-
plugin_manager.plugins_for(:
|
33
|
-
plugin.new(self).
|
32
|
+
plugin_manager.plugins_for(:pre_capture).each do |plugin|
|
33
|
+
plugin.new(runner: self).execute_pre_capture
|
34
34
|
end
|
35
35
|
|
36
36
|
# do main capture to snapshot_loc
|
@@ -41,14 +41,14 @@ module Lolcommits
|
|
41
41
|
## resize snapshot first
|
42
42
|
resize_snapshot!
|
43
43
|
|
44
|
-
# execute
|
45
|
-
plugin_manager.plugins_for(:
|
46
|
-
plugin.new(self).
|
44
|
+
# execute post_capture plugins, use to alter the capture
|
45
|
+
plugin_manager.plugins_for(:post_capture).each do |plugin|
|
46
|
+
plugin.new(runner: self).execute_post_capture
|
47
47
|
end
|
48
48
|
|
49
|
-
# execute
|
50
|
-
plugin_manager.plugins_for(:
|
51
|
-
plugin.new(self).
|
49
|
+
# execute capture_ready plugins, capture is ready for export/sharing
|
50
|
+
plugin_manager.plugins_for(:capture_ready).each do |plugin|
|
51
|
+
plugin.new(runner: self).execute_capture_ready
|
52
52
|
end
|
53
53
|
|
54
54
|
# clean away any tmp files
|
data/lib/lolcommits/version.rb
CHANGED
data/lolcommits.gemspec
CHANGED
@@ -18,6 +18,26 @@ Gem::Specification.new do |s|
|
|
18
18
|
developers. `git blame` has never been so much fun.
|
19
19
|
EOF
|
20
20
|
|
21
|
+
s.post_install_message = <<-EOF
|
22
|
+
-------------------------------------------------------------------------------
|
23
|
+
|
24
|
+
Lolcommits: quick message from the dev team! v0.9.5 extracts the Twitter plugin
|
25
|
+
into a gem. If you want to continue tweeting your lol's install and configure
|
26
|
+
the lolcommits-twitter gem - like this;
|
27
|
+
|
28
|
+
gem install lolcommits-twitter
|
29
|
+
lolcommits --config -p twitter
|
30
|
+
# confirm PIN, options and there's one new setting to auto-open the tweet URL
|
31
|
+
|
32
|
+
That's it! You can revoke the old Lolcommits app token from here:
|
33
|
+
|
34
|
+
https://twitter.com/settings/applications
|
35
|
+
|
36
|
+
Happy Lol'ing!
|
37
|
+
|
38
|
+
-------------------------------------------------------------------------------
|
39
|
+
EOF
|
40
|
+
|
21
41
|
s.files = `git ls-files`.split("\n")
|
22
42
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
43
|
s.executables = 'lolcommits'
|
@@ -42,7 +62,7 @@ Gem::Specification.new do |s|
|
|
42
62
|
s.add_runtime_dependency('git', '~> 1.3.0')
|
43
63
|
|
44
64
|
# built-in lolcommits plugin
|
45
|
-
s.add_runtime_dependency('lolcommits-loltext')
|
65
|
+
s.add_runtime_dependency('lolcommits-loltext') # TODO: add min 0.0.4
|
46
66
|
|
47
67
|
# plugin gems
|
48
68
|
s.add_runtime_dependency('yam', '~> 2.5.0') # yammer
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lolcommits
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.5.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Rothenberg
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-07-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aruba
|
@@ -373,7 +373,6 @@ files:
|
|
373
373
|
- lib/lolcommits/plugin/lol_protonet.rb
|
374
374
|
- lib/lolcommits/plugin/lol_slack.rb
|
375
375
|
- lib/lolcommits/plugin/lol_tumblr.rb
|
376
|
-
- lib/lolcommits/plugin/lol_twitter.rb
|
377
376
|
- lib/lolcommits/plugin/lol_yammer.rb
|
378
377
|
- lib/lolcommits/plugin/lolsrv.rb
|
379
378
|
- lib/lolcommits/plugin/term_output.rb
|
@@ -387,7 +386,6 @@ files:
|
|
387
386
|
- lolcommits.gemspec
|
388
387
|
- test/images/test_image.jpg
|
389
388
|
- test/lolcommits_test.rb
|
390
|
-
- test/plugins_test.rb
|
391
389
|
- vendor/ext/CommandCam/COPYING
|
392
390
|
- vendor/ext/CommandCam/CommandCam.exe
|
393
391
|
- vendor/ext/CommandCam/LICENSE
|
@@ -398,7 +396,24 @@ homepage: http://mroth.github.com/lolcommits/
|
|
398
396
|
licenses:
|
399
397
|
- LGPL-3
|
400
398
|
metadata: {}
|
401
|
-
post_install_message:
|
399
|
+
post_install_message: |2
|
400
|
+
-------------------------------------------------------------------------------
|
401
|
+
|
402
|
+
Lolcommits: quick message from the dev team! v0.9.5 extracts the Twitter plugin
|
403
|
+
into a gem. If you want to continue tweeting your lol's install and configure
|
404
|
+
the lolcommits-twitter gem - like this;
|
405
|
+
|
406
|
+
gem install lolcommits-twitter
|
407
|
+
lolcommits --config -p twitter
|
408
|
+
# confirm PIN, options and there's one new setting to auto-open the tweet URL
|
409
|
+
|
410
|
+
That's it! You can revoke the old Lolcommits app token from here:
|
411
|
+
|
412
|
+
https://twitter.com/settings/applications
|
413
|
+
|
414
|
+
Happy Lol'ing!
|
415
|
+
|
416
|
+
-------------------------------------------------------------------------------
|
402
417
|
rdoc_options: []
|
403
418
|
require_paths:
|
404
419
|
- lib
|
@@ -409,9 +424,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
409
424
|
version: '2.0'
|
410
425
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
411
426
|
requirements:
|
412
|
-
- - "
|
427
|
+
- - ">"
|
413
428
|
- !ruby/object:Gem::Version
|
414
|
-
version:
|
429
|
+
version: 1.3.1
|
415
430
|
requirements:
|
416
431
|
- imagemagick
|
417
432
|
- a webcam
|
@@ -1,176 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
require 'oauth'
|
3
|
-
require 'simple_oauth'
|
4
|
-
require 'rest_client'
|
5
|
-
require 'addressable/uri'
|
6
|
-
|
7
|
-
module Lolcommits
|
8
|
-
module Plugin
|
9
|
-
class LolTwitter < Base
|
10
|
-
TWITTER_API_ENDPOINT = 'https://api.twitter.com'.freeze
|
11
|
-
TWITTER_CONSUMER_KEY = 'qc096dJJCxIiqDNUqEsqQ'.freeze
|
12
|
-
TWITTER_CONSUMER_SECRET = 'rvjNdtwSr1H0TvBvjpk6c4bvrNydHmmbvv7gXZQI'.freeze
|
13
|
-
TWITTER_RESERVED_MEDIA_CHARS = 24
|
14
|
-
TWITTER_RETRIES = 2
|
15
|
-
TWITTER_PIN_REGEX = /^\d{4,}$/ # 4 or more digits
|
16
|
-
DEFAULT_SUFFIX = '#lolcommits'.freeze
|
17
|
-
|
18
|
-
def run_captureready
|
19
|
-
tweet = build_tweet(runner.message)
|
20
|
-
|
21
|
-
attempts = 0
|
22
|
-
begin
|
23
|
-
attempts += 1
|
24
|
-
puts "Tweeting: #{tweet}"
|
25
|
-
debug "--> Tweeting! (attempt: #{attempts}, tweet length: #{tweet.length} chars)"
|
26
|
-
post_tweet(tweet, File.open(runner.main_image, 'r'))
|
27
|
-
rescue StandardError => e
|
28
|
-
debug "Tweet FAILED! #{e.class} - #{e.message}"
|
29
|
-
retry if attempts < TWITTER_RETRIES
|
30
|
-
puts "ERROR: Tweet FAILED! (after #{attempts} attempts) - #{e.message}"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def post_url
|
35
|
-
# TODO: this endpoint is deprecated, use the new approach instead
|
36
|
-
# https://dev.twitter.com/rest/reference/post/statuses/update_with_mediath_media
|
37
|
-
@post_url ||= TWITTER_API_ENDPOINT + '/1.1/statuses/update_with_media.json'
|
38
|
-
end
|
39
|
-
|
40
|
-
def post_tweet(status, media)
|
41
|
-
RestClient.post(
|
42
|
-
post_url,
|
43
|
-
{
|
44
|
-
'media[]' => media,
|
45
|
-
'status' => status
|
46
|
-
}, Authorization: oauth_header
|
47
|
-
)
|
48
|
-
end
|
49
|
-
|
50
|
-
def build_tweet(commit_message)
|
51
|
-
prefix = config_with_default('prefix', '')
|
52
|
-
suffix = " #{config_with_default('suffix', DEFAULT_SUFFIX)}"
|
53
|
-
prefix = "#{prefix} " unless prefix.empty?
|
54
|
-
|
55
|
-
available_commit_msg_size = max_tweet_size - (prefix.length + suffix.length)
|
56
|
-
if commit_message.length > available_commit_msg_size
|
57
|
-
commit_message = "#{commit_message[0..(available_commit_msg_size - 3)]}..."
|
58
|
-
end
|
59
|
-
|
60
|
-
"#{prefix}#{commit_message}#{suffix}"
|
61
|
-
end
|
62
|
-
|
63
|
-
def configure_options!
|
64
|
-
options = super
|
65
|
-
# ask user to configure tokens if enabling
|
66
|
-
if options['enabled']
|
67
|
-
auth_config = configure_auth!
|
68
|
-
return unless auth_config
|
69
|
-
options = options.merge(auth_config).merge(configure_prefix_suffix)
|
70
|
-
end
|
71
|
-
options
|
72
|
-
end
|
73
|
-
|
74
|
-
def configure_auth!
|
75
|
-
puts '---------------------------'
|
76
|
-
puts 'Need to grab twitter tokens'
|
77
|
-
puts '---------------------------'
|
78
|
-
|
79
|
-
request_token = oauth_consumer.get_request_token
|
80
|
-
rtoken = request_token.token
|
81
|
-
rsecret = request_token.secret
|
82
|
-
|
83
|
-
print "\n1) Please open this url in your browser to get a PIN for lolcommits:\n\n"
|
84
|
-
puts request_token.authorize_url
|
85
|
-
print "\n2) Enter PIN, then press enter: "
|
86
|
-
twitter_pin = gets.strip.downcase.to_s
|
87
|
-
|
88
|
-
unless twitter_pin =~ TWITTER_PIN_REGEX
|
89
|
-
puts "\nERROR: '#{twitter_pin}' is not a valid Twitter Auth PIN"
|
90
|
-
return
|
91
|
-
end
|
92
|
-
|
93
|
-
begin
|
94
|
-
debug "Requesting Twitter OAuth Token with PIN: #{twitter_pin}"
|
95
|
-
OAuth::RequestToken.new(oauth_consumer, rtoken, rsecret)
|
96
|
-
access_token = request_token.get_access_token(oauth_verifier: twitter_pin)
|
97
|
-
rescue OAuth::Unauthorized
|
98
|
-
puts "\nERROR: Twitter PIN Auth FAILED!"
|
99
|
-
return
|
100
|
-
end
|
101
|
-
|
102
|
-
return unless access_token.token && access_token.secret
|
103
|
-
puts ''
|
104
|
-
puts '------------------------------'
|
105
|
-
puts 'Thanks! Twitter Auth Succeeded'
|
106
|
-
puts '------------------------------'
|
107
|
-
{
|
108
|
-
'access_token' => access_token.token,
|
109
|
-
'secret' => access_token.secret
|
110
|
-
}
|
111
|
-
end
|
112
|
-
|
113
|
-
def configure_prefix_suffix
|
114
|
-
print "\n3) Prefix all tweets with something? e.g. @user (leave blank for no prefix): "
|
115
|
-
prefix = gets.strip
|
116
|
-
print "\n4) End all tweets with something? e.g. #hashtag (leave blank for default suffix #{DEFAULT_SUFFIX}): "
|
117
|
-
suffix = gets.strip
|
118
|
-
|
119
|
-
config = {}
|
120
|
-
config['prefix'] = prefix unless prefix.empty?
|
121
|
-
config['suffix'] = suffix unless suffix.empty?
|
122
|
-
config
|
123
|
-
end
|
124
|
-
|
125
|
-
def configured?
|
126
|
-
!configuration['enabled'].nil? &&
|
127
|
-
configuration['access_token'] &&
|
128
|
-
configuration['secret']
|
129
|
-
end
|
130
|
-
|
131
|
-
def oauth_header
|
132
|
-
uri = Addressable::URI.parse(post_url)
|
133
|
-
SimpleOAuth::Header.new(:post, uri, {}, oauth_credentials)
|
134
|
-
end
|
135
|
-
|
136
|
-
def oauth_credentials
|
137
|
-
{
|
138
|
-
consumer_key: TWITTER_CONSUMER_KEY,
|
139
|
-
consumer_secret: TWITTER_CONSUMER_SECRET,
|
140
|
-
token: configuration['access_token'],
|
141
|
-
token_secret: configuration['secret']
|
142
|
-
}
|
143
|
-
end
|
144
|
-
|
145
|
-
def oauth_consumer
|
146
|
-
@oauth_consumer ||= OAuth::Consumer.new(
|
147
|
-
TWITTER_CONSUMER_KEY,
|
148
|
-
TWITTER_CONSUMER_SECRET,
|
149
|
-
site: TWITTER_API_ENDPOINT,
|
150
|
-
request_endpoint: TWITTER_API_ENDPOINT,
|
151
|
-
sign_in: true
|
152
|
-
)
|
153
|
-
end
|
154
|
-
|
155
|
-
def config_with_default(key, default = nil)
|
156
|
-
if configuration[key]
|
157
|
-
configuration[key].strip.empty? ? default : configuration[key]
|
158
|
-
else
|
159
|
-
default
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
def max_tweet_size
|
164
|
-
139 - TWITTER_RESERVED_MEDIA_CHARS
|
165
|
-
end
|
166
|
-
|
167
|
-
def self.name
|
168
|
-
'twitter'
|
169
|
-
end
|
170
|
-
|
171
|
-
def self.runner_order
|
172
|
-
:captureready
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
data/test/plugins_test.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'coveralls'
|
2
|
-
Coveralls.wear!
|
3
|
-
|
4
|
-
require 'minitest/autorun'
|
5
|
-
require 'ffaker'
|
6
|
-
|
7
|
-
# Loads lolcommits directly from the lib folder so don't have to create
|
8
|
-
# a gem before testing
|
9
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
10
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
11
|
-
require 'lolcommits'
|
12
|
-
|
13
|
-
include Lolcommits
|
14
|
-
|
15
|
-
class PluginsTest < MiniTest::Test
|
16
|
-
def test_lol_twitter_build_tweet
|
17
|
-
# issue #136, https://github.com/mroth/lolcommits/issues/136
|
18
|
-
long_commit_message = FFaker::Lorem.sentence(500)
|
19
|
-
plugin = Lolcommits::Plugin::LolTwitter.new(nil)
|
20
|
-
max_tweet_size = 116
|
21
|
-
suffix = '... #lolcommits'
|
22
|
-
|
23
|
-
Lolcommits::Plugin::LolTwitter.send(:define_method, :max_tweet_size, proc { max_tweet_size })
|
24
|
-
Lolcommits::Plugin::LolTwitter.send(:define_method, :configuration, proc { {} })
|
25
|
-
assert_equal "#{long_commit_message[0..(max_tweet_size - suffix.length)]}#{suffix}", plugin.build_tweet(long_commit_message)
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_lol_twitter_prefix_suffix
|
29
|
-
plugin = Lolcommits::Plugin::LolTwitter.new(nil)
|
30
|
-
Lolcommits::Plugin::LolTwitter.send(:define_method, :max_tweet_size, proc { 116 })
|
31
|
-
assert_match 'commit msg #lolcommits', plugin.build_tweet('commit msg')
|
32
|
-
|
33
|
-
plugin_config = {
|
34
|
-
'prefix' => '@prefixing!',
|
35
|
-
'suffix' => '#suffixing!'
|
36
|
-
}
|
37
|
-
Lolcommits::Plugin::LolTwitter.send(:define_method, :configuration, proc { plugin_config })
|
38
|
-
assert_equal '@prefixing! commit msg #suffixing!', plugin.build_tweet('commit msg')
|
39
|
-
end
|
40
|
-
end
|