Skip to content

Commit

Permalink
added day_of_week translator
Browse files Browse the repository at this point in the history
  • Loading branch information
cheezy committed Feb 15, 2013
1 parent da6cc87 commit afe31d0
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,7 @@
=== Version 0.14 === Version 0.14
* Enhancements * Enhancements
* Added months_abbr translator * Added months_abbr translator
* Added day_of_week translator
* Changed so translator methods are not call after mixing with class * Changed so translator methods are not call after mixing with class


=== Version 0.13 / 2013-2-7 === Version 0.13 / 2013-2-7
Expand Down
3 changes: 3 additions & 0 deletions features/data_magic.feature
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ Feature: Functionality of the data_magic gem
Scenario: Getting a random month abbreviation Scenario: Getting a random month abbreviation
Then the value for "month_abbr" should be a valid month abbreviation Then the value for "month_abbr" should be a valid month abbreviation


Scenario: Getting a day name
Then the value for "some_day" should be a valid day

Scenario: It should allow one to add new translator methods Scenario: It should allow one to add new translator methods
When I add the blah translator When I add the blah translator
Then the value for "blah" should be "foobar" Then the value for "blah" should be "foobar"
5 changes: 5 additions & 0 deletions features/step_definitions/data_magic_steps.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ class TestClass
months.should include @data[key] months.should include @data[key]
end end


Then /^the value for "(.*?)" should be a valid day$/ do |key|
days = %w[Sunday Monday Tuesday Wednesday Thursday Friday Saturday]
days.should include @data[key]
end

When /^I add the blah translator$/ do When /^I add the blah translator$/ do
module Blah module Blah
def blah def blah
Expand Down
1 change: 1 addition & 0 deletions features/yaml/example.yml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dm:
5daysago: ~5.days_ago 5daysago: ~5.days_ago
some_month: ~month some_month: ~month
month_abbr: ~month_abbr month_abbr: ~month_abbr
some_day: ~day_of_week


dynamic: dynamic:
blah: ~blah blah: ~blah
Expand Down
10 changes: 10 additions & 0 deletions lib/data_magic/date_translation.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ def month
def month_abbr def month_abbr
randomize(Date::ABBR_MONTHNAMES[1..-1]) randomize(Date::ABBR_MONTHNAMES[1..-1])
end end
alias_method :dm_month_abbr, :month_abbr


#
# return a day of the week
#
def day_of_week
randomize(Date::DAYNAMES)
end
alias_method :dm_day_of_week, :day_of_week


end end
end end

0 comments on commit afe31d0

Please sign in to comment.