Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ["3.2", "3.3", "3.4"]
ruby-version: ["3.3", "3.4", "4.0"]
cldr-version: [41]

steps:
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inherit_gem:
rubocop-shopify: rubocop.yml

AllCops:
TargetRubyVersion: 3.2
TargetRubyVersion: 3.3
UseCache: true
CacheRootDirectory: tmp/rubocop
NewCops: enable
Expand Down
25 changes: 13 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ GEM
rake
rdoc
semver2
json (2.17.1.2)
json (2.21.1)
jwt (2.10.3)
base64
language_server-protocol (3.17.0.6)
Expand Down Expand Up @@ -79,8 +79,8 @@ GEM
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
parallel (1.27.0)
parser (3.3.10.0)
parallel (2.1.0)
parser (3.3.11.1)
ast (~> 2.4.1)
racc
power_assert (3.0.1)
Expand Down Expand Up @@ -109,25 +109,26 @@ GEM
erb
psych (>= 4.0.0)
tsort
regexp_parser (2.11.3)
regexp_parser (2.12.0)
reline (0.6.3)
io-console (~> 0.5)
rubocop (1.81.7)
rubocop (1.88.2)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (~> 1.10)
parallel (>= 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.47.1, < 2.0)
rubocop-ast (>= 1.49.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.48.0)
rubocop-ast (1.50.0)
parser (>= 3.3.7.2)
prism (~> 1.4)
rubocop-shopify (2.18.0)
rubocop (~> 1.62)
prism (~> 1.7)
rubocop-shopify (3.0.1)
lint_roller
rubocop (~> 1.72, >= 1.72.1)
ruby-lsp (0.26.10)
language_server-protocol (~> 3.17.0)
prism (>= 1.2, < 2.0)
Expand All @@ -143,7 +144,7 @@ GEM
tsort (0.2.0)
unicode-display_width (3.2.0)
unicode-emoji (~> 4.1)
unicode-emoji (4.1.0)
unicode-emoji (4.2.0)

PLATFORMS
aarch64-linux
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ There are still a number of issues that need to be addressed before it can be co

## Requirements

