icu4x 0.5.2-x86_64-linux → 0.6.1-x86_64-linux

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: b1d7e0a07b1ef3854c298d00dc2b890dac0de72cb0fdda96f81ebc0ca80da53d
4
- data.tar.gz: e92ea08fe5727fb9feaf2441ce365fae13dc6ba1316d478ec539ad691b5e3dfb
3
+ metadata.gz: ec01535e816ded3136a1bb3c6f8dbbd76e00d8aa60caf627499b00003d6fdebc
4
+ data.tar.gz: ea6b3b455b5e38856071f9e3fb0a56aa9c023f6873f240355dca94c8caf2e945
5
5
  SHA512:
6
- metadata.gz: afe1bc9f2f6c817e71633f7fbc03bb38ef56932ec26716f7e51872307c76c5355445a68cbf90d1ec3d4808d9baff2020cc738cf636aac6e85fa8026392c068fd
7
- data.tar.gz: daa307d4f33f5e567654d7a22ebc64d1ddd2d9cbd0259356ec8b33b35da2b54b80b308c775d6080e2de9013a422bbe02f41c8e311d6615303f3a82ee46055bda
6
+ metadata.gz: c3b51a4f16c85c84d6facc0e701263c2600e17adb9fd78bbc0337aea762d37572afcdf547fbe66d84efe23238e3781daf4a2fca042761879a34b69bcad541c7d
7
+ data.tar.gz: 521eb35ef28f1c384413d3e821a8c9b065c17d11f6677b95034c686f55d0a23cb8c9256c205b99ba5441036eb69556a9aabb2a6d8c446e82cd3d1656cf5d4c6f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.6.1] - 2026-01-02
4
+
5
+ ### Changed
6
+
7
+ - Re-release to publish companion data gems with Trusted Publisher configuration
8
+
9
+ ## [0.6.0] - 2026-01-02
10
+
11
+ ### Added
12
+
13
+ - **Companion data gems**: `icu4x-data-full`, `icu4x-data-recommended`, `icu4x-data-modern` for bundled locale data
14
+ - Auto-configures default provider on require (e.g., `require "icu4x/data/recommended"`)
15
+ - **RakeTask**: `ICU4X::RakeTask` for integrating data generation into build workflows
16
+ - **Symbolic locale specifiers**: `DataGenerator.export` accepts `:full`, `:recommended`, `:modern`, `:moderate`, `:basic` symbols
17
+ - **Automatic 'und' locale**: `DataGenerator.export` automatically includes the `und` (undetermined) locale for fallback
18
+
3
19
  ## [0.5.2] - 2026-01-01
4
20
 
5
21
  ### Fixed
data/README.md CHANGED
@@ -35,7 +35,28 @@ Add to your Gemfile:
35
35
  gem "icu4x"
36
36
  ```
37
37
 
38
- Then generate locale data for your application:
38
+ ### Option 1: Use Pre-built Data Gem (Quick Start)
39
+
40
+ Add a companion data gem for instant setup:
41
+
42
+ ```ruby
43
+ gem "icu4x"
44
+ gem "icu4x-data-recommended" # 164 locales, ~24MB
45
+ ```
46
+
47
+ ```ruby
48
+ require "icu4x"
49
+ require "icu4x/data/recommended" # Auto-configures default provider
50
+ ```
51
+
52
+ Available data gems:
53
+ - `icu4x-data-full` - All CLDR locales (700+)
54
+ - `icu4x-data-recommended` - Recommended locales (164)
55
+ - `icu4x-data-modern` - Modern coverage locales (103)
56
+
57
+ ### Option 2: Generate Custom Data
58
+
59
+ For fine-grained control, generate only the locales you need:
39
60
 
40
61
  ```ruby
41
62
  require "icu4x"
