worldwide 1.20.0 → 1.20.1

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: 1cbb9e0606b63675d9a783759723f4083661820aae022057574e8abaf4490963
4
- data.tar.gz: d94f426622537b52d93c10a0f9be29980ad131915788ba77224d6043f5583284
3
+ metadata.gz: 40c3a685e5846885ead15eb0a8490aa47f0910908b6a41ca0bdce27888afe1f2
4
+ data.tar.gz: 18bb293a93002c123a9c5422097c6d3769f446415bbf5d244732f76eb4429067
5
5
  SHA512:
6
- metadata.gz: 66cc5d0a9561244ae777703aac0acf90a702cb0f891f88d93e8bdf4c5cf72c000c5ee7c107d348dd90dd2531078f505433ad260c97407c3e4fe63df87840f709
7
- data.tar.gz: 208de89a7c70089590460ab0675ff1e212752a6f1297dc57a0403ede1605803d31d8b52c5a1081ecaa604b00fe3abe00379396ade030436a46168145c49501a9
6
+ metadata.gz: 8b82badbfee1579e5c221ab08a0d45efac14dd162dde9708920abcfec5b23f74eec4c635347cb9ced57872709e3f5623dc3e27766c26f967346995f33a086e6f
7
+ data.tar.gz: 816675466a49cba1ead3a41b6f37afc0d666c72697455ad84ffd54064f0d8f54eb1754456560c1493bf8527f5baf88a871246343c566991084baa254d648876d
data/.gitignore CHANGED
@@ -25,3 +25,7 @@ Thumbs.db
25
25
  /doc/
26
26
 
27
27
  .idea
28
+
29
+ # Vendored CLDR data downloaded during `rake cldr:data:import`
30
+ # Contains temporary Unicode CLDR files used to generate data/cldr/
31
+ /vendor/
data/CHANGELOG.md CHANGED
@@ -28,6 +28,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
28
28
  ## [Unreleased]
29
29
 
30
30
  ---
