faker 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/History.txt +3 -0
  3. data/README.md +42 -6
  4. data/lib/faker.rb +11 -2
  5. data/lib/faker/address.rb +1 -0
  6. data/lib/faker/avatar.rb +2 -2
  7. data/lib/faker/business.rb +4 -4
  8. data/lib/faker/code.rb +33 -1
  9. data/lib/faker/company.rb +6 -0
  10. data/lib/faker/date.rb +34 -0
  11. data/lib/faker/hacker.rb +31 -0
  12. data/lib/faker/internet.rb +7 -4
  13. data/lib/faker/number.rb +41 -3
  14. data/lib/faker/phone_number.rb +3 -3
  15. data/lib/faker/time.rb +48 -0
  16. data/lib/faker/version.rb +1 -1
  17. data/lib/locales/{de-at.yml → de-AT.yml} +1 -1
  18. data/lib/locales/{de-ch.yml → de-CH.yml} +1 -1
  19. data/lib/locales/{en-au.yml → en-AU.yml} +1 -1
  20. data/lib/locales/{en-bork.yml → en-BORK.yml} +1 -1
  21. data/lib/locales/{en-ca.yml → en-CA.yml} +1 -1
  22. data/lib/locales/{en-gb.yml → en-GB.yml} +1 -1
  23. data/lib/locales/{en-ind.yml → en-IND.yml} +1 -1
  24. data/lib/locales/{en-nep.yml → en-NEP.yml} +0 -0
  25. data/lib/locales/{en-us.yml → en-US.yml} +1 -1
  26. data/lib/locales/en.yml +10 -2
  27. data/lib/locales/fr.yml +1 -1
  28. data/lib/locales/ja.yml +2 -0
  29. data/lib/locales/{nb-no.yml → nb-NO.yml} +1 -1
  30. data/lib/locales/pl.yml +1 -1
  31. data/lib/locales/{pt-br.yml → pt-BR.yml} +2 -2
  32. data/lib/locales/ru.yml +9 -0
  33. data/lib/locales/sk.yml +1 -1
  34. data/lib/locales/zh-CN.yml +27 -0
  35. data/test/test_en_us_locale.rb +2 -2
  36. data/test/test_faker_code.rb +12 -0
  37. data/test/test_faker_company.rb +7 -0
  38. data/test/test_faker_date.rb +52 -0
  39. data/test/test_faker_hacker_talk.rb +37 -0
  40. data/test/test_faker_internet.rb +7 -0
  41. data/test/test_faker_number.rb +52 -1
  42. data/test/test_faker_street.rb +1 -1
  43. data/test/test_faker_time.rb +74 -0
  44. data/test/test_helper.rb +7 -0
  45. data/test/test_locale.rb +11 -7
  46. metadata +25 -14
@@ -3,3 +3,10 @@ require 'rubygems'
3
3
  require 'yaml'
4
4
  YAML::ENGINE.yamler = 'syck' if defined? YAML::ENGINE
5
5
  require File.expand_path(File.dirname(__FILE__) + '/../lib/faker')
6
+
7
+ # configure I18n
8
+ locales_path = File.expand_path(File.dirname(__FILE__) + '../lib/locales')
9
+ I18n.available_locales = Dir[locales_path + '/*'].map do |file|
10
+ file.split('.').first
11
+ end
12
+ I18n.enforce_available_locales = true
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')
2
2
 
3
- LoadedYaml = ['en', 'en-bork'].inject({}) do |h, locale|
3
+ LoadedYaml = ['en', 'en-BORK'].inject({}) do |h, locale|
4
4
  h[locale] = YAML.load_file(File.expand_path(File.dirname(__FILE__) + "/../lib/locales/#{locale}.yml"))[locale]['faker']
5
5
  h
6
6
  end
@@ -18,24 +18,28 @@ class TestLocale < Test::Unit::TestCase
18
18
  end
19
19
 
20
20
  def test_configured_locale_translation
21
- Faker::Config.locale = 'en-bork'
22
- assert_equal Faker::Base.translate('faker.lorem.words').first, LoadedYaml['en-bork']['lorem']['words'].first
21
+ Faker::Config.locale = 'en-BORK'
22
+ assert_equal Faker::Base.translate('faker.lorem.words').first, LoadedYaml['en-BORK']['lorem']['words'].first
23
23
  end
24
24
 
25
25
  def test_locale_override_when_calling_translate
26
- Faker::Config.locale = 'en-bork'
26
+ Faker::Config.locale = 'en-BORK'
27
27
  assert_equal Faker::Base.translate('faker.lorem.words', :locale => :en).first, LoadedYaml['en']['lorem']['words'].first
28
28
  end
29
29
 
30
30
  def test_translation_fallback
31
- Faker::Config.locale = 'en-bork'
32
- assert_nil LoadedYaml['en-bork']['name']
31
+ Faker::Config.locale = 'en-BORK'
32
+ assert_nil LoadedYaml['en-BORK']['name']
33
33
  assert_equal Faker::Base.translate('faker.name.first_name').first, LoadedYaml['en']['name']['first_name'].first
