human_number 0.1.8 → 0.1.10

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: 42fe66194bf6870029efef196173647a511774b68b13faee24f237d665972722
4
- data.tar.gz: bceac8e6a9b6ff97f8737c72068b0e2e98f11c2525dc0572c42218376e0389dc
3
+ metadata.gz: 25a997b6244948ebded5aa57455a54c930b8ea0f6255e17f620a315e578d0b58
4
+ data.tar.gz: 5ee0a391c1875a6cde5843535949a7995d87ccbc179ffd7734f315e0292f5c98
5
5
  SHA512:
6
- metadata.gz: d39a9b87d7e0f1a8e7bcecbf7184931bfb35c48047992772a2635aeac8079cbaeb31a766e3443afa789b4fb9f45a1a69abe194ab0f309098c43e6860b384d052
7
- data.tar.gz: ea2765ffb9962d98ec8fcd52db74a877edf20cbaa0dae1903c6d8d6edc748016160695734f0f52ca4279a16e65aae3fa235bcce28ec776376440d736fda709cc
6
+ metadata.gz: d566ce576fbf747a5db5263a4ed8fbe84e20ea11d96d51da4217e80ba9c0046eaa1f4e5b4a0e87494be49444e57ed1f5823354050a28edae15c25403ffbc889a
7
+ data.tar.gz: 0e2e0b57bba47bcd184990bd3988b4121abc8297246bd8f8a21fb53c32dbb17a3d39d2547c0dd4f7ea202c543265878698e39b918f4e84c1b2465a98089e1bb5
data/CHANGELOG.md CHANGED
@@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.1.10] - 2025-08-19
9
+
10
+ ### Changed
11
+
12
+ - **BREAKING CHANGE: Default number formatting behavior**: Changed `max_digits` default value from `2` to `nil`
13
+ - Numbers now display complete breakdown by default (e.g., `"1M 234K 567"` instead of `"1.2M"`)
14
+ - Previous abbreviated behavior still available by explicitly setting `max_digits: 2`
15
+ - Affects all methods: `HumanNumber.human_number()`, `HumanNumber.human_currency()`, and Rails helpers
16
+ - Provides safer default behavior with no information loss
17
+ - Maintains backward compatibility for explicit `max_digits` parameter usage
18
+
19
+ ## [0.1.9] - 2025-08-05
20
+
21
+ ### Changed
22
+ - **East Asian separator formatting**: Japanese numbers now use culturally appropriate spacing
23
+ - Japanese: `'12億3456万7890円'` (no spaces between units)
24
+ - Korean/Chinese: `'12억 3456만 7890원'` (spaces maintained as default)
25
+ - **Locale-based separator configuration**: Added `number.human.decimal_units.separator` for customizable unit separators
26
+
8
27
  ## [0.1.8] - 2025-08-05
9
28
 
10
29
  ### Fixed
@@ -102,5 +121,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
102
121
  - **Formatters::Currency**: Currency symbol and format string application
103
122
  - **Clean separation**: Number formatting independent of currency concerns
104
123
 
124
+ [0.1.10]: https://github.com/ether-moon/human_number/releases/tag/v0.1.10
125
+ [0.1.9]: https://github.com/ether-moon/human_number/releases/tag/v0.1.9
105
126
  [0.1.8]: https://github.com/ether-moon/human_number/releases/tag/v0.1.8
106
127
  [0.1.0]: https://github.com/ether-moon/human_number/releases/tag/v0.1.0
data/README.md CHANGED
@@ -158,9 +158,14 @@ HumanNumber.human_number(1_000_000_000, locale: :en) #=> "1B"
158
158
  HumanNumber.human_number(1_234_567, locale: :ko) #=> "120만"
159
159
  HumanNumber.human_number(1_234_567, locale: :ja) #=> "120万"
160
160
  HumanNumber.human_number(100_000_000, locale: :ko) #=> "1억"
161
+
162
+ # Complete mode shows cultural spacing differences
163
+ HumanNumber.human_number(12_345_678, locale: :ko, max_digits: nil) #=> "1234만 5678" # Korean: spaces
164
+ HumanNumber.human_number(12_345_678, locale: :ja, max_digits: nil) #=> "1234万5678" # Japanese: no spaces
161
165
  ```
162
166
 
163
- **Units:** 만/万 (ten thousand), 억/億 (hundred million), 조/兆 (trillion)
167
+ **Units:** 만/万 (ten thousand), 억/億 (hundred million), 조/兆 (trillion)
168
+ **Cultural spacing:** Japanese uses no spaces between units, Korean/Chinese use spaces (configurable via locale files)
164
169
 
165
170
  ### Indian System (lakh/crore)
166
171
  **Used by:** Hindi (hi), Urdu (ur), Bengali (bn), Indian English (en-IN)
@@ -74,7 +74,7 @@ module HumanNumber
74
74
  def default_options
75
75
  {
76
76
  abbr_units: true,
77
- max_digits: 2,
77
+ max_digits: nil,
78
78
  min_unit: nil,
79
79
  trim_zeros: true,
80
80
  }.freeze
@@ -419,6 +419,11 @@ module HumanNumber
419
419
  ].freeze
420
420
 
421
421
  class << self
422
+ def format_number(number, locale:, abbr_units: true, min_unit: nil, max_digits: 2, trim_zeros: true)
423
+ @current_locale = locale.to_sym
424
+ super
425
+ end
426
+
422
427
  private
423
428
 
424
429
  def unit_definitions
@@ -437,6 +442,18 @@ module HumanNumber
437
442
  def apply_symbol_formatting_rules(symbol, _abbr_units)
438
443
  symbol
439
444
  end
445
+
446
+ # Apply culturally appropriate separators for East Asian languages
447
+ def finalize_result(number, formatted_parts)
448
+ separator = lookup_decimal_separator(@current_locale)
449
+ combined_result = formatted_parts.join(separator)
450
+ number.negative? ? "-#{combined_result}" : combined_result
451
+ end
452
+
453
+ # Look up separator from locale file, default to space
454
+ def lookup_decimal_separator(locale)
455
+ I18n.t("#{I18N_DECIMAL_UNITS_KEY}.separator", locale: locale, default: SPACE_SEPARATOR)
456
+ end
440
457
  end
441
458
  end
442
459
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HumanNumber
4
- VERSION = "0.1.8"
4
+ VERSION = "0.1.10"
5
5
  end
data/lib/locales/ja.yml CHANGED
@@ -8,6 +8,7 @@ ja:
8
8
  unit: "¥"
9
9
  human:
10
10
  decimal_units:
11
+ separator: ""
11
12
  abbr_units:
12
13
  thousand: "千"
13
14
  ten_thousand: "万"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: human_number
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ether Moon