Skip to content

Commit

Permalink
Strip nat before parsing, gh-74
Browse files Browse the repository at this point in the history
  • Loading branch information
jmettraux committed Aug 23, 2022
1 parent 6025fb0 commit 6eaf79d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/fugit/nat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def parse(s, opts={})

return nil unless s.is_a?(String)

s = s.strip

#p s; Raabro.pp(Parser.parse(s, debug: 3), colours: true)
#(p s; Raabro.pp(Parser.parse(s, debug: 1), colours: true)) rescue nil

Expand Down
25 changes: 25 additions & 0 deletions spec/nat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,28 @@
end
end

describe Fugit do

describe '.parse_nat' do

{

"every day at five" => '0 5 * * *',
"every day at 5 pm in Asia/Tokyo" => '0 17 * * * Asia/Tokyo',
" \nevery day at five \n" => '0 5 * * *',
"\n every day at 5 pm in Asia/Tokyo\n" => '0 17 * * * Asia/Tokyo',

}.each do |src, cron_s|

it "strips and parses #{src.inspect}" do

r = Fugit.parse_nat(src)

expect(r.class).to eq(Fugit::Cron)
expect(r.to_cron_s).to eq(cron_s)
end
end
end
end


0 comments on commit 6eaf79d

Please sign in to comment.