lolcommits 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MGUzMzkwYmFhNGQyYjE3ZDY3ZjhjZDlhOGZhZTIzMzYzMGMyYzAxYw==
4
+ OTgyMzJkN2VlNzkyODQ1NDdkMWQwM2U3ZjY3NTdmZGNhNDQxNDY1OQ==
5
5
  data.tar.gz: !binary |-
6
- NzE4NTQ1Y2E3ZDM4NTQzYzIyMjYzNzI0NGViMjQ2ZDU0ZDEwZjcxNg==
6
+ ZmM0OTJjZmY5MDY2OGNjNzYxNDZjYTM0NzFlZmY4NjkwN2Y4ZGI3MA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- N2NlZTFiMGJmOGU0NTk3ZTdiMDVlNTI1ZTY4ZWFlNGJjZDIwYzI3MTk4NDVl
10
- Y2UxZWM2N2Y0MjE1OGE4YWZmMWMxMjYxNzIxMzVkZTJkNzQ1ZDVmZWExNDM3
11
- M2JjZmFjODUyMjU4Y2I5NWM1N2NmNTIzMWIxNWI0ZDJlNGFmNzA=
9
+ YTVhNDFhYTE5NzZlMTM1ZGNmNmM2YzI1NTY0Nzk5NWI1ZjU1NGE3MTRjZmVm
10
+ NTdhMmQyYzI2NTQ0NzIwMGU4ODc3YjMxOGQ4MTA0MTYzYzZmOThmMTljMDcx
11
+ OTE2ZThlZWQ3ZjExMmVlNmIzNWE1OWQ5MjNiZTdhNjIyZTY3ZDU=
12
12
  data.tar.gz: !binary |-
