name_bank 0.1.4 → 0.1.5

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
2
  SHA256:
3
- metadata.gz: 8985bb6db2329f6ae7033a3cd2ca2e9f2f1f4af803bf5904fd4e96d8f0f9034e
4
- data.tar.gz: 1fe1d312b363bee756891a16567524d34c845673daa2e2ccb7097d4f1312fc75
3
+ metadata.gz: f9a25e48d0f047db7cb393aa8545f0857daac15e5febc9f941b48c440f957930
4
+ data.tar.gz: 8ad91e35492cf5e6e703246bbffef2804fa2456ce344bd7425532cb3ef145ae0
5
5
  SHA512:
6
- metadata.gz: 4c55c61b735a271ebac955184ea0e6c7f6207c8be04b87b0ee1e041b5f4f9eb542950204a8756c8f862b4fac94072402333f8357f87c5915c6fd631d06b63457
7
- data.tar.gz: 07ca279207e64e4282a6088acd2c379bef69e5df4bc3ec14960e86fd497d765eb07d00402b4d027b4bc9191b8239a43f52fabe71dccb2ba586da8fbce3523a10
6
+ metadata.gz: 3ef330f55cd1fdcb87ca7f1391bc3b1c85af3c033e3bb9a4b349bea43651f8eaa4ea9f3ae9c1bac1db5e758ffb331ee403eb6f4639984dbc6246b95a7d78c5e2
7
+ data.tar.gz: df0010e081ef9c6314934dc15c06f98af62b61aac7395c7c66b3f02a0e9540065b192112c58c109cbd3fa64c745c3f4daa3012f71f88b131cc6a6a271943c448
data/CHANGELOG.md CHANGED
@@ -4,6 +4,21 @@ All notable changes to this project are documented here. The format is based on
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
5
5
  adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.1.5] - 2026-07-24
8
+
9
+ Metadata and documentation only — no API, data or behaviour change.
10
+
11
+ ### Added
12
+ - `spec.metadata` in the gemspec: source, changelog, documentation and bug
13
+ tracker links, and `rubygems_mfa_required`.
14
+ - README: "Where it fits" (factory_bot, `db/seeds.rb`, RSpec examples) and
15
+ "Relation to Faker and FFaker" with a comparison table.
16
+
17
+ ### Changed
18
+ - Gem summary and description rewritten so the gem is findable for fake, test
19
+ and seed name data, and states how it relates to Faker and FFaker.
20
+ - README intro says 106 countries (was "105+").
21
+
7
22
  ## [0.1.4] - 2026-07-24
8
23
 
9
24
  ### Added
data/README.md CHANGED
@@ -1,9 +1,13 @@
1
1
  # name_bank
2
2
 
3
- Authentic, gender-matched given and family names for 105+ countries. Deep
3
+ Authentic, gender-matched given and family names for 106 countries. Deep
4
4
  pools (up to 1500 per country/gender), uniform sampling, deterministic, no
5
5
  runtime dependencies.
6
6
 
