parayaz 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/CHANGELOG.md +6 -2
- data/Gemfile.lock +1 -1
- data/README.md +12 -2
- data/Rakefile +6 -1
- data/lib/parayaz.rb +7 -6
- data/lib/parayaz/version.rb +1 -1
- data/spec/parayaz_spec.rb +46 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a06c75164343226a717d0136cc05decee5b86e8c
|
4
|
+
data.tar.gz: 57a03d709fab7170d2d0313d8d7382291f5ace9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd4bea3e3afaa054bca9d286df2428f8b4bb2111f3c26682bbc640d4ad85700eeb6f0e69a3c8dfde58d7e9e1acae1bca370848ef833bf34c0eed914f57cd17fb
|
7
|
+
data.tar.gz: db9334038783112a630fcd0b7b9e6a49fae35ce1173de76593c0edd4212bfced4c2a9057a5684148cd2f0354729d2b6b38060ebe807377c696878f7bf9b69471
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
|
2
2
|
#### [Current]
|
3
|
+
* [f26aa42](../../commit/f26aa42) - __(Ahmet Sezgin Duran)__ Fix README
|
4
|
+
|
5
|
+
#### 1.0.3
|
6
|
+
* [e66b758](../../commit/e66b758) - __(Ahmet Sezgin Duran)__ Bump version 1.0.3
|
3
7
|
* [a347fd7](../../commit/a347fd7) - __(Ahmet Sezgin Duran)__ Revert back to original file
|
4
8
|
|
5
9
|
#### 1.0.2
|
@@ -7,7 +11,7 @@
|
|
7
11
|
* [e14b059](../../commit/e14b059) - __(Ahmet Sezgin Duran)__ [#1](../../issues/1) Fix negative number error
|
8
12
|
|
9
13
|
#### 1.0.1
|
10
|
-
* [52a9cd6](../../commit/52a9cd6) - __(Murat Kemal
|
14
|
+
* [52a9cd6](../../commit/52a9cd6) - __(Murat Kemal BAYGN)__ Remove kr if zero (0)
|
11
15
|
|
12
16
|
#### 1.0.0
|
13
17
|
* [7c6ca13](../../commit/7c6ca13) - __(Muhammet Dilek)__ bump version 1.0.0
|
@@ -16,6 +20,6 @@
|
|
16
20
|
* [894aaef](../../commit/894aaef) - __(Muhammet Dilek)__ licence added and readme fixed
|
17
21
|
* [103ef64](../../commit/103ef64) - __(Muhammet Dilek)__ update readme
|
18
22
|
* [3d0c5c7](../../commit/3d0c5c7) - __(Muhammet Dilek)__ update readme
|
19
|
-
* [3ee8122](../../commit/3ee8122) - __(Murat Kemal
|
23
|
+
* [3ee8122](../../commit/3ee8122) - __(Murat Kemal BAYGN)__ Fix writing for One Hundred
|
20
24
|
* [6204e7c](../../commit/6204e7c) - __(Muhammet Dilek)__ gem created
|
21
25
|
* [7dee40d](../../commit/7dee40d) - __(Muhammet Dilek)__ Initial commit
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Parayaz
|
2
2
|
|
3
|
-
Turkish number to text money
|
3
|
+
Turkish number to text money according to [TDK][1000]
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -14,17 +14,25 @@ And then execute:
|
|
14
14
|
|
15
15
|
$ bundle
|
16
16
|
|
17
|
+
Or
|
18
|
+
|
19
|
+
$ bundle install --path=vendor/bundle
|
20
|
+
|
17
21
|
Or install it yourself as:
|
18
22
|
|
19
23
|
$ gem install parayaz
|
20
24
|
|
25
|
+
## Tests
|
26
|
+
|
27
|
+
Use `rake test` or `bundle exec rake test` to run specs.
|
28
|
+
|
21
29
|
## Usage
|
22
30
|
```ruby
|
23
31
|
> 123.parayaz
|
24
32
|
# yüzyirmiüçTL
|
25
33
|
|
26
34
|
> 123.55.parayaz
|
27
|
-
# yüzyirmiüçTL,ellibeşkr
|
35
|
+
# yüzyirmiüçTL,ellibeşkr.
|
28
36
|
```
|
29
37
|
|
30
38
|
## Contributing
|
@@ -46,3 +54,5 @@ Or install it yourself as:
|
|
46
54
|
## License
|
47
55
|
|
48
56
|
Copyright 2014 lab2023 - information technologies
|
57
|
+
|
58
|
+
[1000]: http://www.tdk.gov.tr/index.php?option=com_content&view=article&id=182:Sayilarin-s
|
data/Rakefile
CHANGED
data/lib/parayaz.rb
CHANGED
@@ -9,20 +9,21 @@ module Parayaz
|
|
9
9
|
|
10
10
|
price, cents = number.to_s.split('.')
|
11
11
|
|
12
|
-
text = convert_to_text(price)
|
12
|
+
text = convert_to_text(price)
|
13
|
+
text += 'TL' unless text.empty?
|
14
|
+
|
13
15
|
if cents && cents.to_i > 0
|
14
16
|
if cents.size == 1
|
15
17
|
cents = (cents.to_i * 10).to_s
|
16
18
|
end
|
17
|
-
|
18
19
|
if cents.size > 2
|
19
20
|
cents = cents[0..1]
|
20
21
|
end
|
21
|
-
|
22
|
-
text +=
|
22
|
+
text += ',' unless text.empty?
|
23
|
+
text += convert_to_text(cents) + 'kr.'
|
23
24
|
end
|
24
25
|
|
25
|
-
(minus ? 'eksi' : '') + text
|
26
|
+
(minus ? 'eksi ' : '') + text
|
26
27
|
end
|
27
28
|
|
28
29
|
private
|
@@ -53,7 +54,7 @@ module Parayaz
|
|
53
54
|
while !number.zero?
|
54
55
|
number, r = number.divmod(1000)
|
55
56
|
size = r.to_s.split('').map(&:to_i).size
|
56
|
-
new_text = r == 1 && i == 1 ?
|
57
|
+
new_text = r == 1 && i == 1 ? '' : eval("say_#{size}_digit_text(#{size == 1 ? r : r.to_s.split('').map(&:to_i)})")
|
57
58
|
|
58
59
|
unless r == 0
|
59
60
|
new_text += lots[i]
|
data/lib/parayaz/version.rb
CHANGED
data/spec/parayaz_spec.rb
CHANGED
@@ -1,5 +1,51 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Parayaz do
|
4
|
+
context 'Test regular numbers' do
|
5
|
+
it 'should return: birTL' do
|
6
|
+
expect(1.parayaz).to eq 'birTL'
|
7
|
+
end
|
8
|
+
it 'should return: yüzonbirTL' do
|
9
|
+
expect(111.parayaz).to eq 'yüzonbirTL'
|
10
|
+
end
|
11
|
+
it 'should return: binbeşyüzkırkbirTL' do
|
12
|
+
expect(1541.parayaz).to eq 'binbeşyüzkırkbirTL'
|
13
|
+
end
|
14
|
+
end
|
4
15
|
|
16
|
+
context 'Test float numbers' do
|
17
|
+
it 'should return: onikikr.' do
|
18
|
+
expect(0.125.parayaz).to eq 'onikikr.'
|
19
|
+
end
|
20
|
+
it 'should return: birTL,onkr.' do
|
21
|
+
expect(1.1.parayaz).to eq 'birTL,onkr.'
|
22
|
+
end
|
23
|
+
it 'should return: yüzyirmiüçTL,kırkbeşkr.' do
|
24
|
+
expect(123.45.parayaz).to eq 'yüzyirmiüçTL,kırkbeşkr.'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'Test big numbers' do
|
29
|
+
it 'should return birmilyonüçyüzkırkikibindörtyüzotuzsekizTL' do
|
30
|
+
expect(1342438.parayaz).to eq 'birmilyonüçyüzkırkikibindörtyüzotuzsekizTL'
|
31
|
+
end
|
32
|
+
it 'should return dokuzmilyarsekizyüzyetmişaltımilyonbeşyüzkırküçbinikiyüzonTL' do
|
33
|
+
expect(9876543210.parayaz).to eq 'dokuzmilyarsekizyüzyetmişaltımilyonbeşyüzkırküçbinikiyüzonTL'
|
34
|
+
end
|
35
|
+
it 'should return sekiztrilyonyüzondokuzmilyarsekizyüzyetmişaltımilyonbeşyüzkırküçbinikiyüzonTL,onikikr.' do
|
36
|
+
expect(8119876543210.123456.parayaz).to eq 'sekiztrilyonyüzondokuzmilyarsekizyüzyetmişaltımilyonbeşyüzkırküçbinikiyüzonTL,onikikr.'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'Test negative numbers' do
|
41
|
+
it 'should return eksi birTL' do
|
42
|
+
expect(-1.parayaz).to eq 'eksi birTL'
|
43
|
+
end
|
44
|
+
it 'should return eksi on kr.' do
|
45
|
+
expect(-0.1.parayaz).to eq 'eksi onkr.'
|
46
|
+
end
|
47
|
+
it 'should return eksi elli kr.' do
|
48
|
+
expect(-0.5.parayaz).to eq 'eksi ellikr.'
|
49
|
+
end
|
50
|
+
end
|
5
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parayaz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lab2023
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|