13
- N2RjMjRhYWQwOWVjZThhNzg5OTMwNmJiNDY0Njk2ZWM0M2M2Y2YyMDQ3MDcz
14
- MjU4MzU1OTJlNzEyYjg4ZTdiNmI4NGI1ZGYyYTA5NjRiMzE0OGNmOGY3MmE3
15
- ZjMwYmMxMGYxMjgyMjBjMmUzZjViMmMzNmYyYjZmYjNlY2Y2ODc=
13
+ MjVhZDM2ZGU3OGE3MzdkNzE0NmMyNzJmZWVkYTRhMjNjNGYyM2JiNDQ3YjUy
14
+ NzljMmQ0NDE3MGI2ZmVmMDdkZDE4MWViZTljODczZTU3YjlhMGQ2ODNiNjU3
15
+ YzFkNGQxMzJhMzRhMTBhYjMyMDE4NjM3ZTE0ZjVhYmNiMGU5Mjc=
@@ -1,5 +1,10 @@
1
+ AllCops:
2
+ Excludes:
3
+ - vendor/bundle/**
4
+
1
5
  inherit_from: rubocop-todo.yml
2
6
 
3
7
  # Enforce Ruby 1.8.7 compatible syntax
4
8
  HashSyntax:
5
9
  EnforcedStyle: hash_rockets
10
+
data/CHANGELOG CHANGED
@@ -1,6 +1,13 @@
1
1
  0.x.x (in development)
2
2
  * TODO: figure out problems with GUI clients
3
3
 
4
+ 0.5.4 (13 April 2014)
5
+ * Excluded vendor/bundle from rubocop cops (@matthutchinson)
6
+ * Peg fivemat gem to ~> 1.2.1 (@mroth)
7
+ * Fix lolsrv log file issue (@matthutchinson #202)
8
+ * Yammer Plugin added (@mrclmvn #160)
9
+ * Refactor on capture options (@mroth)
10
+
4
11
  0.5.3 (30 March 2014)
5
12
  * Fixed permissions on CommandCam (755) for cygwin (@matthutchinson)
6
13
  * Added `--devices` option, mac only for now (@matthutchinson #183, #174)
@@ -96,31 +96,32 @@ def do_capture
96
96
  capture_device = Choice.choices[:device] || ENV['LOLCOMMITS_DEVICE'] || nil
97
97
  capture_font = Choice.choices[:font] || ENV['LOLCOMMITS_FONT'] || nil
98
98
 
99
+ capture_options = {
100
+ :capture_delay => capture_delay,
101
+ :capture_stealth => capture_stealth,
102
+ :capture_device => capture_device,
103
+ :font => capture_font,
104
+ :capture_animate => capture_animate,
105
+ :config => configuration
106
+ }
107
+
99
108
  fork_me? do
100
109
  if Choice.choices[:test]
101
110
  info '*** Capturing in test mode.'
102
- runner = Lolcommits::Runner.new(
103
- :capture_delay => capture_delay,
104
- :capture_stealth => capture_stealth,
105
- :capture_device => capture_device,
106
- :capture_animate => capture_animate,
107
- :message => Choice.choices[:msg],
108
- :sha => Choice.choices[:sha],
109
- :config => configuration,
110
- :font => capture_font
111
- )
111
+
112
+ # get optional fake commit msg and sha from command line
113
+ override_text = {
114
+ :message => Choice.choices[:msg],
115
+ :sha => Choice.choices[:sha]
116
+ }
117
+
118
+ runner = Lolcommits::Runner.new(capture_options.merge override_text)
112
119
  runner.run
113
120
 
121
+ # automatically open so the user can see the test image results immediately
114
122
  Launchy.open(runner.main_image)
115
123
  else
116
- runner = Lolcommits::Runner.new(
117
- :capture_delay => capture_delay,
118
- :capture_stealth => capture_stealth,
119
- :capture_device => capture_device,
120
- :capture_animate => capture_animate,
121
- :config => configuration,
122
- :font => capture_font
123
- )
124
+ runner = Lolcommits::Runner.new(capture_options)
124
125
  runner.run
125
126
  end
126
127
  end
@@ -30,6 +30,7 @@ require 'lolcommits/plugins/tranzlate'
30
30
  require 'lolcommits/plugins/lol_twitter'
31
31
  require 'lolcommits/plugins/uploldz'
32
32
  require 'lolcommits/plugins/lolsrv'
33
+ require 'lolcommits/plugins/lol_yammer'
33
34
 
34
35
  # require runner after all the plugins have been required
35
36
  require 'lolcommits/runner'
@@ -0,0 +1,85 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'yammer'
3
+ require 'rest_client'
4
+
5
+ # https://developer.yammer.com/oauth2-quickstart/
6
+ YAMMER_CLIENT_ID = 'bgORyeKtnjZJSMwp8oln9g'
7
+ YAMMER_CLIENT_SECRET = 'oer2WdGzh74a5QBbW3INUxblHK3yg9KvCZmiBa2r0'
8
+ YAMMER_ACCESS_TOKEN_URL = 'https://www.yammer.com/oauth2/access_token.json'
9
+ YAMMER_RETRY_COUNT = 2
10
+
11
+ module Lolcommits
12
+ class LolYammer < Plugin
13
+ def self.name
14
+ 'yammer'
15
+ end
16
+
17
+ def configured?
18
+ !configuration['access_token'].nil?
19
+ end
20
+
21
+ def configure_access_token
22
+ print "Open the URL below and copy the `code` param from query after redirected, enter it as `access_token`:\n"
23
+ print "https://www.yammer.com/dialog/oauth?client_id=#{YAMMER_CLIENT_ID}&response_type=code\n"
24
+ print 'Enter code param from the redirected URL, then press enter: '
25
+ code = STDIN.gets.to_s.strip
26
+
27
+ url = "#{YAMMER_ACCESS_TOKEN_URL}"
28
+ debug "access_token url: #{url}"
29
+ params = {
30
+ 'client_id' => YAMMER_CLIENT_ID,
31
+ 'client_secret' => YAMMER_CLIENT_SECRET,
32
+ 'code' => code
33
+ }
34
+ debug "params : #{params.inspect}"
35
+ result = JSON.parse(RestClient.post(url, params))
36
+ debug "response : #{result.inspect}"
37
+ # no need for 'return', last line is always the return value
38
+ { 'access_token' => result['access_token']['token'] }
39
+ end
40
+
41
+ def configure_options!
42
+ options = super
43
+ if options['enabled'] == true
44
+ auth_config = configure_access_token
45
+ if auth_config
46
+ options.merge!(auth_config)
47
+ else
48
+ return
49
+ end
50
+ end
51
+ options
52
+ end
53
+
54
+ def run
55
+ return unless valid_configuration?
56
+
57
+ commit_msg = self.runner.message
58
+ post = "#{commit_msg} #lolcommits"
59
+ puts "Yammer post: #{post}" unless self.runner.capture_stealth
60
+
61
+ Yammer.configure do |c|
62
+ c.client_id = YAMMER_CLIENT_ID
63
+ c.client_secret = YAMMER_CLIENT_SECRET
64
+ end
65
+
66
+ client = Yammer::Client.new(:access_token => configuration['access_token'])
67
+
68
+ retries = YAMMER_RETRY_COUNT
69
+ begin
70
+ lolimage = File.new(self.runner.main_image)
71
+ response = client.create_message(post, :attachment1 => lolimage)
72
+ debug response.body.inspect
73
+ if response
74
+ puts "\t--> Status posted!" unless self.runner.capture_stealth
75
+ end
76
+ rescue => e
77
+ retries -= 1
78
+ retry if retries > 0
79
+ puts "Status not posted - #{e.message}"
80
+ puts 'Try running config again:'
81
+ puts "\tlolcommits --config --plugin yammer"
82
+ end
83
+ end
84
+ end
85
+ end
@@ -2,16 +2,12 @@
2
2
  require 'rest_client'
3
3
  require 'pp'
4
4
  require 'json'
5
- require 'logger'
6
5
 
7
6
  module Lolcommits
8
7
  class Lolsrv < Plugin
9
8
  def initialize(runner)
10
9
  super
11
10
  self.options << 'server'
12
- if self.runner
13
- @logger = Logger.new(File.new(self.runner.config.loldir + '/lolsrv.log', 'a+'))
14
- end
15
11
  end
16
12
 
17
13
  def run
@@ -63,8 +59,7 @@ module Lolcommits
63
59
 
64
60
  def log_error(e, message)
65
61
  debug message
66
- @logger.info message
67
- @logger.info e.backtrace
62
+ debug e.backtrace
68
63
  end
69
64
 
70
65
  def self.name
@@ -18,6 +18,7 @@ module Lolcommits
18
18
  set_callback :run, :after, :execute_lolcommits_lolsrv
19
19
  set_callback :run, :after, :execute_lolcommits_lol_twitter
20
20
  set_callback :run, :after, :execute_lolcommits_dot_com
21
+ set_callback :run, :after, :execute_lolcommits_lol_yammer
21
22
  set_callback :run, :after, :execute_lolcommits_loltext
22
23
  # Executed First
23
24
 
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Lolcommits
3
- VERSION = '0.5.3'
3
+ VERSION = '0.5.4'
4
4
  end
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
31
31
  s.add_development_dependency('rdoc')
32
32
  s.add_development_dependency('aruba', '~> 0.5.1')
33
33
  s.add_development_dependency('rake', '~> 10.0.2')
34
- s.add_development_dependency('fivemat')
34
+ s.add_development_dependency('fivemat', '~> 1.2.1')
35
35
  s.add_development_dependency('faker')
36
36
  s.add_development_dependency('travis')
37
37
  s.add_development_dependency('coveralls')
@@ -42,6 +42,7 @@ Gem::Specification.new do |s|
42
42
 
43
43
  # plugin dependencies
44
44
  s.add_runtime_dependency('twitter', '~> 4.8.1') #twitter
45
+ s.add_runtime_dependency('yam', '~> 2.0.1') #yammer
45
46
  s.add_runtime_dependency('oauth') #twitter
46
47
  s.add_runtime_dependency('rest-client') #uploldz
47
48
  s.add_runtime_dependency('httmultiparty') #dot_com
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lolcommits
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Rothenberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-30 00:00:00.000000000 Z
11
+ date: 2014-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_magick
@@ -154,16 +154,16 @@ dependencies:
154
154
  name: fivemat
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ! '>='
157
+ - - ~>
158
158
  - !ruby/object:Gem::Version
159
- version: '0'
159
+ version: 1.2.1
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ! '>='
164
+ - - ~>
165
165
  - !ruby/object:Gem::Version
166
- version: '0'
166
+ version: 1.2.1
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: faker
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -248,6 +248,20 @@ dependencies:
248
248
  - - ~>
249
249
  - !ruby/object:Gem::Version
250
250
  version: 4.8.1
251
+ - !ruby/object:Gem::Dependency
252
+ name: yam
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - ~>
256
+ - !ruby/object:Gem::Version
257
+ version: 2.0.1
258
+ type: :runtime
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - ~>
263
+ - !ruby/object:Gem::Version
264
+ version: 2.0.1
251
265
  - !ruby/object:Gem::Dependency
252
266
  name: oauth
253
267
  requirement: !ruby/object:Gem::Requirement
@@ -377,6 +391,7 @@ files:
377
391
  - lib/lolcommits/plugin.rb
378
392
  - lib/lolcommits/plugins/dot_com.rb
379
393
  - lib/lolcommits/plugins/lol_twitter.rb
394
+ - lib/lolcommits/plugins/lol_yammer.rb
380
395
  - lib/lolcommits/plugins/lolsrv.rb
381
396
  - lib/lolcommits/plugins/loltext.rb
382
397
  - lib/lolcommits/plugins/tranzlate.rb