lolcommits 0.6.0 → 0.6.1

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZjA1ZjZlYWRmOGZjOGM4MDcxNTQ4NGQzYWM5OGI3MTY0ODQ5ZjliYQ==
4
+ MzE2YjAyOGQ3MzBhNzVmZjI2MmFjMTc2MmY4YWYwYWQ0NDRjYzZjMA==
5
5
  data.tar.gz: !binary |-
6
- YTAwODliMjE0MjIxNTljYjI4OWU5MzllM2E0ODM0YTZiNGE4MjIyOQ==
6
+ NjMyYmUxMDI0Y2E4NzhiMDE0Yzc0YTQ5NjFmYzkxMzVkMDRiYWFlNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzJkNmZhMWVlZTQ2MmQ1NWE4NTA1NDU3MWE2YTc3NzRjMTY3MDk2MmIyOGEw
10
- NGRiNzhlZWE4ZDY3OTFjZWYwNDJlZjA2NTMxMGNkNWU3MWVjOTM5MTQ5ZGRk
11
- ZTI5MTcyYzgyNTZjNGMyMWY1YTg2MzU1MTI4ZWVkZDc1MzJjOWE=
9
+ OTI0M2VjZTkwODZmOGVkYzVmYzFiNmY5ODgzMDMyZjZkMDA3YjU2ZTgxMmQy
10
+ ODlmZGRkMjE2NWFlNWJlODZjMTJjMDQzMGViOTE3ZmU2N2IzMjUzNWYyZDM4
11
+ MDdkZTkzMDc5ZDk1YWEyNGIzOTM2ZWE5ZTZjYWU3OGRlNGQ0ZjU=
12
12
  data.tar.gz: !binary |-
13
- Y2JlNTIwZjMyNmFiODc4MDU0NjU2NThmZDQwOTg0ZmNiYzEyMDk5YWYzMGEy
14
- M2MwNmJkOGU3ZjZjN2QwOGIyMjE3YjVmNTBlZDY4MDk1Y2JkOTdiM2YxYjc3
15
- NDQwOTZlNWYwOTAzZmY4ZWU1NGI2NDQ1MGU5ODNkMjUwZjA2MmY=
13
+ YTQ1Yzk0YmZkZWIyODRmZDQxMWY2N2VlYmNhMjc5ODc5MmMxOWEwNGRkYjMz
14
+ NTlmZDNmM2M2N2Q1N2Q5NmYxZTdkMWE3MGM5ZjdjOTQ0MjNhNDJkOGYxZmYz
15
+ MGQ1YzdkZTk3MWEwM2ExNTQyZGVjODZhMzkxOWJjM2YzMGFjOGY=
@@ -6,8 +6,8 @@ rvm:
6
6
  - 1.9.2
7
7
  - 1.9.3
8
8
  - 2.0.0
9
- - 2.1.5
10
- - 2.2.2
9
+ - 2.1.7
10
+ - 2.2.3
11
11
  - ruby-head
12
12
 
13
13
  before_install:
@@ -3,6 +3,12 @@
3
3
  0.7.0 (WIP)
4
4
  * extract plugins to seperate gems ...
5
5
 
