percentage 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -3
- data/lib/percentage/yaml.rb +29 -0
- data/percentage.gemspec +9 -3
- metadata +10 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fdafcbd9c4dc5f1343a84c5f9eaa0977457c968c41909af91b4d0c29dc621c3
|
4
|
+
data.tar.gz: db6e50503c2fe194e3692d15b1b51a25cf313a9841f1109d17d0e6e34a6d894a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8eeef0a8515aa30575554043d39096dfbcea96bf074f808def87813a1460d736c3709cea4b4ccb78c40e480f843d1496153b328f1c6de4965d111ab5d755224c
|
7
|
+
data.tar.gz: e41dbb802b57713316a34346645f59fdfe1a8477dae9c811e4b6fc8a3599a79eb9a8dbd06068f5b8f67b6c82ff20a07e57df9c01e65f7986ec7f5288c837a93e
|
data/README.md
CHANGED
@@ -1,12 +1,19 @@
|
|
1
1
|
# percentage
|
2
2
|
|
3
|
-
|
3
|
+
![Gem Version](https://badge.fury.io/rb/percentage.svg)
|
4
|
+
![Build Status](https://github.com/readysteady/percentage/workflows/Test/badge.svg)
|
4
5
|
|
5
6
|
|
6
|
-
|
7
|
+
Ruby gem for working with percentages.
|
7
8
|
|
8
9
|
|
9
|
-
##
|
10
|
+
## Install
|
11
|
+
|
12
|
+
Using Bundler:
|
13
|
+
|
14
|
+
$ bundle add percentage
|
15
|
+
|
16
|
+
Using RubyGems:
|
10
17
|
|
11
18
|
$ gem install percentage
|
12
19
|
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
class Percentage
|
4
|
+
def encode_with(coder)
|
5
|
+
coder.represent_scalar(nil, to_s)
|
6
|
+
end
|
7
|
+
|
8
|
+
module ScalarScannerPatch
|
9
|
+
INTEGER = /\A(\d+)%\z/
|
10
|
+
|
11
|
+
DECIMAL = /\A(\d+\.\d+)%\z/
|
12
|
+
|
13
|
+
def tokenize(string)
|
14
|
+
if !string.empty? && string.match(INTEGER)
|
15
|
+
return Percentage($1.to_i)
|
16
|
+
end
|
17
|
+
|
18
|
+
if !string.empty? && string.match(DECIMAL)
|
19
|
+
return Percentage(BigDecimal($1))
|
20
|
+
end
|
21
|
+
|
22
|
+
super string
|
23
|
+
end
|
24
|
+
|
25
|
+
YAML::ScalarScanner.prepend(self)
|
26
|
+
end
|
27
|
+
|
28
|
+
private_constant :ScalarScannerPatch
|
29
|
+
end
|
data/percentage.gemspec
CHANGED
@@ -1,14 +1,20 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'percentage'
|
3
|
-
s.version = '1.
|
3
|
+
s.version = '1.4.0'
|
4
4
|
s.license = 'LGPL-3.0'
|
5
5
|
s.platform = Gem::Platform::RUBY
|
6
6
|
s.authors = ['Tim Craft']
|
7
7
|
s.email = ['mail@timcraft.com']
|
8
|
-
s.homepage = 'https://github.com/
|
9
|
-
s.description = '
|
8
|
+
s.homepage = 'https://github.com/readysteady/percentage'
|
9
|
+
s.description = 'Ruby gem for working with percentages'
|
10
10
|
s.summary = 'See description'
|
11
11
|
s.files = Dir.glob('lib/**/*.rb') + %w(LICENSE.txt README.md percentage.gemspec)
|
12
12
|
s.required_ruby_version = '>= 1.9.3'
|
13
13
|
s.require_path = 'lib'
|
14
|
+
s.metadata = {
|
15
|
+
'homepage' => 'https://github.com/readysteady/percentage',
|
16
|
+
'source_code_uri' => 'https://github.com/readysteady/percentage',
|
17
|
+
'bug_tracker_uri' => 'https://github.com/readysteady/percentage/issues',
|
18
|
+
'changelog_uri' => 'https://github.com/readysteady/percentage/blob/master/CHANGES.md'
|
19
|
+
}
|
14
20
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: percentage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Craft
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: Ruby gem for working with percentages
|
14
14
|
email:
|
15
15
|
- mail@timcraft.com
|
16
16
|
executables: []
|
@@ -20,11 +20,16 @@ files:
|
|
20
20
|
- LICENSE.txt
|
21
21
|
- README.md
|
22
22
|
- lib/percentage.rb
|
23
|
+
- lib/percentage/yaml.rb
|
23
24
|
- percentage.gemspec
|
24
|
-
homepage: https://github.com/
|
25
|
+
homepage: https://github.com/readysteady/percentage
|
25
26
|
licenses:
|
26
27
|
- LGPL-3.0
|
27
|
-
metadata:
|
28
|
+
metadata:
|
29
|
+
homepage: https://github.com/readysteady/percentage
|
30
|
+
source_code_uri: https://github.com/readysteady/percentage
|
31
|
+
bug_tracker_uri: https://github.com/readysteady/percentage/issues
|
32
|
+
changelog_uri: https://github.com/readysteady/percentage/blob/master/CHANGES.md
|
28
33
|
post_install_message:
|
29
34
|
rdoc_options: []
|
30
35
|
require_paths:
|