pechkin 1.0.0 → 1.0.1

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
2
  SHA256:
3
- metadata.gz: 4b9031bb8570fd2ca66241e30271167194aebae7a832ecdc3b98fb07630505e2
4
- data.tar.gz: 57685b4ededcd3935e412611750b0ed716f386b5d759f88004993cd64162f90d
3
+ metadata.gz: 966f3990124a55de12aa9c9d29af6e1cec929fd316e64db6940bcec3157f5828
4
+ data.tar.gz: cc818d878a47c8c7ff816c20e42cdc0a0a02e7046e8955f82290794c6e3179dd
5
5
  SHA512:
6
- metadata.gz: 3d04eab93cb96a74e68a1f3d7b47707c917c8909b20d251180db0dadfa0144b35b38ac6be19dfed89c4fc66f1ab50ae9d83f9f4df7782bd05c1b085e246d388a
7
- data.tar.gz: 680509c985a97814062b85d3039268334f8b8b5623a4724c772c2c054f4fdbcddf32d13c2dd94d2932119a9c445c1664472730eb5c2f1ceda982d9314584155b
6
+ metadata.gz: 9765527f70a1565db8cb5192579b6ba3d6529de6ead792be6825ff8818077ffcef46f67d91e5ac62745553532391a92cfb96c8ee5130681b248e99c55479532b
7
+ data.tar.gz: 4a0e8de6ec9c458a895e4df1b26b2a5b89c66d581e4cbd8cdec300bf137a0783838e6c3340f7984f9801913e9e7661c44ab6e87d5954d79d0769111ae618aaaf
data/lib/pechkin.rb CHANGED
@@ -55,22 +55,29 @@ module Pechkin # :nodoc:
55
55
  end
56
56
 
57
57
  def send_data
58
- ch, msg = options.send_data.match(%r{^([^/]+)/(.+)}) do |m|
59
- [m[1], m[2]]
60
- end
58
+ ch, msg = parse_endpoint(options.send_data)
61
59
 
62
60
  raise "#{ch}/#{msg} not found" unless handler.message?(ch, msg)
63
61
 
64
- data = options.data
65
- if data.start_with?('@')
66
- f = data[1..-1]
67
- raise "File not found #{f}" unless File.exist?(f)
68
-
69
- data = IO.read(f)
70
- end
62
+ data = read_data(options.data)
71
63
 
72
64
  handler.preview = options.preview
73
65
  handler.handle(ch, msg, JSON.parse(data, symbolize_names: true))
74
66
  end
67
+
68
+ def read_data(data)
69
+ return data unless data.start_with?('@')
70
+
71
+ file = data[1..-1]
72
+ raise "File not found #{file}" unless File.exist?(file)
73
+
74
+ IO.read(file)
75
+ end
76
+
77
+ def parse_endpoint(endpoint)
78
+ endpoint.match(%r{^([^/]+)/(.+)}) do |m|
79
+ [m[1], m[2]]
80
+ end
81
+ end
75
82
  end
76
83
  end
data/lib/pechkin/app.rb CHANGED
@@ -40,8 +40,8 @@ module Pechkin
40
40
  def call(env)
41
41
  RequestHandler.new(handler, env).handle
42
42
  rescue StandardError => e
43
- body = '{"status": "error", "reason":"' + e.message + '"'
44
- ['503', { 'Content-Type' => 'application/json' }, body]
43
+ body = { status: 'error', reason: e.message }.to_json
44
+ ['503', { 'Content-Type' => 'application/json' }, [body]]
45
45
  end
46
46
  end
47
47
 
@@ -95,7 +95,7 @@ module Pechkin
95
95
  end
96
96
 
97
97
  def response(code, body)
98
- [code.to_s, DEFAULT_HEADERS, body]
98
+ [code.to_s, DEFAULT_HEADERS, [body]]
99
99
  end
100
100
 
101
101
  def post?
@@ -25,7 +25,7 @@ module Pechkin
25
25
  # Find message and try substitute values to message parameters.
26
26
  message_config = substitute(data, fetch_message(channel_config, msg_id))
27
27
 
28
- data = (message_config['parameters'] || {}).merge(data)
28
+ data = (message_config['variables'] || {}).merge(data)
29
29
  template = message_config['template']
30
30
 
31
31
  text = ''
@@ -1,7 +1,7 @@
1
1
  module Pechkin
2
2
  # Keeps actual version
3
3
  module Version
4
- VERSION = [1, 0, 0].freeze
4
+ VERSION = [1, 0, 1].freeze
5
5
  class << self
6
6
  def version_string
7
7
  VERSION.join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pechkin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Arkhanhelsky
@@ -25,33 +25,33 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.1.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: rack
28
+ name: prometheus-client
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 2.0.6
33
+ version: 1.0.0
34
34
  type: :runtime
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: 2.0.6
40
+ version: 1.0.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: prometheus-client
42
+ name: rack
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 1.0.0
47
+ version: 2.0.6
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 1.0.0
54
+ version: 2.0.6
55
55
  description:
56
56
  email: ilya.arkhanhelsky at gmail.com
57
57
  executables: