pretty_fractions 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 918ad4e76b8c46244fe35f0369d7df3f9574992596816923a3675d0bb811f9f9
4
+ data.tar.gz: e8ea388d1addaecbe043265360ceab5328387abdbcbb03934cca29a0f372561e
5
+ SHA512:
6
+ metadata.gz: d7027a51173fbc05c6aff2ec4db2e6195c26d3a6c378d93ea8ff2695f7143e085577b9159d00ef9935ab0a80938d11eb041e3c76297bb96d08a3cab9a38d876e
7
+ data.tar.gz: 673eee65f081977fa0edf765cc48e98e158c3204cbe62174c5436d377993df3744a997dba66796d1713ff479d70ec8b4c6b718a8e288a09bfef03f10b263801b
@@ -0,0 +1,11 @@
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
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,37 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+ NewCops: enable
4
+
5
+ Style/Documentation:
6
+ Description: 'Document classes and non-namespace modules.'
7
+ Enabled: false
8
+
9
+ Metrics/BlockLength:
10
+ Enabled: true
11
+ Exclude:
12
+ - spec/**/*.rb
13
+
14
+ Layout/LineLength:
15
+ Description: 'Limit lines to 100 characters.'
16
+ Enabled: true
17
+ Max: 100
18
+ AllowURI: true
19
+ URISchemes:
20
+ - http
21
+ - https
22
+
23
+ Layout/ArgumentAlignment:
24
+ StyleGuide: '#no-double-indent'
25
+ Enabled: true
26
+ EnforcedStyle: with_fixed_indentation
27
+
28
+ Layout/MultilineMethodCallIndentation:
29
+ Enabled: true
30
+ EnforcedStyle: indented
31
+
32
+ Layout/DotPosition:
33
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains'
34
+ EnforcedStyle: trailing
35
+
36
+ Layout/ArrayAlignment:
37
+ EnforcedStyle: with_fixed_indentation
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.6
6
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in pretty_fractions.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 12.0'
9
+ gem 'rspec', '~> 3.0'
10
+ gem 'rubocop'
11
+
12
+ group :development, :test do
13
+ gem 'pry-byebug'
14
+ end
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pretty_fractions (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.1)
10
+ byebug (11.1.3)
11
+ coderay (1.1.3)
12
+ diff-lcs (1.4.4)
13
+ method_source (1.0.0)
14
+ parallel (1.19.2)
15
+ parser (2.7.2.0)
16
+ ast (~> 2.4.1)
17
+ pry (0.13.1)
18
+ coderay (~> 1.1)
19
+ method_source (~> 1.0)
20
+ pry-byebug (3.9.0)
21
+ byebug (~> 11.0)
22
+ pry (~> 0.13.0)
23
+ rainbow (3.0.0)
24
+ rake (12.3.3)
25
+ regexp_parser (1.8.2)
26
+ rexml (3.2.4)
27
+ rspec (3.9.0)
28
+ rspec-core (~> 3.9.0)
29
+ rspec-expectations (~> 3.9.0)
30
+ rspec-mocks (~> 3.9.0)
31
+ rspec-core (3.9.3)
32
+ rspec-support (~> 3.9.3)
33
+ rspec-expectations (3.9.2)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (~> 3.9.0)
36
+ rspec-mocks (3.9.1)
37
+ diff-lcs (>= 1.2.0, < 2.0)
38
+ rspec-support (~> 3.9.0)
39
+ rspec-support (3.9.3)
40
+ rubocop (0.93.1)
41
+ parallel (~> 1.10)
42
+ parser (>= 2.7.1.5)
43
+ rainbow (>= 2.2.2, < 4.0)
44
+ regexp_parser (>= 1.8)
45
+ rexml
46
+ rubocop-ast (>= 0.6.0)
47
+ ruby-progressbar (~> 1.7)
48
+ unicode-display_width (>= 1.4.0, < 2.0)
49
+ rubocop-ast (0.8.0)
50
+ parser (>= 2.7.1.5)
51
+ ruby-progressbar (1.10.1)
52
+ unicode-display_width (1.7.0)
53
+
54
+ PLATFORMS
55
+ ruby
56
+
57
+ DEPENDENCIES
58
+ pretty_fractions!
59
+ pry-byebug
60
+ rake (~> 12.0)
61
+ rspec (~> 3.0)
62
+ rubocop
63
+
64
+ BUNDLED WITH
65
+ 2.1.4
@@ -0,0 +1,37 @@
1
+ # PrettyFractions
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/pretty_fractions`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'pretty_fractions'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install pretty_fractions
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ PrettyFractions.pretty_print(1/8r)
25
+ => "⅛"
26
+ ```
27
+
28
+ ## Development
29
+
30
+ 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.
31
+
32
+ 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
33
+
34
+ ## Contributing
35
+
36
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pretty_fractions.
37
+
@@ -0,0 +1,8 @@
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
+ task default: :spec
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'pretty_fractions'
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__)
@@ -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,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pretty_fractions/version'
4
+
5
+ module PrettyFractions
6
+ class Error < StandardError; end
7
+
8
+ FRACTIONS = {
9
+ 1/4r => '¼',
10
+ 1/2r => '½',
11
+ 3/4r => '¾',
12
+ 1/7r => '⅐',
13
+ 1/9r => '⅑',
14
+ 1/10r => '⅒',
15
+ 1/3r => '⅓',
16
+ 2/3r => '⅔',
17
+ 1/5r => '⅕',
18
+ 2/5r => '⅖',
19
+ 3/5r => '⅗',
20
+ 4/5r => '⅘',
21
+ 1/6r => '⅙',
22
+ 5/6r => '⅚',
23
+ 1/8r => '⅛',
24
+ 3/8r => '⅜',
25
+ 5/8r => '⅝',
26
+ 7/8r => '⅞'
27
+ }.freeze
28
+
29
+ def self.pretty_print(value)
30
+ whole, fraction = value.to_r.divmod(1)
31
+
32
+ "#{whole.zero? ? nil : whole}#{FRACTIONS.fetch(fraction, fraction)}"
33
+ end
34
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PrettyFractions
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/pretty_fractions/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'pretty_fractions'
7
+ spec.version = PrettyFractions::VERSION
8
+ spec.authors = ['Yana Petrova']
9
+ spec.email = ['janavpetrova@gmail.com']
10
+
11
+ spec.summary = 'Pretty print rationals'
12
+ spec.description = 'Pretty print rationals'
13
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
14
+
15
+ # Specify which files should be added to the gem when it is released.
16
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pretty_fractions
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yana Petrova
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-10-17 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Pretty print rationals
14
+ email:
15
+ - janavpetrova@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".rspec"
22
+ - ".rubocop.yml"
23
+ - ".travis.yml"
24
+ - Gemfile
25
+ - Gemfile.lock
26
+ - README.md
27
+ - Rakefile
28
+ - bin/console
29
+ - bin/setup
30
+ - lib/pretty_fractions.rb
31
+ - lib/pretty_fractions/version.rb
32
+ - pretty_fractions.gemspec
33
+ homepage:
34
+ licenses: []
35
+ metadata: {}
36
+ post_install_message:
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 2.6.0
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubygems_version: 3.0.3
52
+ signing_key:
53
+ specification_version: 4
54
+ summary: Pretty print rationals
55
+ test_files: []