simple_text_reformatter 1.0.1 → 1.0.2

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: b33414914245577f2379cab589207addfb06a6c795171fb5fb8a36f6dab864ad
4
- data.tar.gz: bee312d64fb84d9ead645395763e4bbe827bc5fa103ade7bd9e5938bc3c1f28c
3
+ metadata.gz: ef8a43cbae5fe8f52d6bbb6c467aa039c8edafb3650c55c9af220082a5eb27b6
4
+ data.tar.gz: 11d1fc199f7dcad6966dd445b09c8fc6ec66a9c070d480ad2ce3566f8f665a7e
5
5
  SHA512:
6
- metadata.gz: e928ff26086eba0b933cf2f48a1dc4a06633bf8f268661f08885fc55f11939ee373a4350b78a62257501c55aa72b80a091e464c06fd62f22a1ed3cad29a0f795
7
- data.tar.gz: 56622ecc2488f8b6712f6d12f396c7566614a83dbfb70da267ffb15e6efc9812675f35ce9caf60d327ad71f1d4427ac5d0e5bb86c0e5ce0900730ffa5ae0aac4
6
+ metadata.gz: 37cf36bdf021f7cf7a81cf92b8d6d58330573e282a2531804436210c642049c3e0f260a89f9ce04a90a4f1ce24757dde943757e973a4237dd472f971aada9dd2
7
+ data.tar.gz: cefba39edc6be2250c9a2a501e90476d60239a9ad98581457aad988b0c1f3ce76db0ccba8157c5a8ed306898c7c9fd079f2575f44f49c9d02ec6fce6fc3c9b32
data/Gemfile.lock CHANGED
@@ -1,13 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple_text_reformatter (1.0.0)
4
+ simple_text_reformatter (1.0.2)
5
+ money
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
9
10
  coderay (1.1.3)
11
+ concurrent-ruby (1.1.8)
12
+ i18n (1.8.8)
13
+ concurrent-ruby (~> 1.0)
10
14
  method_source (1.0.0)
15
+ money (6.14.0)
16
+ i18n (>= 0.6.4, <= 2)
11
17
  pry (0.13.1)
12
18
  coderay (~> 1.1)
13
19
  method_source (~> 1.0)
@@ -1,3 +1,4 @@
1
+ require "simple_text_reformatter/currency_formatter"
1
2
  require "simple_text_reformatter/phone_number_formatter"
2
3
  require "simple_text_reformatter/version"
3
4
 
@@ -7,4 +8,8 @@ module SimpleTextReformatter
7
8
  def self.format_as_phone_number(string)
8
9
  SimpleTextReformatter::PhoneNumberFormatter.new(string).reformat
9
10
  end
11
+
12
+ def self.format_as_currency(string)
13
+ SimpleTextReformatter::CurrencyFormatter.new(string.to_s).reformat
14
+ end
10
15
  end
@@ -0,0 +1,18 @@
1
+ require 'money'
2
+
3
+ Money.locale_backend = nil
4
+ Money.default_infinite_precision = false
5
+
6
+ module SimpleTextReformatter
7
+ class CurrencyFormatter
8
+ def initialize(currency_string)
9
+ @currency_string = currency_string
10
+ end
11
+
12
+ def reformat
13
+ amount = @currency_string.to_f * 100
14
+
15
+ return Money.new(amount, 'USD').format
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module SimpleTextReformatter
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -27,4 +27,6 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "rake", "~> 10.0"
28
28
  spec.add_development_dependency "pry"
29
29
  spec.add_development_dependency "rb-readline"
30
+
31
+ spec.add_dependency "money"
30
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_text_reformatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elliott Young
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-25 00:00:00.000000000 Z
11
+ date: 2021-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: money
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: A very simple text reformatter. For use in another project, but I suppose
70
84
  could be useful.
71
85
  email:
@@ -84,6 +98,7 @@ files:
84
98
  - bin/console
85
99
  - bin/setup
86
100
  - lib/simple_text_reformatter.rb
101
+ - lib/simple_text_reformatter/currency_formatter.rb
87
102
  - lib/simple_text_reformatter/phone_number_formatter.rb
88
103
  - lib/simple_text_reformatter/version.rb
89
104
  - simple_text_reformatter.gemspec