31
+ ## [1.20.1] - 2025-10-14
32
+ - Patch pt subdivisions to remove superscript marker on Spanish provinces [#392](https://github.com/Shopify/worldwide/pull/392)
31
33
 
32
34
  ## [1.20.0] - 2025-10-15
33
35
  - Add has_provinces? method to Region [#396](https://github.com/Shopify/worldwide/pull/396)
data/CLAUDE.md ADDED
@@ -0,0 +1,158 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Overview
6
+
7
+ The `worldwide` gem provides internationalization and localization APIs for Ruby, including address validation/formatting, currency handling, date/time formatting, region/country data, phone validation, and more. It also includes a TypeScript/JavaScript package at `lang/typescript`.
8
+
9
+ ## Build and Development Commands
10
+
11
+ ### Ruby Gem
12
+ - Install dependencies: `bundle install`
13
+ - Run tests: `bundle exec rake test`
14
+ - Run single test file: `bundle exec ruby -Itest test/path/to/test_file.rb`
15
+ - Run single test method: `bundle exec ruby -Itest test/path/to/test_file.rb -n test_method_name`
16
+ - Lint: `bundle exec rubocop`
17
+ - Auto-fix lint issues: `bundle exec rubocop -a`
18
+ - Run tests and linting: `bundle exec rake` (default task)
19
+ - Console: `bin/console` or `bundle exec rake console`
20
+
21
+ ### TypeScript Package
22
+ - Navigate to TypeScript directory: `cd lang/typescript`
23
+ - Install dependencies: `pnpm install`
24
+ - Build: `pnpm build`
25
+ - Run tests: `pnpm test`
26
+ - Watch tests: `pnpm test:watch`
27
+ - Lint: `pnpm lint`
28
+ - Type check: `pnpm typecheck`
29
+ - Format: `pnpm format`
30
+
31
+ ### Rake Tasks
32
+ - Update CLDR data: See `rake/tasks/cldr.rake` and "Updating CLDR Data" section below
33
+
34
+ ## Updating CLDR Data
35
+
36
+ The gem uses Unicode CLDR (Common Locale Data Repository) for internationalization data. To update CLDR data, run these rake tasks **in order**:
37
+
38
+ 1. **Clean old data**: `bundle exec rake cldr:data:clean`
39
+ - Removes pre-existing CLDR files to prepare for fresh import
40
+
41
+ 2. **Import from Unicode**: `bundle exec rake cldr:data:import`
42
+ - Downloads CLDR data from unicode.org (version specified in `data/cldr.yml`)
43
+ - Converts XML to YAML format
44
+ - Stores raw data in `vendor/cldr/` and processed data in `vendor/ruby-cldr/`
45
+ - Takes several minutes; downloads ~50MB of data
46
+ - Optional: `VERSION=42` to download a specific CLDR version
47
+ - Optional: `COMPONENTS=Units,Calendars` to import specific components only
48
+
49
+ 3. **Apply patches**: `bundle exec rake cldr:data:patch`
50
+ - Applies fixes to upstream CLDR data defined in `rake/cldr/patch.rb`
51
+ - Corrects inconsistencies in CLDR (e.g., `²` duplicate markers, inconsistent naming conventions)
52
+ - Updates `data/cldr/` files with patched data
53
+
54
+ 4. **Generate additional data**: `bundle exec rake cldr:data:generate`
55
+ - Generates locale-specific data (date/time formats, missing plurals)
56
+ - Takes several minutes
57
+
58
+ 5. **Generate file indices**: `bundle exec rake cldr:data:generate_paths`
59
+ - Creates lookup indices for fast file loading
60
+
61
+ ### Adding Custom CLDR Patches
62
+
63
+ To fix CLDR data inconsistencies:
64
+
65
+ 1. Edit `rake/cldr/patch.rb` and add your patch using `patch_subdivisions` or `patch_file`
66
+ 2. Run the patch task: `bundle exec rake cldr:data:patch`
67
+ 3. Verify changes in the appropriate `data/cldr/locales/*/` file
68
+ 4. Commit both the patch code and the resulting data file changes
69
+ 5. Consider reporting the issue upstream at https://unicode-org.atlassian.net
70
+
71
+ Example patch:
72
+ ```ruby
73
+ # Remove ² markers from Spanish subdivisions in Portuguese
74
+ patch_subdivisions(:pt, [
75
+ [:esna, "Navarra²", "Navarra"],
76
+ [:esri, "La Rioja²", "La Rioja"],
77
+ ])
78
+ ```
79
+
80
+ **Important**: The `vendor/` directory is gitignored - it contains temporary build artifacts that should not be committed.
81
+
82
+ ## Architecture
83
+
84
+ ### Data-Driven Design
85
+ The gem is heavily data-driven, with locale/region data stored in YAML files under `data/`:
86
+ - `data/regions/` - Contains country/territory-specific data (one file per ISO country code)
87
+ - `data/cldr/` - Unicode CLDR data for localization
88
+ - `data/world.yml` - Global region hierarchy and metadata
89
+ - `data/country_codes.yml` - Country code mappings
90
+ - `data/extant_outcodes.yml` - Postal code prefix data for validation
91
+
92
+ ### Core Module Structure
93
+ The `Worldwide` module provides a facade with factory methods:
94
+ - `Worldwide.region(code:)` - Access region/country data
95
+ - `Worldwide.address(...)` - Create and manipulate addresses
96
+ - `Worldwide.currency(code:)` - Currency information and formatting
97
+ - `Worldwide.locale(code:)` - Locale information
98
+ - `Worldwide.numbers`, `Worldwide.names`, `Worldwide.lists` - Formatting utilities
99
+
100
+ ### Key Components
101
+
102
+ **Regions & Addresses**
103
+ - `Worldwide::Region` - Represents countries, territories, provinces, states, etc.
104
+ - `Worldwide::Address` - Address objects with validation, normalization, and formatting
105
+ - `Worldwide::AddressValidator` - Validates address completeness and correctness
106
+ - `Worldwide::Zip` - Postal code validation and normalization
107
+
108
+ **Localization**
109
+ - `Worldwide::Locale` - Locale metadata and translations
110
+ - `Worldwide::Locales` - Locale collections and lookups
111
+ - `Worldwide::RubyI18nConfig` - Configures Ruby's I18n library
112
+ - `Worldwide::Config` - Global configuration
113
+
114
+ **Formatting**
115
+ - `Worldwide::Numbers` - Number formatting per locale
116
+ - `Worldwide::Currency` - Currency symbols, names, and money formatting
117
+ - `Worldwide::TimeFormatter` - Time/date formatting helpers
118
+ - `Worldwide::Names` - Person name formatting respecting cultural conventions
119
+ - `Worldwide::Lists` - List formatting with locale-appropriate conjunctions
120
+ - `Worldwide::Punctuation` - Punctuation rules per locale
121
+
122
+ **Validation**
123
+ - `Worldwide::Phone` - Phone number validation using phonelib
124
+ - Region-specific postal code validation
125
+ - Address field completeness checking
126
+
127
+ ### Testing
128
+ Uses Minitest with:
129
+ - `minitest/autorun` for test running
130
+ - `minitest/reporters` for better output
131
+ - `minitest/focus` for focusing on specific tests (dev only)
132
+ - `mocha/minitest` for mocking/stubbing
133
+
134
+ Test files are organized under `test/worldwide/` mirroring the `lib/worldwide/` structure.
135
+
136
+ ### Dependencies
137
+ - `activesupport` (>= 7.0) - Rails utilities
138
+ - `i18n` - Ruby internationalization library
139
+ - `phonelib` (~> 0.8) - Phone number validation
140
+ - `ruby-cldr` (git ref) - CLDR data parser (dev/build only)
141
+
142
+ ### Ruby Version
143
+ Requires Ruby >= 3.1.0
144
+
145
+ ## Code Conventions
146
+ - Frozen string literals: All Ruby files should start with `# frozen_string_literal: true`
147
+ - Style: Follow Shopify Ruby style guide via `rubocop-shopify`
148
+ - Module caching: Use instance variables for caching (e.g., `@currencies_cache`)
149
+ - Data loading: Lazy-load YAML data to minimize memory footprint
150
+ - Locale awareness: Most classes accept `locale:` parameter, defaulting to `I18n.locale`
151
+
152
+ ## Important Notes
153
+ - **This is a public gem**: Avoid adding internal-only references or artifacts
154
+ - When modifying region data, update the corresponding YAML file in `data/regions/`
155
+ - CLDR data is periodically updated; don't manually edit `data/cldr/` files directly - use patches
156
+ - The gem supports both country-level and province/state-level validation
157
+ - Address formatting varies significantly by country; check `data/regions/XX.yml` for country-specific rules
158
+ - The TypeScript package provides equivalent address concatenation/splitting utilities
data/Gemfile.lock CHANGED
@@ -13,7 +13,7 @@ GIT
13
13
  PATH
14
14
  remote: .
15
15
  specs:
16
- worldwide (1.20.0)
16
+ worldwide (1.20.1)
17
17
  activesupport (>= 7.0)
18
18
  i18n
19
19
  phonelib (~> 0.8)
@@ -1076,15 +1076,15 @@ pt:
1076
1076
  esmc: Região de Múrcia
1077
1077
  esmd: Comunidade de Madrid
1078
1078
  esml: Melilla
1079
- esna: Navarra²
1079
+ esna: Navarra
1080
1080
  esnc: Navarra
1081
1081
  esor: Ourense
1082
1082
  esp: Palência
1083
- espm: Baleares²
1083
+ espm: Baleares
1084
1084
  espo: Pontevedra
1085
1085
  espv: Comunidade autónoma do País Basco
1086
1086
  esri: La Rioja²
1087
- ess: Cantábria²
1087
+ ess: Cantábria
1088
1088
  essa: Salamanca
1089
1089
  esse: Província de Sevilha
1090
1090
  essg: Segóvia
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Worldwide
4
- VERSION = "1.20.0"
4
+ VERSION = "1.20.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: worldwide
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.20.0
4
+ version: 1.20.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
@@ -72,6 +72,7 @@ files:
72
72
  - ".ruby-version"
73
73
  - ".vscode/settings.json"
74
74
  - CHANGELOG.md
75
+ - CLAUDE.md
75
76
  - Gemfile
76
77
  - Gemfile.lock
77
78
  - LICENSE.md