turkish_numeric 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 29df8a76d18edcf7da4ba05ffb469626b89146760c7618aae45d517da61ebab5
4
+ data.tar.gz: b3907fe5ab989fc6899c3ed0211070ebfa591836c466a889fcb6b0795901d1be
5
+ SHA512:
6
+ metadata.gz: 2562228d34a67fa9dcff088ba07a3f7c6ccdf103e0d37516f19f2bc2c7e93fc6fac1437c4d6790d02d8d1d0f22025f75dc05e5a66ae7ee017c1683e1ed60508d
7
+ data.tar.gz: 45d6147d125729765de105534711d3fa3be3369e62246e263b3013e5cd6fa50b3314e76529d16d85950e57d18ef7c2df68228664ce11e26fa0fe8317576698f1
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ # ide files
14
+ /.idea/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,23 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.7.0
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: single_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: single_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
14
+ Exclude:
15
+ - 'spec/*'
16
+
17
+ Style/MixinUsage:
18
+ Exclude:
19
+ - 'spec/*'
20
+
21
+ Metrics/BlockLength:
22
+ Exclude:
23
+ - 'spec/*'
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.0
6
+ before_install: gem install bundler -v 2.2.5
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ # Changelog
2
+ ## [Version 0.0.1](https://github.com/sbagdat/turkish_numeric/releases/tag/v0.0.1) (2021-02-05)
3
+ - First Release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at sbagdat@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in turkish_numeric.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
9
+ gem 'rspec', '~> 3.0'
10
+ gem 'rubocop', '~> 1.7'
11
+ gem 'rubocop-rake'
12
+ gem 'rubocop-rspec'
data/Gemfile.lock ADDED
@@ -0,0 +1,62 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ turkish_numeric (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ diff-lcs (1.4.4)
11
+ parallel (1.20.1)
12
+ parser (3.0.0.0)
13
+ ast (~> 2.4.1)
14
+ rainbow (3.0.0)
15
+ rake (13.0.3)
16
+ regexp_parser (2.0.3)
17
+ rexml (3.2.4)
18
+ rspec (3.10.0)
19
+ rspec-core (~> 3.10.0)
20
+ rspec-expectations (~> 3.10.0)
21
+ rspec-mocks (~> 3.10.0)
22
+ rspec-core (3.10.1)
23
+ rspec-support (~> 3.10.0)
24
+ rspec-expectations (3.10.1)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.10.0)
27
+ rspec-mocks (3.10.2)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.10.0)
30
+ rspec-support (3.10.2)
31
+ rubocop (1.9.1)
32
+ parallel (~> 1.10)
33
+ parser (>= 3.0.0.0)
34
+ rainbow (>= 2.2.2, < 4.0)
35
+ regexp_parser (>= 1.8, < 3.0)
36
+ rexml
37
+ rubocop-ast (>= 1.2.0, < 2.0)
38
+ ruby-progressbar (~> 1.7)
39
+ unicode-display_width (>= 1.4.0, < 3.0)
40
+ rubocop-ast (1.4.1)
41
+ parser (>= 2.7.1.5)
42
+ rubocop-rake (0.5.1)
43
+ rubocop
44
+ rubocop-rspec (2.2.0)
45
+ rubocop (~> 1.0)
46
+ rubocop-ast (>= 1.1.0)
47
+ ruby-progressbar (1.11.0)
48
+ unicode-display_width (2.0.0)
49
+
50
+ PLATFORMS
51
+ x86_64-darwin-19
52
+
53
+ DEPENDENCIES
54
+ rake (~> 13.0)
55
+ rspec (~> 3.0)
56
+ rubocop (~> 1.7)
57
+ rubocop-rake
58
+ rubocop-rspec
59
+ turkish_numeric!
60
+
61
+ BUNDLED WITH
62
+ 2.2.5
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Sıtkı Bağdat
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 ADDED
@@ -0,0 +1,60 @@
1
+ # TurkishNumeric
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/turkish_numeric.svg)](https://badge.fury.io/rb/turkish_numeric)
4
+ [![Build Status](https://travis-ci.com/sbagdat/turkish_numeric.svg?branch=main)](https://travis-ci.com/sbagdat/turkish_numeric)
5
+ [![Code Climate](https://codeclimate.com/github/sbagdat/turkish_numeric/badges/gpa.svg)](https://codeclimate.com/github/sbagdat/turkish_numeric)
6
+ [![Coverage Status](https://coveralls.io/repos/github/sbagdat/turkish_numeric/badge.svg?branch=main)](https://coveralls.io/github/sbagdat/turkish_numeric?branch=main)
7
+
8
+ Translate any numeric value into Turkish text.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'turkish_numeric'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle install
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install turkish_numeric
25
+
26
+ ## Usage
27
+
28
+ After the installation of the gem, you can use it as shown below:
29
+
30
+ ```ruby
31
+ require 'turkish_numeric'
32
+
33
+ include TurkishNumeric
34
+
35
+ # Translating integers
36
+ TrNum(34_430_002).to_text # => "otuz dört milyon dört yüz otuz bin iki"
37
+
38
+ # Translating floats
39
+ TrNum(1234.00001).to_text # => "bin iki yüz otuz dört tam yüz binde bir"
40
+ ```
41
+
42
+ For more examples look at teh test files [here](spec/tr_num_spec.rb)
43
+
44
+ ## Development
45
+
46
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
47
+
48
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
49
+
50
+ ## Contributing
51
+
52
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sbagdat/turkish_numeric. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/sbagdat/turkish_numeric/blob/main/CODE_OF_CONDUCT.md).
53
+
54
+ ## License
55
+
56
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
57
+
58
+ ## Code of Conduct
59
+
60
+ Everyone interacting in the TurkishNumeric project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/sbagdat/turkish_numeric/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'turkish_numeric'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +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
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'turkish_numeric/version'
4
+ require_relative 'turkish_numeric/tr_num'
5
+
6
+ module TurkishNumeric
7
+ def TrNum(num)
8
+ TrNum.new(num)
9
+ end
10
+ end
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TurkishNumeric
4
+ MAPPINGS = [
5
+ %w[_ bir iki üç dört beş altı yedi sekiz dokuz].freeze,
6
+ %w[_ on yirmi otuz kırk elli altmış yetmiş seksen doksan].freeze
7
+ ].freeze
8
+
9
+ SUBFIX = %w[yüz bin milyon milyar trilyon katrilyon kentilyon sekstilyon septilyon oktilyon
10
+ nonilyon desilyon undesilyon dodesilyon trodesilyon katordesilyon kendesilyon seksdesilyon
11
+ septendesilyon oktodesilyon novemdesilyon vigintilyon].freeze
12
+
13
+ class TrNum
14
+ def initialize(number)
15
+ parse_sign(number)
16
+ parse_number_parts(number)
17
+ end
18
+
19
+ def to_text(spaces: true)
20
+ text = translate_decimal_part
21
+ text += [fractional_prefix] + translate_fractional_part unless fraction.zero?
22
+ clean_text(text, spaces)
23
+ end
24
+
25
+ private
26
+
27
+ attr_accessor :sign, :decimal, :fraction, :fraction_size, :current_processing_part
28
+
29
+ def clean_text(text, spaces)
30
+ text = text.flatten.delete_if(&:empty?).join(' ').strip
31
+ spaces ? text.gsub(/\s+/, ' ') : text.gsub(' ', '').gsub('eksi', 'eksi ')
32
+ # TODO: Add test for non-spaced representation
33
+ end
34
+
35
+ def translate_fractional_part
36
+ translate_partition(fraction)
37
+ end
38
+
39
+ def translate_decimal_part
40
+ [sign] + translate_partition(decimal)
41
+ end
42
+
43
+ def translate_partition(partition)
44
+ self.current_processing_part = partition
45
+ partition.digits.each_slice(3).map.with_index do |triplet, tri_idx|
46
+ translate_triplet(triplet, tri_idx)
47
+ end.reverse
48
+ end
49
+
50
+ def fractional_prefix
51
+ prefix = self.class.new(10**fraction_size).to_text
52
+ "tam #{prefix}#{prefix.end_with?('yüz', 'bin') ? 'de' : 'da'}".gsub('bir', '')
53
+ end
54
+
55
+ def parse_sign(number)
56
+ self.sign = number.negative? ? 'eksi' : ''
57
+ end
58
+
59
+ def translate_triplet(triplet, tri_idx)
60
+ triplet.map.with_index do |num, idx|
61
+ digit = translate_digit(num, idx, triplet)
62
+ "#{digit}#{subfix(num, tri_idx * 3 + idx) unless triplet.all?(&:zero?)}"
63
+ end.reverse
64
+ end
65
+
66
+ def parse_number_parts(number)
67
+ self.decimal = Integer(number.abs)
68
+ fraction_str = number.to_s.split('.')[1] || '0'
69
+ self.fraction_size = fraction_str.size
70
+ self.fraction = Integer(fraction_str)
71
+ end
72
+
73
+ def translate_digit(digit, pos, triplet)
74
+ case digit
75
+ when 0 then translate_zero
76
+ when 1 then translate_one(digit, pos, triplet)
77
+ else MAPPINGS[pos % 2][digit]
78
+ end
79
+ end
80
+
81
+ def translate_zero
82
+ current_processing_part.to_s.size == 1 ? 'sıfır' : ''
83
+ end
84
+
85
+ def translate_one(digit, pos, triplet)
86
+ return '' if triplet.size == 1 && current_processing_part.to_s.size == 4
87
+
88
+ 0.step(66, 3).include?(pos) || pos % 3 == 1 ? MAPPINGS[pos % 2][digit] : ''
89
+ end
90
+
91
+ def subfix(digit, pos)
92
+ sub_pos = pos % 3
93
+ return " #{SUBFIX[0]}" if sub_pos == 2 && !digit.zero?
94
+
95
+ pos >= 3 && sub_pos.zero? ? " #{SUBFIX[pos / 3]}" : ''
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TurkishNumeric
4
+ VERSION = '0.0.1'
5
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'turkish_numeric'
4
+
5
+ RSpec.configure do |config|
6
+ # Enable flags like --only-failures and --next-failure
7
+ config.example_status_persistence_file_path = '.rspec_status'
8
+
9
+ # Disable RSpec exposing methods globally on `Module` and `main`
10
+ config.disable_monkey_patching!
11
+
12
+ config.expect_with :rspec do |c|
13
+ c.syntax = :expect
14
+ end
15
+ end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ include TurkishNumeric
5
+ RSpec.describe TurkishNumeric do
6
+ let(:sample_integers) do
7
+ { 0 => 'sıfır',
8
+ 1 => 'bir',
9
+ 2 => 'iki',
10
+ 3 => 'üç',
11
+ 4 => 'dört',
12
+ 5 => 'beş',
13
+ 6 => 'altı',
14
+ 7 => 'yedi',
15
+ 8 => 'sekiz',
16
+ 9 => 'dokuz',
17
+ 10 => 'on',
18
+ 11 => 'on bir',
19
+ 20 => 'yirmi',
20
+ 21 => 'yirmi bir',
21
+ 30 => 'otuz',
22
+ 40 => 'kırk',
23
+ 50 => 'elli',
24
+ 60 => 'altmış',
25
+ 70 => 'yetmiş',
26
+ 80 => 'seksen',
27
+ 90 => 'doksan',
28
+ 100 => 'yüz',
29
+ 101 => 'yüz bir',
30
+ 111 => 'yüz on bir',
31
+ 200 => 'iki yüz',
32
+ 1_000 => 'bin',
33
+ 1_001 => 'bin bir',
34
+ 1_011 => 'bin on bir',
35
+ 1_111 => 'bin yüz on bir',
36
+ 2_000 => 'iki bin',
37
+ 301_000 => 'üç yüz bir bin',
38
+ 1_000_000 => 'bir milyon',
39
+ 2_000_000 => 'iki milyon',
40
+ 34_430_002 => 'otuz dört milyon dört yüz otuz bin iki',
41
+ 1_000_000_000 => 'bir milyar',
42
+ 603_862_955_583 => 'altı yüz üç milyar sekiz yüz altmış iki milyon dokuz yüz elli beş bin beş yüz seksen üç',
43
+ 999_999_999_999 => 'dokuz yüz doksan dokuz milyar dokuz yüz doksan dokuz milyon dokuz yüz doksan dokuz bin dokuz yüz doksan dokuz',
44
+ -1000 => 'eksi bin',
45
+ -999_999 => 'eksi dokuz yüz doksan dokuz bin dokuz yüz doksan dokuz',
46
+ -1_938_881 => 'eksi bir milyon dokuz yüz otuz sekiz bin sekiz yüz seksen bir' }.freeze
47
+ end
48
+ let(:sample_floats) do
49
+ { 0.5 => 'sıfır tam onda beş',
50
+ 0.555 => 'sıfır tam binde beş yüz elli beş',
51
+ 3.14 => 'üç tam yüzde on dört',
52
+ 1234.00001 => 'bin iki yüz otuz dört tam yüz binde bir',
53
+ 213_321_323.321232 => 'iki yüz on üç milyon üç yüz yirmi bir bin üç yüz yirmi üç tam milyonda üç yüz yirmi bir bin iki yüz otuz iki' }.freeze
54
+ end
55
+
56
+ context 'parsing parts' do
57
+ it 'works for decimal part' do
58
+ expect(TrNum.new(3).instance_variable_get(:@decimal)).to eq 3
59
+ expect(TrNum.new(-3456).instance_variable_get(:@decimal)).to eq 3456
60
+ end
61
+
62
+ it 'works for fractional part' do
63
+ expect(TrNum.new(3).instance_variable_get(:@fraction)).to eq 0
64
+ num = TrNum.new(3.54)
65
+ expect(num.instance_variable_get(:@fraction)).to eq 54
66
+ expect(num.instance_variable_get(:@fraction_size)).to eq 2
67
+ num = TrNum.new(3.00001)
68
+ expect(num.instance_variable_get(:@fraction)).to eq 1
69
+ expect(num.instance_variable_get(:@fraction_size)).to eq 5
70
+ end
71
+ end
72
+
73
+ context 'translates integer numbers into text' do
74
+ it 'works for samples' do
75
+ sample_integers.each do |num, text|
76
+ expect(TrNum.new(num).to_text).to eq text
77
+ end
78
+ end
79
+ end
80
+
81
+ context 'translates floating point numbers into text' do
82
+ it 'works for samples' do
83
+ sample_floats.each do |num, text|
84
+ expect(TrNum.new(num).to_text).to eq text
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe TurkishNumeric do
4
+ it 'has a version number' do
5
+ expect(TurkishNumeric::VERSION).not_to be nil
6
+ end
7
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/turkish_numeric/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'turkish_numeric'
7
+ spec.version = TurkishNumeric::VERSION
8
+ spec.authors = ['Sıtkı Bağdat']
9
+ spec.email = ['sbagdat@gmail.com']
10
+
11
+ spec.summary = 'Translate any numeric value into Turkish text.'
12
+ spec.description = 'Translate any numeric value into Turkish text.'
13
+ spec.homepage = 'https://github.com/sbagdat/turkish_numeric'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
22
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: turkish_numeric
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sıtkı Bağdat
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-02-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Translate any numeric value into Turkish text.
14
+ email:
15
+ - sbagdat@gmail.com
16
+ executables:
17
+ - console
18
+ - setup
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - ".gitignore"
23
+ - ".idea/.gitignore"
24
+ - ".idea/inspectionProfiles/Project_Default.xml"
25
+ - ".idea/modules.xml"
26
+ - ".idea/redis-manager-config.xml"
27
+ - ".idea/turkish_numeric.iml"
28
+ - ".idea/vcs.xml"
29
+ - ".rspec"
30
+ - ".rubocop.yml"
31
+ - ".travis.yml"
32
+ - CHANGELOG.md
33
+ - CODE_OF_CONDUCT.md
34
+ - Gemfile
35
+ - Gemfile.lock
36
+ - LICENSE.txt
37
+ - README.md
38
+ - Rakefile
39
+ - bin/console
40
+ - bin/setup
41
+ - lib/turkish_numeric.rb
42
+ - lib/turkish_numeric/tr_num.rb
43
+ - lib/turkish_numeric/version.rb
44
+ - spec/spec_helper.rb
45
+ - spec/tr_num_spec.rb
46
+ - spec/turkish_numeric_spec.rb
47
+ - turkish_numeric.gemspec
48
+ homepage: https://github.com/sbagdat/turkish_numeric
49
+ licenses:
50
+ - MIT
51
+ metadata: {}
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 2.7.0
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubygems_version: 3.2.5
68
+ signing_key:
69
+ specification_version: 4
70
+ summary: Translate any numeric value into Turkish text.
71
+ test_files:
72
+ - spec/spec_helper.rb
73
+ - spec/tr_num_spec.rb
74
+ - spec/turkish_numeric_spec.rb