remi 0.2.25 → 0.2.26
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/Gemfile.lock +1 -1
- data/features/step_definitions/remi_step.rb +4 -0
- data/features/support/env.rb +17 -2
- data/lib/remi/cucumber/business_rules.rb +23 -3
- data/lib/remi/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 783520781cb755c4f317a95122e3395296ac15da
|
4
|
+
data.tar.gz: 7bbbfd2df7aaa94f3604fec9d77d93f41e3f7740
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f06fda56e67c2dcc7884c13d1fa19a11f5c8d23438a331801b1d312c095ae9d13fae0a723a803b5fae62975832c075e702121d5c9f3621124f628bfca48969b9
|
7
|
+
data.tar.gz: 58d6e66fd1cbe3b79a9938b8e26efb5d2a86ab43e8b3832e4addce69e4f4c215fcd8b4a623c7f5e82fdcf22c884bae5f162a566e419ee75a960930cde090e3da
|
data/Gemfile.lock
CHANGED
@@ -97,6 +97,10 @@ Given /^the (source|target) file uses ([\w ]+) line endings$/ do |st, line_endin
|
|
97
97
|
expect(@brt.send(st.to_sym).csv_options[:row_sep]).to eq Remi::BusinessRules.csv_opt_map[line_endings]
|
98
98
|
end
|
99
99
|
|
100
|
+
Given /^the (source|target) file uses "([^"]+)" as a record separator$/ do |st, line_endings|
|
101
|
+
expect(@brt.send(st.to_sym).csv_options[:row_sep]).to eq line_endings.gsub(/\\n/, "\n").gsub(/\\r/, "\r")
|
102
|
+
end
|
103
|
+
|
100
104
|
Given /^the (source|target) file (contains|does not contain) a header row$/ do |st, header|
|
101
105
|
expect(@brt.send(st.to_sym).csv_options[:headers]).to eq (header == 'contains')
|
102
106
|
end
|
data/features/support/env.rb
CHANGED
@@ -5,8 +5,6 @@ require 'bundler/setup'
|
|
5
5
|
require 'remi'
|
6
6
|
require 'remi/cucumber'
|
7
7
|
|
8
|
-
require_relative 'env_app.rb'
|
9
|
-
|
10
8
|
Remi::Settings.log_level = Logger::ERROR
|
11
9
|
|
12
10
|
Before do
|
@@ -35,3 +33,20 @@ Before '@fails' do
|
|
35
33
|
end
|
36
34
|
end
|
37
35
|
end
|
36
|
+
|
37
|
+
|
38
|
+
# Fix current time to the first time it is called in a test
|
39
|
+
module TimeTesting
|
40
|
+
def current
|
41
|
+
@current_time ||= super
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class Time
|
46
|
+
class << Time
|
47
|
+
prepend TimeTesting
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Include user-defined environment
|
52
|
+
require_relative 'env_app.rb'
|
@@ -29,9 +29,10 @@ module Remi::BusinessRules
|
|
29
29
|
|
30
30
|
def formulas
|
31
31
|
@formulas ||= RegexSieve.new({
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
/\*now(|:[^*]+)\*/i => [:time_reference, :match_now],
|
33
|
+
/\*(today|yesterday|tomorrow)(|:[^*]+)\*/i => [:date_reference, :match_single_day],
|
34
|
+
/\*(this|last|previous|next) (day|month|year|week)(|:[^*]+)\*/i => [:date_reference, :match_single_unit],
|
35
|
+
/\*(\d+)\s(day|days|month|months|year|years|week|weeks) (ago|from now)(|:[^*]+)\*/i => [:date_reference, :match_multiple]
|
35
36
|
})
|
36
37
|
end
|
37
38
|
|
@@ -44,6 +45,8 @@ module Remi::BusinessRules
|
|
44
45
|
to_replace = form.match(base_regex)[0]
|
45
46
|
replace_with = if form_opt[:value][0] == :date_reference
|
46
47
|
date_reference(form_opt[:value][1], form_opt[:match])
|
48
|
+
elsif form_opt[:value][0] == :time_reference
|
49
|
+
time_reference(form_opt[:value][1], form_opt[:match])
|
47
50
|
else
|
48
51
|
to_replace
|
49
52
|
end
|
@@ -51,6 +54,10 @@ module Remi::BusinessRules
|
|
51
54
|
form.gsub(to_replace, replace_with)
|
52
55
|
end
|
53
56
|
|
57
|
+
def time_reference(formula, captured)
|
58
|
+
parsed = self.send("time_reference_#{formula}", *captured)
|
59
|
+
Time.current.send("#{parsed[:unit]}_#{parsed[:direction]}", parsed[:quantity]).strftime(parsed[:format])
|
60
|
+
end
|
54
61
|
|
55
62
|
def date_reference(formula, captured)
|
56
63
|
parsed = self.send("date_reference_#{formula}", *captured)
|
@@ -61,6 +68,19 @@ module Remi::BusinessRules
|
|
61
68
|
str.blank? ? '%Y-%m-%d' : str.slice(1..-1).strip
|
62
69
|
end
|
63
70
|
|
71
|
+
def parse_colon_time_format(str)
|
72
|
+
str.blank? ? '%Y-%m-%d %H:%M:%S' : str.slice(1..-1).strip
|
73
|
+
end
|
74
|
+
|
75
|
+
def time_reference_match_now(form, format=nil)
|
76
|
+
{
|
77
|
+
quantity: 0,
|
78
|
+
unit: 'days',
|
79
|
+
direction: 'ago',
|
80
|
+
format: parse_colon_time_format(format)
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
64
84
|
def date_reference_match_single_day(form, direction, format=nil)
|
65
85
|
{
|
66
86
|
quantity: direction.downcase == 'today' ? 0 : 1,
|
data/lib/remi/version.rb
CHANGED