chatopsify 0.0.5 → 0.0.6

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ad7c973ce861d481cbc1b15b008de15c5a489c84ed1410d61ec2bb834bed9be
4
- data.tar.gz: a87c09f10af7611b2453756767b1b413f4a89bd504afa16e2e353ec79cc58bbe
3
+ metadata.gz: 14141a20c1a8a4cfda8993608f336919ef400ad96644ca994658fd215b494a8b
4
+ data.tar.gz: dbf4b8583120ec65a00d0e47fa82e469ed4fd80e27644d1d9def262c9e8849fb
5
5
  SHA512:
6
- metadata.gz: 2a37716e4e9e248095a2ad2a2754eccd59315b1f684e1efcc5a2d14da788d37f71521e7d1b35344720e2095cbef4908e73336050c76bef40b8769c37a27ebb95
7
- data.tar.gz: b8cb3e14161a00fea4ea68f58199e82ba75741a75dae5733655bb078d724966f819521ed23f8cb47f2d06ad0dfed83e0090487b26670892640c289eea3c9473b
6
+ metadata.gz: 690503d6828f98cd64ce2e90540c6adcdcaccfcc59093ad195f887ee5893c549b8ffd87f6a94e9f2985826cbd12bb8bc63ab6da54b52fdba8137c88ed49465c9
7
+ data.tar.gz: 29c67e0bed4b61b825c49a4e903fc1643516a9d14279bf12b0547e04a3a802b0de0fb80fccc2dce17af082fa0bb4e3675ec185aed0796761aee8f604c82065cb
@@ -8,20 +8,17 @@ jobs:
8
8
  runs-on: ubuntu-latest
9
9
 
10
10
  steps:
11
- - uses: actions/checkout@v2
12
- - name: Set up Ruby 2.6 is
13
- uses: actions/setup-ruby@v1
11
+ - uses: actions/checkout@v4
12
+ - name: Set up Ruby 2.6.4
13
+ uses: ruby/setup-ruby@v1
14
14
  with:
15
- ruby-version: 2.6.x
16
- - uses: actions/cache@v1
17
- with:
18
- path: vendor/bundle
19
- key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
20
- restore-keys: |
21
- ${{ runner.os }}-gems-
15
+ ruby-version: 2.6.4
16
+ # - uses: ruby/setup-ruby@v1
17
+ # with:
18
+ # bundler-cache: true
22
19
  - name: Run Rubocop linter
23
20
  run: |
24
- gem install bundler
21
+ gem install bundler -v 2.4.22
25
22
  bundle config path vendor/bundle
26
23
  bundle install --jobs 4 --retry 3
27
24
  bundle exec rubocop
@@ -8,20 +8,14 @@ jobs:
8
8
  runs-on: ubuntu-latest
9
9
 
10
10
  steps:
11
- - uses: actions/checkout@v2
12
- - name: Set up Ruby 2.6 is
13
- uses: actions/setup-ruby@v1
11
+ - uses: actions/checkout@v4
12
+ - name: Set up Ruby 2.6.4
13
+ uses: ruby/setup-ruby@v1
14
14
  with:
15
- ruby-version: 2.6.x
16
- - uses: actions/cache@v1
17
- with:
18
- path: vendor/bundle
19
- key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
20
- restore-keys: |
21
- ${{ runner.os }}-gems-
15
+ ruby-version: 2.6.4
22
16
  - name: Run test suite
23
17
  run: |
24
- gem install bundler
18
+ gem install bundler -v 2.4.22
25
19
  bundle config path vendor/bundle
26
20
  bundle install --jobs 4 --retry 3
27
21
  bundle exec rake test
data/.rubocop.yml CHANGED
@@ -6,8 +6,14 @@ Style/StringLiteralsInInterpolation:
6
6
  Enabled: true
7
7
  EnforcedStyle: single_quotes
8
8
 
9
+ Metrics/AbcSize:
10
+ Enabled: false
11
+
9
12
  Layout/LineLength:
10
13
  Max: 120
14
+ Metrics/MethodLength:
15
+ Max: 120
16
+
11
17
 
12
18
  AllCops:
13
19
  NewCops: enable
data/Gemfile CHANGED
@@ -5,8 +5,7 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in Chatopsify.gemspec
6
6
  gemspec
7
7
 
8
- gem 'rake', '~> 13.0'
9
-
8
+ gem 'bundler', '~> 2'
10
9
  gem 'minitest', '~> 5.0'
