friendly_numbers 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 433e9b8147e6f42996925ee4ac1d1f85700b262ec5ea9905c046bd68d7bfa59d
4
- data.tar.gz: 8761157d53a90ac189e9af187cbea8a7e45feb4a947926c28bb09026e27845ee
3
+ metadata.gz: '028d287d00642a2c786fbb62ec6a0fedccf2eeaf9681f56534c0198cedc15eb5'
4
+ data.tar.gz: 530fc07161336d27363229ecaba23583380b2d3b982d71830756776833e38c7a
5
5
  SHA512:
6
- metadata.gz: 1daf85daea83121b95608527169abac068464a65300e1ddcc33e958ea32d8d2cc1b06333acb652219ab409a2a3fc9d8339d04c5ab41fd9d2f026d66105f893c3
7
- data.tar.gz: bfb873a0e78426deccd60b3e9c05ddf8199987558a36b439a4da93182530f9b444f108180f7a39cf9874769b33962e2431d3b41f5f3cd34cb18a3df78bf35879
6
+ metadata.gz: 9754a24bb0c90f62a3ab5a05a6bf56e6aa2323e2131df719a4e8e470fa3e40a0d0960bde100e2c76844845b49c61382254d7c6ae8a464c2f30c2fcaf7f4c8f51
7
+ data.tar.gz: 6ce33f8a3af5b5da17266703fab1452e2c38adb6f07e2d7155f6dccf34217cb63bf2bcf9db0032dcd2d5ae861fa93777c9fa5f67a66eb509427973336ab62e3e
@@ -3,33 +3,34 @@
3
3
  version: 2.0
4
4
 
5
5
  jobs:
6
- "ruby-2.4":
6
+ "ruby-2.5":
7
7
  docker:
8
- - image: circleci/ruby:2.4
8
+ - image: circleci/ruby:2.5
9
9
  steps:
10
10
  - checkout
11
- - run: gem install bundler -v 1.13 --no-document
11
+ - run: gem install bundler -v "~> 2.0" --no-document
12
12
  - run: bundle install --path vendor/bundle
13
13
  - run:
14
14
  name: Run tests
15
15
  command: rake test
16
16
 
17
- "ruby-2.5":
17
+ "ruby-2.6":
18
18
  docker:
19
- - image: circleci/ruby:2.5
19
+ - image: circleci/ruby:2.6
20
20
  steps:
21
21
  - checkout
22
- - run: gem install bundler -v 1.13 --no-document
22
+ - run: gem install bundler -v "~> 2.0" --no-document
23
23
  - run: bundle install --path vendor/bundle
24
24
  - run:
25
25
  name: Run tests
26
26
  command: rake test
27
27
 
28
- "ruby-2.6":
28
+ "ruby-2.7":
29
29
  docker:
30
- - image: circleci/ruby:2.6
30
+ - image: circleci/ruby:2.7
31
31
  steps:
32
32
  - checkout
33
+ - run: gem install bundler -v "~> 2.0" --no-document
33
34
  - run: bundle install --path vendor/bundle
34
35
  - run:
35
36
  name: Run tests
@@ -39,6 +40,6 @@ workflows:
39
40
  version: 2
40
41
  build:
41
42
  jobs:
42
- - "ruby-2.4"
43
43
  - "ruby-2.5"
44
44
  - "ruby-2.6"
