unite 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.bundle/config +2 -0
- data/.rspec +1 -1
- data/.ruby-version +1 -0
- data/Gemfile +3 -3
- data/Gemfile.lock +15 -19
- data/README +33 -1
- data/bin/autospec +16 -0
- data/bin/byebug +16 -0
- data/bin/guard +16 -0
- data/bin/htmldiff +16 -0
- data/bin/ldiff +16 -0
- data/bin/rake2thor +16 -0
- data/bin/rspec +16 -0
- data/bin/thor +16 -0
- data/lib/unite/conversion.rb +23 -13
- data/lib/unite/dimension.rb +7 -3
- data/lib/unite/fraction.rb +106 -30
- data/lib/unite/lookup/definitions.rb +26 -10
- data/lib/unite/lookup/derived_unit.rb +4 -1
- data/lib/unite/lookup/simple_unit.rb +5 -1
- data/lib/unite/lookup.rb +12 -2
- data/lib/unite/quantity.rb +1 -1
- data/lib/unite/si_factor.rb +35 -0
- data/lib/unite/simplify.rb +33 -0
- data/lib/unite/unit.rb +34 -0
- data/lib/unite/version.rb +1 -1
- data/lib/unite.rb +3 -1
- data/spec/dimension_spec.rb +7 -2
- data/spec/lookup/derived_unit_spec.rb +0 -4
- data/spec/lookup/simple_unit_spec.rb +0 -2
- data/spec/lookup_spec.rb +18 -2
- data/spec/money_spec.rb +35 -0
- data/spec/quantity_spec.rb +1 -0
- data/spec/spec_helper.rb +1 -2
- data/spec/support/shared_examples/units/arithmetic.rb +21 -0
- data/spec/support/shared_examples/units/conversion.rb +106 -35
- data/spec/support/shared_examples/units/fractions.rb +25 -17
- data/spec/support/shared_examples/units/simplify.rb +26 -0
- data/spec/unit_spec.rb +44 -0
- metadata +49 -18
data/spec/unit_spec.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
module Unite
|
5
|
+
describe Unit do
|
6
|
+
|
7
|
+
subject { Unit.new :expression => expression }
|
8
|
+
|
9
|
+
#include_examples "comparable unit"
|
10
|
+
#include_examples "dimension integer"
|
11
|
+
#include_examples "dimension vectors"
|
12
|
+
#include_examples "unit fractions"
|
13
|
+
|
14
|
+
|
15
|
+
describe ".init" do
|
16
|
+
subject { Unit.init expression }
|
17
|
+
|
18
|
+
context "with just value" do
|
19
|
+
let(:expression) { "200.0" }
|
20
|
+
let(:value) { 200.0 }
|
21
|
+
|
22
|
+
its(:unit) { should == '' }
|
23
|
+
its(:value) { should == 1 }
|
24
|
+
end
|
25
|
+
|
26
|
+
context "with only unit" do
|
27
|
+
let(:expression) { "#{unit}" }
|
28
|
+
let(:unit) { 'L' }
|
29
|
+
|
30
|
+
its(:unit) { should == unit }
|
31
|
+
its(:value) { should == 1 }
|
32
|
+
end
|
33
|
+
|
34
|
+
context "with unit and value" do
|
35
|
+
let(:expression) { "2.0*#{unit}" }
|
36
|
+
let(:unit) { 'L/m^3' }
|
37
|
+
its(:unit) { should == unit }
|
38
|
+
its(:value) { should == 1 }
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
metadata
CHANGED
@@ -1,53 +1,76 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- stellard
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-11-22 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activesupport
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 3.0.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.0
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: activemodel
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - '>='
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: 3.0.0
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.0.0
|
36
41
|
description: Unite provides extensions to your objects to support values with units
|
37
42
|
email:
|
38
43
|
- scott.ellard@gmail.com
|
39
|
-
executables:
|
44
|
+
executables:
|
45
|
+
- autospec
|
46
|
+
- byebug
|
47
|
+
- guard
|
48
|
+
- htmldiff
|
49
|
+
- ldiff
|
50
|
+
- rake2thor
|
51
|
+
- rspec
|
52
|
+
- thor
|
40
53
|
extensions: []
|
41
54
|
extra_rdoc_files: []
|
42
55
|
files:
|
56
|
+
- .bundle/config
|
43
57
|
- .gitignore
|
44
58
|
- .rspec
|
59
|
+
- .ruby-version
|
45
60
|
- Gemfile
|
46
61
|
- Gemfile.lock
|
47
62
|
- Guardfile
|
48
63
|
- MIT-LICENSE
|
49
64
|
- README
|
50
65
|
- Rakefile
|
66
|
+
- bin/autospec
|
67
|
+
- bin/byebug
|
68
|
+
- bin/guard
|
69
|
+
- bin/htmldiff
|
70
|
+
- bin/ldiff
|
71
|
+
- bin/rake2thor
|
72
|
+
- bin/rspec
|
73
|
+
- bin/thor
|
51
74
|
- lib/unite.rb
|
52
75
|
- lib/unite/arithmetic.rb
|
53
76
|
- lib/unite/comparison.rb
|
@@ -62,6 +85,9 @@ files:
|
|
62
85
|
- lib/unite/lookup/property.rb
|
63
86
|
- lib/unite/lookup/simple_unit.rb
|
64
87
|
- lib/unite/quantity.rb
|
88
|
+
- lib/unite/si_factor.rb
|
89
|
+
- lib/unite/simplify.rb
|
90
|
+
- lib/unite/unit.rb
|
65
91
|
- lib/unite/version.rb
|
66
92
|
- spec/arithmetic_spec.rb
|
67
93
|
- spec/comparison_spec.rb
|
@@ -75,6 +101,7 @@ files:
|
|
75
101
|
- spec/lookup/property_spec.rb
|
76
102
|
- spec/lookup/simple_unit_spec.rb
|
77
103
|
- spec/lookup_spec.rb
|
104
|
+
- spec/money_spec.rb
|
78
105
|
- spec/quantity_spec.rb
|
79
106
|
- spec/spec_helper.rb
|
80
107
|
- spec/support/load_debugger.rb
|
@@ -84,30 +111,31 @@ files:
|
|
84
111
|
- spec/support/shared_examples/units/dimension/integer.rb
|
85
112
|
- spec/support/shared_examples/units/dimension/vector.rb
|
86
113
|
- spec/support/shared_examples/units/fractions.rb
|
114
|
+
- spec/support/shared_examples/units/simplify.rb
|
115
|
+
- spec/unit_spec.rb
|
87
116
|
- unite.gemspec
|
88
117
|
homepage: https://github.com/stellard/unite
|
89
118
|
licenses: []
|
119
|
+
metadata: {}
|
90
120
|
post_install_message:
|
91
121
|
rdoc_options: []
|
92
122
|
require_paths:
|
93
123
|
- lib
|
94
124
|
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
-
none: false
|
96
125
|
requirements:
|
97
|
-
- -
|
126
|
+
- - '>='
|
98
127
|
- !ruby/object:Gem::Version
|
99
128
|
version: '0'
|
100
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
-
none: false
|
102
130
|
requirements:
|
103
|
-
- -
|
131
|
+
- - '>='
|
104
132
|
- !ruby/object:Gem::Version
|
105
133
|
version: '0'
|
106
134
|
requirements: []
|
107
135
|
rubyforge_project: unite
|
108
|
-
rubygems_version:
|
136
|
+
rubygems_version: 2.0.3
|
109
137
|
signing_key:
|
110
|
-
specification_version:
|
138
|
+
specification_version: 4
|
111
139
|
summary: Unite provides extensions to your objects to support values with units
|
112
140
|
test_files:
|
113
141
|
- spec/arithmetic_spec.rb
|
@@ -122,6 +150,7 @@ test_files:
|
|
122
150
|
- spec/lookup/property_spec.rb
|
123
151
|
- spec/lookup/simple_unit_spec.rb
|
124
152
|
- spec/lookup_spec.rb
|
153
|
+
- spec/money_spec.rb
|
125
154
|
- spec/quantity_spec.rb
|
126
155
|
- spec/spec_helper.rb
|
127
156
|
- spec/support/load_debugger.rb
|
@@ -131,3 +160,5 @@ test_files:
|
|
131
160
|
- spec/support/shared_examples/units/dimension/integer.rb
|
132
161
|
- spec/support/shared_examples/units/dimension/vector.rb
|
133
162
|
- spec/support/shared_examples/units/fractions.rb
|
163
|
+
- spec/support/shared_examples/units/simplify.rb
|
164
|
+
- spec/unit_spec.rb
|