unite 1.3.0 → 2.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aebeae667614cd23ebc795fa7930b6d55a95cce1
4
- data.tar.gz: 62f3c66b9baec8a9ab0970322489ac43fa1dbd50
3
+ metadata.gz: 9930abefcdceba86dec0ecee779267633ce949b7
4
+ data.tar.gz: ce3d5af30e42ecc00583f142aee8d9818e2cc86d
5
5
  SHA512:
6
- metadata.gz: 0a5f0ee539de7142b8b26a510dd4f2aa6bb1d16fdc1a403f8c7434ca610562d319a2060284dedeefa67e835145e9e78f53c83f0ffa911cd8115e9a9e3e37190d
7
- data.tar.gz: c88e6b42a7d06a16037a3a3c931df650a9852abffa00d39e4ffda5d4cc6971a59e4d6890de230c32a5f72b7b6344efdc304f2a2d860723fcc97fd6686d97613b
6
+ metadata.gz: f2ff02013b735e16150fb1eea3b133036f14a70962f7655a65825b865ae124079f6e0bbd170d7887a30603ce316744794955eacce9ca001e066fc17b3a73d801
7
+ data.tar.gz: fc76fd42c0adbd88e27447adf9fafbc0e4419d55dd89d59eba5918e3a12764c17fb89777c37ed38c8f3e83d097be3138d759462016065130690774fcaf01ebe0
data/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
1
  .rvmrc
2
+ .ruby-version
3
+ .rspec
2
4
  .DS_Store
3
5
  pkg
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ group :test do
7
7
  gem 'SystemTimer', :platform => :mri_18
8
8
  gem 'ruby-debug', :platform => :mri_18
9
9
  gem 'debugger', :platform => :mri_19
10
- gem 'byebug', :platform => :mri_20
10
+ gem 'byebug', :platforms => [:mri_20, :mri_21, :mri_22]
11
11
  gem 'mocha'
12
12
  gem 'rspec'
13
13
  gem 'shoulda-matchers', :git => 'git://github.com/thoughtbot/shoulda-matchers.git', :require => 'false'