11
-
10
+ gem 'rake', '~> 13.0'
12
11
  gem 'rubocop', '~> 1.21'
data/README.md CHANGED
@@ -1,9 +1,10 @@
1
1
  # Chatopsify
2
2
 
3
- ![Gem](https://img.shields.io/gem/v/chatopsify?color=%25234cc61f&label=Gem%20version&logo=ruby&logoColor=red)
4
- ![Gem](https://img.shields.io/gem/dt/chatopsify?color=%2330c754&label=Downloads&logo=rubygems&logoColor=red)
5
- <!-- ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/rs-phunt/Chatopsify/Tests%20%F0%9F%A7%AA?label=Tests&logo=github)
6
- ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/rs-phunt/Chatopsify/Rubocop%20Lint?label=Rubocop&logo=github) -->
3
+ ![Gem](https://img.shields.io/gem/v/chatopsify?color=%25234cc61f&label=Gem%20version&logo=ruby&logoColor=red&link=https%3A%2F%2Frubygems.org%2Fgems%2Fchatopsify)
4
+ ![Gem](https://img.shields.io/gem/dt/chatopsify?color=%2330c754&label=Downloads&logo=rubygems&logoColor=red&link=https%3A%2F%2Frubygems.org%2Fgems%2Fchatopsify)
5
+ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/papakvy/chatopsify/run_rubocop.yml?branch=main&logo=rubocop&logoColor=red&label=Rubocop%20Lint)
6
+ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/papakvy/chatopsify/run_tests.yml?branch=main&logo=rubocop&logoColor=red&label=Tests%20%F0%9F%A7%AA)
7
+ <!-- ![GitHub Repo stars](https://img.shields.io/github/stars/papakvy/chatopsify?logoColor=red) -->
7
8
 
8
9
  ## Installation
9
10
 
data/chatopsify.gemspec CHANGED
@@ -12,15 +12,15 @@ Gem::Specification.new do |spec|
12
12
  spec.email = ['phunt@runsystem.net']
13
13
 
14
14
  spec.summary = 'Publish deployment notifications to ChatOps via the API'
15
- spec.description = 'Publish deployment notifications to ChatOps via the API'
15
+ spec.description = 'chatopsify = ChatOps + Capistrano notifications via API'
16
16
  spec.homepage = 'https://github.com/papakvy/chatopsify'
17
17
  spec.license = 'MIT'
18
18
  spec.required_ruby_version = '>= 2.6'
19
19
 
20
20
  # spec.metadata['allowed_push_host'] = 'TODO: Set to your gem server 'https://example.com''
21
21
  spec.metadata['rubygems_mfa_required'] = 'true'
22
- spec.metadata['homepage_uri'] = spec.homepage
23
- spec.metadata['source_code_uri'] = 'https://github.com/papakvy/chatopsify'
22
+ # spec.metadata['homepage_uri'] = spec.homepage
23
+ # spec.metadata['source_code_uri'] = 'https://github.com/papakvy/chatopsify'
24
24
  spec.metadata['changelog_uri'] = 'https://github.com/papakvy/chatopsify/blob/master/CHANGELOG.md'
25
25
 
26
26
  spec.files = `git ls-files -z`.split("\x0")
@@ -31,8 +31,6 @@ Gem::Specification.new do |spec|
31
31
  # Uncomment to register a new dependency of your gem
32
32
 
33
33
  spec.add_dependency 'capistrano', '~> 3.2', '>= 3.2.0'
34
- spec.add_development_dependency 'bundler', '~> 2'
35
- spec.add_development_dependency 'rake', '~> 1'
36
34
 
37
35
  # For more information and examples about making a new gem, checkout our
38
36
  # guide at: https://bundler.io/guides/creating_gem.html
@@ -4,7 +4,12 @@ namespace :chatops do
4
4
  set :chatops_time_started, Time.now
5
5
  run_locally do
6
6
  if fetch(:chatops_notify_events).include? :started
7
- Chatopsify::Co.call.process(Chatopsify::CoLib.msg_fmt(:starting))
7
+ info 'Notifying ChatOps of deploy started'
8
+ begin
9
+ Chatopsify::Co.call.process(Chatopsify::CoLib.msg_fmt(:starting))
10
+ rescue StandardError => e
11
+ info "ERROR notify_started: #{e}"
12
+ end
8
13
  end
9
14
  end
10
15
  end
@@ -17,7 +22,11 @@ namespace :chatops do
17
22
  run_locally do
18
23
  if fetch(:chatops_notify_events).include? :finished
19
24
  info 'Notifying ChatOps of deploy finished'
20
- Chatopsify::Co.call.process(Chatopsify::CoLib.msg_fmt(:success))
25
+ begin
26
+ Chatopsify::Co.call.process(Chatopsify::CoLib.msg_fmt(:success))
27
+ rescue StandardError => e
28
+ info "ERROR notify_finished: #{e}"
29
+ end
21
30
  end
22
31
  end
23
32
  end
@@ -30,7 +39,11 @@ namespace :chatops do
30
39
  run_locally do
31
40
  if fetch(:chatops_notify_events).include? :failed
32
41
  info 'Notifying ChatOps of deploy failed'
33
- Chatopsify::Co.call.process(Chatopsify::CoLib.msg_fmt(:failed))
42
+ begin
43
+ Chatopsify::Co.call.process(Chatopsify::CoLib.msg_fmt(:failed))
44
+ rescue StandardError => e
45
+ info "ERROR notify_failed: #{e}"
46
+ end
34
47
  end
35
48
  end
36
49
  end
data/lib/chatopsify/co.rb CHANGED
@@ -4,6 +4,7 @@ require 'json'
4
4
  require 'net/http'
5
5
 
6
6
  module Chatopsify
7
+ # ChatOps services
7
8
  class Co
8
9
  def initialize(api_key = nil)
9
10
  @api_key = api_key || load_api_key
@@ -23,8 +24,8 @@ module Chatopsify
23
24
  puts e.message
24
25
  end
25
26
 
26
- def call_get(id = nil)
27
- send_get_request(id)
27
+ def call_delete(id = nil)
28
+ send_delete_request(id)
28
29
  rescue StandardError => e
29
30
  puts e.message
30
31
  end
@@ -65,11 +66,10 @@ module Chatopsify
65
66
  puts "Response: #{res.code} #{res.body}"
66
67
  end
67
68
 
68
- def send_get_request(id = nil)
69
+ def send_delete_request(id = nil)
69
70
  uri = URI(@uri)
70
71
  uri.path += "/#{id}" if id
71
72
 
72
- # req = Net::HTTP::Get.new(co_uri)
73
73
  req = Net::HTTP::Delete.new(uri)
74
74
  req['authorization'] = "Bearer #{o_api_key}"
75
75
  res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
@@ -95,20 +95,23 @@ module Chatopsify
95
95
  end
96
96
  end
97
97
 
98
+ # rubocop:disable Lint/TripleQuotes, Style/StringLiterals, Layout/IndentationWidth
98
99
  def msg_fmt(status = nil)
99
100
  """#{text(status)}
100
101
  | TITLE | CONTENTS |
101
102
  |----------:|:-------------|
102
- | Stage | #{fetch(:stage).upcase!} |
103
- | Server | #{fetch(:ip_address) }|
103
+ | Stage | #{fetch(:stage)&.upcase!} |
104
+ | Server | #{fetch(:ip_address)}|
104
105
  | Branch | #{fetch(:branch)} |
105
106
  | Revision | #{fetch(:current_revision) || '<empty>'} |
106
- | Timestamp | #{Time.now.getlocal("+07:00") || Time.now} |
107
+ | Timestamp | #{Time.now.getlocal('+07:00') || Time.now} |
107
108
  """
108
109
  end
110
+ # rubocop:enable Lint/TripleQuotes, Style/StringLiterals, Layout/IndentationWidth
109
111
  end
110
112
  end
111
113
 
114
+ # CoSecurity service
112
115
  class CoSecurity
113
116
  require 'openssl'
114
117
  require 'securerandom'
@@ -122,44 +125,40 @@ module Chatopsify
122
125
  end
123
126
 
124
127
  def encrypt_string
125
- begin
126
- cipher = OpenSSL::Cipher::AES256.new(:CBC)
127
- cipher.encrypt
128
- salt = SecureRandom.random_bytes(16)
129
- key_iv = OpenSSL::PKCS5.pbkdf2_hmac_sha1(generate_pwd, salt, 2000, cipher.key_len + cipher.iv_len)
130
- key = key_iv[0, cipher.key_len]
131
- iv = key_iv[cipher.key_len, cipher.iv_len]
132
-
133
- cipher.key = key
134
- cipher.iv = iv
135
-
136
- encrypted = cipher.update(@str) + cipher.final
137
- (salt + encrypted).unpack1('H*')
138
- rescue => e
139
- false
140
- end
128
+ cipher = OpenSSL::Cipher.new('aes-256-cbc')
129
+ cipher.encrypt
130
+ salt = SecureRandom.random_bytes(16)
131
+ key_iv = OpenSSL::PKCS5.pbkdf2_hmac_sha1(generate_pwd, salt, 2000, cipher.key_len + cipher.iv_len)
132
+ key = key_iv[0, cipher.key_len]
133
+ iv = key_iv[cipher.key_len, cipher.iv_len]
134
+
135
+ cipher.key = key
136
+ cipher.iv = iv
137
+
138
+ encrypted = cipher.update(@str) + cipher.final
139
+ (salt + encrypted).unpack1('H*')
140
+ rescue StandardError => e
141
+ puts e.message
141
142
  end
142
143
 
143
144
  def decrypt_string
144
- begin
145
- encrypted = [@str].pack('H*')
146
- cipher = OpenSSL::Cipher::AES256.new(:CBC)
147
- cipher.decrypt
145
+ encrypted = [@str].pack('H*')
146
+ cipher = OpenSSL::Cipher.new('aes-256-cbc')
147
+ cipher.decrypt
148
148
 
149
- salt = encrypted[0, 16]
150
- encrypted_data = encrypted[16..-1]
149
+ salt = encrypted[0, 16]
150
+ encrypted_data = encrypted[16..]
151
151
 
152
- key_iv = OpenSSL::PKCS5.pbkdf2_hmac_sha1(generate_pwd, salt, 2000, cipher.key_len + cipher.iv_len)
153
- key = key_iv[0, cipher.key_len]
154
- iv = key_iv[cipher.key_len, cipher.iv_len]
152
+ key_iv = OpenSSL::PKCS5.pbkdf2_hmac_sha1(generate_pwd, salt, 2000, cipher.key_len + cipher.iv_len)
153
+ key = key_iv[0, cipher.key_len]
154
+ iv = key_iv[cipher.key_len, cipher.iv_len]
155
155
 
156
- cipher.key = key
157
- cipher.iv = iv
156
+ cipher.key = key
157
+ cipher.iv = iv
158
158
 
159
- cipher.update(encrypted_data) + cipher.final
160
- rescue => e
161
- false
162
- end
159
+ cipher.update(encrypted_data) + cipher.final
160
+ rescue StandardError => e
161
+ puts e.message
163
162
  end
164
163
 
165
164
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Chatopsify
4
- VERSION = '0.0.5'
4
+ VERSION = '0.0.6'
5
5
  end
data/test/test_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  $LOAD_PATH.unshift File.expand_path('lib', __dir__)
4
- require 'Chatopsify'
4
+ require 'chatopsify'
5
5
 
6
6
  require 'minitest/autorun'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chatopsify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - phunt
@@ -30,35 +30,7 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 3.2.0
33
- - !ruby/object:Gem::Dependency
34
- name: bundler
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '2'
40
- type: :development
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '2'
47
- - !ruby/object:Gem::Dependency
48
- name: rake
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '1'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: '1'
61
- description: Publish deployment notifications to ChatOps via the API
33
+ description: chatopsify = ChatOps + Capistrano notifications via API
62
34
  email:
63
35
  - phunt@runsystem.net
64
36
  executables: []
@@ -84,15 +56,13 @@ files:
84
56
  - lib/chatopsify/co.rb
85
57
  - lib/chatopsify/version.rb
86
58
  - lib/core_ext/custom_lib.rb
87
- - test/chatworkify_test.rb
59
+ - test/chatopsify_test.rb
88
60
  - test/test_helper.rb
89
61
  homepage: https://github.com/papakvy/chatopsify
90
62
  licenses:
91
63
  - MIT
92
64
  metadata:
93
65
  rubygems_mfa_required: 'true'
94
- homepage_uri: https://github.com/papakvy/chatopsify
95
- source_code_uri: https://github.com/papakvy/chatopsify
96
66
  changelog_uri: https://github.com/papakvy/chatopsify/blob/master/CHANGELOG.md
97
67
  post_install_message:
98
68
  rdoc_options: []
File without changes