Binary file
Binary file
Binary file
@@ -0,0 +1,133 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "erb"
4
+ require "fileutils"
5
+ require "pathname"
6
+ require "rake"
7
+ require "rake/tasklib"
8
+ require "rubygems"
9
+ require "rubygems/package"
10
+
11
+ module ICU4X
12
+ # Rake task for generating ICU4X data companion gems.
13
+ #
14
+ # @example Basic usage
15
+ # require "icu4x/data_gem_task"
16
+ #
17
+ # ICU4X::DataGemTask.new
18
+ #
19
+ # This creates the following tasks:
20
+ # - +icu4x:data_gems:build+ - Build all data gems
21
+ # - +icu4x:data_gems:build:full+ - Build icu4x-data-full gem
22
+ # - +icu4x:data_gems:build:recommended+ - Build icu4x-data-recommended gem
23
+ # - +icu4x:data_gems:build:modern+ - Build icu4x-data-modern gem
24
+ # - +icu4x:data_gems:clean+ - Clean data gem build artifacts
25
+ class DataGemTask < ::Rake::TaskLib
26
+ VARIANTS = {
27
+ full: {locales: :full, description: "All CLDR locales (700+)"},
28
+ recommended: {locales: :recommended, description: "Recommended locales (164)"},
29
+ modern: {locales: :modern, description: "Modern coverage locales (103)"}
30
+ }.freeze
31
+ public_constant :VARIANTS
32
+
33
+ TEMPLATE_DIR = Pathname(__dir__).join("../../templates/data_gem")
34
+ public_constant :TEMPLATE_DIR
35
+
36
+ def initialize
37
+ super
38
+ define_tasks
39
+ end
40
+
41
+ private def define_tasks
42
+ namespace "icu4x:data_gems" do
43
+ desc "Build all data gems"
44
+ task build: VARIANTS.keys.map {|v| "build:#{v}" }
45
+
46
+ VARIANTS.each do |variant, config|
47
+ desc "Build icu4x-data-#{variant} gem"
48
+ task "build:#{variant}" => :compile do
49
+ build_gem(variant, config)
50
+ end
51
+ end
52
+
53
+ desc "Clean data gem build artifacts"
54
+ task :clean do
55
+ VARIANTS.each_key {|v| FileUtils.rm_rf(tmp_dir(v)) }
56
+ end
57
+ end
58
+ end
59
+
60
+ private def build_gem(variant, config)
61
+ gem_dir = prepare_gem_structure(variant, config)
62
+ generate_data_blob(gem_dir, variant, config[:locales])
63
+ package_gem(gem_dir, variant)
64
+ end
65
+
66
+ private def prepare_gem_structure(variant, config)
67
+ gem_dir = tmp_dir(variant)
68
+ FileUtils.rm_rf(gem_dir)
69
+ gem_dir.mkpath
70
+
71
+ # Render templates
72
+ require "icu4x/version"
73
+ render_template(
74
+ "gemspec.erb",
75
+ gem_dir / "icu4x-data-#{variant}.gemspec",
76
+ variant:,
77
+ config:,
78
+ version: ICU4X::VERSION
79
+ )
80
+ render_template(
81
+ "README.md.erb",
82
+ gem_dir / "README.md",
83
+ variant:,
84
+ config:
85
+ )
86
+
87
+ lib_data_dir = gem_dir / "lib" / "icu4x" / "data"
88
+ lib_data_dir.mkpath
89
+ render_template(
90
+ "lib/icu4x/data/variant.rb.erb",
91
+ lib_data_dir / "#{variant}.rb",
92
+ variant:
93
+ )
94
+
95
+ # Copy LICENSE
96
+ FileUtils.cp("LICENSE.txt", gem_dir / "LICENSE.txt")
97
+
98
+ gem_dir
99
+ end
100
+
101
+ private def generate_data_blob(gem_dir, variant, locales)
102
+ data_dir = gem_dir / "data"
103
+ data_dir.mkpath
104
+
105
+ require "icu4x"
106
+ ICU4X::DataGenerator.export(
107
+ locales:,
108
+ markers: :all,
109
+ format: :blob,
110
+ output: data_dir / "#{variant}.postcard"
111
+ )
112
+ end
113
+
114
+ private def package_gem(gem_dir, variant)
115
+ Dir.chdir(gem_dir) do
116
+ spec = Gem::Specification.load("icu4x-data-#{variant}.gemspec")
117
+ gem_file = Gem::Package.build(spec)
118
+ pkg_dir = Pathname("../../pkg")
119
+ pkg_dir.mkpath
120
+ FileUtils.mv(gem_file, pkg_dir / gem_file)
121
+ end
122
+ end
123
+
124
+ private def render_template(template_name, output_path, **locals)
125
+ template = ERB.new(TEMPLATE_DIR.join(template_name).read, trim_mode: "-")
126
+ binding_with_locals = binding
127
+ locals.each {|k, v| binding_with_locals.local_variable_set(k, v) }
128
+ output_path.write(template.result(binding_with_locals))
129
+ end
130
+
131
+ private def tmp_dir(variant) = Pathname("tmp/icu4x-data-#{variant}")
132
+ end
133
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rake"
4
+ require "rake/clean"
5
+ require "rake/tasklib"
6
+
7
+ module ICU4X
8
+ # Rake task for generating ICU4X data blobs.
9
+ #
10
+ # @example Basic usage
11
+ # require "icu4x/rake_task"
12
+ #
13
+ # ICU4X::RakeTask.new do |t|
14
+ # t.output = "data/icu4x.postcard"
15
+ # end
16
+ #
17
+ # @example Custom task name and locales
18
+ # ICU4X::RakeTask.new("myapp:generate_data") do |t|
19
+ # t.locales = %w[en ja de]
20
+ # t.output = "data/icu4x.postcard"
21
+ # end
22
+ class RakeTask < ::Rake::TaskLib
23
+ # @return [String] The name of the task
24
+ attr_reader :name
25
+
26
+ # @return [Symbol, Array<String>] Locale specifier or array of locale strings
27
+ # Defaults to +:recommended+
28
+ attr_accessor :locales
29
+
30
+ # @return [Symbol, Array<String>] Data markers to include
31
+ # Defaults to +:all+
32
+ attr_accessor :markers
33
+
34
+ # @return [Pathname, String] Output path relative to Rakefile
35
+ attr_accessor :output
36
+
37
+ # Creates a new RakeTask.
38
+ #
39
+ # @param name [String] Task name (default: "icu4x:data:generate")
40
+ # @yield [self] Configuration block
41
+ # @yieldparam task [RakeTask] The task instance for configuration
42
+ def initialize(name="icu4x:data:generate")
43
+ super()
44
+ @name = name
45
+ @locales = :recommended
46
+ @markers = :all
47
+ @output = nil
48
+
49
+ yield self if block_given?
50
+
51
+ raise ArgumentError, "output is required" if @output.nil?
52
+
53
+ define_tasks
54
+ end
55
+
56
+ private def define_tasks
57
+ output_path = Pathname(@output)
58
+
59
+ desc "Generate ICU4X data blob"
60
+ file output_path.to_s do
61
+ require "icu4x"
62
+ output_path.dirname.mkpath
63
+ ICU4X::DataGenerator.export(
64
+ locales: @locales,
65
+ markers: @markers,
66
+ format: :blob,
67
+ output: output_path
68
+ )
69
+ end
70
+
71
+ desc "Generate ICU4X data blob"
72
+ task @name => output_path.to_s
73
+
74
+ CLOBBER.include(output_path.to_s)
75
+ end
76
+ end
77
+ end
data/lib/icu4x/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ICU4X
4
- VERSION = "0.5.2"
4
+ VERSION = "0.6.1"
5
5
  public_constant :VERSION
