unite 1.0.2 → 1.1.0
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.
- data/Gemfile +1 -1
- data/Gemfile.lock +1 -1
- data/README +3 -0
- data/lib/{unity → unite}/arithmetic.rb +1 -1
- data/lib/{unity → unite}/comparison.rb +1 -1
- data/lib/{unity → unite}/conversion.rb +1 -1
- data/lib/{unity → unite}/dimension/integer.rb +1 -1
- data/lib/{unity → unite}/dimension/vector.rb +2 -2
- data/lib/{unity → unite}/dimension.rb +3 -3
- data/lib/{unity → unite}/fraction.rb +1 -1
- data/lib/{unity → unite}/lookup/definitions.rb +1 -1
- data/lib/{unity → unite}/lookup/derived_unit.rb +1 -1
- data/lib/{unity → unite}/lookup/property.rb +1 -1
- data/lib/{unity → unite}/lookup/simple_unit.rb +1 -1
- data/lib/{unity → unite}/lookup.rb +4 -4
- data/lib/{unity → unite}/quantity.rb +1 -1
- data/lib/unite/version.rb +3 -0
- data/lib/unite.rb +20 -0
- data/spec/arithmetic_spec.rb +1 -1
- data/spec/comparison_spec.rb +1 -1
- data/spec/conversion_spec.rb +1 -1
- data/spec/dimension/integer_spec.rb +1 -1
- data/spec/dimension/vector_spec.rb +1 -1
- data/spec/dimension_spec.rb +1 -1
- data/spec/fabricators/unit_fabricator.rb +4 -4
- data/spec/fraction_spec.rb +1 -1
- data/spec/lookup/derived_unit_spec.rb +2 -2
- data/spec/lookup/property_spec.rb +2 -2
- data/spec/lookup/simple_unit_spec.rb +2 -2
- data/spec/lookup_spec.rb +1 -1
- data/spec/quantity_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/shared_examples/units/arithmetic.rb +2 -2
- data/spec/support/shared_examples/units/comparison.rb +1 -1
- data/spec/support/shared_examples/units/dimension/integer.rb +1 -1
- data/spec/support/shared_examples/units/fractions.rb +1 -1
- data/unite.gemspec +4 -4
- metadata +23 -23
- data/lib/unity/version.rb +0 -3
- data/lib/unity.rb +0 -20
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
module
|
2
|
+
module Unite
|
3
3
|
module Dimension
|
4
4
|
extend self
|
5
5
|
|
@@ -32,6 +32,6 @@ module Unity
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
require '
|
36
|
-
require '
|
35
|
+
require 'unite/dimension/integer'
|
36
|
+
require 'unite/dimension/vector'
|
37
37
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
require 'active_model'
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
require '
|
3
|
+
require 'unite/lookup/simple_unit'
|
4
|
+
require 'unite/lookup/derived_unit'
|
5
|
+
require 'unite/lookup/property'
|
6
6
|
require 'securerandom'
|
7
7
|
|
8
|
-
module
|
8
|
+
module Unite
|
9
9
|
class Lookup
|
10
10
|
|
11
11
|
class Invalid < RuntimeError
|
data/lib/unite.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "unite/version"
|
2
|
+
|
3
|
+
module Unite
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
|
8
|
+
require 'active_support'
|
9
|
+
|
10
|
+
# Dir["#{Rails.root.to_s}/lib/units/**/*.rb"].each {|file| require file }
|
11
|
+
require 'unite/fraction'
|
12
|
+
require 'unite/dimension'
|
13
|
+
require 'unite/comparison'
|
14
|
+
require 'unite/conversion'
|
15
|
+
require 'unite/arithmetic'
|
16
|
+
|
17
|
+
|
18
|
+
require 'unite/lookup'
|
19
|
+
|
20
|
+
require "unite/quantity"
|
data/spec/arithmetic_spec.rb
CHANGED
data/spec/comparison_spec.rb
CHANGED
data/spec/conversion_spec.rb
CHANGED
data/spec/dimension_spec.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
require '
|
3
|
-
require '
|
2
|
+
require 'unite/lookup/simple_unit'
|
3
|
+
require 'unite/lookup/derived_unit'
|
4
4
|
|
5
|
-
Fabricator(:simple_unit, :class_name => "
|
5
|
+
Fabricator(:simple_unit, :class_name => "Unite::SimpleUnit") do
|
6
6
|
si_factor 1000.0
|
7
7
|
name 'km'
|
8
8
|
dimension :length
|
9
9
|
end
|
10
10
|
|
11
|
-
Fabricator(:derived_unit, :class_name => "
|
11
|
+
Fabricator(:derived_unit, :class_name => "Unite::DerivedUnit") do
|
12
12
|
name 'kWh'
|
13
13
|
end
|
14
14
|
|
data/spec/fraction_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
require 'spec_helper'
|
3
|
-
require '
|
3
|
+
require 'unite/lookup/simple_unit.rb'
|
4
4
|
|
5
|
-
module
|
5
|
+
module Unite
|
6
6
|
describe SimpleUnit do
|
7
7
|
it { should ensure_inclusion_of(:dimension).in_array(Dimension::LIST) }
|
8
8
|
it { should validate_presence_of(:si_factor)}
|
data/spec/lookup_spec.rb
CHANGED
data/spec/quantity_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -113,10 +113,10 @@ shared_examples "unit arithmetic" do
|
|
113
113
|
include_examples "division operation"
|
114
114
|
|
115
115
|
it "should raise error for subtraction" do
|
116
|
-
lambda { object1 - object2 }.should raise_exception
|
116
|
+
lambda { object1 - object2 }.should raise_exception Unite::IncompatibleError
|
117
117
|
end
|
118
118
|
it "should raise error for addition" do
|
119
|
-
lambda { object1 + object2 }.should raise_exception
|
119
|
+
lambda { object1 + object2 }.should raise_exception Unite::IncompatibleError
|
120
120
|
end
|
121
121
|
|
122
122
|
end
|
@@ -38,7 +38,7 @@ shared_examples_for "comparable unit" do
|
|
38
38
|
let(:expression2) { "g" }
|
39
39
|
|
40
40
|
it "should raise exception" do
|
41
|
-
lambda { subject }.should raise_exception
|
41
|
+
lambda { subject }.should raise_exception Unite::IncompatibleError
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -15,7 +15,7 @@ shared_examples "dimension integer" do
|
|
15
15
|
let(:property_stub) { stub }
|
16
16
|
before do
|
17
17
|
subject.stubs(:dimension_int => dimension_int)
|
18
|
-
|
18
|
+
Unite::Lookup.stubs(:find_property).with(dimension_int).returns(property_stub)
|
19
19
|
end
|
20
20
|
its(:property) { should == property_stub }
|
21
21
|
end
|
@@ -58,7 +58,7 @@ shared_examples_for "unit fractions" do
|
|
58
58
|
context 'with invalid format' do
|
59
59
|
let(:expression) { 'km/kg/s' }
|
60
60
|
it "should raise exception" do
|
61
|
-
lambda { subject }.should raise_exception
|
61
|
+
lambda { subject }.should raise_exception Unite::InvalidFormat
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
data/unite.gemspec
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "
|
3
|
+
require "unite/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "unite"
|
7
|
-
s.version =
|
7
|
+
s.version = Unite::VERSION
|
8
8
|
s.authors = ["stellard"]
|
9
9
|
s.email = ["scott.ellard@gmail.com"]
|
10
|
-
s.homepage = "https://github.com/stellard/
|
10
|
+
s.homepage = "https://github.com/stellard/unite"
|
11
11
|
s.summary = %q{Unite provides extensions to your objects to support values with units}
|
12
12
|
s.description = %q{Unite provides extensions to your objects to support values with units}
|
13
13
|
|
14
|
-
s.rubyforge_project = "
|
14
|
+
s.rubyforge_project = "unite"
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &70273965523040 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70273965523040
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activemodel
|
27
|
-
requirement: &
|
27
|
+
requirement: &70273965500980 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 3.0.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70273965500980
|
36
36
|
description: Unite provides extensions to your objects to support values with units
|
37
37
|
email:
|
38
38
|
- scott.ellard@gmail.com
|
@@ -48,21 +48,21 @@ files:
|
|
48
48
|
- MIT-LICENSE
|
49
49
|
- README
|
50
50
|
- Rakefile
|
51
|
-
- lib/
|
52
|
-
- lib/
|
53
|
-
- lib/
|
54
|
-
- lib/
|
55
|
-
- lib/
|
56
|
-
- lib/
|
57
|
-
- lib/
|
58
|
-
- lib/
|
59
|
-
- lib/
|
60
|
-
- lib/
|
61
|
-
- lib/
|
62
|
-
- lib/
|
63
|
-
- lib/
|
64
|
-
- lib/
|
65
|
-
- lib/
|
51
|
+
- lib/unite.rb
|
52
|
+
- lib/unite/arithmetic.rb
|
53
|
+
- lib/unite/comparison.rb
|
54
|
+
- lib/unite/conversion.rb
|
55
|
+
- lib/unite/dimension.rb
|
56
|
+
- lib/unite/dimension/integer.rb
|
57
|
+
- lib/unite/dimension/vector.rb
|
58
|
+
- lib/unite/fraction.rb
|
59
|
+
- lib/unite/lookup.rb
|
60
|
+
- lib/unite/lookup/definitions.rb
|
61
|
+
- lib/unite/lookup/derived_unit.rb
|
62
|
+
- lib/unite/lookup/property.rb
|
63
|
+
- lib/unite/lookup/simple_unit.rb
|
64
|
+
- lib/unite/quantity.rb
|
65
|
+
- lib/unite/version.rb
|
66
66
|
- spec/arithmetic_spec.rb
|
67
67
|
- spec/comparison_spec.rb
|
68
68
|
- spec/conversion_spec.rb
|
@@ -85,7 +85,7 @@ files:
|
|
85
85
|
- spec/support/shared_examples/units/dimension/vector.rb
|
86
86
|
- spec/support/shared_examples/units/fractions.rb
|
87
87
|
- unite.gemspec
|
88
|
-
homepage: https://github.com/stellard/
|
88
|
+
homepage: https://github.com/stellard/unite
|
89
89
|
licenses: []
|
90
90
|
post_install_message:
|
91
91
|
rdoc_options: []
|
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
|
-
rubyforge_project:
|
107
|
+
rubyforge_project: unite
|
108
108
|
rubygems_version: 1.8.6
|
109
109
|
signing_key:
|
110
110
|
specification_version: 3
|
data/lib/unity/version.rb
DELETED
data/lib/unity.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require "unity/version"
|
2
|
-
|
3
|
-
module Unity
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
|
8
|
-
require 'active_support'
|
9
|
-
|
10
|
-
# Dir["#{Rails.root.to_s}/lib/units/**/*.rb"].each {|file| require file }
|
11
|
-
require 'unity/fraction'
|
12
|
-
require 'unity/dimension'
|
13
|
-
require 'unity/comparison'
|
14
|
-
require 'unity/conversion'
|
15
|
-
require 'unity/arithmetic'
|
16
|
-
|
17
|
-
|
18
|
-
require 'unity/lookup'
|
19
|
-
|
20
|
-
require "unity/quantity"
|