@@ -0,0 +1,48 @@
1
+ # Install
2
+
3
+ **With Bundler**
4
+ ```ruby
5
+ gem 'unite'
6
+ ```
7
+
8
+ **Without Bundler**
9
+ ```bash
10
+ gem install unite
11
+ ```
12
+
13
+ # It's Science
14
+
15
+ ![It's Science](http://gifrific.com/wp-content/uploads/2012/06/its-science-anchorman.gif)
16
+
17
+ Based on the algorithms developed by Gordon S. Novak, Jr. at the University of Texas, which can be found here:
18
+
19
+ http://www.cs.utexas.edu/users/novak/units95.html
20
+
21
+
22
+ # Dimensions
23
+
24
+ Handles the following dimensions:
25
+
26
+ ```ruby
27
+ [:length, :time, :temperature, :mass, :current, :substance, :luminosity]
28
+ ```
29
+
30
+ Can use `Unite::Quantity` to represent values or include the functionality into your own objects.
31
+
32
+ Look at https://github.com/stellard/unite/blob/master/lib/unite/quantity.rb for a minum implementation
33
+
34
+
35
+ # Examples:
36
+
37
+ _TODO: Needs more info here._
38
+
39
+ ```ruby
40
+ Unite::Quantity.init("1000*km")
41
+ Unite::Quantity.init("1000","km")
42
+ ```
43
+
44
+ Unit definitions are found here:
45
+
46
+ https://github.com/stellard/unite/blob/master/lib/unite/lookup/definitions.rb
47
+
48
+ Specs show good examples of use.
@@ -12,18 +12,17 @@ module Unite
12
12
  # 4 current ampere
13
13
  # 5 substance mole
14
14
  # 6 luminosity candela
15
- # 7 money pound
16
15
  #
17
16
 
18
- VECTOR_LIST = [:length, :time, :temperature, :mass, :current, :substance, :luminosity, :money]
17
+ VECTOR_LIST = [:length, :time, :temperature, :mass, :current, :substance, :luminosity]
19
18
 
20
- DIMSIZES = [20, 20, 20, 10, 10, 10, 10, 10]
21
- DIMVALS = [1, 20, 400, 8000, 80000, 800000, 8000000, 80000000]
19
+ DIMSIZES = [20, 20, 20, 10, 10, 10, 10]
20
+ DIMVALS = [1, 20, 400, 8000, 80000, 800000, 8000000]
22
21
 
23
22
 
24
23
  # also include the dimensionless dimension "none"
25
24
  LIST = VECTOR_LIST + [:none]
26
- UNITS = ['km', 's', 'K', 'kg', 'A', 'mol', 'cd', 'GBP', '']
25
+ UNITS = ['km', 's', 'K', 'kg', 'A', 'mol', 'cd', '']
27
26
  INDICIES = Hash[*LIST.each_with_index.map{|d,i| [d,i]}.flatten]
28
27
 
29
28
 
@@ -46,19 +46,6 @@ module Unite
46
46
 
47
47
  Lookup.add_property Property.new(:name => :mass, :expression => 'g')
48
48
 
49
-
50
- #MONEY
51
- Lookup.add SimpleUnit.new(:name => "GBP", :si_factor => 1, :dimension => :money)
52
-
53
- #Right now only one currency is supported. It is too difficult to be able to convert them.
54
-
55
- # Lookup.add SimpleUnit.new(:name => "EUR", :si_factor => nil, :dimension => :money)
56
- # Lookup.add SimpleUnit.new(:name => "USD", :si_factor => nil, :dimension => :money)
57
- # Lookup.add SimpleUnit.new(:name => "CAD", :si_factor => nil, :dimension => :money)
58
-
59
- Lookup.add_property Property.new(:name => :money, :expression => 'GBP')
60
-
61
-
62
49
  #TEMPERATURE
63
50
  Lookup.add SimpleUnit.new(:name => "K", :si_factor => 1, :dimension => :temperature, :aliases => ['kelvin'])
64
51
  Lookup.add_property Property.new(:name => :temperature, :expression => 'K')
@@ -1,3 +1,3 @@
1
1
  module Unite
2
- VERSION = "1.3.0"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -7,27 +7,27 @@ describe Unite::Dimension do
7
7
 
8
8
  it "should have the correct VECTOR_LIST" do
9
9
  Unite::Dimension::VECTOR_LIST.should ==
10
- [:length, :time, :temperature, :mass, :current, :substance, :luminosity, :money]
10
+ [:length, :time, :temperature, :mass, :current, :substance, :luminosity]
11
11
  end
12
12
 
13
13
 
14
14
  it "should have the correct LIST" do
15
15
  Unite::Dimension::LIST.should ==
16
- [:length, :time, :temperature, :mass, :current, :substance, :luminosity, :money, :none]
16
+ [:length, :time, :temperature, :mass, :current, :substance, :luminosity, :none]
17
17
  end
18
18
 
19
19
 
20
20
  it "should return the correct si unit for dimension name" do
21
21
  Unite::Dimension::LIST.map{|d| Unite::Dimension.si_unit(d)}.should ==
22
- ['km', 's', 'K', 'kg', 'A', 'mol', 'cd', 'GBP', '']
22
+ ['km', 's', 'K', 'kg', 'A', 'mol', 'cd', '']
23
23
  end
24
24
 
25
25
  it "should return the correct si unit for dimension index" do
26
26
  Unite::Dimension::LIST.each_with_index.map {|_,i| Unite::Dimension.si_unit(i)}.should ==
27
- ['km', 's', 'K', 'kg', 'A', 'mol', 'cd', 'GBP', '']
27
+ ['km', 's', 'K', 'kg', 'A', 'mol', 'cd', '']
28
28
  end
29
29
 
30
- its(:blank_dimension_vector) { should == [0,0,0,0,0,0,0,0] }
30
+ its(:blank_dimension_vector) { should == [0,0,0,0,0,0,0] }
31
31
 
32
32
 
33
33
  end
@@ -7,26 +7,26 @@ module Unite
7
7
  it { should validate_presence_of(:name)}
8
8
 
9
9
  %w{ F J Hz N }.each do |unit|
10
- it "should allow valid unit #{unit}" do
10
+ it "should allow valid unit #{unit}" do
11
11
  Fabricate.build(:derived_unit, :name => unit).should be_valid
12
12
  end
13
- end
13
+ end
14
14
 
15
15
  %w{km^3 m/g km*tonne}.each do |unit|
16
- it "should not allow invalid unit #{unit}" do
16
+ it "should not allow invalid unit #{unit}" do
17
17
  Fabricate.build(:derived_unit, :name => unit).should_not be_valid
18
18
  end
19
19
  end
20
20
 
21
21
  describe 'based off of simple units' do
22
22
  subject { DerivedUnit.new(:name => "J", :expression => 'kg*m^2/s^2') }
23
- its(:dimension_vector) { should == [2, -2, 0, 1, 0, 0, 0, 0] }
23
+ its(:dimension_vector) { should == [2, -2, 0, 1, 0, 0, 0] }
24
24
  its(:property_name) { should == :energy }
25
25
  end
26
26
 
27
27
  describe 'based off of other derived unit' do
28
28
  subject { DerivedUnit.new(:name => "kWh", :expression => '3.6e5*J') }
29
- its(:dimension_vector) { should == [2, -2, 0, 1, 0, 0, 0, 0] }
29
+ its(:dimension_vector) { should == [2, -2, 0, 1, 0, 0, 0] }
30
30
  its(:property_name) { should == :energy }
31
31
  end
32
32
 
@@ -3,20 +3,20 @@ shared_examples "dimension vectors" do
3
3
 
4
4
  describe "generating" do
5
5
 
6
- subject { described_class.new :expression => expression }
6
+ subject { described_class.new :expression => expression }
7
7
 
8
8
  describe "something" do
9
9
 
10
- let(:expression) { "m/s^2" }
11
- its(:dimension_vector) { should == [1,-2,0,0,0,0,0,0] }
10
+ let(:expression) { "m/s^2" }
11
+ its(:dimension_vector) { should == [1,-2,0,0,0,0,0] }
12
12
 
13
13
  end
14
14
 
15
15
 
16
16
  describe "when there is no unit" do
17
17
 
18
- let(:expression) { "" }
19
- its(:dimension_vector) { should == [0,0,0,0,0,0,0,0] }
18
+ let(:expression) { "" }
19
+ its(:dimension_vector) { should == [0,0,0,0,0,0,0] }
20
20
 
21
21
  end
22
22
 
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - stellard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-22 00:00:00.000000000 Z
11
+ date: 2015-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.0.0
20
20
  type: :runtime
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: 3.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activemodel
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 3.0.0
34
34
  type: :runtime
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: 3.0.0
41
41
  description: Unite provides extensions to your objects to support values with units
@@ -53,15 +53,13 @@ executables:
53
53
  extensions: []
54
54
  extra_rdoc_files: []
55
55
  files:
56
- - .bundle/config
57
- - .gitignore
58
- - .rspec
59
- - .ruby-version
56
+ - ".bundle/config"
57
+ - ".gitignore"
60
58
  - Gemfile
61
59
  - Gemfile.lock
62
60
  - Guardfile
63
61
  - MIT-LICENSE
64
- - README
62
+ - README.md
65
63
  - Rakefile
66
64
  - bin/autospec
67
65
  - bin/byebug
@@ -123,17 +121,17 @@ require_paths:
123
121
  - lib
124
122
  required_ruby_version: !ruby/object:Gem::Requirement
125
123
  requirements:
126
- - - '>='
124
+ - - ">="
127
125
  - !ruby/object:Gem::Version
128
126
  version: '0'
129
127
  required_rubygems_version: !ruby/object:Gem::Requirement
130
128
  requirements:
131
- - - '>='
129
+ - - ">="
132
130
  - !ruby/object:Gem::Version
133
131
  version: '0'
134
132
  requirements: []
135
133
  rubyforge_project: unite
136
- rubygems_version: 2.0.3
134
+ rubygems_version: 2.2.2
137
135
  signing_key:
138
136
  specification_version: 4
139
137
  summary: Unite provides extensions to your objects to support values with units
data/.rspec DELETED
@@ -1,4 +0,0 @@
1
- --colour
2
- --format d
3
- --profile
4
- --backtrace
@@ -1 +0,0 @@
1
- 2.0.0-p247
data/README DELETED
@@ -1,35 +0,0 @@
1
- gem install unite
2
-
3
- gem 'unite'
4
-
5
-
6
- Based on
7
-
8
- http://www.cs.utexas.edu/users/novak/units95.html
9
-
10
-
11
- Handles the following dimensions
12
-
13
- [:length, :time, :temperature, :mass, :current, :substance, :luminosity, :money]
14
-
15
-
16
- Note: Conversion of Money is not currently supported
17
-
18
-
19
- Can use Unite::Quantity to represent values or include the functionality into your own objects.
20
-
21
- Look at https://github.com/stellard/unite/blob/master/lib/unite/quantity.rb for a minum implementation
22
-
23
- Examples: (needs more info here)
24
-
25
- Unite::Quantity.init("1000*km")
26
- Unite::Quantity.init("1000","km")
27
-
28
- Unit definitions are found here
29
-
30
- https://github.com/stellard/unite/blob/master/lib/unite/lookup/definitions.rb
31
-
32
- Specs show good examples of use.
33
-
34
- I will add more to readme
35
-