6
6
  end
@@ -112,7 +112,18 @@
112
112
  # class DataGenerator
113
113
  # # Exports locale data to a file.
114
114
  # #
115
- # # @param locales [Array<String>] list of locale identifiers to include
115
+ # # The +locales+ parameter accepts either a Symbol for predefined locale sets
116
+ # # based on CLDR coverage levels, or an Array of locale identifier strings.
117
+ # # When using +with_descendants+, ancestor locales (including +und+) are
118
+ # # automatically included for fallback support.
119
+ # #
120
+ # # @param locales [Symbol, Array<String>] locale specification:
121
+ # # - +:full+ - all CLDR locales (700+)
122
+ # # - +:recommended+ - locales with basic, moderate, or modern coverage (164)
123
+ # # - +:modern+ - locales with modern coverage only (103)
124
+ # # - +:moderate+ - locales with moderate coverage only
125
+ # # - +:basic+ - locales with basic coverage only
126
+ # # - +Array<String>+ - explicit list of locale identifiers
116
127
  # # @param markers [Symbol, Array<String>] data markers to include;
117
128
  # # use +:all+ for all markers, or specify individual marker names
118
129
  # # @param format [Symbol] output format, currently only +:blob+ is supported
@@ -128,7 +139,16 @@
128
139
  # # output: Pathname.new("i18n_data.postcard")
129
140
  # # )
130
141
  # #
142
+ # # @example Export data for all modern coverage locales
143
+ # # ICU4X::DataGenerator.export(
144
+ # # locales: :modern,
145
+ # # markers: :all,
146
+ # # format: :blob,
147
+ # # output: Pathname.new("modern_data.postcard")
148
+ # # )
149
+ # #
131
150
  # # @see .available_markers
151
+ # # @see https://cldr.unicode.org/index/cldr-spec/coverage-levels CLDR Coverage Levels
132
152
  # #
133
153
  # def self.export(locales:, markers:, format:, output:); end
134
154
  #
@@ -138,7 +158,7 @@
138
158
  # #
139
159
  # # @example
140
160
  # # markers = ICU4X::DataGenerator.available_markers
141
- # # #=> ["datetime/gregory/datelengths@1", "decimal/symbols@1", ...]
161
+ # # #=> ["CalendarJapaneseExtendedV1", "CalendarJapaneseModernV1", ...]
142
162
  # #
143
163
  # def self.available_markers; end
144
164
  # end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icu4x
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.1
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - OZAWA Sakuro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-01 00:00:00.000000000 Z
11
+ date: 2026-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable
@@ -38,6 +38,8 @@ files:
38
38
  - lib/icu4x/3.2/icu4x.so
39
39
  - lib/icu4x/3.3/icu4x.so
40
40
  - lib/icu4x/3.4/icu4x.so
41
+ - lib/icu4x/data_gem_task.rb
42
+ - lib/icu4x/rake_task.rb
41
43
  - lib/icu4x/version.rb
42
44
  - lib/icu4x/yard_docs.rb
43
45
  - sig/icu4x.rbs