6
+ 0.6.1 (16 September 2015)
7
+ * Optional http auth header user/password in uploldz plugin (@felixroos #283)
8
+ * Slack plugin added (@yasakbulut #284)
9
+ * Updated rubies in Travis settings (@matthutchinson)
10
+ * Fixed README badge URLS (@matthutchinson)
11
+
6
12
  0.6.0 (27 July 2015)
7
13
  * Configurable text options for loltext plugin (@matthutchinson #282)
8
14
  * Working AppVeyor configuration added (@nysthee #280)
data/README.md CHANGED
@@ -6,11 +6,11 @@ archives a lolcat style image with it. Git blame has never been so much fun.
6
6
  By default, the lol images are stored by a Github style short SHA in a
7
7
  `~/.lolcommits` directory created for you.
8
8
 
9
- [![Gem Version](http://img.shields.io/gem/v/lolcommits.svg?style=flat)](https://rubygems.org/gems/lolcommits)
10
- [![Build Status](http://img.shields.io/travis/mroth/lolcommits.svg?style=flat)](https://travis-ci.org/mroth/lolcommits)
11
- [![Dependency Status](http://img.shields.io/gemnasium/mroth/lolcommits.svg?style=flat)](https://gemnasium.com/mroth/lolcommits)
12
- [![CodeClimate Status](http://img.shields.io/codeclimate/github/mroth/lolcommits.svg?style=flat)](https://codeclimate.com/github/mroth/lolcommits)
13
- [![Coverage Status](http://img.shields.io/coveralls/mroth/lolcommits.svg?style=flat)](https://coveralls.io/r/mroth/lolcommits)
9
+ [![Gem Version](https://badge.fury.io/rb/lolcommits.svg)](https://rubygems.org/gems/lolcommits)
10
+ [![Build Status](https://travis-ci.org/mroth/lolcommits.svg?branch=master)](https://travis-ci.org/mroth/lolcommits)
11
+ [![Dependency Status](https://gemnasium.com/mroth/lolcommits.svg)](https://gemnasium.com/mroth/lolcommits)
12
+ [![CodeClimate Status](https://d3s6mut3hikguw.cloudfront.net/github/mroth/lolcommits/badges/gpa.svg)](https://codeclimate.com/github/mroth/lolcommits)
13
+ [![Coverage Status](https://coveralls.io/repos/mroth/lolcommits/badge.svg?branch=master&service=github)](https://coveralls.io/r/mroth/lolcommits)
14
14
 
15
15
  ## Sample images
16
16
 
@@ -27,6 +27,7 @@ require 'lolcommits/plugins/lolsrv'
27
27
  require 'lolcommits/plugins/lol_yammer'
28
28
  require 'lolcommits/plugins/lol_protonet'
29
29
  require 'lolcommits/plugins/lol_tumblr'
30
+ require 'lolcommits/plugins/lol_slack'
30
31
 
31
32
  # require runner after all the plugins have been required
32
33
  require 'lolcommits/runner'
@@ -67,10 +67,10 @@ module Lolcommits
67
67
  def self.die_if_not_git_repo!
68
68
  debug 'Checking for valid git repo'
69
69
  Git.open('.') # FIXME: should be extracted to GitInfo class
70
- rescue ArgumentError
71
- # ruby-git throws an argument error if path isnt for a valid git repo.
72
- fatal "Erm? Can't do that since we're not in a valid git repository!"
73
- exit 1
70
+ rescue ArgumentError
71
+ # ruby-git throws an argument error if path isnt for a valid git repo.
72
+ fatal "Erm? Can't do that since we're not in a valid git repository!"
73
+ exit 1
74
74
  end
75
75
  end
76
76
  end
@@ -68,7 +68,7 @@ module Lolcommits
68
68
  private
69
69
 
70
70
  def remote_https_url(url)
71
- url.gsub(':', '/').gsub(/^git@/, 'https://').gsub(/\.git$/, '') + '/commit/'
71
+ url.tr(':', '/').tr(/^git@/, 'https://').tr(/\.git$/, '') + '/commit/'
72
72
  end
73
73
 
74
74
  def repository(path = '.')
@@ -26,7 +26,7 @@ module Lolcommits
26
26
 
27
27
  :key => configuration['api_key'],
28
28
  :t => t,
29
- :token => Digest::SHA1.hexdigest(configuration['api_secret'] + t)
29
+ :token => Digest::SHA1.hexdigest(configuration['api_secret'] + t)
30
30
  })
31
31
  rescue => e
32
32
  log_error(e, "ERROR: HTTMultiParty POST FAILED #{e.class} - #{e.message}")
@@ -0,0 +1,68 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'rest_client'
3
+
4
+ module Lolcommits
5
+ class LolSlack < Plugin
6
+ ENDPOINT_URL = 'https://slack.com/api/files.upload'
7
+ RETRY_COUNT = 2
8
+
9
+ def self.name
10
+ 'slack'
11
+ end
12
+
13
+ def self.runner_order
14
+ :postcapture
15
+ end
16
+
17
+ def configured?
18
+ !configuration['access_token'].nil?
19
+ end
20
+
21
+ def configure
22
+ print "Open the URL below and issue a token for your user:\n"
23
+ print "https://api.slack.com/web\n"
24
+ print "Enter the generated token below, then press enter: (e.g. xxxx-xxxxxxxxx-xxxx) \n"
25
+ code = STDIN.gets.to_s.strip
26
+ print "Enter a comma-seperated list of channel IDs to post images in, then press enter: (e.g. C1234567890,C1234567890)\n"
27
+ print "NOTE: you must use channel IDs (not channel names). Grab them from here; https://api.slack.com/methods/channels.list/test\n"
28
+ channels = STDIN.gets.to_s.strip
29
+
30
+ { 'access_token' => code,
31
+ 'channels' => channels }
32
+ end
33
+
34
+ def configure_options!
35
+ options = super
36
+ if options['enabled']
37
+ config = configure
38
+ options.merge!(config)
39
+ end
40
+ options
41
+ end
42
+
43
+ def run_postcapture
44
+ return unless valid_configuration?
45
+
46
+ retries = RETRY_COUNT
47
+ begin
48
+
49
+ response = RestClient.post(
50
+ ENDPOINT_URL,
51
+ :file => File.new(runner.main_image),
52
+ :token => configuration['access_token'],
53
+ :filetype => 'jpg',
54
+ :filename => runner.sha,
55
+ :title => runner.message + "[#{runner.git_info.repo}]",
56
+ :channels => configuration['channels'])
57
+
58
+ debug response
59
+ rescue => e
60
+ retries -= 1
61
+ retry if retries > 0
62
+ puts "Posting to slack failed - #{e.message}"
63
+ puts 'Try running config again:'
64
+ puts "\tlolcommits --config --plugin slack"
65
+ end
66
+ end
67
+ end
68
+ end
@@ -68,7 +68,7 @@ module Lolcommits
68
68
  c.client_secret = YAMMER_CLIENT_SECRET
69
69
  end
70
70
 
71
- client = Yammer::Client.new(:access_token => configuration['access_token'])
71
+ client = Yammer::Client.new(:access_token => configuration['access_token'])
72
72
 
73
73
  retries = YAMMER_RETRY_COUNT
74
74
  begin
@@ -63,7 +63,7 @@ module Lolcommits
63
63
 
64
64
  # sort option keys since different `Hash#keys` varys across Ruby versions
65
65
  defaults.keys.sort_by(&:to_s).reduce({}) do |acc, opt|
66
- print " #{opt.to_s.gsub('_', ' ')} (#{defaults[opt]}): "
66
+ print " #{opt.to_s.tr('_', ' ')} (#{defaults[opt]}): "
67
67
  val = parse_user_input(STDIN.gets.strip)
68
68
  acc.merge(opt => val)
69
69
  end
@@ -1,5 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  require 'rest_client'
3
+ require 'base64'
3
4
 
4
5
  module Lolcommits
5
6
  class Uploldz < Plugin
@@ -7,7 +8,12 @@ module Lolcommits
7
8
 
8
9
  def initialize(runner)
9
10
  super
10
- options.concat(%w(endpoint optional_key))
11
+ options.concat(%w(
12
+ endpoint
13
+ optional_key
14
+ optional_http_auth_username
15
+ optional_http_auth_password
16
+ ))
11
17
  end
12
18
 
13
19
  def run_postcapture
@@ -18,13 +24,17 @@ module Lolcommits
18
24
  else
19
25
  debug "Posting capture to #{configuration['endpoint']}"
20
26
  RestClient.post(configuration['endpoint'],
21
- :file => File.new(runner.main_image),
22
- :message => runner.message,
23
- :repo => runner.git_info.repo,
24
- :author_name => runner.git_info.author_name,
25
- :author_email => runner.git_info.author_email,
26
- :sha => runner.sha,
27
- :key => configuration['optional_key'])
27
+ {
28
+ :file => File.new(runner.main_image),
29
+ :message => runner.message,
30
+ :repo => runner.git_info.repo,
31
+ :author_name => runner.git_info.author_name,
32
+ :author_email => runner.git_info.author_email,
33
+ :sha => runner.sha,
34
+ :key => configuration['optional_key']
35
+ },
36
+ :Authorization => authorization_header
37
+ )
28
38
  end
29
39
  rescue => e
30
40
  log_error(e, "ERROR: RestClient POST FAILED #{e.class} - #{e.message}")
@@ -34,6 +44,14 @@ module Lolcommits
34
44
  !configuration['enabled'].nil? && configuration['endpoint']
35
45
  end
36
46
 
47
+ def authorization_header
48
+ user = configuration['optional_http_auth_username']
49
+ password = configuration['optional_http_auth_password']
50
+ return unless user || password
51
+
52
+ 'Basic ' + Base64.encode64("#{user}:#{password}").chomp
53
+ end
54
+
37
55
  def self.name
38
56
  'uploldz'
39
57
  end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Lolcommits
3
- VERSION = '0.6.0'
3
+ VERSION = '0.6.1'
4
4
  end
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.6.0
4
+ version: 0.6.1
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: 2015-07-27 00:00:00.000000000 Z
12
+ date: 2015-09-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -416,6 +416,7 @@ files:
416
416
  - lib/lolcommits/plugin.rb
417
417
  - lib/lolcommits/plugins/dot_com.rb
418
418
  - lib/lolcommits/plugins/lol_protonet.rb
419
+ - lib/lolcommits/plugins/lol_slack.rb
419
420
  - lib/lolcommits/plugins/lol_tumblr.rb
420
421
  - lib/lolcommits/plugins/lol_twitter.rb
421
422
  - lib/lolcommits/plugins/lol_yammer.rb