lolcommits 0.5.6 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/.rubocop.yml +3 -4
- data/.rubocop_todo.yml +202 -0
- data/.travis.yml +2 -7
- data/CHANGELOG +9 -3
- data/Rakefile +4 -4
- data/bin/lolcommits +11 -1
- data/features/support/env.rb +1 -1
- data/lib/lolcommits/git_info.rb +25 -11
- data/lib/lolcommits/plugins/lol_twitter.rb +61 -25
- data/lib/lolcommits/plugins/lolsrv.rb +4 -4
- data/lib/lolcommits/plugins/uploldz.rb +9 -6
- data/lib/lolcommits/runner.rb +8 -11
- data/lib/lolcommits/version.rb +1 -1
- data/lolcommits.gemspec +31 -29
- data/test/test_lolcommits.rb +18 -14
- metadata +105 -105
- data/rubocop-todo.yml +0 -249
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWE3MGEwZGZkZDk1ZGVhMzgyOGUzODdhMjY4OGQ5OWNjYjc4YWYwZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODczNTk4MGFlODMwODg5OTdjMGJkNWJhOTk1N2QwMzMyZjkwZWE1Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjJhYTc0YTVmY2E2ZGU4MmU3ODBkYjQyYTUyYjg2ODM1NjY5YTdiY2E0Mzli
|
10
|
+
NjRhOTVlODNhMDdjNzI2NjM1MjcxN2VjN2EzYzJjNmYxMTQ4ZTU1NWQyNTk5
|
11
|
+
ZDljZTc1MTQ0ODY4NzhmMjQyYjYxNTVmYTVhY2M0OTA2OGM0MDU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OGY4Zjg5OGU3Mzc1MGZlODg1YzQzODE0NTQ3Y2FhMGQ1ODU1YTQwODhhY2Nk
|
14
|
+
ODVmOWM3ZGM5MDYyNTM2YTkzMDA5ZDhlYTE3YzQ1Y2IzNmMwM2ZjYTliNmJl
|
15
|
+
NTkwZmFlYTI5ZjNlODUyM2FkODc0ZTVhNzUxMjk4YTBkN2YyMjE=
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
+
# on 2014-12-09 17:12:22 +0000 using RuboCop version 0.27.1.
|
3
|
+
# The point is for the user to remove these configuration records
|
4
|
+
# one by one as the offenses are removed from the code base.
|
5
|
+
# Note that changes in the inspected code, or installation of new
|
6
|
+
# versions of RuboCop, may require this file to be generated again.
|
7
|
+
|
8
|
+
# Offense count: 22
|
9
|
+
Lint/AmbiguousRegexpLiteral:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
# Offense count: 8
|
13
|
+
# Cop supports --auto-correct.
|
14
|
+
Lint/DeprecatedClassMethods:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
# Offense count: 2
|
18
|
+
# Cop supports --auto-correct.
|
19
|
+
Lint/StringConversionInInterpolation:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
# Offense count: 1
|
23
|
+
# Cop supports --auto-correct.
|
24
|
+
Lint/UnusedMethodArgument:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
# Offense count: 1
|
28
|
+
Lint/UselessAccessModifier:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
# Offense count: 2
|
32
|
+
Lint/UselessAssignment:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
# Offense count: 23
|
36
|
+
Metrics/AbcSize:
|
37
|
+
Max: 59
|
38
|
+
|
39
|
+
# Offense count: 2
|
40
|
+
# Configuration parameters: CountComments.
|
41
|
+
Metrics/ClassLength:
|
42
|
+
Max: 184
|
43
|
+
|
44
|
+
# Offense count: 6
|
45
|
+
Metrics/CyclomaticComplexity:
|
46
|
+
Max: 10
|
47
|
+
|
48
|
+
# Offense count: 101
|
49
|
+
# Configuration parameters: AllowURI, URISchemes.
|
50
|
+
Metrics/LineLength:
|
51
|
+
Max: 157
|
52
|
+
|
53
|
+
# Offense count: 26
|
54
|
+
# Configuration parameters: CountComments.
|
55
|
+
Metrics/MethodLength:
|
56
|
+
Max: 32
|
57
|
+
|
58
|
+
# Offense count: 5
|
59
|
+
Metrics/PerceivedComplexity:
|
60
|
+
Max: 11
|
61
|
+
|
62
|
+
# Offense count: 3
|
63
|
+
# Cop supports --auto-correct.
|
64
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
65
|
+
Style/BarePercentLiterals:
|
66
|
+
Enabled: false
|
67
|
+
|
68
|
+
# Offense count: 1
|
69
|
+
Style/CaseEquality:
|
70
|
+
Enabled: false
|
71
|
+
|
72
|
+
# Offense count: 1
|
73
|
+
# Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep.
|
74
|
+
Style/CaseIndentation:
|
75
|
+
Enabled: false
|
76
|
+
|
77
|
+
# Offense count: 25
|
78
|
+
Style/Documentation:
|
79
|
+
Enabled: false
|
80
|
+
|
81
|
+
# Offense count: 1
|
82
|
+
Style/DoubleNegation:
|
83
|
+
Enabled: false
|
84
|
+
|
85
|
+
# Offense count: 1
|
86
|
+
# Cop supports --auto-correct.
|
87
|
+
Style/EmptyLines:
|
88
|
+
Enabled: false
|
89
|
+
|
90
|
+
# Offense count: 1
|
91
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
92
|
+
Style/FormatString:
|
93
|
+
Enabled: false
|
94
|
+
|
95
|
+
# Offense count: 4
|
96
|
+
# Configuration parameters: AllowedVariables.
|
97
|
+
Style/GlobalVars:
|
98
|
+
Enabled: false
|
99
|
+
|
100
|
+
# Offense count: 10
|
101
|
+
# Configuration parameters: MinBodyLength.
|
102
|
+
Style/GuardClause:
|
103
|
+
Enabled: false
|
104
|
+
|
105
|
+
# Offense count: 12
|
106
|
+
# Configuration parameters: MaxLineLength.
|
107
|
+
Style/IfUnlessModifier:
|
108
|
+
Enabled: false
|
109
|
+
|
110
|
+
# Offense count: 1
|
111
|
+
# Cop supports --auto-correct.
|
112
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
113
|
+
Style/IndentHash:
|
114
|
+
Enabled: true
|
115
|
+
|
116
|
+
# Offense count: 13
|
117
|
+
# Cop supports --auto-correct.
|
118
|
+
Style/LeadingCommentSpace:
|
119
|
+
Enabled: false
|
120
|
+
|
121
|
+
# Offense count: 7
|
122
|
+
# Cop supports --auto-correct.
|
123
|
+
Style/NegatedIf:
|
124
|
+
Enabled: false
|
125
|
+
|
126
|
+
# Offense count: 7
|
127
|
+
# Cop supports --auto-correct.
|
128
|
+
Style/Not:
|
129
|
+
Enabled: false
|
130
|
+
|
131
|
+
# Offense count: 1
|
132
|
+
Style/OneLineConditional:
|
133
|
+
Enabled: false
|
134
|
+
|
135
|
+
# Offense count: 79
|
136
|
+
# Cop supports --auto-correct.
|
137
|
+
# Configuration parameters: PreferredDelimiters.
|
138
|
+
Style/PercentLiteralDelimiters:
|
139
|
+
Enabled: false
|
140
|
+
|
141
|
+
# Offense count: 3
|
142
|
+
# Cop supports --auto-correct.
|
143
|
+
Style/Proc:
|
144
|
+
Enabled: false
|
145
|
+
|
146
|
+
# Offense count: 1
|
147
|
+
# Cop supports --auto-correct.
|
148
|
+
Style/RedundantBegin:
|
149
|
+
Enabled: false
|
150
|
+
|
151
|
+
# Offense count: 76
|
152
|
+
# Cop supports --auto-correct.
|
153
|
+
Style/RedundantSelf:
|
154
|
+
Enabled: false
|
155
|
+
|
156
|
+
# Offense count: 1
|
157
|
+
Style/RegexpLiteral:
|
158
|
+
MaxSlashes: 2
|
159
|
+
|
160
|
+
# Offense count: 1
|
161
|
+
# Cop supports --auto-correct.
|
162
|
+
Style/SingleSpaceBeforeFirstArg:
|
163
|
+
Enabled: false
|
164
|
+
|
165
|
+
# Offense count: 2
|
166
|
+
# Cop supports --auto-correct.
|
167
|
+
Style/SpaceAfterComma:
|
168
|
+
Enabled: false
|
169
|
+
|
170
|
+
# Offense count: 1
|
171
|
+
# Cop supports --auto-correct.
|
172
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
173
|
+
Style/SpaceBeforeBlockBraces:
|
174
|
+
Enabled: false
|
175
|
+
|
176
|
+
# Offense count: 5
|
177
|
+
# Cop supports --auto-correct.
|
178
|
+
Style/SpaceInsideParens:
|
179
|
+
Enabled: false
|
180
|
+
|
181
|
+
# Offense count: 1
|
182
|
+
# Cop supports --auto-correct.
|
183
|
+
Style/SpecialGlobalVars:
|
184
|
+
Enabled: false
|
185
|
+
|
186
|
+
# Offense count: 15
|
187
|
+
# Cop supports --auto-correct.
|
188
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
189
|
+
Style/StringLiterals:
|
190
|
+
Enabled: false
|
191
|
+
|
192
|
+
# Offense count: 1
|
193
|
+
# Cop supports --auto-correct.
|
194
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
195
|
+
Style/StringLiteralsInInterpolation:
|
196
|
+
Enabled: false
|
197
|
+
|
198
|
+
# Offense count: 4
|
199
|
+
# Cop supports --auto-correct.
|
200
|
+
# Configuration parameters: WordRegex.
|
201
|
+
Style/WordArray:
|
202
|
+
MinSize: 3
|
data/.travis.yml
CHANGED
@@ -4,18 +4,13 @@ rvm:
|
|
4
4
|
- 1.9.2
|
5
5
|
- 1.9.3
|
6
6
|
- 2.0.0
|
7
|
-
- 2.1.
|
8
|
-
- 2.
|
7
|
+
- 2.1.5
|
8
|
+
- 2.2.0
|
9
9
|
- ruby-head
|
10
10
|
|
11
11
|
before_install:
|
12
|
-
# use earlier version of Rubygems to avoid fatal bundler error on 1.8.7
|
13
|
-
- gem update --system 2.1.11
|
14
|
-
- gem --version
|
15
12
|
- sudo apt-get update -qq
|
16
13
|
- sudo apt-get install -qq -y mplayer ffmpeg
|
17
|
-
# imagemagick is installed by default on normal travis image now
|
18
|
-
# - sudo apt-get install -qq -y imagemagick libmagickwand-dev
|
19
14
|
|
20
15
|
matrix:
|
21
16
|
allow_failures:
|
data/CHANGELOG
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
-
0.
|
2
|
-
*
|
3
|
-
|
1
|
+
0.6.0 (WIP)
|
2
|
+
* extract plugins to seperate gems ...
|
3
|
+
|
4
|
+
0.5.7 (28 December 2014)
|
5
|
+
* Uploldz plugin sends more post params (@clops #224 @matthutchinson #241)
|
6
|
+
* More configurable twitter plugin (@woodrowbarlow #207 @matthutchinson)
|
7
|
+
* Upgrade all gems that can be, 4 held back (#244 @matthutchinson)
|
8
|
+
* Ruby 2.2.0 compatible (#244 @matthutchinson)
|
9
|
+
* Glob /dev/video* for default video device (linux only) (#246 @Ferada)
|
4
10
|
|
5
11
|
0.5.6 (24 November 2014)
|
6
12
|
* Updates and clean ups on the gemspec (@mroth #228)
|
data/Rakefile
CHANGED
@@ -48,12 +48,12 @@ Rake::RDocTask.new do |rd|
|
|
48
48
|
end
|
49
49
|
|
50
50
|
# only run rubocop on platforms where it is supported, sigh
|
51
|
-
if RUBY_VERSION >= '1.9.
|
51
|
+
if RUBY_VERSION >= '1.9.3'
|
52
52
|
require 'rubocop/rake_task'
|
53
|
-
|
54
|
-
task :default => [:rubocop
|
53
|
+
RuboCop::RakeTask.new
|
54
|
+
task :default => [:rubocop, :test, :features]
|
55
55
|
else
|
56
|
-
task :default => [:test
|
56
|
+
task :default => [:test, :features]
|
57
57
|
end
|
58
58
|
|
59
59
|
|
data/bin/lolcommits
CHANGED
@@ -87,13 +87,23 @@ def capture_animate
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
+
def default_device
|
91
|
+
result = Choice.choices[:device] || ENV['LOLCOMMITS_DEVICE']
|
92
|
+
|
93
|
+
if Configuration.platform_linux?
|
94
|
+
result ||= Dir.glob('/dev/video*').first
|
95
|
+
end
|
96
|
+
|
97
|
+
result
|
98
|
+
end
|
99
|
+
|
90
100
|
#
|
91
101
|
# IF --CAPTURE, DO CAPTURE
|
92
102
|
#
|
93
103
|
def do_capture
|
94
104
|
capture_delay = Choice.choices[:delay] || ENV['LOLCOMMITS_DELAY'] || 0
|
95
105
|
capture_stealth = Choice.choices[:stealth] || ENV['LOLCOMMITS_STEALTH'] || nil
|
96
|
-
capture_device =
|
106
|
+
capture_device = default_device
|
97
107
|
capture_font = Choice.choices[:font] || ENV['LOLCOMMITS_FONT'] || nil
|
98
108
|
|
99
109
|
capture_options = {
|
data/features/support/env.rb
CHANGED
@@ -4,7 +4,7 @@ require 'methadone/cucumber'
|
|
4
4
|
require 'open3'
|
5
5
|
require 'test/unit/assertions'
|
6
6
|
include Test::Unit::Assertions
|
7
|
-
require '
|
7
|
+
require 'ffaker'
|
8
8
|
require 'lolcommits/configuration'
|
9
9
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'path_helpers')
|
10
10
|
include Lolcommits
|
data/lib/lolcommits/git_info.rb
CHANGED
@@ -2,11 +2,10 @@
|
|
2
2
|
module Lolcommits
|
3
3
|
class GitInfo
|
4
4
|
include Methadone::CLILogging
|
5
|
-
attr_accessor :sha, :message, :repo_internal_path, :repo, :url
|
5
|
+
attr_accessor :sha, :message, :repo_internal_path, :repo, :url,
|
6
|
+
:author_name, :author_email
|
6
7
|
|
7
|
-
|
8
|
-
url.gsub(':', '/').gsub(/^git@/, 'https://').gsub(/\.git$/, '') + '/commit/'
|
9
|
-
end
|
8
|
+
GIT_URL_REGEX = /.*[:]([\/\w\-]*).git/
|
10
9
|
|
11
10
|
def initialize
|
12
11
|
debug 'GitInfo: attempting to read local repository'
|
@@ -18,21 +17,36 @@ module Lolcommits
|
|
18
17
|
self.message = commit.message.split("\n").first
|
19
18
|
self.sha = commit.sha[0..10]
|
20
19
|
self.repo_internal_path = g.repo.path
|
21
|
-
self.url = remote_https_url(g.remote.url) if g.remote.url
|
22
20
|
|
23
|
-
|
24
|
-
|
21
|
+
if g.remote.url
|
22
|
+
self.url = remote_https_url(g.remote.url)
|
23
|
+
match = g.remote.url.match(GIT_URL_REGEX)
|
24
|
+
end
|
25
|
+
|
25
26
|
if match
|
26
27
|
self.repo = match[1]
|
27
28
|
elsif !g.repo.path.empty?
|
28
29
|
self.repo = g.repo.path.split(File::SEPARATOR)[-2]
|
29
30
|
end
|
30
31
|
|
32
|
+
if commit.author
|
33
|
+
self.author_name = commit.author.name
|
34
|
+
self.author_email = commit.author.email
|
35
|
+
end
|
36
|
+
|
31
37
|
debug 'GitInfo: parsed the following values from commit:'
|
32
|
-
debug "GitInfo: \t#{
|
33
|
-
debug "GitInfo: \t#{
|
34
|
-
debug "GitInfo: \t#{
|
35
|
-
debug "GitInfo: \t#{
|
38
|
+
debug "GitInfo: \t#{message}"
|
39
|
+
debug "GitInfo: \t#{sha}"
|
40
|
+
debug "GitInfo: \t#{repo_internal_path}"
|
41
|
+
debug "GitInfo: \t#{repo}"
|
42
|
+
debug "GitInfo: \t#{author_name}" if author_name
|
43
|
+
debug "GitInfo: \t#{author_email}" if author_email
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def remote_https_url(url)
|
49
|
+
url.gsub(':', '/').gsub(/^git@/, 'https://').gsub(/\.git$/, '') + '/commit/'
|
36
50
|
end
|
37
51
|
end
|
38
52
|
end
|
@@ -9,26 +9,26 @@ $VERBOSE = original_verbose # activate warning messages again.
|
|
9
9
|
|
10
10
|
module Lolcommits
|
11
11
|
class LolTwitter < Plugin
|
12
|
+
TWITTER_API_ENDPOINT = 'https://api.twitter.com'
|
12
13
|
TWITTER_CONSUMER_KEY = 'qc096dJJCxIiqDNUqEsqQ'
|
13
14
|
TWITTER_CONSUMER_SECRET = 'rvjNdtwSr1H0TvBvjpk6c4bvrNydHmmbvv7gXZQI'
|
14
15
|
TWITTER_RETRIES = 2
|
15
16
|
TWITTER_PIN_REGEX = /^\d{4,}$/ # 4 or more digits
|
17
|
+
DEFAULT_SUFFIX = '#lolcommits'
|
16
18
|
|
17
19
|
def run_postcapture
|
18
20
|
return unless valid_configuration?
|
21
|
+
tweet = build_tweet(self.runner.message)
|
19
22
|
|
20
23
|
attempts = 0
|
21
|
-
|
22
24
|
begin
|
23
25
|
attempts += 1
|
24
|
-
tweet = build_tweet(self.runner.message)
|
25
26
|
puts "Tweeting: #{tweet}"
|
26
|
-
debug "--> Tweeting! (attempt: #{attempts}, tweet
|
27
|
+
debug "--> Tweeting! (attempt: #{attempts}, tweet length: #{tweet.length} chars)"
|
27
28
|
if client.update_with_media(tweet, File.open(self.runner.main_image, 'r'))
|
28
29
|
puts "\t--> Tweet Sent!"
|
29
30
|
end
|
30
|
-
rescue Twitter::Error::
|
31
|
-
Twitter::Error::BadRequest,
|
31
|
+
rescue Twitter::Error::ServerError,
|
32
32
|
Twitter::Error::ClientError => e
|
33
33
|
debug "Tweet FAILED! #{e.class} - #{e.message}"
|
34
34
|
retry if attempts < TWITTER_RETRIES
|
@@ -36,12 +36,19 @@ module Lolcommits
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
def build_tweet(commit_message
|
40
|
-
|
39
|
+
def build_tweet(commit_message)
|
40
|
+
prefix = config_with_default('prefix', '')
|
41
|
+
suffix = " #{config_with_default('suffix', DEFAULT_SUFFIX)}"
|
42
|
+
unless prefix.empty?
|
43
|
+
prefix = "#{prefix} "
|
44
|
+
end
|
45
|
+
|
46
|
+
available_commit_msg_size = max_tweet_size - (prefix.length + suffix.length)
|
41
47
|
if commit_message.length > available_commit_msg_size
|
42
48
|
commit_message = "#{commit_message[0..(available_commit_msg_size - 3)]}..."
|
43
49
|
end
|
44
|
-
|
50
|
+
|
51
|
+
"#{prefix}#{commit_message}#{suffix}"
|
45
52
|
end
|
46
53
|
|
47
54
|
def configure_options!
|
@@ -50,7 +57,7 @@ module Lolcommits
|
|
50
57
|
if options['enabled']
|
51
58
|
auth_config = configure_auth!
|
52
59
|
if auth_config
|
53
|
-
options.merge
|
60
|
+
options = options.merge(auth_config).merge(configure_prefix_suffix)
|
54
61
|
else
|
55
62
|
return # return nil if configure_auth failed
|
56
63
|
end
|
@@ -63,13 +70,7 @@ module Lolcommits
|
|
63
70
|
puts 'Need to grab twitter tokens'
|
64
71
|
puts '---------------------------'
|
65
72
|
|
66
|
-
|
67
|
-
TWITTER_CONSUMER_SECRET,
|
68
|
-
:site => 'https://api.twitter.com',
|
69
|
-
:request_endpoint => 'https://api.twitter.com',
|
70
|
-
:sign_in => true)
|
71
|
-
|
72
|
-
request_token = consumer.get_request_token
|
73
|
+
request_token = oauth_consumer.get_request_token
|
73
74
|
rtoken = request_token.token
|
74
75
|
rsecret = request_token.secret
|
75
76
|
|
@@ -85,7 +86,7 @@ module Lolcommits
|
|
85
86
|
|
86
87
|
begin
|
87
88
|
debug "Requesting Twitter OAuth Token with PIN: #{twitter_pin}"
|
88
|
-
OAuth::RequestToken.new(
|
89
|
+
OAuth::RequestToken.new(oauth_consumer, rtoken, rsecret)
|
89
90
|
access_token = request_token.get_access_token(:oauth_verifier => twitter_pin)
|
90
91
|
rescue OAuth::Unauthorized
|
91
92
|
puts "\nERROR: Twitter PIN Auth FAILED!"
|
@@ -93,12 +94,29 @@ module Lolcommits
|
|
93
94
|
end
|
94
95
|
|
95
96
|
if access_token.token && access_token.secret
|
96
|
-
|
97
|
-
|
98
|
-
|
97
|
+
puts ''
|
98
|
+
puts '------------------------------'
|
99
|
+
puts 'Thanks! Twitter Auth Succeeded'
|
100
|
+
puts '------------------------------'
|
101
|
+
{
|
102
|
+
'access_token' => access_token.token,
|
103
|
+
'secret' => access_token.secret
|
104
|
+
}
|
99
105
|
end
|
100
106
|
end
|
101
107
|
|
108
|
+
def configure_prefix_suffix
|
109
|
+
print "\n3) Prefix all tweets with something? e.g. @user (leave blank for no prefix): "
|
110
|
+
prefix = STDIN.gets.strip
|
111
|
+
print "\n4) End all tweets with something? e.g. #hashtag (leave blank for default suffix #{DEFAULT_SUFFIX}): "
|
112
|
+
suffix = STDIN.gets.strip
|
113
|
+
|
114
|
+
config = {}
|
115
|
+
config['prefix'] = prefix unless prefix.empty?
|
116
|
+
config['suffix'] = suffix unless suffix.empty?
|
117
|
+
config
|
118
|
+
end
|
119
|
+
|
102
120
|
def configured?
|
103
121
|
!configuration['enabled'].nil? &&
|
104
122
|
configuration['access_token'] &&
|
@@ -106,14 +124,32 @@ module Lolcommits
|
|
106
124
|
end
|
107
125
|
|
108
126
|
def client
|
109
|
-
@client ||= Twitter::Client.new
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
127
|
+
@client ||= Twitter::REST::Client.new do |config|
|
128
|
+
config.consumer_key = TWITTER_CONSUMER_KEY
|
129
|
+
config.consumer_secret = TWITTER_CONSUMER_SECRET
|
130
|
+
config.access_token = configuration['access_token']
|
131
|
+
config.access_token_secret = configuration['secret']
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def oauth_consumer
|
136
|
+
@oauth_consumer ||= OAuth::Consumer.new(
|
137
|
+
TWITTER_CONSUMER_KEY,
|
138
|
+
TWITTER_CONSUMER_SECRET,
|
139
|
+
:site => TWITTER_API_ENDPOINT,
|
140
|
+
:request_endpoint => TWITTER_API_ENDPOINT,
|
141
|
+
:sign_in => true
|
114
142
|
)
|
115
143
|
end
|
116
144
|
|
145
|
+
def config_with_default(key, default = nil)
|
146
|
+
if configuration[key]
|
147
|
+
configuration[key].strip.empty? ? default : configuration[key]
|
148
|
+
else
|
149
|
+
default
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
117
153
|
def max_tweet_size
|
118
154
|
139 - client.configuration.characters_reserved_per_media
|
119
155
|
end
|