pechkin 1.0.2 → 1.0.3

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: c55d33ae23eb9132b6f63595dd39161b0a8f32fe48fa9dc34659b591f94f9da5
4
- data.tar.gz: 9fd2dd3bf7ea025c853c9230a5d3eb0914f1e6da8ba44c645260ac9547a9dbe4
3
+ metadata.gz: b1676e5e77d5898b67a9614012f5d982cb2c75c97847ba8fe22bfaf409988f78
4
+ data.tar.gz: bd7a612a913ce4433ec8a4d78687f5eddb75b1cf28ca6675f33833b0ebc76955
5
5
  SHA512:
6
- metadata.gz: e9053f20524428bd653c9c03df3cd8c8f2d575a79c5e73b9ebacd97f81f6a02ce6e603bd82e8674b2e72e4d6eae87a872492c67c43a637be710398ac9e122147
7
- data.tar.gz: 51b92ecafaa72cc5baee024dd154a9dbe85a0675c98864730f7a021c2058d33cc337171e0064fb514c9f11349a5307da828d4a5cc3ecc4dddb80eded1738a357
6
+ metadata.gz: 806a857ddaf52ead16bbeec58bd1b9b4d3af8690011297fa35014058d3f0b1510ffa6694e4a651f33eab71814cae677b12d169df2c1a2fbd26eb57fd0f017169
7
+ data.tar.gz: c699ddf5ad93cc7e5c9996fa398d734a5029fef470311c488cfc0d3df4d7124e8bb7b02498e7e69e27ce64d8109f5bab27f264642feefba5dc5a7ab6947877d1
@@ -8,8 +8,37 @@ module Pechkin
8
8
 
9
9
  # Message template to render final message.
10
10
  class MessageTemplate
11
+ class << self
12
+ def ruby_v260_or_later?(ruby_version = RUBY_VERSION)
13
+ # Need to compare two versions, one is 2.6.0 - which supports keyword
14
+ # arguments in ERB#initialize. Everything below that should use legacy
15
+ # arguments
16
+ rb_v260 = [2, 6, 0]
17
+ rb_current = ruby_version.split('.').map(&:to_i)
18
+
19
+ rb_v260.zip(rb_current).each do |x, y|
20
+ x ||= 0
21
+ y ||= 0
22
+ return false if y < x
23
+ end
24
+
25
+ true
26
+ end
27
+ end
28
+
29
+ RUBY_V260 = MessageTemplate.ruby_v260_or_later?
30
+
11
31
  def initialize(erb)
12
- @erb_template = ERB.new(erb, nil, trim_mode: '-')
32
+ # ERB#initialize has different signature starting from Ruby 2.6.*
33
+ # See link:
34
+ # https://github.com/ruby/ruby/blob/2311087/NEWS#stdlib-updates-outstanding-ones-only
35
+ if MessageTemplate::RUBY_V260
36
+ @erb_template = ERB.new(erb, trim_mode: '-')
37
+ else
38
+ safe_level = nil
39
+ trim_mode = '-'
40
+ @erb_template = ERB.new(erb, safe_level, trim_mode)
41
+ end
13
42
  end
14
43
 
15
44
  def render(data)
@@ -1,7 +1,7 @@
1
1
  module Pechkin
2
2
  # Keeps actual version
3
3
  module Version
4
- VERSION = [1, 0, 2].freeze
4
+ VERSION = [1, 0, 3].freeze
5
5
  class << self
6
6
  def version_string
7
7
  VERSION.join('.')
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.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Arkhanhelsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-10 00:00:00.000000000 Z
11
+ date: 2019-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape