formatting 0.0.17 → 0.0.18

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 31a50e279bf40d7bd3e6a284ab518d258d0f1120
4
- data.tar.gz: 66448a804ff7bc12a5dfaba0dbcfe9643221b66a
2
+ SHA256:
3
+ metadata.gz: bc0d48715ff358482643c0ab965fcd3965399fb78eec281e109142917d0e249c
4
+ data.tar.gz: 74079c3f59a8f5c7e925ba627f1213c7956a7be5b5e23a7e0f5a9ad7dee19447
5
5
  SHA512:
6
- metadata.gz: f19832f4814387e8397459f2d7c038684832235987d7c2d05c8ddc00a66f76358adfc9d2052f605a5b280796f1adb4907e328d09deb5f671be7ca3fdea529862
7
- data.tar.gz: e95ab8b878a6f1b081ee28fd261385aa13e7229019467ce9ea92bde2ae0b02ef3ac7d71bc1b0c8a9a53c3aa3abc7f7e843cce167fd47b931a840874b48baa0de
6
+ metadata.gz: 1fa29df5ceb15a52ff8630678295306dd88cc2de04f0aa2ca46bf2a636bfe56dcd0afd6fc7356ba68229e1c33ba7171bcdf6fe339bee209b7f407d44930aaf08
7
+ data.tar.gz: 5d43ba483c1d4b0c1e5805e70d6689242b8ff4261d8b4089372eac01115cb382a3f1cf147ad29c4667d35610cdba811a49be12d8173db58dd926c3a656349203
@@ -0,0 +1,26 @@
1
+ name: Ruby CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ runs-on: ubuntu-latest
13
+
14
+ strategy:
15
+ matrix:
16
+ ruby-version: ["3.0", "2.7", "2.6", "2.5"]
17
+
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - name: Set up Ruby ${{ matrix.ruby-version }}
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby-version }}
24
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
25
+ - name: Run tests
26
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .rspec_results
data/.rubocop.yml ADDED
@@ -0,0 +1,5 @@
1
+ AllCops:
2
+ Exclude:
3
+ - "tmp/**/*"
4
+ inherit_gem:
5
+ barsoom_utils: shared_rubocop.yml
data/Gemfile CHANGED
@@ -1,4 +1,14 @@
1
- source 'https://rubygems.org'
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
2
4
 
3
5
  # Specify your gem's dependencies in formatting.gemspec
4
6
  gemspec
7
+
8
+ group :development do
9
+ gem "barsoom_utils", github: "barsoom/barsoom_utils"
10
+ gem "bundler"
11
+ gem "rake"
12
+ gem "rspec"
13
+ gem "rubocop"
14
+ end
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Ruby CI](https://github.com/barsoom/formatting/actions/workflows/ci.yml/badge.svg)](https://github.com/barsoom/formatting/actions/workflows/ci.yml)
2
+
1
3
  # Formatting
2
4
 
3
5
  Rails-less formatting for your unit-testable code.
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rspec/core/rake_task"
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/formatting.gemspec CHANGED
@@ -1,24 +1,22 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("lib", __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'formatting/version'
5
+ require "formatting/version"
5
6
 
6
7
  Gem::Specification.new do |spec|
7
8
  spec.name = "formatting"
8
9
  spec.version = Formatting::VERSION
9
- spec.authors = ["Henrik Nyh", "Tomas Skogberg"]
10
- spec.email = ["henrik@barsoom.se", "tomas@barsoom.se"]
10
+ spec.authors = [ "Henrik Nyh", "Tomas Skogberg" ]
11
+ spec.email = [ "henrik@barsoom.se", "tomas@barsoom.se" ]
11
12
  spec.summary = %q{Rails-less formatting for your unit-testable code.}
12
13
  spec.homepage = ""
13
14
  spec.license = "MIT"
15
+ spec.metadata = { "rubygems_mfa_required" => "true" }
14
16
 
15
17
  spec.files = `git ls-files`.split($/)
16
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ["lib"]
19
+ spec.require_paths = [ "lib" ]
19
20
 
20
21
  spec.add_dependency "attr_extras"
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec"
24
22
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "attr_extras"
2
4
 
3
5
  module Formatting
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "attr_extras"
2
4
 
3
5
  module Formatting
@@ -39,7 +41,7 @@ module Formatting
39
41
  end
40
42
 
41
43
  # Avoid negative zero.
42
- number = 0 if number.zero?
44
+ number = number.abs if number.zero?
43
45
 
44
46
  if round
45
47
  number = number.round(round) if has_decimals
@@ -59,7 +61,7 @@ module Formatting
59
61
  decimals = decimals.ljust(min_decimals, "0")
60
62
  end
61
63
 
62
- [integer, decimals].compact.join(decimal_separator)
64
+ [ integer, decimals ].compact.join(decimal_separator)
63
65
  end
64
66
 
65
67
  private
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "attr_extras"
2
4
 
3
5
  module Formatting
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Formatting
2
- VERSION = "0.0.17"
4
+ VERSION = "0.0.18"
3
5
  end
data/lib/formatting.rb CHANGED
@@ -1,4 +1,5 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  # ^ so NON_BREAKING_SPACE is treated as UTF-8 in Ruby 1.9.
3
4
 
4
5
  require "formatting/version"
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
- describe Formatting::Currency do
5
+ RSpec.describe Formatting::Currency do
4
6
  it "can be included as a module" do
5
7
  object = Object.new
6
8
  object.extend Formatting::Currency
@@ -8,7 +10,7 @@ describe Formatting::Currency do
8
10
  end
9
11
  end
10
12
 
11
- describe Formatting do
13
+ RSpec.describe Formatting do
12
14
  describe ".format_currency" do
13
15
  let(:item) { double }
14
16
 
@@ -18,7 +20,7 @@ describe Formatting do
18
20
  end
19
21
 
20
22
  it "can take a record and a method name" do
21
- item.stub(price: 2)
23
+ allow(item).to receive(:price).and_return(2)
22
24
  expect_formatted(item, :price).to eq space_to_nbsp("2.00")
23
25
  end
24
26
 
@@ -48,12 +50,12 @@ describe Formatting do
48
50
  end
49
51
 
50
52
  it "is read from the record's #currency if present" do
51
- item.stub(currency: "SEK")
53
+ allow(item).to receive(:currency).and_return("SEK")
52
54
  expect_formatted(item, 1).to eq space_to_nbsp("1.00 SEK")
53
55
  end
54
56
 
55
57
  it "is not added if the record's #currency is blank" do
56
- item.stub(currency: "")
58
+ allow(item).to receive(:currency).and_return("")
57
59
  expect_formatted(item, 1).to eq space_to_nbsp("1.00")
58
60
  end
59
61
 
@@ -68,8 +70,8 @@ describe Formatting do
68
70
 
69
71
  context "format string option" do
70
72
  it "is used if provided" do
71
- expect_formatted(item, 123, format: "C: <currency> A: <amount>", currency: "XYZ").
72
- to eq space_to_nbsp("C: XYZ A: 123.00")
73
+ expect_formatted(item, 123, format: "C: <currency> A: <amount>", currency: "XYZ")
74
+ .to eq space_to_nbsp("C: XYZ A: 123.00")
73
75
  end
74
76
 
75
77
  it "will have spaces turned into non-breaking spaces" do
@@ -79,8 +81,8 @@ describe Formatting do
79
81
  end
80
82
 
81
83
  it "is stripped" do
82
- expect_formatted(item, 123, format: "<amount> <currency>", currency: nil).
83
- to eq space_to_nbsp("123.00")
84
+ expect_formatted(item, 123, format: "<amount> <currency>", currency: nil)
85
+ .to eq space_to_nbsp("123.00")
84
86
  end
85
87
  end
86
88
 
data/spec/number_spec.rb CHANGED
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
- describe Formatting::Number do
5
+ RSpec.describe Formatting::Number do
4
6
  it "can be included as a module" do
5
7
  object = Object.new
6
8
  object.extend Formatting::Number
@@ -8,7 +10,7 @@ describe Formatting::Number do
8
10
  end
9
11
  end
10
12
 
11
- describe Formatting do
13
+ RSpec.describe Formatting do
12
14
  describe ".format_number" do
13
15
  it "formats a number" do
14
16
  expect_formatted(1234567.89).to eq space_to_nbsp("1 234 567.89")
@@ -25,9 +27,9 @@ describe Formatting do
25
27
 
26
28
  it "uses I18n.t('number.format.delimiter') if present" do
27
29
  allow(i18n).to receive(:t).with(:separator, instance_of(Hash))
28
- expect(i18n).to receive(:t).
29
- with(:delimiter, scope: "number.format", default: space_to_nbsp(" ")).
30
- and_return(";")
30
+ expect(i18n).to receive(:t)
31
+ .with(:delimiter, scope: "number.format", default: space_to_nbsp(" "))
32
+ .and_return(";")
31
33
  expect_formatted(1234).to include "1;234"
32
34
  end
33
35
  end
@@ -90,7 +92,6 @@ describe Formatting do
90
92
  end
91
93
  end
92
94
 
93
-
94
95
  context "minimum number of decimals" do
95
96
  it "defaults to two decimals" do
96
97
  expect_formatted(12).to eq "12.00"
data/spec/percent_spec.rb CHANGED
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
- describe Formatting::Percent do
5
+ RSpec.describe Formatting::Percent do
4
6
  it "can be included as a module" do
5
7
  object = Object.new
6
8
  object.extend Formatting::Percent
@@ -8,7 +10,7 @@ describe Formatting::Percent do
8
10
  end
9
11
  end
10
12
 
11
- describe Formatting, ".format_percent" do
13
+ RSpec.describe Formatting, ".format_percent" do
12
14
  it "formats a number" do
13
15
  expect_formatted(1.2).to eq "1.20%"
14
16
  end
@@ -26,7 +28,7 @@ describe Formatting, ".format_percent" do
26
28
  let(:i18n) { stub_const("I18n", double) }
27
29
 
28
30
  it "defaults sensibly for some locales that require spacing the sign" do
29
- i18n.stub(locale: :sv)
31
+ allow(i18n).to receive(:locale).and_return(:sv)
30
32
  expect_formatted(1).to eq space_to_nbsp("1.00 %")
31
33
  end
32
34
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "formatting"
2
4
 
3
5
  module Helpers
@@ -8,4 +10,10 @@ end
8
10
 
9
11
  RSpec.configure do |config|
10
12
  config.include Helpers
13
+
14
+ config.example_status_persistence_file_path = ".rspec_results"
15
+ config.disable_monkey_patching!
16
+
17
+ config.order = :random
18
+ Kernel.srand config.seed
11
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formatting
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Nyh
@@ -9,62 +9,20 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-04 00:00:00.000000000 Z
12
+ date: 2021-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: attr_extras
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
26
- - !ruby/object:Gem::Version
27
- version: '0'
28
- - !ruby/object:Gem::Dependency
29
- name: bundler
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - ~>
33
- - !ruby/object:Gem::Version
34
- version: '1.3'
35
- type: :development
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ~>
40
- - !ruby/object:Gem::Version
41
- version: '1.3'
42
- - !ruby/object:Gem::Dependency
43
- name: rake
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - '>='
47
- - !ruby/object:Gem::Version
48
- version: '0'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - '>='
54
- - !ruby/object:Gem::Version
55
- version: '0'
56
- - !ruby/object:Gem::Dependency
57
- name: rspec
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - '>='
61
- - !ruby/object:Gem::Version
62
- version: '0'
63
- type: :development
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - '>='
25
+ - - ">="
68
26
  - !ruby/object:Gem::Version
69
27
  version: '0'
70
28
  description:
@@ -75,7 +33,9 @@ executables: []
75
33
  extensions: []
76
34
  extra_rdoc_files: []
77
35
  files:
78
- - .gitignore
36
+ - ".github/workflows/ci.yml"
37
+ - ".gitignore"
38
+ - ".rubocop.yml"
79
39
  - Gemfile
80
40
  - LICENSE.txt
81
41
  - README.md
@@ -93,24 +53,24 @@ files:
93
53
  homepage: ''
94
54
  licenses:
95
55
  - MIT
96
- metadata: {}
56
+ metadata:
57
+ rubygems_mfa_required: 'true'
97
58
  post_install_message:
98
59
  rdoc_options: []
99
60
  require_paths:
100
61
  - lib
101
62
  required_ruby_version: !ruby/object:Gem::Requirement
102
63
  requirements:
103
- - - '>='
64
+ - - ">="
104
65
  - !ruby/object:Gem::Version
105
66
  version: '0'
106
67
  required_rubygems_version: !ruby/object:Gem::Requirement
107
68
  requirements:
108
- - - '>='
69
+ - - ">="
109
70
  - !ruby/object:Gem::Version
110
71
  version: '0'
111
72
  requirements: []
112
- rubyforge_project:
113
- rubygems_version: 2.2.0
73
+ rubygems_version: 3.2.31
114
74
  signing_key:
115
75
  specification_version: 4
116
76
  summary: Rails-less formatting for your unit-testable code.