45
+ - "ruby-2.7"
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
@@ -0,0 +1,13 @@
1
+ inherit_mode:
2
+ merge:
3
+ - Exclude
4
+
5
+ require:
6
+ - rubocop-performance
7
+ - standard/cop/semantic_blocks
8
+
9
+ inherit_gem:
10
+ standard: config/base.yml
11
+
12
+ inherit_from:
13
+ - .rubocop_strict.yml
@@ -0,0 +1,6 @@
1
+ inherit_from:
2
+ - .rubocop_todo.yml
3
+
4
+ Lint/Debugger:
5
+ Enabled: true
6
+ Exclude: []
@@ -0,0 +1,69 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config --auto-gen-only-exclude`
3
+ # on 2020-04-19 03:43:42 +0000 using RuboCop version 0.80.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Cop supports --auto-correct.
11
+ Layout/EmptyLineAfterMagicComment:
12
+ Exclude:
13
+ - 'friendly_numbers.gemspec'
14
+
15
+ # Offense count: 13
16
+ # Cop supports --auto-correct.
17
+ # Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
18
+ Layout/ExtraSpacing:
19
+ Exclude:
20
+ - 'friendly_numbers.gemspec'
21
+ - 'lib/friendly_numbers/seconds_to_time.rb'
22
+
23
+ # Offense count: 3
24
+ # Cop supports --auto-correct.
25
+ # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
26
+ # SupportedStyles: space, no_space, compact
27
+ # SupportedStylesForEmptyBraces: space, no_space
28
+ Layout/SpaceInsideHashLiteralBraces:
29
+ Exclude:
30
+ - 'test/seconds_to_time_test.rb'
31
+
32
+ # Offense count: 1
33
+ # Cop supports --auto-correct.
34
+ Style/Encoding:
35
+ Exclude:
36
+ - 'friendly_numbers.gemspec'
37
+
38
+ # Offense count: 1
39
+ # Cop supports --auto-correct.
40
+ # Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
41
+ # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
42
+ Style/HashSyntax:
43
+ Exclude:
44
+ - 'Rakefile'
45
+
46
+ # Offense count: 2
47
+ # Cop supports --auto-correct.
48
+ # Configuration parameters: PreferredDelimiters.
49
+ Style/PercentLiteralDelimiters:
50
+ Exclude:
51
+ - 'friendly_numbers.gemspec'
52
+ - 'lib/friendly_numbers/number_to_human_size.rb'
53
+
54
+ # Offense count: 1
55
+ # Cop supports --auto-correct.
56
+ Style/RedundantPercentQ:
57
+ Exclude:
58
+ - 'friendly_numbers.gemspec'
59
+
60
+ # Offense count: 7
61
+ # Cop supports --auto-correct.
62
+ # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
63
+ # SupportedStyles: single_quotes, double_quotes
64
+ Style/StringLiterals:
65
+ Exclude:
66
+ - 'Gemfile'
67
+ - 'Rakefile'
68
+ - 'friendly_numbers.gemspec'
69
+ - 'test/test_helper.rb'
@@ -1,5 +1,9 @@
1
1
  # master
2
2
 
3
+ # 0.6.0 (2020-05-14)
4
+ - BREAKING: `number_to_currency` no longer rounds when truncating to precision
5
+ - `number_to_currency` properly handles partitioning of larger negative numbers (#2)
6
+
3
7
  # 0.5.0 (2019-03-28)
4
8
  - Properly escape percent sign in percentage helper
5
9
  - Fix handling of whole numbers in currency helper
data/Gemfile CHANGED
@@ -2,3 +2,8 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in friendly_numbers.gemspec
4
4
  gemspec
5
+
6
+ gem "bundler"
7
+ gem "rake"
8
+ gem "minitest"
9
+ gem "standard"
@@ -0,0 +1,45 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ friendly_numbers (0.6.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.0)
10
+ jaro_winkler (1.5.4)
11
+ minitest (5.13.0)
12
+ parallel (1.19.1)
13
+ parser (2.7.1.1)
14
+ ast (~> 2.4.0)
15
+ rainbow (3.0.0)
16
+ rake (13.0.1)
17
+ rexml (3.2.4)
18
+ rubocop (0.80.1)
19
+ jaro_winkler (~> 1.5.1)
20
+ parallel (~> 1.10)
21
+ parser (>= 2.7.0.1)
22
+ rainbow (>= 2.2.2, < 4.0)
23
+ rexml
24
+ ruby-progressbar (~> 1.7)
25
+ unicode-display_width (>= 1.4.0, < 1.7)
26
+ rubocop-performance (1.5.2)
27
+ rubocop (>= 0.71.0)
28
+ ruby-progressbar (1.10.1)
29
+ standard (0.2.3)
30
+ rubocop (~> 0.80.1)
31
+ rubocop-performance (~> 1.5.2)
32
+ unicode-display_width (1.6.1)
33
+
34
+ PLATFORMS
35
+ ruby
36
+
37
+ DEPENDENCIES
38
+ bundler
39
+ friendly_numbers!
40
+ minitest
41
+ rake
42
+ standard
43
+
44
+ BUNDLED WITH
45
+ 2.1.4
@@ -25,8 +25,4 @@ Gem::Specification.new do |spec|
25
25
  spec.bindir = "exe"
26
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
27
  spec.require_paths = ["lib"]
28
-
29
- spec.add_development_dependency "bundler", "~> 1.13"
30
- spec.add_development_dependency "rake", "~> 10.0"
31
- spec.add_development_dependency "minitest", "~> 5.0"
32
28
  end
@@ -11,23 +11,16 @@ module FriendlyNumbers
11
11
  def convert(value, options) # :nodoc:
12
12
  options = DEFAULTS.merge(options)
13
13
 
14
- whole, part = value.divmod(1)
14
+ value = value.truncate(options[:precision]).to_f.to_s + ("0" * options[:precision].to_i)
15
+ whole, part = value.split(".", 2)
15
16
 
16
- parted = partition(whole, options[:separator])
17
+ parted = whole.reverse.gsub(/...(?!-)(?=.)/, '\&,').reverse
17
18
 
18
19
  if options[:precision].nonzero?
19
- decimal = sprintf("%.0#{options[:precision]}f", part.abs)[1..-1] # Strip leading 0
20
+ options[:unit] + parted + "." + part[0, options[:precision]]
21
+ else
22
+ options[:unit] + parted
20
23
  end
21
-
22
- options[:unit] + parted + decimal.to_s
23
- end
24
-
25
- def partition(whole, separator)
26
- whole.to_s.chars.reverse
27
- .each_slice(3)
28
- .map(&:join)
29
- .join(separator)
30
- .reverse
31
24
  end
32
25
  end
33
26
  end
@@ -1,3 +1,3 @@
1
1
  module FriendlyNumbers
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,57 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: friendly_numbers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Daniels
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-28 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.13'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.13'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '10.0'
41
- - !ruby/object:Gem::Dependency
42
- name: minitest
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '5.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '5.0'
11
+ date: 2020-05-14 00:00:00.000000000 Z
12
+ dependencies: []
55
13
  description: |2
56
14
  Friendly number helpers without the mess. Working on a Roda or Sinatra application
57
15
  and want to format a number into a currency or friendly file size? Got you covered.
@@ -65,8 +23,12 @@ extra_rdoc_files: []
65
23
  files:
66
24
  - ".circleci/config.yml"
67
25
  - ".gitignore"
26
+ - ".rubocop.yml"
27
+ - ".rubocop_strict.yml"
28
+ - ".rubocop_todo.yml"
68
29
  - CHANGELOG.md
69
30
  - Gemfile
31
+ - Gemfile.lock
70
32
  - LICENSE.txt
71
33
  - README.md
72
34
  - Rakefile
@@ -98,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
60
  - !ruby/object:Gem::Version
99
61
  version: '0'
100
62
  requirements: []
101
- rubygems_version: 3.0.1
63
+ rubygems_version: 3.1.2
102
64
  signing_key:
103
65
  specification_version: 4
104
66
  summary: Friendly number helpers for your non-Rails/Padrino apps.