* Ruby 3.2+
* Ruby 3.3+
* [Thor](http://whatisthor.com/)

## Installation
Expand Down
6 changes: 3 additions & 3 deletions lib/cldr/export/data/aliases.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Export
module Data
class Aliases < Base
# only these aliases will be exported
ALIAS_TAGS = ["languageAlias", "territoryAlias"]
ALIAS_TAGS = ["languageAlias", "territoryAlias"].freeze

def initialize
super(nil)
Expand All @@ -16,8 +16,8 @@ def initialize
private

def aliases
ALIAS_TAGS.each_with_object({}) do |alias_tag, ret|
ret[alias_tag.sub("Alias", "")] = alias_for(alias_tag)
ALIAS_TAGS.to_h do |alias_tag|
[alias_tag.sub("Alias", ""), alias_for(alias_tag)]
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/cldr/export/data/lists.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def list_pattern(list_pattern)
end

def get_pattern_parts(list_pattern)
select(list_pattern, "listPatternPart").each_with_object({}) do |part, part_ret|
part_ret[part.attribute("type").value.to_sym] = part.content
select(list_pattern, "listPatternPart").to_h do |part|
[part.attribute("type").value.to_sym, part.content]
end
end

Expand Down
6 changes: 3 additions & 3 deletions lib/cldr/export/data/locale_display_pattern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ def initialize(locale)
private

def locale_display_pattern
@locale_display_pattern ||= select("localeDisplayNames/localeDisplayPattern/*").each_with_object({}) do |node, result|
result[node.name.underscore] = node.content
end
@locale_display_pattern ||= select("localeDisplayNames/localeDisplayPattern/*").to_h do |node|
[node.name.underscore, node.content]
end
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/cldr/export/data/numbers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def symbols(number_system)
return xpath_to_symbols_alias(aliased["path"])
end

select("numbers/symbols[@numberSystem=\"#{number_system}\"]/*").each_with_object({}) do |node, result|
result[name(node).to_sym] = node.content
select("numbers/symbols[@numberSystem=\"#{number_system}\"]/*").to_h do |node|
[name(node).to_sym, node.content]
end
end

Expand Down
12 changes: 6 additions & 6 deletions lib/cldr/export/data/plural_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ def initialize(locale)
super()

find_rules(locale).each_pair do |rule_type, rule_data|
self[rule_type.to_sym] = rule_data.each_with_object({}) do |rule, ret|
ret[rule.attributes["count"].text] = rule.text
end
self[rule_type.to_sym] = rule_data.to_h do |rule|
[rule.attributes["count"].text, rule.text]
end
end

deep_sort!
Expand All @@ -23,9 +23,9 @@ def initialize(locale)
private

def sources
@sources ||= ["plurals", "ordinals"].each_with_object({}) do |source_name, ret|
ret[source_name] = Cldr::Export::DataFile.parse(File.read("#{Cldr::Export::Data::RAW_DATA.directory}/supplemental/#{source_name}.xml"))
end
@sources ||= ["plurals", "ordinals"].to_h do |source_name|
[source_name, Cldr::Export::DataFile.parse(File.read("#{Cldr::Export::Data::RAW_DATA.directory}/supplemental/#{source_name}.xml"))]
end
end

def find_rules(locale)
Expand Down
2 changes: 1 addition & 1 deletion lib/cldr/export/data/plurals/rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def to_ruby(options = {})
ruby = namespaces.reverse.inject(ruby) { |ruby, namespace| "{ #{namespace.inspect} => #{ruby} }" }
"#{locale.inspect} => #{ruby}"
end.join(",\n")
code = code.split("\n").map(&:to_s).join("\n")
code = code.split("\n").join("\n")
"{ #{code} }"
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/cldr/export/data/timezones.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def metazones
protected

def nodes_to_hash(nodes)
nodes.each_with_object({}) do |node, result|
result[node.name.to_sym] = node.content
nodes.to_h do |node|
[node.name.to_sym, node.content]
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions lib/cldr/export/data/units.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ def initialize(locale)
private

def unit_length
select("units/unitLength").each_with_object({}) do |node, result|
result[node.attribute("type").value.underscore.to_sym] = units(node)
select("units/unitLength").to_h do |node|
[node.attribute("type").value.underscore.to_sym, units(node)]
end
end

def units(node)
aliased = select_single(node, "alias")
return units_xpath_to_key(aliased.attribute("path").value) if aliased

node.xpath("unit").each_with_object({}) do |node, result|
result[node.attribute("type").value.underscore.to_sym] = unit(node)
node.xpath("unit").to_h do |node|
[node.attribute("type").value.underscore.to_sym, unit(node)]
end
end

Expand All @@ -47,8 +47,8 @@ def unit(node)
end

def duration_unit
select("units/durationUnit").each_with_object({}) do |node, result|
result[node.attribute("type").value.underscore.to_sym] = node.xpath("durationUnitPattern").first.content
select("units/durationUnit").to_h do |node|
[node.attribute("type").value.underscore.to_sym, node.xpath("durationUnitPattern").first.content]
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/cldr/export/data/variables.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Export
module Data
class Variables < Base
# only these variables will be exported
VARIABLE_IDS = ["$grandfathered", "$language", "$territory", "$script", "$variant"]
VARIABLE_IDS = ["$grandfathered", "$language", "$territory", "$script", "$variant"].freeze

def initialize
super(nil)
Expand Down
2 changes: 1 addition & 1 deletion lib/cldr/export/deep_validate_keys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def validate(hash, component, key_path = [])
["."],
[".", "."],
],
}
}.freeze

def paths_match?(pattern, key)
raise NotImplementedError, "Multiple * in pattern is unsupported" if pattern.count { |element| element == "*" } > 1
Expand Down
4 changes: 2 additions & 2 deletions lib/cldr/format/date.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Date < Datetime::Base
"E" => :weekday,
"e" => :weekday_local,
"c" => :weekday_local_stand_alone,
}
}.freeze

def era(date, pattern, length)
raise NotImplementedError, "not implemented"
Expand Down Expand Up @@ -119,7 +119,7 @@ def day(date, pattern, length)
end
end

WEEKDAY_KEYS = [:sun, :mon, :tue, :wed, :thu, :fri, :sat]
WEEKDAY_KEYS = [:sun, :mon, :tue, :wed, :thu, :fri, :sat].freeze

def weekday(date, pattern, length)
key = WEEKDAY_KEYS[date.wday]
Expand Down
4 changes: 2 additions & 2 deletions lib/cldr/format/datetime/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def initialize(format, calendar)
protected

def compile(format)
(class << self; self; end).class_eval(<<-code)
(class << self; self; end).class_eval(<<-CODE)
def apply(date, options = {}); #{compile_format(format)}; end
code
CODE
end

# compile_format("EEEE, d. MMMM y") # =>
Expand Down
2 changes: 1 addition & 1 deletion lib/cldr/format/decimal/number.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Decimal
class Number
attr_reader :prefix, :suffix, :integer_format, :fraction_format, :symbols