7
+ Realistic fake name data for database seeds, factories, fixtures and demo
8
+ environments — a companion to [Faker](https://github.com/faker-ruby/faker) and
9
+ [FFaker](https://github.com/ffaker/ffaker) for the name part.
10
+
7
11
  ## Installation
8
12
 
9
13
  Add to your Gemfile:
@@ -42,6 +46,81 @@ Sampling is uniform over each pool and fully deterministic for a given
42
46
  `rng` — the same seed always yields the same name. `gender:` is `:male`
43
47
  or `:female`.
44
48
 
49
+ ## Where it fits
50
+
51
+ A factory_bot factory:
52
+
53
+ ```ruby
54
+ FactoryBot.define do
55
+ factory :user do
56
+ transient do
57
+ country { "DE" }
58
+ person_gender { :female }
59
+ rng { Random.new }
60
+ person { NameBank.full_name(country: country, gender: person_gender, rng: rng) }
61
+ end
62
+
63
+ first_name { person[:firstname] }
64
+ last_name { person[:lastname] }
65
+ end
66
+ end
67
+ ```
68
+
69
+ Database seeds with a fixed seed, so every run produces the same data:
70
+
71
+ ```ruby
72
+ # db/seeds.rb
73
+ rng = Random.new(20_260_724)
74
+
75
+ %w[DE FR IT ES PL].each do |country|
76
+ 100.times do
77
+ person = NameBank.full_name(country: country, gender: [:male, :female].sample(random: rng), rng: rng)
78
+ User.create!(first_name: person[:firstname], last_name: person[:lastname], country: country)
79
+ end
80
+ end
81
+ ```
82
+
83
+ An RSpec example — the seeded RNG makes the case reproducible:
84
+
85
+ ```ruby
86
+ it "fits a long Cyrillic name into the invoice header" do
87
+ rng = Random.new(1234)
88
+ customer = NameBank.full_name(country: "RU", gender: :female, rng: rng, script: :native)
89
+
90
+ header = InvoicePdf.new(customer).header
91
+
92
+ expect(header).to include(customer[:lastname])
93
+ end
94
+ ```
95
+
96
+ ## Relation to Faker and FFaker
97
+
98
+ Faker and FFaker are full fake-data suites — addresses, companies, lorem ipsum,
99
+ and much more. name_bank does one thing: people names. Use it alongside them,
100
+ not instead of them.
101
+
102
+ | | Faker | FFaker | name_bank |
103
+ | -------------------- | ------------------------------------------------------------ | ------------------------------------------ | ----------------------------------------------------------- |
104
+ | Scope | full fake-data suite | full fake-data suite | people names only |
105
+ | Names addressed by | 58 language/region locales (`de`, `de-AT`, `en-US`) | 30 language modules (`FFaker::NameDE`) | 106 ISO country codes (`DE`, `RU`, `JP`) |
106
+ | Gendered given names | in about 24 of those locales | in 17 of the 30 name modules | in every country |
107
+ | Pool depth | uneven: `en` 1219 m / 4271 f, `de` 574 / 585, `ru` 52 / 56, `ko` 21 | varies per module | up to 1500 per country, gender and script; 89 of 106 at the cap |
108
+ | Native script | one form per locale | one form per module | Latin and native as separate pools, 35 countries |
109
+ | Randomness | global `Faker::Config.random` | global `FFaker::Random.seed` | `rng:` passed in per call, no global state |
110
+
111
+ Counts measured against `faker` and `ffaker` `main` on 2026-07-24.
112
+
113
+ Moving a name call over:
114
+
115
+ ```ruby
116
+ Faker::Name.first_name
117
+ FFaker::NameDE.first_name
118
+ # both: gender-agnostic, locale/module picked from global state
119
+
120
+ NameBank.first_name(country: "DE", gender: :female, rng: rng)
121
+ # country and gender explicit, RNG explicit
122
+ ```
123
+
45
124
  ## Scripts
46
125
 
47
126
  Names come in Latin (default) and, for countries with a non-Latin writing
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NameBank
4
+ # The pool-key schema: the base YAML keys, how native-script keys are named,
5
+ # and how a gender maps to its key. Shared by the runtime Repository and the
6
+ # build-time SplitScripts tool so the key names live in one place.
7
+ module PoolSchema
8
+ KEYS = %w[firstnames_male firstnames_female lastnames].freeze
9
+
10
+ module_function
11
+
12
+ def native_key(key)
13
+ "#{key}_native"
14
+ end
15
+
16
+ def gender_key(gender)
17
+ case gender
18
+ when :male then "firstnames_male"
19
+ when :female then "firstnames_female"
20
+ else raise ArgumentError, "gender must be :male or :female, got #{gender.inspect}"
21
+ end
22
+ end
23
+ end
24
+ end
@@ -5,8 +5,6 @@ require "yaml"
5
5
  module NameBank
6
6
  # Lazy, memoized loader of per-country name pools stored as YAML in data_dir.
7
7
  class Repository
8
- KEYS = %w[firstnames_male firstnames_female lastnames].freeze
9
-
10
8
  def initialize(data_dir:)
11
9
  @data_dir = data_dir
12
10
  @countries_cache = {}
@@ -14,7 +12,7 @@ module NameBank
14
12
  end
15
13
 
16
14
  def firstnames(country:, gender:, variant: nil, script: :latin)
17
- pool(load(country, variant), gender_key(gender), script, country)
15
+ pool(load(country, variant), PoolSchema.gender_key(gender), script, country)
18
16
  end
19
17
 
20
18
  def lastnames(country:, variant: nil, script: :latin)
@@ -23,7 +21,7 @@ module NameBank
23
21
 
24
22
  def scripts(country:)
25
23
  data = load(country, nil)
26
- KEYS.any? { |k| data["#{k}_native"]&.any? } ? %i[latin native] : %i[latin]
24
+ PoolSchema::KEYS.any? { |k| data[PoolSchema.native_key(k)]&.any? } ? %i[latin native] : %i[latin]
27
25
  end
28
26
 
29
27
  def countries
@@ -36,20 +34,12 @@ module NameBank
36
34
 
37
35
  private
38
36
 
39
- def gender_key(gender)
40
- case gender
41
- when :male then "firstnames_male"
42
- when :female then "firstnames_female"
43
- else raise ArgumentError, "gender must be :male or :female, got #{gender.inspect}"
44
- end
45
- end
46
-
47
37
  def pool(data, key, script, country)
48
38
  names =
49
39
  case script
50
40
  when :latin then data.fetch(key)
51
41
  when :native
52
- native = data["#{key}_native"]
42
+ native = data[PoolSchema.native_key(key)]
53
43
  native && !native.empty? ? native : data.fetch(key)
54
44
  else
55
45
  raise ArgumentError, "script must be :latin or :native, got #{script.inspect}"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NameBank
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.5"
5
5
  end
data/lib/name_bank.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "name_bank/version"
4
+ require_relative "name_bank/pool_schema"
4
5
  require_relative "name_bank/repository"
5
6
 
6
7
  module NameBank
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: name_bank
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Bartels
@@ -37,9 +37,16 @@ dependencies:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: '13.0'
40
- description: A fast, dependency-free generator of authentic, gender-matched given
41
- names and surnames for 105+ countries, plus hand-curated pools and cultural variants.
42
- Uniform, deterministic sampling from a caller-supplied RNG.
40
+ description: 'NameBank generates authentic, gender-matched given names and surnames
41
+ for 106 countries, addressed by ISO alpha-2 country code, including native-script
42
+ pools (Cyrillic, Arabic, Han, Hangul, Kana, Greek, Hebrew and more) for 35 of them.
43
+ Pools hold up to 1500 names per country, gender and script. Use it for realistic
44
+ fake name data in database seeds, factory_bot factories, RSpec fixtures, demo and
45
+ staging data. It complements the general-purpose fake data gems Faker and FFaker
46
+ rather than replacing them: keep those for addresses, companies and lorem ipsum,
47
+ and use name_bank where you need per-country, gender-matched people names with deep
48
+ pools. Sampling is uniform and deterministic from a caller-supplied RNG — no global
49
+ locale or random state. No runtime dependencies.'
43
50
  executables: []
44
51
  extensions: []
45
52
  extra_rdoc_files: []
@@ -157,12 +164,18 @@ files:
157
164
  - data/variants/US/african_american.yml
158
165
  - docs/name-counts.md
159
166
  - lib/name_bank.rb
167
+ - lib/name_bank/pool_schema.rb
160
168
  - lib/name_bank/repository.rb
161
169
  - lib/name_bank/version.rb
162
170
  homepage: https://github.com/roughneck/name_bank
163
171
  licenses:
164
172
  - Apache-2.0
165
- metadata: {}
173
+ metadata:
174
+ source_code_uri: https://github.com/roughneck/name_bank
175
+ changelog_uri: https://github.com/roughneck/name_bank/blob/master/CHANGELOG.md
176
+ documentation_uri: https://rubydoc.info/gems/name_bank
177
+ bug_tracker_uri: https://github.com/roughneck/name_bank/issues
178
+ rubygems_mfa_required: 'true'
166
179
  rdoc_options: []
167
180
  require_paths:
168
181
  - lib
@@ -179,5 +192,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
192
  requirements: []
180
193
  rubygems_version: 3.6.9
181
194
  specification_version: 4
182
- summary: Authentic, gender-matched given and family names for 105+ countries.
195
+ summary: Authentic, gender-matched given names and surnames for 106 countries — fake
196
+ name data for seeds, factories and tests.
183
197
  test_files: []