lolcommits-slack 0.0.2 → 0.0.3

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: c9ad2c07401cb1d094bc9a627af6e6f4566ebe6f
4
- data.tar.gz: 3ab347e1fbb18a26fefb360376e875ccea3eeaa1
2
+ SHA256:
3
+ metadata.gz: f10b4933ce906fbbe9a3e27f9f5ed623da1e768511f4c57f1f15ab30473b0d95
4
+ data.tar.gz: f995f7b137d0a7d749a0e3eaa395eef8814c2d0f30009b0939ad4344fa7241e6
5
5
  SHA512:
6
- metadata.gz: 165b0aa1181726475066fc17c32e3cb684da0ece597f23f5c559e7c675d1611f8c51aab668a41603268037330025e7639e0525f0c86887d09efcd37ad5c2651e
7
- data.tar.gz: ca94265e28d186d5e7c687618b1943cc5d3de5690e3e657008dc9df8349b9b3ba509739fb48cff035eb3ea157ca2318b941c0faeda68a5c7162b160cc74d4d2d
6
+ metadata.gz: c087299c9709c53be553ef452973908ebb254b52279bf416c71bd5930711e1ea8582832cbd84d680c9a2f9ef0108a259e5a0b6732372e97ba9e584288e4248bf
7
+ data.tar.gz: b8e3caf920b124662b5efefbdb8555a1641c8bb621343783a17dc0a26ac8993e0add459a38be1af3127f0a3ea3569b1f42a10f9f29b38d610e083a1aca134cfc
data/.travis.yml CHANGED
@@ -4,13 +4,14 @@ cache: bundler
4
4
  rvm:
5
5
  - 2.0.0
6
6
  - 2.1.10
7
- - 2.2.8
8
- - 2.3.5
9
- - 2.4.2
7
+ - 2.2.9
8
+ - 2.3.6
9
+ - 2.4.3
10
+ - 2.5.0
10
11
  - ruby-head
11
12
 
12
13
  before_install:
13
- - gem install bundler -v 1.13.7
14
+ - gem update --system
14
15
  - git --version
15
16
  - git config --global user.email "lol@commits.org"
16
17
  - git config --global user.name "Lolcommits"
@@ -18,3 +19,14 @@ before_install:
18
19
  matrix:
19
20
  allow_failures:
20
21
  - rvm: ruby-head