DEFAULT_SYMBOLS = { group: ",", decimal: ".", plus_sign: "+", minus_sign: "-" }
DEFAULT_SYMBOLS = { group: ",", decimal: ".", plus_sign: "+", minus_sign: "-" }.freeze
FORMAT_PATTERN = /([^0#,\.]*)([0#,\.]+)([^0#,\.]*)$/

def initialize(format, symbols = {})
Expand Down
2 changes: 1 addition & 1 deletion lib/cldr/format/time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Time < Datetime::Base
"Z" => :timezone,
"v" => :timezone_generic_non_location,
"V" => :timezone_metazone,
}
}.freeze

def period(time, pattern, length)
calendar[:periods][:format][:wide][time.strftime("%p").downcase.to_sym]
Expand Down
2 changes: 1 addition & 1 deletion lib/cldr/ldml/attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def parse(attlist, comments)

attr_reader :element_name, :attribute_name, :type, :mode

def initialize(element_name, attribute_name, type, mode, status, deprecated) # rubocop:disable Metrics/ParameterLists
def initialize(element_name, attribute_name, type, mode, status, deprecated)
@element_name = element_name
@attribute_name = attribute_name
@type = type
Expand Down
2 changes: 1 addition & 1 deletion lib/cldr/validate_upstream_assumptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def validate_aliases_only_in_root_locale

# Aliases need explicit special handling. Once that handling has been added,
# the element chain covered by the handling gets added to this list.
SUPPORTED_ALIAS_ELEMENT_CHAINS = [ # rubocop:disable Metrics/CollectionLiteralLength
SUPPORTED_ALIAS_ELEMENT_CHAINS = [
"/ldml/dates/calendars/calendar[@type=\"gregorian\"]/dayPeriods/dayPeriodContext[@type=\"format\"]/dayPeriodWidth[@type=\"narrow\"]/alias",
"/ldml/dates/calendars/calendar[@type=\"gregorian\"]/dayPeriods/dayPeriodContext[@type=\"format\"]/dayPeriodWidth[@type=\"wide\"]/alias",
"/ldml/dates/calendars/calendar[@type=\"gregorian\"]/dayPeriods/dayPeriodContext[@type=\"stand-alone\"]/dayPeriodWidth[@type=\"abbreviated\"]/alias",
Expand Down
2 changes: 1 addition & 1 deletion lib/core_ext/hash/deep_prune.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ def deep_prune!(comparator = ->(v) { v.is_a?(Hash) && v.empty? })
end
end

Hash.send(:include, DeepPrune)
Hash.include DeepPrune
2 changes: 1 addition & 1 deletion lib/core_ext/hash/deep_sort.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ def <=>(other)
end
end

Hash.send(:include, DeepSort::DeepSortHash)
Hash.include DeepSort::DeepSortHash
6 changes: 0 additions & 6 deletions ruby-cldr.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,4 @@ Gem::Specification.new do |s|
s.add_dependency("psych", [">= 4.0.0"])
s.add_dependency("rubyzip", [">= 0"])
s.add_dependency("thor", [">= 1.3.0"])
s.add_development_dependency("jeweler", [">= 0"])
s.add_development_dependency("pry", [">= 0"])
s.add_development_dependency("pry-nav", [">= 0"])
s.add_development_dependency("rubocop-shopify", [">= 0"])
s.add_development_dependency("ruby-lsp", [">= 0"])
s.add_development_dependency("test-unit", [">= 0"])
end
3 changes: 1 addition & 2 deletions test/export/data/currencies_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

class TestCldrCurrencies < Test::Unit::TestCase
test "currencies :de" do
# rubocop:disable Layout/MultilineArrayLineBreaks
codes = [ # rubocop:disable Metrics/CollectionLiteralLength
codes = [
:ADP, :AED, :AFA, :AFN, :ALL, :AMD, :ANG, :AOA, :AOK, :AON, :AOR,
:ARA, :ARP, :ARS, :ATS, :AUD, :AWG, :AZM, :AZN, :BAD, :BAM, :BBD,
:BDT, :BEC, :BEF, :BEL, :BGL, :BGN, :BHD, :BIF, :BMD, :BND, :BOB,
Expand Down
3 changes: 1 addition & 2 deletions test/export/data/languages_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

class TestCldrDataLanguages < Test::Unit::TestCase
test "languages :de" do
# rubocop:disable Layout/MultilineArrayLineBreaks
codes = [ # rubocop:disable Metrics/CollectionLiteralLength
codes = [
:aa, :ab, :ace, :ach, :ada, :ady, :ae, :aeb, :af,
:afh, :agq, :ain, :ak, :akk, :akz, :ale, :aln, :alt, :am,
:an, :ang, :anp, :ar, :"ar-001", :arc, :arn, :aro, :arp,
Expand Down
Loading
Loading