rusprice 0.2.2 → 0.2.3
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/.gitignore +14 -13
- data/.rspec +2 -2
- data/.travis.yml +5 -5
- data/CODE_OF_CONDUCT.md +74 -74
- data/Gemfile +4 -4
- data/LICENSE.txt +21 -21
- data/README.md +49 -48
- data/Rakefile +8 -8
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/lib/rusprice.rb +60 -62
- data/lib/rusprice/version.rb +3 -3
- data/rusprice.gemspec +40 -38
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d55e2e8881f67b5620b424933d397fbc336fc64c
|
4
|
+
data.tar.gz: 46a6c8ad3ff58db0497c8d7af5f88c892dd507e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2f198c2f66f13fe9992b7231076805473eef1310530c08c37c40f389911fef359ec0d16e47657efa983b2cf98d8281941a339b4d17acd0c584faf7b8ef9772f
|
7
|
+
data.tar.gz: c2040d700c815c7bf2822a10a47169efdf5dfc1d81d0c018a7e7e61156a318ab5bfd95a08547d502b031e3b191f2a64bc6dbea5897674b32da687e4da5827b8b
|
data/.gitignore
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
-
/.bundle/
|
2
|
-
/.yardoc
|
3
|
-
/.yardopts
|
4
|
-
/Gemfile.lock
|
5
|
-
/_yardoc/
|
6
|
-
/coverage/
|
7
|
-
/doc/
|
8
|
-
/pkg/
|
9
|
-
/spec/reports/
|
10
|
-
/tmp/
|
11
|
-
|
12
|
-
|
13
|
-
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/.yardopts
|
4
|
+
/Gemfile.lock
|
5
|
+
/_yardoc/
|
6
|
+
/coverage/
|
7
|
+
/doc/
|
8
|
+
/pkg/
|
9
|
+
/spec/reports/
|
10
|
+
/tmp/
|
11
|
+
/.idea/
|
12
|
+
|
13
|
+
# rspec failure tracking
|
14
|
+
.rspec_status
|
data/.rspec
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
--format documentation
|
2
|
-
--color
|
1
|
+
--format documentation
|
2
|
+
--color
|
data/.travis.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
rvm:
|
4
|
-
- 2.3.3
|
5
|
-
before_install: gem install bundler -v 1.14.4
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.3.3
|
5
|
+
before_install: gem install bundler -v 1.14.4
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -1,74 +1,74 @@
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
2
|
-
|
3
|
-
## Our Pledge
|
4
|
-
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
-
orientation.
|
11
|
-
|
12
|
-
## Our Standards
|
13
|
-
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
15
|
-
include:
|
16
|
-
|
17
|
-
* Using welcoming and inclusive language
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
19
|
-
* Gracefully accepting constructive criticism
|
20
|
-
* Focusing on what is best for the community
|
21
|
-
* Showing empathy towards other community members
|
22
|
-
|
23
|
-
Examples of unacceptable behavior by participants include:
|
24
|
-
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
-
advances
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
-
* Public or private harassment
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
30
|
-
address, without explicit permission
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
-
professional setting
|
33
|
-
|
34
|
-
## Our Responsibilities
|
35
|
-
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
38
|
-
response to any instances of unacceptable behavior.
|
39
|
-
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
-
threatening, offensive, or harmful.
|
45
|
-
|
46
|
-
## Scope
|
47
|
-
|
48
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
-
when an individual is representing the project or its community. Examples of
|
50
|
-
representing a project or community include using an official project e-mail
|
51
|
-
address, posting via an official social media account, or acting as an appointed
|
52
|
-
representative at an online or offline event. Representation of a project may be
|
53
|
-
further defined and clarified by project maintainers.
|
54
|
-
|
55
|
-
## Enforcement
|
56
|
-
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at klekotnev@gmail.com. All
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
63
|
-
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
66
|
-
members of the project's leadership.
|
67
|
-
|
68
|
-
## Attribution
|
69
|
-
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
-
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
-
|
73
|
-
[homepage]: http://contributor-covenant.org
|
74
|
-
[version]: http://contributor-covenant.org/version/1/4/
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at klekotnev@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in rusprice.gemspec
|
4
|
-
gemspec
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in rusprice.gemspec
|
4
|
+
gemspec
|
data/LICENSE.txt
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2017 Igor Klekotnev
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Igor Klekotnev
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,48 +1,49 @@
|
|
1
|
-
# RusPrice
|
2
|
-
[](https://badge.fury.io/rb/rusprice)
|
3
|
-
|
4
|
-
**ВНИМАНИЕ!!!** Те, кто успел заюзать [версию 0.1.0](https://github.com/klekot/rusprice/tree/v0.1.0) обратите внимание, что в дальнейших версиях гема изменилась логика включения в проект.
|
5
|
-
Начиная с [версии 0.2.0](https://github.com/klekot/rusprice/tree/
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
-
|
13
|
-
-
|
14
|
-
-
|
15
|
-
- Число 0.
|
16
|
-
- Число 0.
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
1
|
+
# RusPrice
|
2
|
+
[](https://badge.fury.io/rb/rusprice) [](https://travis-ci.org/klekot/rusprice)
|
3
|
+
|
4
|
+
**ВНИМАНИЕ!!!** Те, кто успел заюзать [версию 0.1.0](https://github.com/klekot/rusprice/tree/v0.1.0) обратите внимание, что в дальнейших версиях гема изменилась логика включения в проект.
|
5
|
+
Начиная с [версии 0.2.0](https://github.com/klekot/rusprice/tree/v.0.2.0) не надо создавать экземпляры **RusPrice::Converter**, достаточно вызвать метод "rusprice" на любом числе в вашем коде.
|
6
|
+
Кроме того в [версии 0.1.0](https://github.com/klekot/rusprice/tree/v0.1.0) присутствует ["проблема 999"](https://github.com/klekot/rusprice/issues/1), исправленная в версии [версии 0.2.1](https://github.com/klekot/rusprice/tree/v0.2.1).
|
7
|
+
|
8
|
+
Гем позволяет преобразовать число, представляющее некую цену в строку вида "X рублей Y копеек". Форма слов "рубль" и "копейка" будет изменена согласно правилам русского языка в зависимости от данного числа.
|
9
|
+
Метод "rusprice" добавляется в класс Numeric и может быть вызван на любом числе (см. "Примеры использования").
|
10
|
+
|
11
|
+
## Примечание
|
12
|
+
- Отрицательное число будет преобразовано в положительное;
|
13
|
+
- Дробная часть будет округлена до двух знаков (используется метод "Float#round");
|
14
|
+
- Числа 0 и 0.0 преобразуются к строке "0 рублей";
|
15
|
+
- Число 0.001 преобразуются к строке "0 рублей";
|
16
|
+
- Число 0.005 преобразуются к строке "1 копейка";
|
17
|
+
- Число 0.999 преобразуется к строке "1 рубль".
|
18
|
+
|
19
|
+
## Установка
|
20
|
+
|
21
|
+
Добавьте следующую строку в Gemfile:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
gem 'rusprice'
|
25
|
+
```
|
26
|
+
|
27
|
+
Потом выполните команду:
|
28
|
+
|
29
|
+
$ bundle
|
30
|
+
|
31
|
+
Вы также можете установить rusprice в свою систему:
|
32
|
+
|
33
|
+
$ gem install rusprice
|
34
|
+
|
35
|
+
## Примеры использования
|
36
|
+
```ruby
|
37
|
+
123.45.rusprice
|
38
|
+
# "123 рубля 45 копеек"
|
39
|
+
|
40
|
+
98.rusprice
|
41
|
+
# "98 рублей"
|
42
|
+
|
43
|
+
0.72.rusprice
|
44
|
+
# "72 копейки"
|
45
|
+
```
|
46
|
+
|
47
|
+
## Лицензия
|
48
|
+
|
49
|
+
Этот гем распространяется по [лицензии MIT](http://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
|
5
|
-
YARD::Rake::YardocTask.new
|
6
|
-
RSpec::Core::RakeTask.new(:spec)
|
7
|
-
|
8
|
-
task :
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'yard'
|
4
|
+
|
5
|
+
YARD::Rake::YardocTask.new
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
task default: :spec
|
data/bin/console
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require
|
14
|
-
IRB.start(__FILE__)
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'rusprice'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
set -euo pipefail
|
3
|
-
IFS=$'\n\t'
|
4
|
-
set -vx
|
5
|
-
|
6
|
-
bundle install
|
7
|
-
|
8
|
-
# Do any other automated setup that you need to do here
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
set -vx
|
5
|
+
|
6
|
+
bundle install
|
7
|
+
|
8
|
+
# Do any other automated setup that you need to do here
|
data/lib/rusprice.rb
CHANGED
@@ -1,62 +1,60 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
module RusPrice
|
4
|
-
RUBLE =
|
5
|
-
PENNY = 'копейка'
|
6
|
-
|
7
|
-
def rusprice
|
8
|
-
self_value = self
|
9
|
-
self_value = self *
|
10
|
-
dec_part = (self_value % 1).round(2)
|
11
|
-
if
|
12
|
-
rub_part = (self_value - (self_value % 1)).to_i + 1
|
13
|
-
kop_part = 0
|
14
|
-
else
|
15
|
-
rub_part = (self_value - (self_value % 1)).to_i
|
16
|
-
kop_part = (dec_part * 100).to_i
|
17
|
-
end
|
18
|
-
rub_case = cases rub_part, RUBLE
|
19
|
-
kop_case = cases kop_part, PENNY
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
'
|
37
|
-
elsif (number % 10
|
38
|
-
'
|
39
|
-
|
40
|
-
'
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
'
|
47
|
-
elsif (number % 10
|
48
|
-
'
|
49
|
-
|
50
|
-
'
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
include RusPrice
|
62
|
-
end
|
1
|
+
require 'rusprice/version'
|
2
|
+
|
3
|
+
module RusPrice
|
4
|
+
RUBLE = 'рубль'.freeze
|
5
|
+
PENNY = 'копейка'.freeze
|
6
|
+
|
7
|
+
def rusprice
|
8
|
+
self_value = self
|
9
|
+
self_value = self * -1 if negative?
|
10
|
+
dec_part = (self_value % 1).round(2)
|
11
|
+
if dec_part == 1.0
|
12
|
+
rub_part = (self_value - (self_value % 1)).to_i + 1
|
13
|
+
kop_part = 0
|
14
|
+
else
|
15
|
+
rub_part = (self_value - (self_value % 1)).to_i
|
16
|
+
kop_part = (dec_part * 100).to_i
|
17
|
+
end
|
18
|
+
rub_case = cases rub_part, RUBLE
|
19
|
+
kop_case = cases kop_part, PENNY
|
20
|
+
output = if kop_part.zero?
|
21
|
+
"#{rub_part} #{rub_case}"
|
22
|
+
elsif rub_part.zero?
|
23
|
+
"#{kop_part} #{kop_case}"
|
24
|
+
else
|
25
|
+
"#{rub_part} #{rub_case} #{kop_part} #{kop_case}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def cases(number, kind)
|
32
|
+
if kind == 'рубль'
|
33
|
+
if [11, 12, 13, 14].include?(number % 100)
|
34
|
+
'рублей'
|
35
|
+
elsif number % 10 == 1
|
36
|
+
'рубль'
|
37
|
+
elsif [2, 3, 4].include?(number % 10)
|
38
|
+
'рубля'
|
39
|
+
else
|
40
|
+
'рублей'
|
41
|
+
end
|
42
|
+
elsif kind == 'копейка'
|
43
|
+
if [11, 12, 13, 14].include?(number % 100)
|
44
|
+
'копеек'
|
45
|
+
elsif number % 10 == 1
|
46
|
+
'копейка'
|
47
|
+
elsif [2, 3, 4].include?(number % 10)
|
48
|
+
'копейки'
|
49
|
+
else
|
50
|
+
'копеек'
|
51
|
+
end
|
52
|
+
else
|
53
|
+
''
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
class Numeric
|
59
|
+
include RusPrice
|
60
|
+
end
|
data/lib/rusprice/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module RusPrice
|
2
|
-
VERSION =
|
3
|
-
end
|
1
|
+
module RusPrice
|
2
|
+
VERSION = '0.2.3'.freeze
|
3
|
+
end
|
data/rusprice.gemspec
CHANGED
@@ -1,38 +1,40 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
spec.
|
9
|
-
spec.
|
10
|
-
spec.
|
11
|
-
|
12
|
-
|
13
|
-
spec.
|
14
|
-
spec.
|
15
|
-
spec.
|
16
|
-
|
17
|
-
|
18
|
-
#
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
spec.
|
32
|
-
|
33
|
-
spec.
|
34
|
-
|
35
|
-
spec.add_development_dependency
|
36
|
-
spec.add_development_dependency
|
37
|
-
spec.add_development_dependency
|
38
|
-
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'rusprice/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'rusprice'
|
9
|
+
spec.version = RusPrice::VERSION
|
10
|
+
spec.authors = ['Igor Klekotnev']
|
11
|
+
spec.email = ['klekotnev@gmail.com']
|
12
|
+
|
13
|
+
spec.summary = "Gem allows to convert number into string like 'X рублей Y копеек' accordingly russian language rules."
|
14
|
+
spec.description = "Gem allows to convert number into string like 'X рублей Y копеек' accordingly russian language rules."
|
15
|
+
spec.homepage = 'https://github.com/klekot/rusprice'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
19
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
20
|
+
|
21
|
+
if spec.respond_to?(:metadata)
|
22
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
23
|
+
else
|
24
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
25
|
+
'public gem pushes.'
|
26
|
+
end
|
27
|
+
|
28
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
29
|
+
f.match(%r{^(test|spec|features)/})
|
30
|
+
end
|
31
|
+
spec.bindir = 'exe'
|
32
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
|
+
spec.require_paths = ['lib']
|
34
|
+
|
35
|
+
spec.add_development_dependency 'bundler', '~> 1.14'
|
36
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
37
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
38
|
+
spec.add_development_dependency 'redcarpet', '~> 3.4.0'
|
39
|
+
spec.add_development_dependency 'yard', '~> 0.9.8'
|
40
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rusprice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Klekotnev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
122
|
version: '0'
|
123
123
|
requirements: []
|
124
124
|
rubyforge_project:
|
125
|
-
rubygems_version: 2.
|
125
|
+
rubygems_version: 2.6.11
|
126
126
|
signing_key:
|
127
127
|
specification_version: 4
|
128
128
|
summary: Gem allows to convert number into string like 'X рублей Y копеек' accordingly
|