lite-measurements 1.1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/README.md +18 -4
- data/lib/generators/lite/measurements/templates/install.rb +9 -3
- data/lib/lite/measurements.rb +8 -9
- data/lib/lite/measurements/digital_storage.rb +7 -2
- data/lib/lite/measurements/length.rb +13 -3
- data/lib/lite/measurements/mass.rb +14 -3
- data/lib/lite/measurements/monkey_patches.rb +5 -17
- data/lib/lite/measurements/monkey_patches/digital_storage.rb +9 -0
- data/lib/lite/measurements/monkey_patches/length.rb +9 -0
- data/lib/lite/measurements/monkey_patches/mass.rb +9 -0
- data/lib/lite/measurements/monkey_patches/temperature.rb +9 -0
- data/lib/lite/measurements/monkey_patches/time.rb +9 -0
- data/lib/lite/measurements/time.rb +10 -3
- data/lib/lite/measurements/version.rb +1 -1
- metadata +6 -2
- data/lib/lite/measurements/configuration.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c03231a244a23709daa52499d7ec9ecad0233139eb8882ada2f8f3167411a47b
|
4
|
+
data.tar.gz: 281405d760c0a9da7a85a788c3ae648a2ade4b7cffa64f5da692389624904db6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f5820c8c673b2da8c9efd0b6572f2590d7a72a1c38b816c6c5333f00a73b983675c145f5702554f7e00c6e31795d0cd8ae1b564aa005d5ad570312881b5f9e3
|
7
|
+
data.tar.gz: 99829fc29512c0844c00e10459dfc1fd2785a72d655cd3e83e68b3838718fb5aa51685f888769daab32f7050c74ac3d68f5bc24cc4c725d2dd7212a307b7e165
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [2.0.0] - 2021-07-22
|
10
|
+
### Changed
|
11
|
+
- Improved setup
|
12
|
+
- Update install generator to reflect configuration changes
|
13
|
+
### Removed
|
14
|
+
- Removed configuration to use explicit inclusions
|
15
|
+
|
9
16
|
## [1.1.1] - 2021-07-21
|
10
17
|
### Changed
|
11
18
|
- Improved Railtie support
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -29,13 +29,27 @@ Or install it yourself as:
|
|
29
29
|
|
30
30
|
## Configurations
|
31
31
|
|
32
|
+
Any and all monkey patches must be explicitly included anywhere you want to use it.
|
33
|
+
|
34
|
+
To globally use the monkey patches, just create an initializer requiring them.
|
35
|
+
|
32
36
|
`rails g lite:measurements:install` will generate the following file:
|
33
|
-
`../config/initalizers/
|
37
|
+
`../config/initalizers/lite_measurements.rb`
|
38
|
+
|
39
|
+
They can be disabled by commenting any of them out.
|
34
40
|
|
35
41
|
```ruby
|
36
|
-
|
37
|
-
|
38
|
-
|
42
|
+
# frozen_string_literal: true
|
43
|
+
|
44
|
+
require 'lite/measurements/monkey_patches'
|
45
|
+
|
46
|
+
# - or-
|
47
|
+
|
48
|
+
# require 'lite/measurements/monkey_patches/digital_storage'
|
49
|
+
# require 'lite/measurements/monkey_patches/length'
|
50
|
+
# require 'lite/measurements/monkey_patches/mass'
|
51
|
+
# require 'lite/measurements/monkey_patches/temperature'
|
52
|
+
# require 'lite/measurements/monkey_patches/time'
|
39
53
|
```
|
40
54
|
|
41
55
|
## Measurements
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
require 'lite/measurements/monkey_patches'
|
4
|
+
|
5
|
+
# - or-
|
6
|
+
|
7
|
+
# require 'lite/measurements/monkey_patches/digital_storage'
|
8
|
+
# require 'lite/measurements/monkey_patches/length'
|
9
|
+
# require 'lite/measurements/monkey_patches/mass'
|
10
|
+
# require 'lite/measurements/monkey_patches/temperature'
|
11
|
+
# require 'lite/measurements/monkey_patches/time'
|
data/lib/lite/measurements.rb
CHANGED
@@ -3,12 +3,11 @@
|
|
3
3
|
require 'generators/lite/measurements/install_generator' if defined?(Rails::Generators)
|
4
4
|
|
5
5
|
require 'lite/measurements/version'
|
6
|
-
require 'lite/measurements/
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
6
|
+
require 'lite/measurements/helpers/conversion_helper'
|
7
|
+
require 'lite/measurements/helpers/shift_helper'
|
8
|
+
require 'lite/measurements/base'
|
9
|
+
require 'lite/measurements/digital_storage'
|
10
|
+
require 'lite/measurements/length'
|
11
|
+
require 'lite/measurements/mass'
|
12
|
+
require 'lite/measurements/temperature'
|
13
|
+
require 'lite/measurements/time'
|
@@ -7,8 +7,13 @@ module Lite
|
|
7
7
|
include Lite::Measurements::Helpers::ShiftHelper
|
8
8
|
|
9
9
|
DIGITAL_STORAGE_UNITS = {
|
10
|
-
bytes: 1.0,
|
11
|
-
|
10
|
+
bytes: 1.0,
|
11
|
+
kilobytes: 1024.0,
|
12
|
+
megabytes: 1024.0**2,
|
13
|
+
gigabytes: 1024.0**3,
|
14
|
+
terabytes: 1024.0**4,
|
15
|
+
petabytes: 1024.0**5,
|
16
|
+
exabytes: 1024.0**6
|
12
17
|
}.freeze
|
13
18
|
|
14
19
|
def convert(from:, to:)
|
@@ -10,11 +10,21 @@ module Lite
|
|
10
10
|
CONVERTER = 0.0254
|
11
11
|
|
12
12
|
IMPERICAL_UNITS = {
|
13
|
-
inches: 1.0,
|
13
|
+
inches: 1.0,
|
14
|
+
feet: 12.0,
|
15
|
+
yards: 36.0,
|
16
|
+
miles: 63_360.0,
|
17
|
+
nautical_miles: 72_913.386
|
14
18
|
}.freeze
|
15
19
|
METRIC_UNITS = {
|
16
|
-
micrometers: 0.000001,
|
17
|
-
|
20
|
+
micrometers: 0.000001,
|
21
|
+
millimeters: 0.001,
|
22
|
+
centimeters: 0.01,
|
23
|
+
decimeters: 0.1,
|
24
|
+
meters: 1.0,
|
25
|
+
dekameters: 10.0,
|
26
|
+
hectometers: 100.0,
|
27
|
+
kilometers: 1_000.0
|
18
28
|
}.freeze
|
19
29
|
|
20
30
|
# rubocop:disable Metrics/MethodLength, Layout/LineLength
|
@@ -10,11 +10,22 @@ module Lite
|
|
10
10
|
CONVERTER = 28.349523125
|
11
11
|
|
12
12
|
IMPERICAL_UNITS = {
|
13
|
-
ounces: 1.0,
|
13
|
+
ounces: 1.0,
|
14
|
+
pounds: 16.0,
|
15
|
+
stones: 224.0,
|
16
|
+
us_tons: 32_000.0,
|
17
|
+
imperial_tons: 35_840.0
|
14
18
|
}.freeze
|
15
19
|
METRIC_UNITS = {
|
16
|
-
micrograms: 0.000001,
|
17
|
-
|
20
|
+
micrograms: 0.000001,
|
21
|
+
milligrams: 0.001,
|
22
|
+
centigrams: 0.01,
|
23
|
+
decigrams: 0.1,
|
24
|
+
grams: 1.0,
|
25
|
+
dekagrams: 10.0,
|
26
|
+
hectograms: 100.0,
|
27
|
+
kilograms: 1_000.0,
|
28
|
+
metric_tons: 1_000_000.0
|
18
29
|
}.freeze
|
19
30
|
|
20
31
|
# rubocop:disable Metrics/MethodLength, Layout/LineLength
|
@@ -1,19 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
length: Lite::Measurements::Length,
|
9
|
-
mass: Lite::Measurements::Mass,
|
10
|
-
temperature: Lite::Measurements::Temperature,
|
11
|
-
time: Lite::Measurements::Time
|
12
|
-
}.each do |name, klass|
|
13
|
-
define_method("convert_#{name}") do |from:, to:|
|
14
|
-
klass.convert(self, from: from, to: to)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
3
|
+
require 'lite/measurements/monkey_patches/digital_storage'
|
4
|
+
require 'lite/measurements/monkey_patches/length'
|
5
|
+
require 'lite/measurements/monkey_patches/mass'
|
6
|
+
require 'lite/measurements/monkey_patches/temperature'
|
7
|
+
require 'lite/measurements/monkey_patches/time'
|
@@ -7,9 +7,16 @@ module Lite
|
|
7
7
|
include Lite::Measurements::Helpers::ShiftHelper
|
8
8
|
|
9
9
|
TIME_UNITS = {
|
10
|
-
milliseconds: 0.001,
|
11
|
-
|
12
|
-
|
10
|
+
milliseconds: 0.001,
|
11
|
+
seconds: 1.0,
|
12
|
+
minutes: 60.0,
|
13
|
+
hours: 3600.0,
|
14
|
+
days: 86_400.0,
|
15
|
+
weeks: 604_800.0,
|
16
|
+
years: 31_557_600.0,
|
17
|
+
decades: 31_557_600.0 * 10.0,
|
18
|
+
centuries: 31_557_600.0 * 100.0,
|
19
|
+
millenniums: 31_557_600.0 * 1_000.0
|
13
20
|
}.freeze
|
14
21
|
|
15
22
|
def convert(from:, to:)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lite-measurements
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
@@ -168,13 +168,17 @@ files:
|
|
168
168
|
- lib/lite/measurements.rb
|
169
169
|
- lib/lite/measurements/.DS_Store
|
170
170
|
- lib/lite/measurements/base.rb
|
171
|
-
- lib/lite/measurements/configuration.rb
|
172
171
|
- lib/lite/measurements/digital_storage.rb
|
173
172
|
- lib/lite/measurements/helpers/conversion_helper.rb
|
174
173
|
- lib/lite/measurements/helpers/shift_helper.rb
|
175
174
|
- lib/lite/measurements/length.rb
|
176
175
|
- lib/lite/measurements/mass.rb
|
177
176
|
- lib/lite/measurements/monkey_patches.rb
|
177
|
+
- lib/lite/measurements/monkey_patches/digital_storage.rb
|
178
|
+
- lib/lite/measurements/monkey_patches/length.rb
|
179
|
+
- lib/lite/measurements/monkey_patches/mass.rb
|
180
|
+
- lib/lite/measurements/monkey_patches/temperature.rb
|
181
|
+
- lib/lite/measurements/monkey_patches/time.rb
|
178
182
|
- lib/lite/measurements/temperature.rb
|
179
183
|
- lib/lite/measurements/time.rb
|
180
184
|
- lib/lite/measurements/version.rb
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Lite
|
4
|
-
module Measurements
|
5
|
-
|
6
|
-
class Configuration
|
7
|
-
|
8
|
-
attr_accessor :monkey_patches
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
@monkey_patches = true
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
class << self
|
17
|
-
|
18
|
-
attr_writer :configuration
|
19
|
-
|
20
|
-
def configuration
|
21
|
-
@configuration ||= Configuration.new
|
22
|
-
end
|
23
|
-
|
24
|
-
def configure
|
25
|
-
yield(configuration)
|
26
|
-
end
|
27
|
-
|
28
|
-
def reset_configuration!
|
29
|
-
@configuration = Configuration.new
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|