ci_slack 0.0.4 → 0.0.5
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 +4 -4
- data/lib/ci_slack/configuration.rb +9 -3
- data/lib/ci_slack/messager.rb +7 -4
- data/lib/ci_slack/rspec/notifier.rb +1 -1
- data/lib/ci_slack/version.rb +1 -1
- data/test/messager_test.rb +2 -2
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 3e7fc82227bb4a7377109f371acd8b1dd65be275
         | 
| 4 | 
            +
              data.tar.gz: 31424e4553462864c599eafd1f0f181e4aed2c72
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 3cfa35a4ad6a9e5577b71b6ed8e4a4b1e9f42df7f5496275e3391e48e37a79771ff266db033054558d3ce94316ef3b1a2282824e9cc4b11fb7fcd360f9162332
         | 
| 7 | 
            +
              data.tar.gz: 82a5de91f080ddd442b18ba0b9e4163122014e7d561f06c6864e148742a71996b621d01a1448a06ea9843d9d32cef19d394135eb24de57c92fbfa8e91359c77c
         | 
| @@ -1,16 +1,22 @@ | |
| 1 1 | 
             
            module CiSlack
         | 
| 2 2 | 
             
              class Configuration
         | 
| 3 | 
            -
                attr_accessor : | 
| 4 | 
            -
                              :bot_name, :project, :slack_names
         | 
| 3 | 
            +
                attr_accessor :webhook, :channel, :ci_computer,
         | 
| 4 | 
            +
                              :bot_name, :project, :slack_names,
         | 
| 5 | 
            +
                              :failed_icon, :success_icon,
         | 
| 6 | 
            +
                              :failed_title, :success_title
         | 
| 5 7 |  | 
| 6 8 | 
             
                def initialize
         | 
| 7 | 
            -
                  @icon = 'failed'
         | 
| 8 9 | 
             
                  @webhook = ''
         | 
| 9 10 | 
             
                  @channel = '#ci'
         | 
| 10 11 | 
             
                  @bot_name = 'CI BOT'
         | 
| 11 12 | 
             
                  @project = ''
         | 
| 12 13 | 
             
                  @slack_names = {}
         | 
| 13 14 | 
             
                  @ci_computer = 'CI'
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  @failed_icon = 'failed'
         | 
| 17 | 
            +
                  @success_icon = 'successful'
         | 
| 18 | 
            +
                  @failed_title = 'CI FAILED!'
         | 
| 19 | 
            +
                  @success_title = 'SUCCESS'
         | 
| 14 20 | 
             
                end
         | 
| 15 21 | 
             
              end
         | 
| 16 22 | 
             
            end
         | 
    
        data/lib/ci_slack/messager.rb
    CHANGED
    
    | @@ -3,19 +3,22 @@ require 'ci_slack' | |
| 3 3 |  | 
| 4 4 | 
             
            module CiSlack
         | 
| 5 5 | 
             
              class Messager
         | 
| 6 | 
            -
                 | 
| 6 | 
            +
                # status: failed or success
         | 
| 7 | 
            +
                def deliver(message = nil, status = :success)
         | 
| 7 8 | 
             
                  return unless ENV[ci_computer.to_s]
         | 
| 8 9 |  | 
| 9 10 | 
             
                  author, commit_message = last_git_log
         | 
| 10 11 | 
             
                  slack_name = slack_names.select { |key, _| author.downcase =~ key }.values.first || author
         | 
| 11 12 |  | 
| 12 | 
            -
                  text = "#{ project }.  | 
| 13 | 
            +
                  text = "#{ project }. #{ send(status.to_s + '_title') }\n<@#{ slack_name }> : #{ commit_message }\n#{ message }"
         | 
| 13 14 |  | 
| 14 | 
            -
                  client.post(text: text, icon_emoji: ":#{  | 
| 15 | 
            +
                  client.post(text: text, icon_emoji: ":#{ send(status.to_s + '_icon') }:")
         | 
| 15 16 | 
             
                end
         | 
| 16 17 |  | 
| 17 18 | 
             
                def method_missing(method, *args)
         | 
| 18 | 
            -
                  if %i[ | 
| 19 | 
            +
                  if %i[success_icon failed_icon
         | 
| 20 | 
            +
                        failed_title success_title
         | 
| 21 | 
            +
                        webhook channel ci_computer
         | 
| 19 22 | 
             
                        bot_name project slack_names].include?(method)
         | 
| 20 23 | 
             
                    CiSlack.configuration.send(method)
         | 
| 21 24 | 
             
                  else
         | 
    
        data/lib/ci_slack/version.rb
    CHANGED
    
    
    
        data/test/messager_test.rb
    CHANGED
    
    | @@ -21,7 +21,7 @@ class MessagerTest < ActiveSupport::TestCase | |
| 21 21 |  | 
| 22 22 | 
             
                messager = CiSlack::Messager.new
         | 
| 23 23 |  | 
| 24 | 
            -
                assert_nil(messager. | 
| 24 | 
            +
                assert_nil(messager.deliver('message'))
         | 
| 25 25 | 
             
              end
         | 
| 26 26 |  | 
| 27 27 | 
             
              test "computer with ci: ENV['CI'] is present" do
         | 
| @@ -30,7 +30,7 @@ class MessagerTest < ActiveSupport::TestCase | |
| 30 30 | 
             
                messager = CiSlack::Messager.new
         | 
| 31 31 |  | 
| 32 32 | 
             
                assert_raise Slack::Notifier::APIError do
         | 
| 33 | 
            -
                  messager. | 
| 33 | 
            +
                  messager.deliver('message')
         | 
| 34 34 | 
             
                end
         | 
| 35 35 | 
             
              end
         | 
| 36 36 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: ci_slack
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.5
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - skrinits
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2017- | 
| 11 | 
            +
            date: 2017-12-01 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: slack-notifier
         |