34
34
  end
35
35
 
36
36
  def test_regex
37
- Faker::Config.locale = 'en-gb'
37
+ Faker::Config.locale = 'en-GB'
38
38
  re = /[A-PR-UWYZ][A-HK-Y]?[0-9][ABEHMNPRVWXY0-9]? {1,2}[0-9][ABD-HJLN-UW-Z]{2}/
39
39
  assert re.match(result = Faker::Address.postcode), "#{result} didn't match #{re}"
40
40
  end
41
+
42
+ def test_available_locales
43
+ assert I18n.locale_available?('en-GB')
44
+ end
41
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Curtis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-09 00:00:00.000000000 Z
11
+ date: 2014-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -45,24 +45,27 @@ files:
45
45
  - lib/faker/code.rb
46
46
  - lib/faker/commerce.rb
47
47
  - lib/faker/company.rb
48
+ - lib/faker/date.rb
48
49
  - lib/faker/finance.rb
50
+ - lib/faker/hacker.rb
49
51
  - lib/faker/internet.rb
50
52
  - lib/faker/lorem.rb
51
53
  - lib/faker/name.rb
52
54
  - lib/faker/number.rb
53
55
  - lib/faker/phone_number.rb
54
56
  - lib/faker/team.rb
57
+ - lib/faker/time.rb
55
58
  - lib/faker/version.rb
56
- - lib/locales/de-at.yml
57
- - lib/locales/de-ch.yml
59
+ - lib/locales/de-AT.yml
60
+ - lib/locales/de-CH.yml
58
61
  - lib/locales/de.yml
59
- - lib/locales/en-au.yml
60
- - lib/locales/en-bork.yml
61
- - lib/locales/en-ca.yml
62
- - lib/locales/en-gb.yml
63
- - lib/locales/en-ind.yml
64
- - lib/locales/en-nep.yml
65
- - lib/locales/en-us.yml
62
+ - lib/locales/en-AU.yml
63
+ - lib/locales/en-BORK.yml
64
+ - lib/locales/en-CA.yml
65
+ - lib/locales/en-GB.yml
66
+ - lib/locales/en-IND.yml
67
+ - lib/locales/en-NEP.yml
68
+ - lib/locales/en-US.yml
66
69
  - lib/locales/en.yml
67
70
  - lib/locales/es.yml
68
71
  - lib/locales/fa.yml
@@ -70,13 +73,14 @@ files:
70
73
  - lib/locales/it.yml
71
74
  - lib/locales/ja.yml
72
75
  - lib/locales/ko.yml
73
- - lib/locales/nb-no.yml
76
+ - lib/locales/nb-NO.yml
74
77
  - lib/locales/nl.yml
75
78
  - lib/locales/pl.yml
76
- - lib/locales/pt-br.yml
79
+ - lib/locales/pt-BR.yml
77
80
  - lib/locales/ru.yml
78
81
  - lib/locales/sk.yml
79
82
  - lib/locales/vi.yml
83
+ - lib/locales/zh-CN.yml
80
84
  - test/test_array_sample_method_compat.rb
81
85
  - test/test_avatar.rb
82
86
  - test/test_en_locale.rb
@@ -89,18 +93,22 @@ files:
89
93
  - test/test_faker_code.rb
90
94
  - test/test_faker_commerce.rb
91
95
  - test/test_faker_company.rb
96
+ - test/test_faker_date.rb
97
+ - test/test_faker_hacker_talk.rb
92
98
  - test/test_faker_internet.rb
93
99
  - test/test_faker_lorem.rb
94
100
  - test/test_faker_name.rb
95
101
  - test/test_faker_number.rb
96
102
  - test/test_faker_street.rb
97
103
  - test/test_faker_team.rb
104
+ - test/test_faker_time.rb
98
105
  - test/test_flexible.rb
99
106
  - test/test_helper.rb
100
107
  - test/test_locale.rb
101
108
  - test/test_pl_locale.rb
102
109
  homepage: http://faker.rubyforge.org
103
- licenses: []
110
+ licenses:
111
+ - MIT
104
112
  metadata: {}
105
113
  post_install_message:
106
114
  rdoc_options: []
@@ -135,12 +143,15 @@ test_files:
135
143
  - test/test_faker_code.rb
136
144
  - test/test_faker_commerce.rb
137
145
  - test/test_faker_company.rb
146
+ - test/test_faker_date.rb
147
+ - test/test_faker_hacker_talk.rb
138
148
  - test/test_faker_internet.rb
139
149
  - test/test_faker_lorem.rb
140
150
  - test/test_faker_name.rb
141
151
  - test/test_faker_number.rb
142
152
  - test/test_faker_street.rb
143
153
  - test/test_faker_team.rb
154
+ - test/test_faker_time.rb
144
155
  - test/test_flexible.rb
145
156
  - test/test_helper.rb
146
157
  - test/test_locale.rb