nepali_number 0.1.1 → 0.2.0
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +54 -2
- data/lib/nepali_number/formatter.rb +17 -1
- data/lib/nepali_number/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a820051dbeea8f45d3a9f5b8e23b170f3d2339827cbbf94a9a81c0074cb7bf95
|
|
4
|
+
data.tar.gz: 69652253a7c525b58b6f41d67f7663e0193adf1083ecf36fcdb4b51ce9584a19
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4c6b68ff373bfef520a3bbe2d9f6a88ddad7b910d203a775dac8d39d5b245e3c6d67636a28d4b9eb1494f8d0ec9d4ee3c57614fff70ed2434de74fdf80c4b357
|
|
7
|
+
data.tar.gz: 86c53d7f1287b9b6ae95c21ce6a1e262f3e6b45dfbb344c2e60a46375fdcfb73fbb1f21acc6e60bc98370bd1e5110a7d51984926cff2252d47f5ed597282ff8f
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
## [0.2.0] - 2026-10-05
|
|
2
|
+
|
|
3
|
+
- Fix whole `BigDecimal` values rendering with a phantom decimal place. `BigDecimal#to_s("F")` always emits at least one digit after the point, so `NepaliNumber.format(BigDecimal("10"))` returned `"10.0"` and `BigDecimal("100.00")` returned `"100.0"`. Whole values now render as whole numbers: `"10"`, `"1,00,000"`. This also reaches `NepaliNumber.currency`, where whole money previously gained a `.0`.
|
|
4
|
+
- A value that genuinely carries a fraction is unchanged (`BigDecimal("10.5")` still formats as `"10.5"`). Truncating or rounding a fraction stays the caller's decision; the formatter no longer invents one.
|
|
5
|
+
|
|
1
6
|
## [0.1.1] - 2026-09-06
|
|
2
7
|
|
|
3
8
|
- Change default currency symbol from `रु.` to `रु` and remove the default space, so `NepaliNumber.currency(100)` now returns `रु100` (matching `रु1.45` style per Wikipedia/NPR convention).
|
data/README.md
CHANGED
|
@@ -22,6 +22,18 @@ NepaliNumber.format("123456.78")
|
|
|
22
22
|
# => "1,23,456.78"
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
A `BigDecimal` with no fractional part formats as a whole number, whatever scale
|
|
26
|
+
its literal carried. One that genuinely has a fraction keeps it, so rounding or
|
|
27
|
+
truncating stays the caller's decision rather than the formatter's.
|
|
28
|
+
|
|
29
|
+
```ruby
|
|
30
|
+
NepaliNumber.format(BigDecimal("100.0000"))
|
|
31
|
+
# => "100"
|
|
32
|
+
|
|
33
|
+
NepaliNumber.format(BigDecimal("10.5"))
|
|
34
|
+
# => "10.5"
|
|
35
|
+
```
|
|
36
|
+
|
|
25
37
|
### Currency
|
|
26
38
|
|
|
27
39
|
```ruby
|
|
@@ -63,9 +75,49 @@ When Rails is loaded, NepaliNumber adds explicit helpers:
|
|
|
63
75
|
|
|
64
76
|
## Development
|
|
65
77
|
|
|
66
|
-
After checking out the repo, run `bin/setup`
|
|
78
|
+
After checking out the repo, run `bin/setup` (or `bundle install`) to install dependencies. You can also run `bin/console` for an interactive prompt.
|
|
79
|
+
|
|
80
|
+
### Running tests
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
bundle install
|
|
84
|
+
bundle exec rake test # Minitest (test/test_nepali_number.rb)
|
|
85
|
+
bundle exec rake standard # lint (Standard Ruby)
|
|
86
|
+
bundle exec rake # runs test + standard
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Publishing to RubyGems
|
|
90
|
+
|
|
91
|
+
This repo uses custom release tasks (`Rakefile:19`) — `bundler/gem_tasks` release is not used.
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
# 0. Ensure a clean working tree
|
|
95
|
+
git status --porcelain # must be empty
|
|
96
|
+
|
|
97
|
+
# 1. Bump version in lib/nepali_number/version.rb:4
|
|
98
|
+
bundle exec rake release:bump[patch] # or [minor], [major], or [0.2.0]
|
|
99
|
+
# 2. Update CHANGELOG.md and commit
|
|
100
|
+
git add lib/nepali_number/version.rb CHANGELOG.md
|
|
101
|
+
git commit -m "Bump version to X.Y.Z"
|
|
102
|
+
|
|
103
|
+
# 3. Verify, build, and print publish commands
|
|
104
|
+
bundle exec rake release:prepare # runs release:check_clean, test, standard, build
|
|
105
|
+
# -> builds pkg/nepali_number-X.Y.Z.gem (pkg/ is gitignored)
|
|
106
|
+
|
|
107
|
+
# 4. Push to RubyGems (MFA OTP required)
|
|
108
|
+
bundle exec gem push pkg/nepali_number-X.Y.Z.gem --otp <6-digit-code>
|
|
109
|
+
# gem push uses credentials in ~/.local/share/gem/credentials (see `gem env`)
|
|
110
|
+
|
|
111
|
+
# 5. Tag and push tag
|
|
112
|
+
git tag vX.Y.Z
|
|
113
|
+
git push origin vX.Y.Z
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Tips:
|
|
67
117
|
|
|
68
|
-
|
|
118
|
+
- `bundle exec rake release:build` — build only.
|
|
119
|
+
- `bundle exec rake release:commands` — print artifact path and `gem push` / `git tag` commands without running checks.
|
|
120
|
+
- To install locally without publishing: `bundle exec rake install`.
|
|
69
121
|
|
|
70
122
|
## Contributing
|
|
71
123
|
|
|
@@ -23,12 +23,28 @@ module NepaliNumber
|
|
|
23
23
|
|
|
24
24
|
private
|
|
25
25
|
|
|
26
|
+
# BigDecimal#to_s("F") always emits at least one decimal place, so a value
|
|
27
|
+
# carrying no fraction at all -- BigDecimal("10") -- came out as "10.0". That
|
|
28
|
+
# is an artifact of the rendering, not the number: it made whole share
|
|
29
|
+
# quantities read as fractional, and it did the same to whole money.
|
|
30
|
+
#
|
|
31
|
+
# A value that does carry a fraction keeps it. Callers that need a fraction
|
|
32
|
+
# rounded or dropped decide that themselves; the formatter's job is to not
|
|
33
|
+
# invent one.
|
|
26
34
|
def normalize(number)
|
|
27
|
-
return number
|
|
35
|
+
return normalize_bigdecimal(number) if number.is_a?(BigDecimal)
|
|
28
36
|
|
|
29
37
|
number.to_s.delete(",")
|
|
30
38
|
end
|
|
31
39
|
|
|
40
|
+
def normalize_bigdecimal(number)
|
|
41
|
+
return number.to_i.to_s if number.frac.zero?
|
|
42
|
+
|
|
43
|
+
# to_s("F") keeps the full precision here, which is the point -- only the
|
|
44
|
+
# trailing ".0" of a whole value was ever wrong.
|
|
45
|
+
number.to_s("F")
|
|
46
|
+
end
|
|
47
|
+
|
|
32
48
|
def group_integer(integer, delimiter)
|
|
33
49
|
return integer if integer.length <= 3
|
|
34
50
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nepali_number
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Saroj Maharjan (zoras)
|
|
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
69
69
|
- !ruby/object:Gem::Version
|
|
70
70
|
version: '0'
|
|
71
71
|
requirements: []
|
|
72
|
-
rubygems_version: 4.0.
|
|
72
|
+
rubygems_version: 4.0.22
|
|
73
73
|
specification_version: 4
|
|
74
74
|
summary: Nepali number formatting, humanization, digit conversion, and currency helpers.
|
|
75
75
|
test_files: []
|