22
+
23
+ env:
24
+ global:
25
+ - CC_TEST_REPORTER_ID=23a400f6c5d8a15d9f1b4c6102ed07115d1a1d3bc979e5bc36cd43e2558edf7c
26
+ - GIT_COMMITTED_AT=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then git log -1 --pretty=format:%ct; else git log -1 --skip 1 --pretty=format:%ct; fi)
27
+ before_script:
28
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
29
+ - chmod +x ./cc-test-reporter
30
+ - ./cc-test-reporter before-build - GIT_COMMITTED_AT=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then git log -1 --pretty=format:%ct; else git log -1 --skip 1 --pretty=format:%ct; fi)
31
+ after_script:
32
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  [![Gem Version](https://img.shields.io/gem/v/lolcommits-slack.svg?style=flat)](http://rubygems.org/gems/lolcommits-slack)
4
4
  [![Travis Build Status](https://travis-ci.org/lolcommits/lolcommits-slack.svg?branch=master)](https://travis-ci.org/lolcommits/lolcommits-slack)
5
- [![Coverage Status](https://coveralls.io/repos/github/lolcommits/lolcommits-slack/badge.svg?branch=master)](https://coveralls.io/github/lolcommits/lolcommits-slack)
6
- [![Code Climate](https://codeclimate.com/github/lolcommits/lolcommits-slack/badges/gpa.svg)](https://codeclimate.com/github/lolcommits/lolcommits-slack)
5
+ [![Maintainability](https://img.shields.io/codeclimate/maintainability/lolcommits/lolcommits-slack.svg)](https://codeclimate.com/github/lolcommits/lolcommits-slack/maintainability)
6
+ [![Test Coverage](https://img.shields.io/codeclimate/c/lolcommits/lolcommits-slack.svg)](https://codeclimate.com/github/lolcommits/lolcommits-slack/test_coverage)
7
7
  [![Gem Dependency Status](https://gemnasium.com/badges/github.com/lolcommits/lolcommits-slack.svg)](https://gemnasium.com/github.com/lolcommits/lolcommits-slack)
8
8
 
9
9
  [lolcommits](https://lolcommits.github.io/) takes a snapshot with your webcam
@@ -110,7 +110,7 @@ The gem is available as open source under the terms of
110
110
  ## Links
111
111
 
112
112
  * [Travis CI](https://travis-ci.org/lolcommits/lolcommits-slack)
113
- * [Test Coverage](https://coveralls.io/github/lolcommits/lolcommits-slack?branch=master)
113
+ * [Test Coverage](https://codeclimate.com/github/lolcommits/lolcommits-slack/test_coverage)
114
114
  * [Code Climate](https://codeclimate.com/github/lolcommits/lolcommits-slack)
115
115
  * [RDoc](http://rdoc.info/projects/lolcommits/lolcommits-slack)
116
116
  * [Issues](http://github.com/lolcommits/lolcommits-slack/issues)
@@ -10,17 +10,6 @@ module Lolcommits
10
10
  # Number of times to retry if RestClient.post fails
11
11
  RETRY_COUNT = 2
12
12
 
13
- ##
14
- # Returns the name of the plugin.
15
- #
16
- # Identifies the plugin to lolcommits.
17
- #
18
- # @return [String] the plugin name
19
- #
20
- def self.name
21
- 'slack'
22
- end
23
-
24
13
  ##
25
14
  # Returns position(s) of when this plugin should run during the capture
26
15
  # process.
@@ -52,11 +41,11 @@ module Lolcommits
52
41
  response = RestClient.post(
53
42
  ENDPOINT_URL,
54
43
  file: File.new(runner.main_image),
55
- token: configuration['access_token'],
44
+ token: configuration[:access_token],
56
45
  filetype: 'jpg',
57
46
  filename: runner.sha,
58
47
  title: runner.message + "[#{runner.vcs_info.repo}]",
59
- channels: configuration['channels']
48
+ channels: configuration[:channels]
60
49
  )
61
50
 
62
51
  debug response
@@ -86,7 +75,7 @@ module Lolcommits
86
75
  def configure_options!
87
76
  options = super
88
77
 
89
- if options['enabled']
78
+ if options[:enabled]
90
79
  print "open the url below and issue a token for your user:\n"
91
80
  print "https://api.slack.com/custom-integrations/legacy-tokens\n"
92
81
  print "enter the generated token below, then press enter: (e.g. xxxx-xxxxxxxxx-xxxx) \n"
@@ -97,24 +86,13 @@ module Lolcommits
97
86
  channels = parse_user_input(gets.strip)
98
87
 
99
88
  options.merge!(
100
- 'access_token' => code,
101
- 'channels' => channels
89
+ access_token: code,
90
+ channels: channels
102
91
  )
103
92
  end
104
93
 
105
94
  options
106
95
  end
107
-
108
- ##
109
- # Returns true/false indicating if the plugin has been configured.
110
- #
111
- # Checks the `access_token` ond `channels` options have been set.
112
- #
113
- # @return [Boolean] true/false
114
- #
115
- def configured?
116
- !configuration['access_token'].nil? && !configuration['channels'].nil?
117
- end
118
96
  end
119
97
  end
120
98
  end
@@ -1,5 +1,5 @@
1
1
  module Lolcommits
2
2
  module Slack
3
- VERSION = "0.0.2".freeze
3
+ VERSION = "0.0.3".freeze
4
4
  end
5
5
  end
@@ -34,11 +34,10 @@ Gem::Specification.new do |spec|
34
34
 
35
35
  spec.add_runtime_dependency "rest-client"
36
36
 
37
- spec.add_development_dependency "lolcommits", "~> 0.9.6"
37
+ spec.add_development_dependency "lolcommits", ">= 0.10.0"
38
38
  spec.add_development_dependency "webmock"
39
39
  spec.add_development_dependency "bundler"
40
40
  spec.add_development_dependency "rake"
41
41
  spec.add_development_dependency "minitest"
42
42
  spec.add_development_dependency "simplecov"
43
- spec.add_development_dependency "coveralls"
44
43
  end
@@ -5,14 +5,6 @@ describe Lolcommits::Plugin::Slack do
5
5
  include Lolcommits::TestHelpers::GitRepo
6
6
  include Lolcommits::TestHelpers::FakeIO
7
7
 
8
- def plugin_name
9
- 'slack'
10
- end
11
-
12
- it 'should have a name' do
13
- ::Lolcommits::Plugin::Slack.name.must_equal plugin_name
14
- end
15
-
16
8
  it 'should run on pre_capture and capture_ready' do
17
9
  ::Lolcommits::Plugin::Slack.runner_order.must_equal [:capture_ready]
18
10
  end
@@ -20,9 +12,8 @@ describe Lolcommits::Plugin::Slack do
20
12
  describe 'with a runner' do
21
13
 
22
14
  def runner
23
- # a simple lolcommits runner with an empty configuration Hash
15
+ # a simple lolcommits runner
24
16
  @_runner ||= Lolcommits::Runner.new(
25
- config: OpenStruct.new(read_configuration: {}),
26
17
  main_image: Tempfile.new('test_image')
27
18
  )
28
19
  end
@@ -32,22 +23,11 @@ describe Lolcommits::Plugin::Slack do
32
23
  end
33
24
 
34
25
  def valid_enabled_config
35
- @_config ||= OpenStruct.new(
36
- read_configuration: {
37
- plugin.class.name => {
38
- 'enabled' => true,
39
- 'access_token' => 'acbd-1234-wxyz-5678',
40
- 'channels' => 'c123,c456'
41
- }
42
- }
43
- )
44
- end
45
-
46
- describe 'initalizing' do
47
- it 'should assign runner and an enabled option' do
48
- plugin.runner.must_equal runner
49
- plugin.options.must_equal ['enabled']
50
- end
26
+ {
27
+ enabled: true,
28
+ access_token: 'acbd-1234-wxyz-5678',
29
+ channels: 'c123,c456'
30
+ }
51
31
  end
52
32
 
53
33
  describe '#run_capture_ready' do
@@ -58,7 +38,7 @@ describe Lolcommits::Plugin::Slack do
58
38
  it 'should post the message to slack' do
59
39
  stub_request(:any, plugin.class::ENDPOINT_URL)
60
40
  in_repo do
61
- plugin.config = valid_enabled_config
41
+ plugin.configuration = valid_enabled_config
62
42
  output = fake_io_capture { plugin.run_capture_ready }
63
43
  assert_equal output, "Posting to Slack ... done!\n"
64
44
 
@@ -71,10 +51,10 @@ describe Lolcommits::Plugin::Slack do
71
51
  it 'should retry (and explain) if there is a failure (req timeout)' do
72
52
  in_repo do
73
53
  stub_request(:any, plugin.class::ENDPOINT_URL).to_timeout
74
- plugin.config = valid_enabled_config
54
+ plugin.configuration = valid_enabled_config
75
55
 
76
56
  Proc.new { plugin.run_capture_ready }.
77
- must_output("Posting to Slack ... failed! Request Timeout - retrying ...\nPosting to Slack ... failed! Request Timeout - giving up ...\nTry running config again:\n\tlolcommits --config -p slack\n")
57
+ must_output("Posting to Slack ... failed! Timed out connecting to server - retrying ...\nPosting to Slack ... failed! Timed out connecting to server - giving up ...\nTry running config again:\n\tlolcommits --config -p slack\n")
78
58
 
79
59
  assert_requested :post, plugin.class::ENDPOINT_URL,
80
60
  headers: { 'Content-Type' => /multipart\/form-data;/ },
@@ -87,46 +67,37 @@ describe Lolcommits::Plugin::Slack do
87
67
 
88
68
  describe '#enabled?' do
89
69
  it 'should be false by default' do
90
- plugin.enabled?.must_equal false
70
+ assert_nil plugin.enabled?
91
71
  end
92
72
 
93
73
  it 'should true when configured' do
94
- plugin.config = valid_enabled_config
74
+ plugin.configuration = valid_enabled_config
95
75
  plugin.enabled?.must_equal true
96
76
  end
97
77
  end
98
78
 
99
79
  describe 'configuration' do
100
- it 'should not be configured by default' do
101
- plugin.configured?.must_equal false
102
- end
103
-
104
80
  it 'should allow plugin options to be configured' do
105
81
  configured_plugin_options = {}
106
82
 
107
- output = fake_io_capture(inputs: %w(true abc-def c1,c3,c4)) do
83
+ fake_io_capture(inputs: %w(true abc-def c1,c3,c4)) do
108
84
  configured_plugin_options = plugin.configure_options!
109
85
  end
110
86
 
111
- configured_plugin_options.must_equal( {
112
- "enabled" => true,
113
- "access_token" => 'abc-def',
114
- "channels" => 'c1,c3,c4'
87
+ configured_plugin_options.must_equal({
88
+ enabled: true,
89
+ access_token: 'abc-def',
90
+ channels: 'c1,c3,c4'
115
91
  })
116
92
  end
117
93
 
118
- it 'should indicate when configured' do
119
- plugin.config = valid_enabled_config
120
- plugin.configured?.must_equal true
121
- end
122
-
123
94
  describe '#valid_configuration?' do
124
95
  it 'should be false without config set' do
125
96
  plugin.valid_configuration?.must_equal(false)
126
97
  end
127
98
 
128
99
  it 'should be true for a valid configuration' do
129
- plugin.config = valid_enabled_config
100
+ plugin.configuration = valid_enabled_config
130
101
  plugin.valid_configuration?.must_equal true
131
102
  end
132
103
  end
data/test/test_helper.rb CHANGED
@@ -1,26 +1,18 @@
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
- # lolcommit test helpers
10
- require 'webmock/minitest'
6
+ # lolcommits test helpers
11
7
  require 'lolcommits/test_helpers/git_repo'
12
8
  require 'lolcommits/test_helpers/fake_io'
13
9
 
14
10
  if ENV['COVERAGE']
15
- if ENV['TRAVIS']
16
- require 'coveralls'
17
- Coveralls.wear!
18
- else
19
- require 'simplecov'
20
- end
11
+ require 'simplecov'
21
12
  end
22
13
 
23
14
  # plugin gem test libs
15
+ require 'webmock/minitest'
24
16
  require 'lolcommits/plugin/slack'
25
17
  require 'minitest/autorun'
26
18
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lolcommits-slack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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-05 00:00:00.000000000 Z
11
+ date: 2018-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: lolcommits
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.9.6
33
+ version: 0.10.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.9.6
40
+ version: 0.10.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: webmock
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -108,20 +108,6 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: coveralls
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
111
  description: Automatically post your lolcommits to Slack
126
112
  email:
127
113
  - matt@hiddenloop.com
@@ -167,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
153
  version: '0'
168
154
  requirements: []
169
155
  rubyforge_project:
170
- rubygems_version: 2.6.13
156
+ rubygems_version: 2.7.3
171
157
  signing_key:
172
158
  specification_version: 4
173
159
  summary: Sends lolcommits to one (or more) Slack channels