phys-units 0.9.5 → 0.9.6
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/README.md +13 -11
 - data/lib/phys/units/quantity.rb +2 -1
 - data/lib/phys/units/units_mixin.rb +3 -3
 - data/lib/phys/units/version.rb +1 -1
 - data/phys-units.gemspec +2 -2
 - data/spec/quantity_spec.rb +3 -0
 - metadata +7 -4
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 2fde159ecadb15d7e998517345fffcf06c2d5f7f
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: d7c2afc3236ca0b3e6f4714887bdd7c04270f4ea
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 6889be94b9817330ae6212ba00eb255dba0920048f9a732f19311038b89b72d33ec528b89d6ffa4f0b85278afcc01c737560b756dc6cfddd8e58e529568d1792
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 341229db824b450d8594b785933456d4e871b0a79ecca8d17fa994dc26e43a07e3c25c3be1fb7bf656dce4780bd9a5a717243f57f83af3e5d03b96965e795c02
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,6 +1,9 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Phys-Units
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            [GNU Units](http://www.gnu.org/software/units/)-compatible library for 
     | 
| 
      
 3 
     | 
    
         
            +
            [GNU Units](http://www.gnu.org/software/units/) -compatible Ruby library for
         
     | 
| 
      
 4 
     | 
    
         
            +
            unit conversion of physical quantities.
         
     | 
| 
      
 5 
     | 
    
         
            +
            Major features: (1) It uses rich database of GNU Units.
         
     | 
| 
      
 6 
     | 
    
         
            +
            (2) It provides normal class interface without modifying built-in classes.
         
     | 
| 
       4 
7 
     | 
    
         
             
            Former name is [Quanty](http://narray.rubyforge.org/quanty/quanty-en.html),
         
     | 
| 
       5 
8 
     | 
    
         
             
            the first Ruby units library released in 2001.
         
     | 
| 
       6 
9 
     | 
    
         | 
| 
         @@ -20,12 +23,12 @@ Or install from source tree: 
     | 
|
| 
       20 
23 
     | 
    
         | 
| 
       21 
24 
     | 
    
         
             
            Load Phys-Units library in your Ruby script:
         
     | 
| 
       22 
25 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
      
 26 
     | 
    
         
            +
                require 'phys/units'
         
     | 
| 
       24 
27 
     | 
    
         | 
| 
       25 
28 
     | 
    
         
             
            ## Overview
         
     | 
| 
       26 
29 
     | 
    
         | 
| 
       27 
30 
     | 
    
         
             
            ### Phys::Quantity
         
     | 
| 
       28 
     | 
    
         
            -
            is the primary class of Phys-Units library 
     | 
| 
      
 31 
     | 
    
         
            +
            is the primary class of Phys-Units library.
         
     | 
| 
       29 
32 
     | 
    
         
             
            This class represents Physical Quantities with a Unit of measurement.
         
     | 
| 
       30 
33 
     | 
    
         
             
            It contains *Value* and *Unit*.
         
     | 
| 
       31 
34 
     | 
    
         | 
| 
         @@ -44,8 +47,7 @@ It contains *Value* and *Unit*. 
     | 
|
| 
       44 
47 
     | 
    
         | 
| 
       45 
48 
     | 
    
         
             
            ### Phys::Unit
         
     | 
| 
       46 
49 
     | 
    
         
             
            is a class to represent Physical Units of measurement.
         
     | 
| 
       47 
     | 
    
         
            -
            This class is used in the Phys::Quantity for calculations with Units 
     | 
| 
       48 
     | 
    
         
            -
            and users do not always need to know its mechanism.
         
     | 
| 
      
 50 
     | 
    
         
            +
            This class is used in the Phys::Quantity for calculations with Units.
         
     | 
| 
       49 
51 
     | 
    
         
             
            It has *Factor* and *Dimension*:
         
     | 
| 
       50 
52 
     | 
    
         | 
| 
       51 
53 
     | 
    
         
             
            * *Factor* of the unit is a scale factor relative to its base unit.
         
     | 
| 
         @@ -92,7 +94,7 @@ by the following features: 
     | 
|
| 
       92 
94 
     | 
    
         
             
            * Compatible with GNU Units except currency and nonlinear units.
         
     | 
| 
       93 
95 
     | 
    
         
             
            * Provides 2331 units, 85 prefixes, including UTF-8 unit names.
         
     | 
| 
       94 
96 
     | 
    
         
             
            * Defines Units by reading GNU Units text data
         
     | 
| 
       95 
     | 
    
         
            -
              ( 
     | 
| 
      
 97 
     | 
    
         
            +
              (See [load_units.rb](https://github.com/masa16/phys-units/blob/master/lib/phys/units/load_units.rb)),
         
     | 
| 
       96 
98 
     | 
    
         
             
              unlike other libraries which define Units in Ruby code.
         
     | 
| 
       97 
99 
     | 
    
         
             
            * Provides orthodox design of class interface.
         
     | 
| 
       98 
100 
     | 
    
         
             
            * No addition or modification to Ruby standard classes in standard usage,
         
     | 
| 
         @@ -106,15 +108,15 @@ by the following features: 
     | 
|
| 
       106 
108 
     | 
    
         | 
| 
       107 
109 
     | 
    
         
             
            ## Appendix Feature
         
     | 
| 
       108 
110 
     | 
    
         | 
| 
       109 
     | 
    
         
            -
            Mix-in feature provides simple calculator 
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
      
 111 
     | 
    
         
            +
            Mix-in feature provides a simple unit calculator.
         
     | 
| 
      
 112 
     | 
    
         
            +
            Note that this usage involves global changes on a build-in class and will cause conflicts with other libraries.
         
     | 
| 
       111 
113 
     | 
    
         | 
| 
       112 
     | 
    
         
            -
                $ irb - 
     | 
| 
      
 114 
     | 
    
         
            +
                $ irb -r phys/units/mixin
         
     | 
| 
       113 
115 
     | 
    
         | 
| 
       114 
     | 
    
         
            -
                irb>  
     | 
| 
      
 116 
     | 
    
         
            +
                irb> 2.5.miles/hr >> m/s
         
     | 
| 
       115 
117 
     | 
    
         
             
                => Phys::Quantity[1.1176,"m/s"]
         
     | 
| 
       116 
118 
     | 
    
         | 
| 
       117 
     | 
    
         
            -
                irb> 23.tempC 
     | 
| 
      
 119 
     | 
    
         
            +
                irb> 23.tempC >> tempF
         
     | 
| 
       118 
120 
     | 
    
         
             
                => Phys::Quantity[73.4,"tempF"]
         
     | 
| 
       119 
121 
     | 
    
         | 
| 
       120 
122 
     | 
    
         
             
                irb> print_units LENGTH
         
     | 
    
        data/lib/phys/units/quantity.rb
    CHANGED
    
    | 
         @@ -29,7 +29,7 @@ module Phys 
     | 
|
| 
       29 
29 
     | 
    
         
             
              #            [ 0.0, 1609.34, 3218.69, 4828.03, 6437.38 ]
         
     | 
| 
       30 
30 
     | 
    
         
             
              # * *Unit* is an instance of Phys::Unit class.
         
     | 
| 
       31 
31 
     | 
    
         
             
              #   It is created from the second argument of Quantity constructor.
         
     | 
| 
       32 
     | 
    
         
            -
              #    
     | 
| 
      
 32 
     | 
    
         
            +
              #   See document of Phys::Unit.
         
     | 
| 
       33 
33 
     | 
    
         
             
              #        Phys::Quantity[2.5,"miles"].unit #=> #<Phys::Unit 1609.344,{"m"=>1},@expr="5280 ft">
         
     | 
| 
       34 
34 
     | 
    
         
             
              #
         
     | 
| 
       35 
35 
     | 
    
         
             
              # @example
         
     | 
| 
         @@ -144,6 +144,7 @@ module Phys 
     | 
|
| 
       144 
144 
     | 
    
         
             
                  self.class.new( val, expr, unit )
         
     | 
| 
       145 
145 
     | 
    
         
             
                end
         
     | 
| 
       146 
146 
     | 
    
         
             
                alias convert want
         
     | 
| 
      
 147 
     | 
    
         
            +
                alias >> want
         
     | 
| 
       147 
148 
     | 
    
         | 
| 
       148 
149 
     | 
    
         
             
                # Addition.
         
     | 
| 
       149 
150 
     | 
    
         
             
                # Before the operation, it converts +other+ to the unit of +self+.
         
     | 
| 
         @@ -18,7 +18,7 @@ module Phys 
     | 
|
| 
       18 
18 
     | 
    
         
             
              #
         
     | 
| 
       19 
19 
     | 
    
         
             
              #   Phys::UnitsMixin.module_eval do
         
     | 
| 
       20 
20 
     | 
    
         
             
              #     puts 123.4*km
         
     | 
| 
       21 
     | 
    
         
            -
              #     puts  
     | 
| 
      
 21 
     | 
    
         
            +
              #     puts 23*mile/hr >> m/s
         
     | 
| 
       22 
22 
     | 
    
         
             
              #     puts h.to_si
         
     | 
| 
       23 
23 
     | 
    
         
             
              #     case mile/hr
         
     | 
| 
       24 
24 
     | 
    
         
             
              #     when m
         
     | 
| 
         @@ -32,7 +32,7 @@ module Phys 
     | 
|
| 
       32 
32 
     | 
    
         
             
              #
         
     | 
| 
       33 
33 
     | 
    
         
             
              #   include Phys::UnitsMixin
         
     | 
| 
       34 
34 
     | 
    
         
             
              #
         
     | 
| 
       35 
     | 
    
         
            -
              #    
     | 
| 
      
 35 
     | 
    
         
            +
              #   1*miles/hr >> m/s    #=> Phys::Quantity[0.44704,"m/s"]
         
     | 
| 
       36 
36 
     | 
    
         
             
              #
         
     | 
| 
       37 
37 
     | 
    
         
             
              module UnitsMixin
         
     | 
| 
       38 
38 
     | 
    
         
             
                include UnitMeasures
         
     | 
| 
         @@ -68,7 +68,7 @@ module Phys 
     | 
|
| 
       68 
68 
     | 
    
         
             
              #     include Phys::UnitsNumericMixin
         
     | 
| 
       69 
69 
     | 
    
         
             
              #   end
         
     | 
| 
       70 
70 
     | 
    
         
             
              #
         
     | 
| 
       71 
     | 
    
         
            -
              #    
     | 
| 
      
 71 
     | 
    
         
            +
              #   1.miles/1.hr >> 'm/s'  #=> Phys::Quantity[0.44704,"m/s"]
         
     | 
| 
       72 
72 
     | 
    
         
             
              module UnitsNumericMixin
         
     | 
| 
       73 
73 
     | 
    
         
             
                alias method_missing_units_alias method_missing
         
     | 
| 
       74 
74 
     | 
    
         
             
                def method_missing(method, *args, &block)
         
     | 
    
        data/lib/phys/units/version.rb
    CHANGED
    
    
    
        data/phys-units.gemspec
    CHANGED
    
    | 
         @@ -8,8 +8,8 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       8 
8 
     | 
    
         
             
              spec.version       = Phys::Unit::VERSION
         
     | 
| 
       9 
9 
     | 
    
         
             
              spec.authors       = ["Masahiro TANAKA"]
         
     | 
| 
       10 
10 
     | 
    
         
             
              spec.email         = ["masa16.tanaka@gmail.com"]
         
     | 
| 
       11 
     | 
    
         
            -
              spec. 
     | 
| 
       12 
     | 
    
         
            -
              spec. 
     | 
| 
      
 11 
     | 
    
         
            +
              spec.summary       = %q{Library for Unit conversion of Physical Quantities using GNU Units data. Formerly 'Quanty'.}
         
     | 
| 
      
 12 
     | 
    
         
            +
              spec.description   = %q{Library for Unit conversion of Physical Quantities. Features: (1) It uses rich database of GNU Units. (2) It does not modify built-in classes. Former name is 'Quanty'.}
         
     | 
| 
       13 
13 
     | 
    
         
             
              spec.homepage      = "https://github.com/masa16/phys-units"
         
     | 
| 
       14 
14 
     | 
    
         
             
              spec.license       = "GPL"
         
     | 
| 
       15 
15 
     | 
    
         | 
    
        data/spec/quantity_spec.rb
    CHANGED
    
    | 
         @@ -45,6 +45,9 @@ describe "Phys::Quantity" do 
     | 
|
| 
       45 
45 
     | 
    
         
             
                  it {@q.expr.should == "km"}
         
     | 
| 
       46 
46 
     | 
    
         
             
                  it {@q.unit.should == Phys::Unit["km"]}
         
     | 
| 
       47 
47 
     | 
    
         
             
                  it {@q.want("cm").value.should == 125000}
         
     | 
| 
      
 48 
     | 
    
         
            +
                  it {(@q >> "cm").value.should == 125000}
         
     | 
| 
      
 49 
     | 
    
         
            +
                  it {(@q >> U["cm"]).value.should == 125000}
         
     | 
| 
      
 50 
     | 
    
         
            +
                  it {(@q >> Q[1,"cm"]).value.should == 125000}
         
     | 
| 
       48 
51 
     | 
    
         
             
                  it {(@q + @r).should == Q[1.75,"km"]}
         
     | 
| 
       49 
52 
     | 
    
         
             
                  it {(@q - @r).should == Q[0.75,"km"]}
         
     | 
| 
       50 
53 
     | 
    
         
             
                  it {@q.abs.should == Q[1.25,"km"]}
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: phys-units
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.9. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.9.6
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Masahiro TANAKA
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2013- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2013-06-01 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -38,7 +38,9 @@ dependencies: 
     | 
|
| 
       38 
38 
     | 
    
         
             
                - - '>='
         
     | 
| 
       39 
39 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       40 
40 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       41 
     | 
    
         
            -
            description:  
     | 
| 
      
 41 
     | 
    
         
            +
            description: 'Library for Unit conversion of Physical Quantities. Features: (1) It
         
     | 
| 
      
 42 
     | 
    
         
            +
              uses rich database of GNU Units. (2) It does not modify built-in classes. Former
         
     | 
| 
      
 43 
     | 
    
         
            +
              name is ''Quanty''.'
         
     | 
| 
       42 
44 
     | 
    
         
             
            email:
         
     | 
| 
       43 
45 
     | 
    
         
             
            - masa16.tanaka@gmail.com
         
     | 
| 
       44 
46 
     | 
    
         
             
            executables: []
         
     | 
| 
         @@ -100,7 +102,8 @@ rubyforge_project: 
     | 
|
| 
       100 
102 
     | 
    
         
             
            rubygems_version: 2.0.0
         
     | 
| 
       101 
103 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       102 
104 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       103 
     | 
    
         
            -
            summary:  
     | 
| 
      
 105 
     | 
    
         
            +
            summary: Library for Unit conversion of Physical Quantities using GNU Units data.
         
     | 
| 
      
 106 
     | 
    
         
            +
              Formerly 'Quanty'.
         
     | 
| 
       104 
107 
     | 
    
         
             
            test_files:
         
     | 
| 
       105 
108 
     | 
    
         
             
            - spec/all_units_spec.rb
         
     | 
| 
       106 
109 
     | 
    
         
             
            - spec/helper.rb
         
     |