pechkin 1.3.2 → 1.4.0
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/pechkin/app/app_builder.rb +2 -4
- data/lib/pechkin/app/request_handler.rb +1 -1
- data/lib/pechkin/auth.rb +1 -0
- data/lib/pechkin/channel.rb +1 -1
- data/lib/pechkin/cli.rb +1 -1
- data/lib/pechkin/command/base.rb +1 -1
- data/lib/pechkin/command/send_data.rb +1 -0
- data/lib/pechkin/configuration/configuration_loader.rb +1 -1
- data/lib/pechkin/configuration/configuration_loader_bots.rb +1 -3
- data/lib/pechkin/configuration/configuration_loader_channels.rb +2 -6
- data/lib/pechkin/configuration/configuration_loader_views.rb +1 -3
- data/lib/pechkin/connector/slack.rb +2 -0
- data/lib/pechkin/connector/telegram.rb +2 -0
- data/lib/pechkin/exceptions.rb +3 -0
- data/lib/pechkin/handler.rb +1 -1
- data/lib/pechkin/message_matcher.rb +5 -3
- data/lib/pechkin/version.rb +1 -1
- data/lib/pechkin.rb +2 -2
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fa8abd425ad6a776104aabeeb6916d4b8b4d77ae0f0d7e24b75f102bb70b016
|
4
|
+
data.tar.gz: 1b5b43910b029f8553f54ddfa5d70a7195b2db86d35a38ba1fcffc37521b7d4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d636b920cb207c03ce1f96ceeb47ec478214743e0ef4f49895c07982fcf68d2b724d4006058ef00de6903c986c6f40e8678ebbb7ccdaa681d6b552cfb70111a1
|
7
|
+
data.tar.gz: 5254cb1f323cb46af16b889d82ffd565a9a0f30e5665cc6c5487e59926f25e66b8a573e004ffcf4c2a34b8f17187b0e67443ef5bf5ffec3b8e2a68e079557def
|
@@ -15,9 +15,7 @@ module Pechkin
|
|
15
15
|
use Prometheus::Middleware::Collector, registry: prometheus
|
16
16
|
# Add Auth check if found htpasswd file or it was excplicitly provided
|
17
17
|
# See CLI class for configuration details
|
18
|
-
if options.htpasswd
|
19
|
-
use Pechkin::Auth::Middleware, auth_file: options.htpasswd
|
20
|
-
end
|
18
|
+
use Pechkin::Auth::Middleware, auth_file: options.htpasswd if options.htpasswd
|
21
19
|
use Prometheus::Middleware::Exporter, registry: prometheus
|
22
20
|
|
23
21
|
run app
|
@@ -34,7 +32,7 @@ module Pechkin
|
|
34
32
|
file = File.open(log_file, File::WRONLY | File::APPEND)
|
35
33
|
Logger.new(file)
|
36
34
|
else
|
37
|
-
Logger.new(
|
35
|
+
Logger.new($stdout)
|
38
36
|
end
|
39
37
|
end
|
40
38
|
end
|
@@ -2,7 +2,7 @@ module Pechkin
|
|
2
2
|
# Http requests handler. We need fresh instance per each request. To keep
|
3
3
|
# internal state isolated
|
4
4
|
class RequestHandler
|
5
|
-
REQ_PATH_PATTERN = %r{^/(.+)/([^/]+)/?$}
|
5
|
+
REQ_PATH_PATTERN = %r{^/(.+)/([^/]+)/?$}.freeze
|
6
6
|
|
7
7
|
attr_reader :req, :handler,
|
8
8
|
:channel_id, :message_id,
|
data/lib/pechkin/auth.rb
CHANGED
data/lib/pechkin/channel.rb
CHANGED
@@ -3,7 +3,7 @@ module Pechkin
|
|
3
3
|
class Chanel
|
4
4
|
attr_accessor :logger
|
5
5
|
|
6
|
-
def initialize(connector, channel_list, logger = ::Logger.new(
|
6
|
+
def initialize(connector, channel_list, logger = ::Logger.new($stdout))
|
7
7
|
@connector = connector
|
8
8
|
@channel_list = channel_list
|
9
9
|
@channel_list = [channel_list] unless channel_list.is_a?(Array)
|
data/lib/pechkin/cli.rb
CHANGED
@@ -13,7 +13,7 @@ module Pechkin
|
|
13
13
|
# @opt names [Array<String>] list of command line keys
|
14
14
|
# @opt desc [String] option description
|
15
15
|
# @opt type [Class] argument type to parse from command line, e.g. Integer
|
16
|
-
def opt(name, default: nil,
|
16
|
+
def opt(name, names:, default: nil, desc: '', type: nil)
|
17
17
|
@cli_options ||= []
|
18
18
|
|
19
19
|
# raise ':names is nil or empty' if names.nil? || names.empty?
|
data/lib/pechkin/command/base.rb
CHANGED
@@ -9,7 +9,7 @@ module Pechkin
|
|
9
9
|
# command behaviour
|
10
10
|
# @opt stdout [IO] IO object which represents STDOUT
|
11
11
|
# @opt stderr [IO] IO object which represents STDERR
|
12
|
-
def initialize(options, stdout:
|
12
|
+
def initialize(options, stdout: $stdout, stderr: $stderr)
|
13
13
|
@options = options
|
14
14
|
@stdout = stdout
|
15
15
|
@stderr = stderr
|
@@ -15,9 +15,7 @@ module Pechkin
|
|
15
15
|
def load_bots_configuration(working_dir, bots)
|
16
16
|
bots_dir = File.join(working_dir, 'bots')
|
17
17
|
|
18
|
-
unless File.directory?(bots_dir)
|
19
|
-
raise ConfigurationError, "'#{bots_dir}' is not a directory"
|
20
|
-
end
|
18
|
+
raise ConfigurationError, "'#{bots_dir}' is not a directory" unless File.directory?(bots_dir)
|
21
19
|
|
22
20
|
Dir["#{bots_dir}/*.yml"].each do |bot_file|
|
23
21
|
name = File.basename(bot_file, '.yml')
|
@@ -22,9 +22,7 @@ module Pechkin
|
|
22
22
|
def load_channels_configuration(working_dir, channels)
|
23
23
|
channels_dir = File.join(working_dir, 'channels')
|
24
24
|
|
25
|
-
unless File.directory?(channels_dir)
|
26
|
-
raise ConfigurationError, "'#{channels_dir}' is not a directory"
|
27
|
-
end
|
25
|
+
raise ConfigurationError, "'#{channels_dir}' is not a directory" unless File.directory?(channels_dir)
|
28
26
|
|
29
27
|
Dir["#{channels_dir}/*"].each do |channel_dir|
|
30
28
|
next unless File.directory?(channel_dir)
|
@@ -63,9 +61,7 @@ module Pechkin
|
|
63
61
|
message_config = YAML.safe_load(IO.read(file))
|
64
62
|
name = File.basename(file, '.yml')
|
65
63
|
|
66
|
-
if message_config.key?('template')
|
67
|
-
message_config['template'] = get_template(message_config['template'])
|
68
|
-
end
|
64
|
+
message_config['template'] = get_template(message_config['template']) if message_config.key?('template')
|
69
65
|
|
70
66
|
messages[name] = message_config
|
71
67
|
end
|
@@ -15,9 +15,7 @@ module Pechkin
|
|
15
15
|
def load_views_configuration(working_dir, views)
|
16
16
|
views_dir = File.join(working_dir, 'views')
|
17
17
|
|
18
|
-
unless File.directory?(views_dir)
|
19
|
-
raise ConfigurationError, "'#{views_dir}' is not a directory"
|
20
|
-
end
|
18
|
+
raise ConfigurationError, "'#{views_dir}' is not a directory" unless File.directory?(views_dir)
|
21
19
|
|
22
20
|
Dir["#{views_dir}/**/*.erb"].each do |f|
|
23
21
|
relative_path = f["#{views_dir}/".length..-1]
|
data/lib/pechkin/exceptions.rb
CHANGED
data/lib/pechkin/handler.rb
CHANGED
@@ -5,7 +5,7 @@ module Pechkin
|
|
5
5
|
attr_reader :channels, :message_matcher
|
6
6
|
attr_accessor :logger
|
7
7
|
|
8
|
-
def initialize(channels, stdout =
|
8
|
+
def initialize(channels, stdout = $stdout, stderr = $stderr)
|
9
9
|
@channels = channels
|
10
10
|
# Create empty logger by default
|
11
11
|
@logger = Logger.new(IO::NULL)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module Pechkin
|
2
2
|
class MessageMatchError < StandardError; end
|
3
|
+
|
3
4
|
# Allows to match message configuration against received data.
|
4
5
|
#
|
5
6
|
# Data is checked againts either allow or forbid rules. But not both at the
|
@@ -51,11 +52,12 @@ module Pechkin
|
|
51
52
|
# can take one field in rule and check it separately as new rule. If all
|
52
53
|
# fields are passed check then whole rule passed.
|
53
54
|
def check_rule(top_rule, sub_rule, data)
|
54
|
-
result =
|
55
|
+
result = case sub_rule
|
56
|
+
when Hash
|
55
57
|
check_hash_rule(top_rule, sub_rule, data)
|
56
|
-
|
58
|
+
when Array
|
57
59
|
check_array_rule(top_rule, sub_rule, data)
|
58
|
-
|
60
|
+
when String
|
59
61
|
check_string_rule(top_rule, sub_rule, data)
|
60
62
|
else
|
61
63
|
sub_rule.eql?(data)
|
data/lib/pechkin/version.rb
CHANGED
data/lib/pechkin.rb
CHANGED
@@ -28,8 +28,8 @@ module Pechkin # :nodoc:
|
|
28
28
|
cmd = Command::Dispatcher.new(options).dispatch
|
29
29
|
cmd.execute
|
30
30
|
rescue StandardError => e
|
31
|
-
warn
|
32
|
-
warn "\t
|
31
|
+
warn "Error: #{e.message}"
|
32
|
+
warn "\t#{e.backtrace.reverse.join("\n\t")}" if options.debug?
|
33
33
|
exit 2
|
34
34
|
end
|
35
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pechkin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Arkhanhelsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: htauth
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.1.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.1.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: powerpack
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.
|
61
|
+
version: 2.2.3
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.
|
68
|
+
version: 2.2.3
|
69
69
|
description:
|
70
70
|
email: ilya.arkhanhelsky at gmail.com
|
71
71
|
executables:
|
@@ -117,16 +117,16 @@ require_paths:
|
|
117
117
|
- lib
|
118
118
|
required_ruby_version: !ruby/object:Gem::Requirement
|
119
119
|
requirements:
|
120
|
-
- - "
|
120
|
+
- - ">"
|
121
121
|
- !ruby/object:Gem::Version
|
122
|
-
version: '
|
122
|
+
version: '2.5'
|
123
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
124
|
requirements:
|
125
125
|
- - ">="
|
126
126
|
- !ruby/object:Gem::Version
|
127
127
|
version: '0'
|
128
128
|
requirements: []
|
129
|
-
rubygems_version: 3.
|
129
|
+
rubygems_version: 3.2.22
|
130
130
|
signing_key:
|
131
131
|
specification_version: 4
|
132
132
|
summary: Web service to proxy webhooks to Telegram Bot API
|