Skip to content

Commit

Permalink
added dm_* aliases for all methods to get around name collisions
Browse files Browse the repository at this point in the history
  • Loading branch information
cheezy committed Feb 7, 2013
1 parent 46da66a commit 979ad18
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
@@ -1,3 +1,8 @@
=== Version 0.13
* Enhancements
* Added months translator
* Added dm_* aliases for all generators

=== Version 0.12 / 2012-12-28
* Enhancements
* Added today translator
Expand Down
3 changes: 3 additions & 0 deletions lib/data_magic/date_translation.rb
Expand Up @@ -11,6 +11,7 @@ module DateTranslation
def today(format = '%D')
Date.today.strftime(format)
end
alias_method :dm_today, :today

#
# return tomorrow's date
Expand All @@ -24,6 +25,7 @@ def tomorrow(format = '%D')
tomorrow = Date.today + 1
tomorrow.strftime(format)
end
alias_method :dm_tomorrow, :tomorrow

#
# return yesterday's date
Expand All @@ -37,5 +39,6 @@ def yesterday(format = '%D')
yesterday = Date.today - 1
yesterday.strftime(format)
end
alias_method :dm_yesterday, :yesterday
end
end
28 changes: 28 additions & 0 deletions lib/data_magic/translation.rb
Expand Up @@ -6,90 +6,103 @@ module Translation
def full_name
Faker::Name.name
end
alias_method :dm_full_name, :full_name

#
# return a random first name
#
def first_name
Faker::Name.first_name
end
alias_method :dm_first_name, :first_name

#
# return a random last name
#
def last_name
Faker::Name.last_name
end
alias_method :dm_last_name, :last_name

#
# return a random name prefix
#
def name_prefix
Faker::Name.prefix
end
alias_method :dm_name_prefix, :name_prefix

#
# return a random name suffix
#
def name_suffix
Faker::Name.suffix
end
alias_method :dm_name_suffix, :name_suffix

#
# return a random title
#
def title
Faker::Name.title
end
alias_method :dm_title, :title

#
# return a random street address
#
def street_address(include_secondary=false)
Faker::Address.street_address(include_secondary)
end
alias_method :dm_street_address, :street_address

#
# return a random secondary address
#
def secondary_address
Faker::Address.secondary_address
end
alias_method :dm_secondary_address, :secondary_address

#
# return a random city
#
def city
Faker::Address.city
end
alias_method :dm_city, :city

#
# return a random state
#
def state
Faker::Address.state
end
alias_method :dm_state, :state

#
# return a random state abbreviation
#
def state_abbr
Faker::Address.state_abbr
end
alias_method :dm_state_abbr, :state_abbr

#
# return a random 5 or 9 digit zip code
#
def zip_code
Faker::Address.zip
end
alias_method :dm_zip_code, :zip_code

#
# return a random country
#
def country
Faker::Address.country
end
alias_method :dm_country, :country


#
Expand All @@ -98,76 +111,87 @@ def country
def company_name
Faker::Company.name
end
alias_method :dm_company_name, :company_name

#
# return a random catch phrase
#
def catch_phrase
Faker::Company.catch_phrase
end
alias_method :dm_catch_phrase, :catch_phrase

#
# return random words - default is 3 words
#
def words(number = 3)
Faker::Lorem.words(number).join(' ')
end
alias_method :dm_words, :words

#
# return a random sentence - default minimum word count is 4
#
def sentence(min_word_count = 4)
Faker::Lorem.sentence(min_word_count)
end
alias_method :dm_sentence, :sentence

#
# return random sentences - default is 3 sentences
#
def sentences(sentence_count = 3)
Faker::Lorem.sentences(sentence_count).join(' ')
end
alias_method :dm_sentences, :sentences

#
# return random paragraphs - default is 3 paragraphs
#
def paragraphs(paragraph_count = 3)
Faker::Lorem.paragraphs(paragraph_count).join('\n\n')
end
alias_method :dm_paragraphs, :paragraphs

#
# return random characters - default is 255 characters
#
def characters(character_count = 255)
Faker::Lorem.characters(character_count)
end
alias_method :dm_characters, :characters

#
# return a random email address
#
def email_address(name=nil)
Faker::Internet.email(name)
end
alias_method :dm_email_address, :email_address

#
# return a random domain name
#
def domain_name
Faker::Internet.domain_name
end
alias_method :dm_domain_name, :domain_name

#
# return a random url
#
def url
Faker::Internet.url
end
alias_method :dm_url, :url

#
# return a random user name
#
def user_name
Faker::Internet.user_name
end
alias_method :dm_user_name, :user_name

#
# return a random phone number
Expand All @@ -176,6 +200,7 @@ def phone_number
value = Faker::PhoneNumber.phone_number
remove_extension(value)
end
alias_method :dm_phone_number, :phone_number

#
# return a random cell number
Expand All @@ -184,6 +209,7 @@ def cell_phone
value = Faker::PhoneNumber.cell_phone
remove_extension(value)
end
alias_method :dm_cell_phone, :cell_phone

#
# return a random value from an array or range
Expand All @@ -195,6 +221,7 @@ def randomize(value)
else value
end
end
alias_method :dm_randomize, :randomize

#
# return a value based on a mast
Expand All @@ -214,6 +241,7 @@ def mask(value)
end
result
end
alias_method :dm_mask, :mask

def month
randomize(%w[January February March April May June July August September October November December])
Expand Down

0 comments on commit 979ad18

Please sign in to comment.