numbers_and_words_pl 0.0.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 +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +15 -0
- data/Rakefile +2 -0
- data/lib/numbers_and_words_pl.rb +7 -0
- data/lib/numbers_and_words_pl/helper.rb +28 -0
- data/lib/numbers_and_words_pl/pl.yml +17 -0
- data/lib/numbers_and_words_pl/version.rb +3 -0
- data/numbers_and_words_pl.gemspec +23 -0
- data/spec/number_to_words_pl_spec.rb +18 -0
- data/spec/pl.yml +51 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ce6b333b3a05dc00352c83d992298ec0a5a2ee37
|
4
|
+
data.tar.gz: 4ec7af6ea70206eb68b6fe66d9714f8843cad9b3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 50491b0c65bb1b96c89c1ff0c94eaccb767ecf9d284adc943a6d2a3e6b1315c4277dec33b00869da3040e9044695f9850c4d00c2e28de58d2655af3a9b654d6e
|
7
|
+
data.tar.gz: c4011e9fb1a0dc69a717bb74d527bb183402a99a20057d0101683f430504d978b08db7bf21382d6da25c4a91305016afe28d765d879989bb703cb88e97352790
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Alexander Lang
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# NumbersAndWordsPl
|
2
|
+
|
3
|
+
Since I was not smart enough to figure out how to add Polish to the *numbers_and_words* gem I created my own.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Add the gem to your Gemfile, include the `NumebersAndWordsPl::Helper` module and call `to_words_pl 123`.
|
8
|
+
|
9
|
+
## Contributing
|
10
|
+
|
11
|
+
1. Fork it ( https://github.com/[my-github-username]/numbers_and_words_pl/fork )
|
12
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
13
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
14
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
15
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module NumbersAndWordsPl
|
2
|
+
module Helper
|
3
|
+
PL_NUMBERS = YAML.parse(File.read(File.dirname(__FILE__) + '/pl.yml')).to_ruby['numbers']
|
4
|
+
|
5
|
+
def to_words_pl(integer)
|
6
|
+
case integer
|
7
|
+
when 0..9
|
8
|
+
PL_NUMBERS['ones'][integer]
|
9
|
+
when 10..19
|
10
|
+
PL_NUMBERS['teens'][integer - 10]
|
11
|
+
when 20..99
|
12
|
+
tens, ones = integer.to_s.split('').map(&:to_i)
|
13
|
+
"#{PL_NUMBERS['tens'][tens]} #{PL_NUMBERS['ones'][ones] if ones > 0}".strip
|
14
|
+
when 100..999
|
15
|
+
hundreds = integer.to_s[0].to_i - 1
|
16
|
+
rest = integer.to_s[1..-1].to_i
|
17
|
+
"#{PL_NUMBERS['hundreds'][hundreds]} #{to_words_pl rest if rest > 0}".strip
|
18
|
+
when 1_000..999_999
|
19
|
+
thousands = integer.to_s[0..-4].to_i
|
20
|
+
one_few_many = thousands < 5 ? (thousands == 1 ? 'one' : 'few') : 'many'
|
21
|
+
rest = integer.to_s[-3..-1].to_i
|
22
|
+
"#{to_words_pl thousands if thousands > 1} #{PL_NUMBERS['thousands'][one_few_many]} #{to_words_pl rest if rest > 0}".strip
|
23
|
+
else
|
24
|
+
fail "number #{integer} not supported"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
numbers:
|
2
|
+
ones: ['zero', jeden, dwa, trzy, cztery, pięć, sześć, siedem, osiem, dziewięć]
|
3
|
+
teens: [dziesięć, jedenaście, dwanaście, trzynaście, czternaście, piętnaście, szesnaście, siedemnaście, osiemnaście, dziewiętnaście]
|
4
|
+
tens: [zero, dziesięć, dwadzieścia, trzydzieści, czterdzieści, pięćdziesiąt, sześćdziesiąt, siedemdziesiąt, osiemdziesiąt, dziewięćdziesiąt]
|
5
|
+
hundreds: [sto, dwieście, trzysta, czterysta, pięćset, sześćset, siedemset, osiemset, dziewięćset]
|
6
|
+
thousands:
|
7
|
+
one: tysiąc
|
8
|
+
few: tysiące
|
9
|
+
many: tysięcy
|
10
|
+
millions:
|
11
|
+
one: milion
|
12
|
+
few: miliony
|
13
|
+
many: milionów
|
14
|
+
billions:
|
15
|
+
one: bilion
|
16
|
+
few: biliony
|
17
|
+
many: bilionów
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'numbers_and_words_pl/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "numbers_and_words_pl"
|
8
|
+
spec.version = NumbersAndWordsPl::VERSION
|
9
|
+
spec.authors = ["Alexander Lang", "Katharina Mehner"]
|
10
|
+
spec.email = ["alex@upstre.am"]
|
11
|
+
spec.summary = %q{Turns an integer number into written words in Polish.}
|
12
|
+
spec.homepage = "http://github.com/langalex/numbers_and_words_pl"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
$LOAD_PATH << File.dirname(__FILE__) + '../lib'
|
2
|
+
require 'numbers_and_words_pl'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
describe NumbersAndWordsPl::Helper do
|
6
|
+
include NumbersAndWordsPl::Helper
|
7
|
+
fixtures = YAML.parse(File.read(File.dirname(__FILE__) + '/pl.yml')).to_ruby['to_words']
|
8
|
+
|
9
|
+
fixtures.each do |group, numbers|
|
10
|
+
context "with #{group}" do
|
11
|
+
numbers.each do |number, word|
|
12
|
+
it "translates #{number}" do
|
13
|
+
expect(to_words_pl(number)).to eql(word)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/spec/pl.yml
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
to_words:
|
2
|
+
ones:
|
3
|
+
0: 'zero'
|
4
|
+
1: jeden
|
5
|
+
9: dziewięć
|
6
|
+
teens:
|
7
|
+
10: dziesięć
|
8
|
+
11: jedenaście
|
9
|
+
19: dziewiętnaście
|
10
|
+
20: dwadzieścia
|
11
|
+
21: dwadzieścia jeden
|
12
|
+
80: osiemdziesiąt
|
13
|
+
90: dziewięćdziesiąt
|
14
|
+
99: dziewięćdziesiąt dziewięć
|
15
|
+
hundreds:
|
16
|
+
100: sto
|
17
|
+
101: sto jeden
|
18
|
+
111: sto jedenaście
|
19
|
+
120: sto dwadzieścia
|
20
|
+
121: sto dwadzieścia jeden
|
21
|
+
900: dziewięćset
|
22
|
+
909: dziewięćset dziewięć
|
23
|
+
919: dziewięćset dziewiętnaście
|
24
|
+
990: dziewięćset dziewięćdziesiąt
|
25
|
+
999: dziewięćset dziewięćdziesiąt dziewięć
|
26
|
+
thousands:
|
27
|
+
1000: tysiąc
|
28
|
+
1001: tysiąc jeden
|
29
|
+
2000: dwa tysiące
|
30
|
+
4000: cztery tysiące
|
31
|
+
5000: pięć tysięcy
|
32
|
+
11000: jedenaście tysięcy
|
33
|
+
21000: dwadzieścia jeden tysięcy
|
34
|
+
999000: dziewięćset dziewięćdziesiąt dziewięć tysięcy
|
35
|
+
999999: dziewięćset dziewięćdziesiąt dziewięć tysięcy dziewięćset dziewięćdziesiąt dziewięć
|
36
|
+
# millionens:
|
37
|
+
# 1000000: jeden milion
|
38
|
+
# 2000000: dwa miliony
|
39
|
+
# 4000000: cztery miliony
|
40
|
+
# 5000000: pięć milionów
|
41
|
+
# 999000000: dziewięćset dziewięćdziesiąt dziewięć milionów
|
42
|
+
# 999000999: dziewięćset dziewięćdziesiąt dziewięć milionów dziewięćset dziewięćdziesiąt dziewięć
|
43
|
+
# 999999000: dziewięćset dziewięćdziesiąt dziewięć milionów dziewięćset dziewięćdziesiąt dziewięć tysięcy
|
44
|
+
# 999999999: dziewięćset dziewięćdziesiąt dziewięć milionów dziewięćset dziewięćdziesiąt dziewięć tysięcy dziewięćset dziewięćdziesiąt dziewięć
|
45
|
+
# billions:
|
46
|
+
# 1174315110: jeden miliard sto siedemdziesiąt cztery milionów trzysta piętnaście tysięcy sto dziesięć
|
47
|
+
# 1174315119: jeden miliard sto siedemdziesiąt cztery milionów trzysta piętnaście tysięcy sto dziewiętnaście
|
48
|
+
# 15174315119: piętnaście miliardów sto siedemdziesiąt cztery milionów trzysta piętnaście tysięcy sto dziewiętnaście
|
49
|
+
# 35174315119: trzydzieści pięć miliardów sto siedemdziesiąt cztery milionów trzysta piętnaście tysięcy sto dziewiętnaście
|
50
|
+
# 935174315119: dziewięćset trzydzieści pięć miliardów sto siedemdziesiąt cztery milionów trzysta piętnaście tysięcy sto dziewiętnaście
|
51
|
+
# 2935174315119: dwa biliony dziewięćset trzydzieści pięć miliardów sto siedemdziesiąt cztery milionów trzysta piętnaście tysięcy sto dziewiętnaście
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: numbers_and_words_pl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander Lang
|
8
|
+
- Katharina Mehner
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-02-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.7'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.7'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '10.0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '10.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '3.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '3.0'
|
56
|
+
description:
|
57
|
+
email:
|
58
|
+
- alex@upstre.am
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- lib/numbers_and_words_pl.rb
|
69
|
+
- lib/numbers_and_words_pl/helper.rb
|
70
|
+
- lib/numbers_and_words_pl/pl.yml
|
71
|
+
- lib/numbers_and_words_pl/version.rb
|
72
|
+
- numbers_and_words_pl.gemspec
|
73
|
+
- spec/number_to_words_pl_spec.rb
|
74
|
+
- spec/pl.yml
|
75
|
+
homepage: http://github.com/langalex/numbers_and_words_pl
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.2.2
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Turns an integer number into written words in Polish.
|
99
|
+
test_files:
|
100
|
+
- spec/number_to_words_pl_spec.rb
|
101
|
+
- spec/pl.yml
|