faker 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.txt +3 -0
- data/README.md +42 -6
- data/lib/faker.rb +11 -2
- data/lib/faker/address.rb +1 -0
- data/lib/faker/avatar.rb +2 -2
- data/lib/faker/business.rb +4 -4
- data/lib/faker/code.rb +33 -1
- data/lib/faker/company.rb +6 -0
- data/lib/faker/date.rb +34 -0
- data/lib/faker/hacker.rb +31 -0
- data/lib/faker/internet.rb +7 -4
- data/lib/faker/number.rb +41 -3
- data/lib/faker/phone_number.rb +3 -3
- data/lib/faker/time.rb +48 -0
- data/lib/faker/version.rb +1 -1
- data/lib/locales/{de-at.yml → de-AT.yml} +1 -1
- data/lib/locales/{de-ch.yml → de-CH.yml} +1 -1
- data/lib/locales/{en-au.yml → en-AU.yml} +1 -1
- data/lib/locales/{en-bork.yml → en-BORK.yml} +1 -1
- data/lib/locales/{en-ca.yml → en-CA.yml} +1 -1
- data/lib/locales/{en-gb.yml → en-GB.yml} +1 -1
- data/lib/locales/{en-ind.yml → en-IND.yml} +1 -1
- data/lib/locales/{en-nep.yml → en-NEP.yml} +0 -0
- data/lib/locales/{en-us.yml → en-US.yml} +1 -1
- data/lib/locales/en.yml +10 -2
- data/lib/locales/fr.yml +1 -1
- data/lib/locales/ja.yml +2 -0
- data/lib/locales/{nb-no.yml → nb-NO.yml} +1 -1
- data/lib/locales/pl.yml +1 -1
- data/lib/locales/{pt-br.yml → pt-BR.yml} +2 -2
- data/lib/locales/ru.yml +9 -0
- data/lib/locales/sk.yml +1 -1
- data/lib/locales/zh-CN.yml +27 -0
- data/test/test_en_us_locale.rb +2 -2
- data/test/test_faker_code.rb +12 -0
- data/test/test_faker_company.rb +7 -0
- data/test/test_faker_date.rb +52 -0
- data/test/test_faker_hacker_talk.rb +37 -0
- data/test/test_faker_internet.rb +7 -0
- data/test/test_faker_number.rb +52 -1
- data/test/test_faker_street.rb +1 -1
- data/test/test_faker_time.rb +74 -0
- data/test/test_helper.rb +7 -0
- data/test/test_locale.rb +11 -7
- metadata +25 -14
data/test/test_helper.rb
CHANGED
@@ -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
|
data/test/test_locale.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')
|
2
2
|
|
3
|
-
LoadedYaml = ['en', 'en-
|
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-
|
22
|
-
assert_equal Faker::Base.translate('faker.lorem.words').first, LoadedYaml['en-
|
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-
|
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-
|
32
|
-
assert_nil LoadedYaml['en-
|
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-
|
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.
|
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
|
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-
|
57
|
-
- lib/locales/de-
|
59
|
+
- lib/locales/de-AT.yml
|
60
|
+
- lib/locales/de-CH.yml
|
58
61
|
- lib/locales/de.yml
|
59
|
-
- lib/locales/en-
|
60
|
-
- lib/locales/en-
|
61
|
-
- lib/locales/en-
|
62
|
-
- lib/locales/en-
|
63
|
-
- lib/locales/en-
|
64
|
-
- lib/locales/en-
|
65
|
-
- lib/locales/en-
|
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-
|
76
|
+
- lib/locales/nb-NO.yml
|
74
77
|
- lib/locales/nl.yml
|
75
78
|
- lib/locales/pl.yml
|
76
|
-
- lib/locales/pt-
|
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
|