Hi Ian & co,
I have also been trying to allow pickle to understand time formats.
The best way to do it - methinks - is to hook into the cucumber
transforms. So I have the following transform:
Transform /^(\d+) (second|minute|hour|day|week|fortnight|year)s? (from
[_ ]now|ago)$/ do |number, unit, time_arrow|
number.to_i.send(unit).send(
time_arrow.tr(' ', '_'))
end
And then all we need is for pickle to apply the transforms to it's
matched values...
I got it to work by hacking into pickle's Parser::parse_field method.
Since I considered this just a spike, I have not written any specs for
it yet. The ugliest part of the code is getting a hold of the cucumber
language set which is where the transforms live. Before submitting a
real patch, I will write a cucumber patch that will provide a better
way of getting hold of this. So please ignore the resulting ugliness,
it will be engineered away.
I was hoping you could put an eyeball on the code and if you can think
of any issues with this.
http://github.com/tomtt/pickle/tree/apply_transforms
Running garlic there were no failing specs, but they did not pass due
to lack of coverage.
Cheers, Tom.
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Tom ten Thij
Unboxed Consulting,
http://unboxedconsulting.com
T:
+44 20 3137 2943 F:
+44 20 7183 4251
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~