fantasy_faker 0.0.3 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fab71ef1b33640b72154b8789896a266f66a6912
4
- data.tar.gz: 7f9b3361ed0716a389a001bb2c9d61fd05063239
2
+ SHA256:
3
+ metadata.gz: babf067689eb2d336f310659e548a6e4bd91cb3526adc40123b16c057f052590
4
+ data.tar.gz: 44d2c5e41e728adfd32654050608fb506ad3c0a87d9f7b9107cd83d3bf33a71f
5
5
  SHA512:
6
- metadata.gz: 6031aed127874c3c0738b805f2c79b6ef8527de299c3e0556095ef1a23cf529a8079a835f46bf57f4570d1ac3a7f16ffe8f4fa57422ea1771d1faddf882de343
7
- data.tar.gz: 4b42a9011e53bbd68c406c3fc392db9a0c9641c44572fe9a0dde1035d6cdd2c0c2215398dcaa899cd2eb819e454ec00cc31f3395a49f733a78d1587912f20a3d
6
+ metadata.gz: 74493db82cf1d264d9217350c3dd75496ecc46899396426050d24abfa82ddffb42f0ee3494b71b37b5a109b37937d09e2d0ea9443155dc34f9163feb3c655ace
7
+ data.tar.gz: 3ccd876fa0ef30915fd0199285cdb8b08feb7358f24e01305163926f21fa0084798a3cc0f8f809f2bf9f096013473b23238306db5cc117346fcbb48edf44ba43
data/CHANGELOG.md ADDED
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0 - October 21, 2026
4
+
5
+ - Expand the first-name dictionaries from 2,499 to 5,040 distinct male names and from 1,380 to 2,795 distinct female names.
6
+ - Add 150 fantasy-themed nicknames per gender in both English and Polish, with matching translations.
7
+ - Replace the male prefixes that produced `Dildonar` and `Amilfreano`.
8
+ - Sort all name prefixes, suffixes, and nicknames alphabetically.
9
+
10
+ ## 0.1.0 - October 16, 2026
11
+
12
+ - Require Ruby 3.0+
13
+ - Add support for `:en` (default) and `:pl` locales, with automatic detection from `I18n.locale` and regional locale mapping (e.g. `en_GB`, `en-US`, `pl_PL`)
14
+ - Add `FantasyFaker.use_locale` (global and block form) and `FantasyFaker.reset_locale`
15
+ - Add English male and female character nickname dictionaries
16
+ - Migrate dictionary files to YAML under `locales/`
17
+ - Add RuboCop configuration and GitHub Actions CI workflow
18
+
19
+ ## 0.0.3 - January 5, 2015
20
+
21
+ - Update `FantasyFaker::Character` name and nickname generation methods
22
+
23
+ ## 0.0.2 - January 3, 2015
24
+
25
+ - Update gem description and metadata
26
+
27
+ ## 0.0.1 - January 2, 2015
28
+
29
+ - Initial release with `FantasyFaker::Character` and Polish character dictionaries
data/README.md CHANGED
@@ -1,31 +1,29 @@
1
- [![Gem Version](https://badge.fury.io/rb/fantasy_faker.svg)](http://badge.fury.io/rb/fantasy_faker)
2
- [![Code Climate](https://codeclimate.com/github/msx2/fantasy_faker/badges/gpa.svg)](https://codeclimate.com/github/msx2/fantasy_faker)
3
- [![Codeship Status for msx2/fantasy_faker](https://codeship.com/projects/367f3fe0-7500-0132-c61e-22ab3bab314c/status?branch=master)](https://codeship.com/projects/55108)
1
+ [![Gem Version](https://badge.fury.io/rb/fantasy_faker.svg)](https://badge.fury.io/rb/fantasy_faker)
4
2
 
5
3
  # FantasyFaker
6
4
 
7
5
  Inspired by [ffaker](https://github.com/EmmanuelOga/ffaker), used to easily generate fake random data: e.g. name, nickname.
8
6
 
9
- Created on a sole purpose to be used in fantasy-climate projects. Currently supports only Polish language.
7
+ Created on a sole purpose to be used in fantasy-climate projects. Requires Ruby 3.0+. Supports English (`:en`, default) and Polish (`:pl`) locales.
10
8
 
11
9
  ## Installation
12
10
 
13
11
  Add this line to your application's Gemfile:
14
12
 
15
- ```
13
+ ```ruby
16
14
  gem 'fantasy_faker'
17
15
  ```
18
16
 
19
17
  And then execute:
20
18
 
21
- ```
22
- $ bundle
19
+ ```sh
20
+ bundle install
23
21
  ```
24
22
 
25
23
  Or install it yourself as:
26
24
 
27
- ```
28
- $ gem install fantasy_faker
25
+ ```sh
26
+ gem install fantasy_faker
29
27
  ```
30
28
 
31
29
  ## Usage
@@ -33,19 +31,43 @@ $ gem install fantasy_faker
33
31
  ```ruby
34
32
  require 'fantasy_faker'
35
33
 
34
+ # Default locale is :en (or read automatically from I18n.locale in Rails)
36
35
  FantasyFaker::Character.male_first_name => "Sarillon"
37
- FantasyFaker::Character.male_nickname => "Dziecię Pustyni"
38
- FantasyFaker::Character.male_name => "Sarillon Dziecię Pustyni" # OR "Sarillon"
36
+ FantasyFaker::Character.male_nickname => "Child of the Desert"
37
+ FantasyFaker::Character.male_name => "Sarillon Child of the Desert" # OR "Sarillon"
39
38
 
40
39
  FantasyFaker::Character.female_first_name => "Linani"
40
+ FantasyFaker::Character.female_nickname => "the Bashful"
41
+ FantasyFaker::Character.female_name => "Linani the Bashful" # OR "Linani"
42
+
43
+ # Force a specific locale (globally or with a block)
44
+ FantasyFaker.use_locale(:pl)
45
+ FantasyFaker::Character.male_nickname => "Dziecię Pustyni"
41
46
  FantasyFaker::Character.female_nickname => "Wstydliwa"
42
- FantasyFaker::Character.female_name => "Linani Wstydliwa" # OR "Linani"
47
+
48
+ FantasyFaker.use_locale(:pl) do
49
+ FantasyFaker::Character.male_name => "Sarillon Dziecię Pustyni"
50
+ end
51
+ ```
52
+
53
+ ## Development
54
+
55
+ Dictionary data is stored in YAML files under `locales/`:
56
+ - `locales/common.yml`: language-independent lists (e.g. name prefixes and suffixes), grouped by module name (`character:`)
57
+ - `locales/en/<module>.yml`: English entries for a module
58
+ - `locales/pl/<module>.yml`: Polish entries for a module
59
+
60
+ ```sh
61
+ bundle install
62
+ bundle exec rspec
63
+ bundle exec rubocop
64
+ bundle exec rake # both
43
65
  ```
44
66
 
45
67
  ## Contributing
46
68
 
47
- 1. Fork it
48
- 2. Create your feature branch (`git checkout -b my-new-feature`)
49
- 3. Commit your changes (`git commit -am 'Add some feature'`)
50
- 4. Push to the branch (`git push origin my-new-feature`)
51
- 5. Create new Pull Request
69
+ Bug reports and pull requests are welcome on GitHub at https://github.com/msx2/fantasy_faker. When submitting changes, please make sure specs and RuboCop pass and document user-facing changes in [CHANGELOG.md](CHANGELOG.md).
70
+
71
+ ## License
72
+
73
+ MIT, see [LICENSE.txt](LICENSE.txt).
@@ -1,17 +1,16 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  module FantasyFaker
4
-
5
4
  module Character
6
5
  extend BaseModule
7
6
  extend self
8
7
 
9
8
  def male_first_name
10
- "%s%s" % [NAME_PREFIXES_MALE.rand, NAME_SUFIXES_MALE.rand]
9
+ '%s%s' % [fetch_data(:name_prefixes_male).rand, fetch_data(:name_sufixes_male).rand]
11
10
  end
12
11
 
13
12
  def male_nickname
14
- NICKNAMES_MALE.rand
13
+ fetch_data(:nicknames_male).rand
15
14
  end
16
15
 
17
16
  def male_name
@@ -21,11 +20,11 @@ module FantasyFaker
21
20
  end
22
21
 
23
22
  def female_first_name
24
- "%s%s" % [NAME_PREFIXES_FEMALE.rand, NAME_SUFIXES_FEMALE.rand]
23
+ '%s%s' % [fetch_data(:name_prefixes_female).rand, fetch_data(:name_sufixes_female).rand]
25
24
  end
26
25
 
27
26
  def female_nickname
28
- NICKNAMES_FEMALE.rand
27
+ fetch_data(:nicknames_female).rand
29
28
  end
30
29
 
31
30
  def female_name
@@ -33,7 +32,5 @@ module FantasyFaker
33
32
 
34
33
  ["#{first_name} #{female_nickname}", first_name].sample
35
34
  end
36
-
37
35
  end
38
-
39
36
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FantasyFaker
2
4
  module ArrayUtils
3
5
  def self.const_array(argument)
@@ -1,19 +1,47 @@
1
- require 'fantasy_faker/utils/array_utils'
1
+ # frozen_string_literal: true
2
2
 
3
- module FantasyFaker
3
+ require 'yaml'
4
+ require_relative 'array_utils'
4
5
 
6
+ module FantasyFaker
5
7
  module BaseModule
6
-
7
8
  def const_missing(const_name)
8
- file_content = File.readlines(data_path(const_name)).map(&:strip)
9
- data = FantasyFaker::ArrayUtils.const_array(file_content)
9
+ fetch_data(const_name)
10
+ end
11
+
12
+ def fetch_data(key)
13
+ normalized_key = underscore(key.to_s)
14
+ current_locale = FantasyFaker.locale
15
+ locale_data(current_locale)[normalized_key] || common_data[normalized_key] ||
16
+ raise(KeyError, "Unknown data key: #{normalized_key}")
17
+ end
18
+
19
+ def locale_data(locale = FantasyFaker.locale)
20
+ @locale_data ||= {}
21
+ @locale_data[locale] ||= load_yaml_arrays(locale_data_path(locale))
22
+ end
10
23
 
11
- const_set(const_name, data)
12
- data
24
+ def common_data
25
+ @common_data ||= begin
26
+ raw = YAML.safe_load_file(common_data_path) || {}
27
+ section = raw[underscore(module_name)] || raw
28
+ section.transform_values { |values| FantasyFaker::ArrayUtils.const_array(values) }
29
+ end
13
30
  end
14
31
 
15
- def data_path(file_name)
16
- "#{FantasyFaker::BASE_LIB_PATH}/fantasy_faker/data/#{underscore(module_name)}/#{underscore(file_name.to_s)}"
32
+ def locale_data_path(locale)
33
+ "#{FantasyFaker::ROOT_PATH}/locales/#{locale}/#{underscore(module_name)}.yml"
34
+ end
35
+
36
+ def common_data_path
37
+ "#{FantasyFaker::ROOT_PATH}/locales/common.yml"
38
+ end
39
+
40
+ def load_yaml_arrays(path)
41
+ return {} unless File.exist?(path)
42
+
43
+ raw = YAML.safe_load_file(path) || {}
44
+ raw.transform_values { |values| FantasyFaker::ArrayUtils.const_array(values) }
17
45
  end
18
46
 
19
47
  def module_name
@@ -21,13 +49,11 @@ module FantasyFaker
21
49
  end
22
50
 
23
51
  def underscore(string)
24
- string.gsub(/::/, '/').
25
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
26
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
27
- tr("-", "_").
28
- downcase
52
+ string.gsub('::', '/')
53
+ .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
54
+ .gsub(/([a-z\d])([A-Z])/, '\1_\2')
55
+ .tr('-', '_')
56
+ .downcase
29
57
  end
30
-
31
58
  end
32
-
33
59
  end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FantasyFaker
4
+ VERSION = '0.2.0'
5
+ end
data/lib/fantasy_faker.rb CHANGED
@@ -1,15 +1,51 @@
1
- module FantasyFaker
2
- VERSION = '0.0.3'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'fantasy_faker/version'
4
+ require_relative 'fantasy_faker/utils/array_utils'
5
+ require_relative 'fantasy_faker/utils/base_module'
6
+ require_relative 'fantasy_faker/character'
3
7
 
4
- require 'fantasy_faker/utils/array_utils'
5
- require 'fantasy_faker/utils/base_module'
8
+ module FantasyFaker
9
+ DEFAULT_LOCALE = :en
10
+ SUPPORTED_LOCALES = %i[en pl].freeze
6
11
 
7
12
  extend BaseModule
8
13
 
9
- BASE_LIB_PATH = File.expand_path('..', __FILE__)
14
+ ROOT_PATH = File.expand_path('../..', __FILE__)
15
+
16
+ class << self
17
+ def use_locale(locale)
18
+ return @forced_locale = normalize_locale(locale) unless block_given?
19
+
20
+ previous_locale = @forced_locale
21
+ @forced_locale = normalize_locale(locale)
22
+ yield
23
+ ensure
24
+ @forced_locale = previous_locale if block_given?
25
+ end
26
+
27
+ def reset_locale
28
+ @forced_locale = nil
29
+ end
30
+
31
+ def locale
32
+ candidate = @forced_locale || i18n_locale || DEFAULT_LOCALE
33
+ SUPPORTED_LOCALES.include?(candidate) ? candidate : DEFAULT_LOCALE
34
+ end
35
+
36
+ private
37
+
38
+ def i18n_locale
39
+ return unless defined?(I18n) && I18n.respond_to?(:locale)
40
+
41
+ normalize_locale(I18n.locale)
42
+ end
43
+
44
+ def normalize_locale(locale)
45
+ return if locale.nil?
10
46
 
11
- # Load all constants.
12
- Dir["#{BASE_LIB_PATH}/fantasy_faker/*.rb"].sort.each do |filename|
13
- require "fantasy_faker/#{File.basename(filename, '.rb')}"
47
+ base = locale.to_s.split(/[-_]/).first
48
+ base&.downcase&.to_sym
49
+ end
14
50
  end
15
51
  end
@@ -0,0 +1,259 @@
1
+ ---
2
+ character:
3
+ name_prefixes_male:
4
+ - Abi
5
+ - Ach
6
+ - Ae
7
+ - Aga
8
+ - Ald
9
+ - Alk
10
+ - Amal
11
+ - Ang
12
+ - Arn
13
+ - Art
14
+ - Aven
15
+ - Baa
16
+ - Bea
17
+ - Beia
18
+ - Bel
19
+ - Bip
20
+ - Borl
21
+ - Cael
22
+ - Cen
23
+ - Chai
24
+ - Cind
25
+ - Daer
26
+ - Dap
27
+ - Del
28
+ - Dorn
29
+ - Dov
30
+ - Dreg
31
+ - Eld
32
+ - Esmer
33
+ - Est
34
+ - Fael
35
+ - Fall
36
+ - Flan
37
+ - Gal
38
+ - Grai
39
+ - Hael
40
+ - Ith
41
+ - Jadea
42
+ - Jar
43
+ - Jem
44
+ - Kaa
45
+ - Kel
46
+ - Khaz
47
+ - Kyl
48
+ - Kyth
49
+ - Lave
50
+ - Lial
51
+ - Lor
52
+ - Mael
53
+ - Marc
54
+ - Mik
55
+ - Miy
56
+ - My
57
+ - Nil
58
+ - Nor
59
+ - Nys
60
+ - Orin
61
+ - Paer
62
+ - Path
63
+ - Peri
64
+ - Pyr
65
+ - Quel
66
+ - Rhun
67
+ - Rugha
68
+ - Sar
69
+ - Soan
70
+ - Syl
71
+ - Thal
72
+ - Tig
73
+ - Timo
74
+ - Vael
75
+ - Wol
76
+ name_sufixes_male:
77
+ - ahm
78
+ - anian
79
+ - arok
80
+ - ath
81
+ - avo
82
+ - cil
83
+ - dan
84
+ - dar
85
+ - dester
86
+ - donar
87
+ - dor
88
+ - drak
89
+ - dreth
90
+ - fen
91
+ - freano
92
+ - ger
93
+ - gons
94
+ - hun
95
+ - iba
96
+ - illon
97
+ - ilo
98
+ - ilo
99
+ - intre
100
+ - isab
101
+ - ius
102
+ - ivo
103
+ - jako
104
+ - ka
105
+ - kall
106
+ - ker
107
+ - las
108
+ - lay
109
+ - lianth
110
+ - lino
111
+ - lion
112
+ - lor
113
+ - manti
114
+ - mar
115
+ - mer
116
+ - mina
117
+ - mir
118
+ - mythe
119
+ - nor
120
+ - olites
121
+ - onga
122
+ - philus
123
+ - pil
124
+ - ra
125
+ - red
126
+ - reni
127
+ - ric
128
+ - rin
129
+ - rinh
130
+ - rion
131
+ - rol
132
+ - scire
133
+ - sharr
134
+ - tarea
135
+ - thar
136
+ - thas
137
+ - thir
138
+ - uan
139
+ - unube
140
+ - vadro
141
+ - val
142
+ - vel
143
+ - ven
144
+ - ven
145
+ - ving
146
+ - vite
147
+ - vor
148
+ - vorn
149
+ name_prefixes_female:
150
+ - Ael
151
+ - Aer
152
+ - Aid
153
+ - Ail
154
+ - Ais
155
+ - Alla
156
+ - Bar
157
+ - Ber
158
+ - Bri
159
+ - Cai
160
+ - Car
161
+ - Cel
162
+ - Cora
163
+ - Dae
164
+ - Dan
165
+ - Dar
166
+ - Dek
167
+ - Dor
168
+ - Eal
169
+ - Eil
170
+ - Ela
171
+ - Fae
172
+ - Fin
173
+ - Gud
174
+ - Gwen
175
+ - Ill
176
+ - Ily
177
+ - Ink
178
+ - Is
179
+ - Jer
180
+ - Jus
181
+ - Kael
182
+ - Kat
183
+ - Lin
184
+ - Lira
185
+ - Lis
186
+ - Lus
187
+ - Mae
188
+ - Mer
189
+ - Mud
190
+ - Nao
191
+ - Ner
192
+ - Nin
193
+ - Ny
194
+ - Oi
195
+ - Oks
196
+ - Oriel
197
+ - Per
198
+ - Pur
199
+ - Rae
200
+ - Red
201
+ - Ris
202
+ - Set
203
+ - Sus
204
+ - Syl
205
+ - Tan
206
+ - Thia
207
+ - Tir
208
+ - Vael
209
+ - Ver
210
+ - Vis
211
+ - Xar
212
+ - Xis
213
+ - Yl
214
+ - Zer
215
+ name_sufixes_female:
216
+ - ana
217
+ - ani
218
+ - ara
219
+ - ara
220
+ - aris
221
+ - asa
222
+ - ea
223
+ - eka
224
+ - elia
225
+ - elle
226
+ - ena
227
+ - era
228
+ - eri
229
+ - eris
230
+ - eth
231
+ - iel
232
+ - ien
233
+ - ienna
234
+ - ina
235
+ - inael
236
+ - ira
237
+ - iri
238
+ - isi
239
+ - issa
240
+ - lida
241
+ - lini
242
+ - liri
243
+ - lisa
244
+ - odi
245
+ - oka
246
+ - oli
247
+ - ona
248
+ - oni
249
+ - ora
250
+ - riel
251
+ - uka
252
+ - ukis
253
+ - una
254
+ - uni
255
+ - ura
256
+ - uri
257
+ - wyn
258
+ - yla
259
+ - ys