lib/waddup/cli.rb in waddup-0.0.2 vs lib/waddup/cli.rb in waddup-0.1.0
- old
+ new
@@ -5,13 +5,13 @@
class CLI
attr_accessor :sources, :from, :to
KEYWORDS = {
- :sources => %w[with],
- :from => %w[from since],
- :to => %w[to until uptil upto through]
+ sources: %w[with],
+ from: %w[from since],
+ to: %w[to until uptil upto through]
}
KEYWORD_BOUNDARY = "(?:\\s#{KEYWORDS.values.flatten.join('|\\s')}|\\Z)"
def parse!
@@ -21,14 +21,14 @@
sources.include? source::ALIAS
end
end
parse_keyword :from do |match|
- @from = Chronic.parse match[1]
+ @from = Chronic.parse match[1], context: :past
end
parse_keyword :to do |match|
- @to = Chronic.parse match[1]
+ @to = Chronic.parse match[1], context: :past
end
end
def parse_keyword(keyword, &block)
@arguments.match /(?:#{KEYWORDS[keyword].join('|')})\s(.+?)#{KEYWORD_BOUNDARY}/i, &block