remi 0.2.25 → 0.2.26

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
  SHA1:
3
- metadata.gz: 46d71d9a012df7bc2c06ad438a1e1ad93d148090
4
- data.tar.gz: a2f7d72215d30dcd1be49ea892f4f77e6839d642
3
+ metadata.gz: 783520781cb755c4f317a95122e3395296ac15da
4
+ data.tar.gz: 7bbbfd2df7aaa94f3604fec9d77d93f41e3f7740
5
5
  SHA512:
6
- metadata.gz: d1c43fc32999b96398b4300b06b94ef9d00d87223ea460ec8f8b4b356bb8cc25a8f44861e6dc817db7bc290513687a5fc1ec75b2685d1a13dbc038af7a059cd5
7
- data.tar.gz: 2f6691422a63b487921066a8e29835864d0f542caf9cb170ce5158e56714620aa9f85dd16cc8e9bf22bca832c461a8ff6d00584312d53dac788ada1d4ce629a8
6
+ metadata.gz: f06fda56e67c2dcc7884c13d1fa19a11f5c8d23438a331801b1d312c095ae9d13fae0a723a803b5fae62975832c075e702121d5c9f3621124f628bfca48969b9
7
+ data.tar.gz: 58d6e66fd1cbe3b79a9938b8e26efb5d2a86ab43e8b3832e4addce69e4f4c215fcd8b4a623c7f5e82fdcf22c884bae5f162a566e419ee75a960930cde090e3da
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- remi (0.2.25)
4
+ remi (0.2.26)
5
5
  activesupport (~> 4.2)
6
6
  bond (~> 0.5)
7
7
  cucumber (~> 2.1)
@@ -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
@@ -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
- /(today|yesterday|tomorrow)(|:[^*]+)\*/i => [:date_reference, :match_single_day],
33
- /(this|last|previous|next) (day|month|year|week)(|:[^*]+)\*/i => [:date_reference, :match_single_unit],
34
- /(\d+)\s(day|days|month|months|year|years|week|weeks) (ago|from now)(|:[^*]+)\*/i => [:date_reference, :match_multiple]
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
@@ -1,3 +1,3 @@
1
1
  module Remi
2
- VERSION = '0.2.25'
2
+ VERSION = '0.2.26'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.25
4
+ version: 0.2.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sterling Paramore