bar-of-progress 0.1.1 → 0.1.2
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 +4 -4
- data/.travis.yml +1 -0
- data/lib/bar-of-progress.rb +11 -4
- data/lib/bar_of_progress/version.rb +1 -1
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee0a9586bd4a588c64c731b1a7daf07d32015fc5
|
4
|
+
data.tar.gz: 19bb56d81c444a8392b847576501cd98981d7b2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7dcd0ef35a006ab61416e7dae643bf03d570ae9131b5ef6bedd73060b3cefe981773d835d969aca82c51003bd5f69675d8aaf522d082ae40430e0bfcec199d78
|
7
|
+
data.tar.gz: 7c2aa02ac6127adea032a40c8596d4902ade6897b3cc1176c2f15555d24013c40fd6c2cd5eb3a764426e38e4273291f707159a0fc18bc03f4616aeb439399436
|
data/.travis.yml
CHANGED
data/lib/bar-of-progress.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require "bar_of_progress/version"
|
4
4
|
|
5
5
|
require 'bigdecimal'
|
6
|
-
require 'bigdecimal/util'
|
7
6
|
|
8
7
|
class BarOfProgress
|
9
8
|
DEFAULTS = {
|
@@ -20,7 +19,7 @@ class BarOfProgress
|
|
20
19
|
@options = DEFAULTS.merge(options)
|
21
20
|
|
22
21
|
#massage data because eww.
|
23
|
-
@options[:total] = @options[:total]
|
22
|
+
@options[:total] = to_d(@options[:total])
|
24
23
|
@options[:length] = @options[:length].to_i
|
25
24
|
end
|
26
25
|
|
@@ -32,7 +31,7 @@ class BarOfProgress
|
|
32
31
|
private
|
33
32
|
|
34
33
|
def clamped_bubbles_for(amount)
|
35
|
-
clamp(bubbles_for(amount), 0, @options[:length])
|
34
|
+
to_d(clamp(bubbles_for(amount), 0, @options[:length]))
|
36
35
|
end
|
37
36
|
|
38
37
|
def partial_bubbles_for(bubbles)
|
@@ -40,7 +39,7 @@ private
|
|
40
39
|
end
|
41
40
|
|
42
41
|
def bubbles_for(amount)
|
43
|
-
(amount
|
42
|
+
(to_d(amount) / @options[:total]) * @options[:length]
|
44
43
|
end
|
45
44
|
|
46
45
|
# This method is amazing.
|
@@ -48,6 +47,14 @@ private
|
|
48
47
|
[[n, min].max, max].min
|
49
48
|
end
|
50
49
|
|
50
|
+
def to_d(thing)
|
51
|
+
if thing.kind_of?(Float)
|
52
|
+
BigDecimal(thing, Float::DIG)
|
53
|
+
else
|
54
|
+
BigDecimal(thing)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
51
58
|
class Output
|
52
59
|
def initialize(complete, partial, options)
|
53
60
|
@complete = complete
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bar-of-progress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Searls
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: Render custom textual progress bars with a simple little API
|
@@ -45,9 +45,9 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- .gitignore
|
49
|
-
- .rspec
|
50
|
-
- .travis.yml
|
48
|
+
- ".gitignore"
|
49
|
+
- ".rspec"
|
50
|
+
- ".travis.yml"
|
51
51
|
- Gemfile
|
52
52
|
- LICENSE.txt
|
53
53
|
- README.md
|
@@ -67,17 +67,17 @@ require_paths:
|
|
67
67
|
- lib
|
68
68
|
required_ruby_version: !ruby/object:Gem::Requirement
|
69
69
|
requirements:
|
70
|
-
- -
|
70
|
+
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: '0'
|
73
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - ">="
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
79
|
rubyforge_project:
|
80
|
-
rubygems_version: 2.
|
80
|
+
rubygems_version: 2.5.1
|
81
81
|
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: Render custom textual progress bars
|