popper 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/ruby.yml +38 -0
- data/lib/popper/action/slack.rb +8 -1
- data/lib/popper/config.rb +38 -41
- data/lib/popper/version.rb +1 -1
- data/popper.gemspec +19 -18
- metadata +41 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b808e5e8c4b22939a7f9aa38f929a48fe47cc99cf569f97149e168d77e5ab5b
|
4
|
+
data.tar.gz: 13f1787819e224b2eeb96dd99cdfc0f210300e31decbe1752f133fc4520a5c81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15e3d186627b15f17b14f57e6829d0fa534e6d3792dad0fc080a51a833e3584044a2dd94bfcdea6c3860868e624538f87654d462559b61b4d0c039db9a42eb1b
|
7
|
+
data.tar.gz: e155391686166a6e6f24c498576fb523ad6bc0ccda98b5c293f9506649568d8a7fc6da488db32068da8a51f7ea537ca50ae1bef993fb03475e18b0e64a02ce94
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
3
|
+
# Please see the documentation for all configuration options:
|
4
|
+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
5
|
+
|
6
|
+
version: 2
|
7
|
+
updates:
|
8
|
+
- package-ecosystem: "bundler" # See documentation for possible values
|
9
|
+
directory: "/" # Location of package manifests
|
10
|
+
schedule:
|
11
|
+
interval: "weekly"
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ "master" ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ "master" ]
|
15
|
+
|
16
|
+
permissions:
|
17
|
+
contents: read
|
18
|
+
|
19
|
+
jobs:
|
20
|
+
test:
|
21
|
+
|
22
|
+
runs-on: ubuntu-latest
|
23
|
+
strategy:
|
24
|
+
matrix:
|
25
|
+
ruby-version: ['2.6', '2.7', '3.0']
|
26
|
+
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v3
|
29
|
+
- name: Set up Ruby
|
30
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
31
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
32
|
+
# uses: ruby/setup-ruby@v1
|
33
|
+
uses: ruby/setup-ruby@0a29871fe2b0200a17a4497bae54fe5df0d973aa # v1.115.3
|
34
|
+
with:
|
35
|
+
ruby-version: ${{ matrix.ruby-version }}
|
36
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
37
|
+
- name: Run tests
|
38
|
+
run: bundle exec rake
|
data/lib/popper/action/slack.rb
CHANGED
@@ -14,7 +14,7 @@ module Popper::Action
|
|
14
14
|
title: mail.subject,
|
15
15
|
color: "good"
|
16
16
|
}
|
17
|
-
note[:text] = mail.utf_body if @action_config.use_body
|
17
|
+
note[:text] = mail_body(mail.utf_body) if @action_config.use_body
|
18
18
|
|
19
19
|
body = @action_config.message || "popper mail notification"
|
20
20
|
body += " #{@action_config.mentions.join(" ")}" if @action_config.mentions
|
@@ -33,5 +33,12 @@ module Popper::Action
|
|
33
33
|
@action_config.respond_to?(:webhook_url)
|
34
34
|
end
|
35
35
|
|
36
|
+
def self.mail_body(body)
|
37
|
+
if @action_config.use_body.kind_of?(Integer) && body.lines.length > @action_config.use_body
|
38
|
+
return body.lines[0, @action_config.use_body].push('--- snip ---').join
|
39
|
+
end
|
40
|
+
|
41
|
+
body
|
42
|
+
end
|
36
43
|
end
|
37
44
|
end
|
data/lib/popper/config.rb
CHANGED
@@ -4,13 +4,15 @@ require 'logger'
|
|
4
4
|
module Popper
|
5
5
|
class Config
|
6
6
|
attr_reader :default, :accounts, :interval
|
7
|
+
|
7
8
|
def initialize(config_path)
|
8
9
|
raise "configure not fond #{config_path}" unless File.exist?(config_path)
|
10
|
+
|
9
11
|
config = read_file(config_path)
|
10
12
|
|
11
|
-
@interval = config.key?(
|
12
|
-
@default = config[
|
13
|
-
@accounts = config.select {|
|
13
|
+
@interval = config.key?('interval') ? config['interval'].to_i : 60
|
14
|
+
@default = config['default'] if config['default']
|
15
|
+
@accounts = config.select { |_k, v| v.is_a?(Hash) && v.key?('login') }.map do |account|
|
14
16
|
_account = AccountAttributes.new(account[1])
|
15
17
|
_account.name = account[0]
|
16
18
|
_account
|
@@ -19,36 +21,36 @@ module Popper
|
|
19
21
|
|
20
22
|
def read_file(file)
|
21
23
|
config = TOML.load_file(file)
|
22
|
-
if config.key?(
|
23
|
-
content = config[
|
24
|
+
if config.key?('include')
|
25
|
+
content = config['include'].map { |p| Dir.glob(p).map { |f| File.read(f) } }.join("\n")
|
24
26
|
config.deep_merge!(TOML::Parser.new(content).parsed)
|
25
27
|
end
|
26
28
|
config
|
27
29
|
end
|
28
30
|
|
29
|
-
%w
|
31
|
+
%w[
|
30
32
|
condition
|
31
33
|
action
|
32
|
-
|
33
|
-
define_method("default_#{name}")
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
}
|
34
|
+
].each do |name|
|
35
|
+
define_method("default_#{name}") do
|
36
|
+
default[name]
|
37
|
+
rescue StandardError
|
38
|
+
{}
|
39
|
+
end
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
class AccountAttributes < OpenStruct
|
44
|
-
def initialize(hash=nil)
|
44
|
+
def initialize(hash = nil)
|
45
|
+
super
|
45
46
|
@table = {}
|
46
47
|
@hash = hash
|
47
48
|
|
48
|
-
hash
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
if hash
|
50
|
+
hash.each do |k, v|
|
51
|
+
@table[k.to_sym] = (v.is_a?(Hash) ? self.class.new(v) : v)
|
52
|
+
end
|
53
|
+
end
|
52
54
|
end
|
53
55
|
|
54
56
|
def to_h
|
@@ -56,53 +58,48 @@ module Popper
|
|
56
58
|
end
|
57
59
|
|
58
60
|
[
|
59
|
-
%w
|
60
|
-
%w
|
61
|
+
%w[select all?],
|
62
|
+
%w[each each]
|
61
63
|
].each do |arr|
|
62
64
|
define_method("rule_with_conditions_#{arr[0]}") do |&blk|
|
63
|
-
@hash[
|
64
|
-
|
65
|
+
@hash['rules'].keys.send(arr[0]) do |rule|
|
66
|
+
condition_by_rule(rule).to_h.send(arr[1]) do |mail_header, conditions|
|
65
67
|
blk.call(rule, mail_header, conditions)
|
66
68
|
end
|
67
69
|
end
|
68
70
|
end
|
69
71
|
end
|
70
72
|
|
71
|
-
%w
|
73
|
+
%w[
|
72
74
|
condition
|
73
75
|
action
|
74
|
-
|
75
|
-
define_method("account_default_#{name}")
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
end
|
81
|
-
}
|
76
|
+
].each do |name|
|
77
|
+
define_method("account_default_#{name}") do
|
78
|
+
@hash['default'][name]
|
79
|
+
rescue StandardError
|
80
|
+
{}
|
81
|
+
end
|
82
82
|
|
83
83
|
# merge default and account default
|
84
84
|
define_method("#{name}_by_rule") do |rule|
|
85
85
|
hash = Popper.configure.send("default_#{name}")
|
86
|
-
hash = hash.deep_merge(
|
86
|
+
hash = hash.deep_merge(send("account_default_#{name}")) if send("account_default_#{name}")
|
87
87
|
hash = hash.deep_merge(rule_by_name(rule)[name]) if rule_by_name(rule).key?(name)
|
88
88
|
|
89
89
|
# replace body to utf_body
|
90
|
-
AccountAttributes.new(Hash[hash.map {|k,v| [k.to_s.gsub(/^body$/,
|
90
|
+
AccountAttributes.new(Hash[hash.map { |k, v| [k.to_s.gsub(/^body$/, 'utf_body').to_sym, v] }])
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
94
|
def rule_by_name(name)
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
{}
|
99
|
-
end
|
95
|
+
@hash['rules'][name]
|
96
|
+
rescue StandardError
|
97
|
+
{}
|
100
98
|
end
|
101
|
-
|
102
99
|
end
|
103
100
|
|
104
101
|
def self.load_config(options)
|
105
|
-
config_path = options[:config] ||
|
102
|
+
config_path = options[:config] || '/etc/popper.conf'
|
106
103
|
@_config = Config.new(config_path)
|
107
104
|
end
|
108
105
|
|
data/lib/popper/version.rb
CHANGED
data/popper.gemspec
CHANGED
@@ -1,31 +1,32 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'popper/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
6
|
+
spec.name = 'popper'
|
8
7
|
spec.version = Popper::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
8
|
+
spec.authors = ['pyama86']
|
9
|
+
spec.email = ['pyama@pepabo.com']
|
11
10
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
11
|
+
spec.summary = 'email notification tool'
|
12
|
+
spec.description = 'email notification tool'
|
13
|
+
spec.homepage = 'http://ten-snapon.com'
|
14
|
+
spec.license = 'MIT'
|
16
15
|
|
17
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.bindir =
|
17
|
+
spec.bindir = 'exe'
|
19
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
21
20
|
|
22
|
-
spec.add_dependency '
|
23
|
-
spec.add_dependency '
|
24
|
-
spec.add_dependency 'toml'
|
21
|
+
spec.add_dependency 'bundler'
|
22
|
+
spec.add_dependency 'faraday'
|
25
23
|
spec.add_dependency 'mail'
|
24
|
+
spec.add_dependency 'net-pop'
|
25
|
+
spec.add_dependency 'net-smtp'
|
26
26
|
spec.add_dependency 'octokit'
|
27
|
-
spec.add_dependency '
|
28
|
-
spec.add_dependency
|
29
|
-
spec.
|
30
|
-
spec.add_development_dependency
|
27
|
+
spec.add_dependency 'slack-notifier'
|
28
|
+
spec.add_dependency 'thor'
|
29
|
+
spec.add_dependency 'toml'
|
30
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
31
|
+
spec.add_development_dependency 'rspec'
|
31
32
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: popper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pyama86
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: faraday
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: mail
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,7 +53,21 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: net-pop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: net-smtp
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - ">="
|
@@ -81,7 +95,7 @@ dependencies:
|
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
98
|
+
name: slack-notifier
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
101
|
- - ">="
|
@@ -95,7 +109,21 @@ dependencies:
|
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
112
|
+
name: thor
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: toml
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
100
128
|
requirements:
|
101
129
|
- - ">="
|
@@ -114,14 +142,14 @@ dependencies:
|
|
114
142
|
requirements:
|
115
143
|
- - "~>"
|
116
144
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
145
|
+
version: '13.0'
|
118
146
|
type: :development
|
119
147
|
prerelease: false
|
120
148
|
version_requirements: !ruby/object:Gem::Requirement
|
121
149
|
requirements:
|
122
150
|
- - "~>"
|
123
151
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
152
|
+
version: '13.0'
|
125
153
|
- !ruby/object:Gem::Dependency
|
126
154
|
name: rspec
|
127
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,6 +172,8 @@ executables:
|
|
144
172
|
extensions: []
|
145
173
|
extra_rdoc_files: []
|
146
174
|
files:
|
175
|
+
- ".github/dependabot.yml"
|
176
|
+
- ".github/workflows/ruby.yml"
|
147
177
|
- ".gitignore"
|
148
178
|
- ".rspec"
|
149
179
|
- ".travis.yml"
|
@@ -187,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
217
|
- !ruby/object:Gem::Version
|
188
218
|
version: '0'
|
189
219
|
requirements: []
|
190
|
-
rubygems_version: 3.
|
220
|
+
rubygems_version: 3.2.33
|
191
221
|
signing_key:
|
192
222
|
specification_version: 4
|
193
223
|
summary: email notification tool
|