ruby-units 2.3.0 → 2.4.1
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/.codeclimate.yml +32 -0
- data/.csslintrc +2 -0
- data/.eslintignore +1 -0
- data/.eslintrc +213 -0
- data/.github/dependabot.yml +16 -0
- data/.github/workflows/codeql-analysis.yml +70 -0
- data/.github/workflows/tests.yml +49 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.rubocop.yml +24 -0
- data/.ruby-version +1 -0
- data/.solargraph.yml +16 -0
- data/CHANGELOG.txt +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +183 -0
- data/Guardfile +31 -0
- data/LICENSE.txt +18 -17
- data/README.md +124 -96
- data/Rakefile +3 -24
- data/lib/ruby-units.rb +0 -1
- data/lib/ruby_units/configuration.rb +5 -4
- data/lib/ruby_units/definition.rb +6 -2
- data/lib/ruby_units/namespaced.rb +0 -3
- data/lib/ruby_units/unit.rb +230 -221
- data/lib/ruby_units/version.rb +1 -4
- data/ruby-units.gemspec +37 -79
- metadata +121 -23
- data/VERSION +0 -1
data/Rakefile
CHANGED
@@ -1,27 +1,6 @@
|
|
1
|
-
require '
|
2
|
-
require 'rake'
|
3
|
-
require 'rake/testtask'
|
4
|
-
require './lib/ruby-units'
|
5
|
-
|
6
|
-
begin
|
7
|
-
require 'jeweler'
|
8
|
-
Jeweler::Tasks.new do |gem|
|
9
|
-
gem.name = 'ruby-units'
|
10
|
-
gem.summary = 'A class that performs unit conversions and unit math'
|
11
|
-
gem.description = 'Provides classes and methods to perform unit math and conversions'
|
12
|
-
gem.authors = ['Kevin Olbrich, Ph.D.']
|
13
|
-
gem.email = ['kevin.olbrich+ruby_units@gmail.com']
|
14
|
-
gem.homepage = 'https://github.com/olbrich/ruby-units'
|
15
|
-
gem.files.exclude('.*', 'test/**/*', 'spec/**/*', 'Gemfile', 'Guardfile')
|
16
|
-
gem.license = 'MIT'
|
17
|
-
end
|
18
|
-
Jeweler::GemcutterTasks.new
|
19
|
-
rescue LoadError
|
20
|
-
puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler'
|
21
|
-
end
|
22
|
-
|
1
|
+
require 'bundler/gem_tasks'
|
23
2
|
require 'rspec/core/rake_task'
|
24
|
-
|
25
|
-
RSpec::Core::RakeTask.new
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
26
5
|
|
27
6
|
task default: :spec
|
data/lib/ruby-units.rb
CHANGED
@@ -24,9 +24,9 @@ module RubyUnits
|
|
24
24
|
|
25
25
|
# holds actual configuration values for RubyUnits
|
26
26
|
class Configuration
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
27
|
+
# Used to separate the scalar from the unit when generating output. A value
|
28
|
+
# of `true` will insert a single space, and `false` will prevent adding a
|
29
|
+
# space to the string representation of a unit.
|
30
30
|
attr_reader :separator
|
31
31
|
|
32
32
|
def initialize
|
@@ -34,7 +34,8 @@ module RubyUnits
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def separator=(value)
|
37
|
-
raise ArgumentError, "configuration 'separator' may only be true or false" unless value
|
37
|
+
raise ArgumentError, "configuration 'separator' may only be true or false" unless value == true || value == false
|
38
|
+
|
38
39
|
@separator = value ? ' ' : nil
|
39
40
|
end
|
40
41
|
end
|
@@ -16,6 +16,10 @@ class RubyUnits::Unit < Numeric
|
|
16
16
|
# @return [Array]
|
17
17
|
attr_accessor :denominator
|
18
18
|
|
19
|
+
# Unit name to be used when generating output. This MUST be a parseable
|
20
|
+
# string or it won't be possible to round trip the unit to a String and
|
21
|
+
# back.
|
22
|
+
#
|
19
23
|
# @return [String]
|
20
24
|
attr_accessor :display_name
|
21
25
|
|
@@ -48,7 +52,7 @@ class RubyUnits::Unit < Numeric
|
|
48
52
|
end
|
49
53
|
|
50
54
|
# set the name, strip off '<' and '>'
|
51
|
-
# @param [String]
|
55
|
+
# @param name_value [String]
|
52
56
|
# @return [String]
|
53
57
|
def name=(name_value)
|
54
58
|
@name = name_value.gsub(/[<>]/, '')
|
@@ -57,7 +61,7 @@ class RubyUnits::Unit < Numeric
|
|
57
61
|
# alias array must contain the name of the unit and entries must be unique
|
58
62
|
# @return [Array]
|
59
63
|
def aliases
|
60
|
-
[[@aliases], @name].flatten.compact.uniq
|
64
|
+
[[@aliases], @name, @display_name].flatten.compact.uniq
|
61
65
|
end
|
62
66
|
|
63
67
|
# define a unit in terms of another unit
|