auom 0.0.4 → 0.0.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.
- data/.gitignore +3 -0
- data/.travis.yml +4 -4
- data/Changelog.md +8 -0
- data/Gemfile +1 -3
- data/Gemfile.devtools +45 -33
- data/README.md +4 -21
- data/Rakefile +1 -4
- data/TODO +0 -2
- data/auom.gemspec +3 -3
- data/config/flay.yml +1 -1
- data/config/flog.yml +1 -1
- data/config/mutant.yml +2 -0
- data/config/roodi.yml +2 -2
- data/lib/auom.rb +29 -26
- data/lib/auom/algebra.rb +2 -8
- data/lib/auom/equalization.rb +0 -58
- data/lib/auom/inspection.rb +43 -6
- data/spec/shared/operation_behavior.rb +3 -1
- data/spec/spec_helper.rb +2 -12
- data/spec/unit/auom/algebra/add_spec.rb +3 -3
- data/spec/unit/auom/equalization/{equal_value_spec.rb → equality_operator_spec.rb} +0 -0
- data/spec/unit/auom/relational/{greater_than_or_equal_to_spec.rb → greater_than_or_equal_to_predicate_spec.rb} +0 -0
- data/spec/unit/auom/relational/{greater_than_spec.rb → greater_than_predicate_spec.rb} +0 -0
- data/spec/unit/auom/relational/{less_than_or_equal_to_spec.rb → less_than_or_equal_to_predicate_spec.rb} +0 -0
- data/spec/unit/auom/relational/{less_than_spec.rb → less_than_predicate_spec.rb} +0 -0
- data/spec/unit/auom/unit/class_methods/try_convert_spec.rb +6 -0
- data/spec/unit/auom/unit/{same_unit_spec.rb → same_unit_predicate_spec.rb} +0 -0
- data/spec/unit/auom/unit/{unitless_spec.rb → unitless_predicate_spec.rb} +2 -2
- metadata +69 -81
- data/config/heckle.yml +0 -14
- data/lib/auom/version.rb +0 -3
- data/spec/shared/command_method_behavior.rb +0 -7
- data/spec/shared/each_method_behaviour.rb +0 -15
- data/spec/shared/hash_method_behavior.rb +0 -17
- data/spec/shared/idempotent_method_behavior.rb +0 -7
- data/spec/shared/invertible_method_behaviour.rb +0 -9
- data/spec/spec.opts +0 -3
- data/spec/unit/auom/equalization/eql_spec.rb +0 -40
- data/spec/unit/auom/equalization/hash_spec.rb +0 -13
    
        data/.gitignore
    CHANGED
    
    
    
        data/.travis.yml
    CHANGED
    
    | @@ -1,11 +1,11 @@ | |
| 1 1 | 
             
            language: ruby
         | 
| 2 | 
            -
            script: 'bundle exec rake  | 
| 2 | 
            +
            script: 'bundle exec rake ci'
         | 
| 3 3 | 
             
            rvm:
         | 
| 4 4 | 
             
              - 1.8.7
         | 
| 5 | 
            -
              - 1.9.2
         | 
| 6 5 | 
             
              - 1.9.3
         | 
| 7 | 
            -
               | 
| 8 | 
            -
               | 
| 6 | 
            +
              - 1.9.2
         | 
| 7 | 
            +
              - jruby-18mode
         | 
| 8 | 
            +
              - jruby-19mode 
         | 
| 9 9 | 
             
              - rbx-18mode
         | 
| 10 10 | 
             
              - rbx-19mode
         | 
| 11 11 | 
             
            notifications:
         | 
    
        data/Changelog.md
    CHANGED
    
    
    
        data/Gemfile
    CHANGED
    
    
    
        data/Gemfile.devtools
    CHANGED
    
    | @@ -1,52 +1,64 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
              gem 'rake',    '~> 0.9.2'
         | 
| 3 | 
            -
              gem 'rspec',   '~> 1.3.2'
         | 
| 4 | 
            -
              gem 'yard',    '~> 0.8.3'
         | 
| 5 | 
            -
            end
         | 
| 1 | 
            +
            # encoding: utf-8
         | 
| 6 2 |  | 
| 7 | 
            -
            group : | 
| 8 | 
            -
              gem ' | 
| 9 | 
            -
              gem ' | 
| 10 | 
            -
              gem ' | 
| 11 | 
            -
              gem 'rb-inotify', :git => 'https://github.com/mbj/rb-inotify'
         | 
| 3 | 
            +
            group :development do
         | 
| 4 | 
            +
              gem 'rake',  '~> 10.0.3'
         | 
| 5 | 
            +
              gem 'rspec', '~> 2.13.0'
         | 
| 6 | 
            +
              gem 'yard',  '~> 0.8.5'
         | 
| 12 7 | 
             
            end
         | 
| 13 8 |  | 
| 14 | 
            -
            group : | 
| 15 | 
            -
              gem ' | 
| 9 | 
            +
            group :yard do
         | 
| 10 | 
            +
              gem 'kramdown', '~> 0.14.2'
         | 
| 16 11 | 
             
            end
         | 
| 17 12 |  | 
| 18 | 
            -
             | 
| 19 | 
            -
               | 
| 20 | 
            -
             | 
| 21 | 
            -
               | 
| 13 | 
            +
            group :guard do
         | 
| 14 | 
            +
              gem 'guard',         '~> 1.6.2'
         | 
| 15 | 
            +
              gem 'guard-bundler', '~> 1.0.0'
         | 
| 16 | 
            +
              gem 'guard-rspec',   '~> 2.4.1'
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              # file system change event handling
         | 
| 19 | 
            +
              gem 'rb-fchange', '~> 0.0.6', :require => false
         | 
| 20 | 
            +
              gem 'rb-fsevent', '~> 0.9.3', :require => false
         | 
| 21 | 
            +
              gem 'rb-inotify', '~> 0.9.0', :require => false
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              gem 'listen', '~> 0.7.3'
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              # notification handling
         | 
| 26 | 
            +
              gem 'libnotify',               '~> 0.8.0', :require => false
         | 
| 27 | 
            +
              gem 'rb-notifu',               '~> 0.0.4', :require => false
         | 
| 28 | 
            +
              gem 'terminal-notifier-guard', '~> 1.5.3', :require => false
         | 
| 22 29 | 
             
            end
         | 
| 23 30 |  | 
| 24 31 | 
             
            group :metrics do
         | 
| 25 | 
            -
              gem 'flay', | 
| 26 | 
            -
              gem 'flog', | 
| 27 | 
            -
              gem 'reek', | 
| 28 | 
            -
              gem 'roodi', | 
| 29 | 
            -
              gem 'yardstick', | 
| 30 | 
            -
              gem 'simplecov'
         | 
| 32 | 
            +
              gem 'flay',            '~> 2.1.0'
         | 
| 33 | 
            +
              gem 'flog',            '~> 3.2.2'
         | 
| 34 | 
            +
              gem 'reek',            '~> 1.3.1'
         | 
| 35 | 
            +
              gem 'metric_fu-roodi', '~> 2.2.1'
         | 
| 36 | 
            +
              gem 'yardstick',       '~> 0.9.4'
         | 
| 31 37 |  | 
| 32 38 | 
             
              platforms :ruby_18, :ruby_19 do
         | 
| 33 39 | 
             
                # this indirectly depends on ffi which does not build on ruby-head
         | 
| 34 40 | 
             
                gem 'yard-spellcheck', '~> 0.1.5'
         | 
| 35 41 | 
             
              end
         | 
| 36 42 |  | 
| 37 | 
            -
              platforms : | 
| 38 | 
            -
                gem ' | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
                gem ' | 
| 43 | 
            -
                gem 'metric_fu',   '~> 2.1.1'
         | 
| 44 | 
            -
                gem 'mspec',       '~> 1.5.17'
         | 
| 45 | 
            -
                gem 'rcov',        '~> 1.0.0'
         | 
| 46 | 
            -
                gem 'ruby2ruby',   '= 1.2.2'   # for heckle
         | 
| 43 | 
            +
              platforms :mri_19, :rbx do
         | 
| 44 | 
            +
                gem 'mutant', '~> 0.2.20'
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
              platforms :mri_19 do
         | 
| 48 | 
            +
                gem 'simplecov', '~> 0.7.1'
         | 
| 47 49 | 
             
              end
         | 
| 48 50 |  | 
| 49 51 | 
             
              platforms :rbx do
         | 
| 50 | 
            -
                gem 'pelusa', '~> 0.2. | 
| 52 | 
            +
                gem 'pelusa', '~> 0.2.2'
         | 
| 53 | 
            +
              end
         | 
| 54 | 
            +
            end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
            group :benchmarks do
         | 
| 57 | 
            +
              gem 'rbench', '~> 0.2.3'
         | 
| 58 | 
            +
            end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
            platform :jruby do
         | 
| 61 | 
            +
              group :jruby do
         | 
| 62 | 
            +
                gem 'jruby-openssl', '~> 0.8.2'
         | 
| 51 63 | 
             
              end
         | 
| 52 64 | 
             
            end
         | 
    
        data/README.md
    CHANGED
    
    | @@ -3,7 +3,7 @@ AUOM Algebra (for) Units of Measuerment | |
| 3 3 |  | 
| 4 4 | 
             
            [](http://travis-ci.org/mbj/auom)
         | 
| 5 5 | 
             
            [](https://gemnasium.com/mbj/auom)
         | 
| 6 | 
            -
            [](https://codeclimate.com/github/mbj/auom)
         | 
| 7 7 |  | 
| 8 8 | 
             
            This is another unit system for ruby.
         | 
| 9 9 | 
             
            It was created since I was not confident about the existing once.
         | 
| @@ -67,26 +67,9 @@ Contributing | |
| 67 67 | 
             
              (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
         | 
| 68 68 | 
             
            * Send me a pull request. Bonus points for topic branches.
         | 
| 69 69 |  | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 70 | 
            +
            Copyright
         | 
| 71 | 
            +
            ---------
         | 
| 72 72 |  | 
| 73 73 | 
             
            Copyright (c) 2012 Markus Schirp
         | 
| 74 74 |  | 
| 75 | 
            -
             | 
| 76 | 
            -
            a copy of this software and associated documentation files (the
         | 
| 77 | 
            -
            "Software"), to deal in the Software without restriction, including
         | 
| 78 | 
            -
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 79 | 
            -
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 80 | 
            -
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 81 | 
            -
            the following conditions:
         | 
| 82 | 
            -
             | 
| 83 | 
            -
            The above copyright notice and this permission notice shall be
         | 
| 84 | 
            -
            included in all copies or substantial portions of the Software.
         | 
| 85 | 
            -
             | 
| 86 | 
            -
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 87 | 
            -
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 88 | 
            -
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 89 | 
            -
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 90 | 
            -
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 91 | 
            -
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 92 | 
            -
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
| 75 | 
            +
            See LICENSE for details
         | 
    
        data/Rakefile
    CHANGED
    
    
    
        data/TODO
    CHANGED
    
    
    
        data/auom.gemspec
    CHANGED
    
    | @@ -1,9 +1,8 @@ | |
| 1 1 | 
             
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            -
            require File.expand_path('../lib/auom/version', __FILE__)
         | 
| 3 2 |  | 
| 4 3 | 
             
            Gem::Specification.new do |s|
         | 
| 5 4 | 
             
              s.name = 'auom'
         | 
| 6 | 
            -
              s.version =  | 
| 5 | 
            +
              s.version = '0.0.6'
         | 
| 7 6 |  | 
| 8 7 | 
             
              s.authors  = ['Markus Schirp']
         | 
| 9 8 | 
             
              s.email    = 'mbj@seonic.net'
         | 
| @@ -17,5 +16,6 @@ Gem::Specification.new do |s| | |
| 17 16 |  | 
| 18 17 | 
             
              s.rubygems_version = '1.8.10'
         | 
| 19 18 |  | 
| 20 | 
            -
              s. | 
| 19 | 
            +
              s.add_dependency('backports', [ '~> 3.0', '>= 3.0.3' ])
         | 
| 20 | 
            +
              s.add_dependency('equalizer', '~> 0.0.5')
         | 
| 21 21 | 
             
            end
         | 
    
        data/config/flay.yml
    CHANGED
    
    
    
        data/config/flog.yml
    CHANGED
    
    | @@ -1,2 +1,2 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 | 
            -
            threshold:  | 
| 2 | 
            +
            threshold: 20.6
         | 
    
        data/config/mutant.yml
    ADDED
    
    
    
        data/config/roodi.yml
    CHANGED
    
    | @@ -3,7 +3,7 @@ AbcMetricMethodCheck: | |
| 3 3 | 
             
              score: 25.1
         | 
| 4 4 | 
             
            AssignmentInConditionalCheck:    { }
         | 
| 5 5 | 
             
            CaseMissingElseCheck:            { }
         | 
| 6 | 
            -
            ClassLineCountCheck:             { line_count:  | 
| 6 | 
            +
            ClassLineCountCheck:             { line_count: 317 }
         | 
| 7 7 | 
             
            ClassNameCheck:                  
         | 
| 8 8 | 
             
              pattern: !ruby/regexp /\A(?:[A-Z]+|[A-Z][a-z](?:[A-Z]?[a-z])+)\z/
         | 
| 9 9 | 
             
            ClassVariableCheck:              { }
         | 
| @@ -14,7 +14,7 @@ ForLoopCheck:                    { } | |
| 14 14 | 
             
            MethodLineCountCheck:            { line_count: 14 }
         | 
| 15 15 | 
             
            MethodNameCheck:                 
         | 
| 16 16 | 
             
              pattern: !ruby/regexp /\A(?:[a-z\d](?:_?[a-z\d])+[?!=]?|\[\]=?|==|<=>|<<|[+*&|-])\z/
         | 
| 17 | 
            -
            ModuleLineCountCheck:            { line_count:  | 
| 17 | 
            +
            ModuleLineCountCheck:            { line_count: 320 }
         | 
| 18 18 | 
             
            ModuleNameCheck:                 
         | 
| 19 19 | 
             
              pattern: !ruby/regexp /\A(?:[A-Z]+|[A-Z][a-z](?:[A-Z]?[a-z])+)\z/
         | 
| 20 20 | 
             
            ParameterNumberCheck:            { parameter_count: 3 }
         | 
    
        data/lib/auom.rb
    CHANGED
    
    | @@ -1,5 +1,6 @@ | |
| 1 1 | 
             
            require 'rational'
         | 
| 2 2 | 
             
            require 'backports'
         | 
| 3 | 
            +
            require 'equalizer'
         | 
| 3 4 |  | 
| 4 5 | 
             
            require 'auom/algebra'
         | 
| 5 6 | 
             
            require 'auom/equalization'
         | 
| @@ -10,6 +11,7 @@ require 'auom/relational' | |
| 10 11 | 
             
            module AUOM
         | 
| 11 12 | 
             
              # A scalar with units
         | 
| 12 13 | 
             
              class Unit
         | 
| 14 | 
            +
                include Equalizer.new(:scalar, :numerators, :denominators)
         | 
| 13 15 | 
             
                include Algebra
         | 
| 14 16 | 
             
                include Equalization
         | 
| 15 17 | 
             
                include Inspection
         | 
| @@ -199,30 +201,6 @@ module AUOM | |
| 199 201 | 
             
                  self
         | 
| 200 202 | 
             
                end
         | 
| 201 203 |  | 
| 202 | 
            -
              private
         | 
| 203 | 
            -
             | 
| 204 | 
            -
                # Initialize unit
         | 
| 205 | 
            -
                #
         | 
| 206 | 
            -
                # @param [Rational] scalar
         | 
| 207 | 
            -
                # @param [Enumerable] numerators
         | 
| 208 | 
            -
                # @param [Enumerable] denominators
         | 
| 209 | 
            -
                #
         | 
| 210 | 
            -
                # @api private
         | 
| 211 | 
            -
                #
         | 
| 212 | 
            -
                def initialize(scalar, numerators, denominators)
         | 
| 213 | 
            -
                  @scalar = scalar
         | 
| 214 | 
            -
             | 
| 215 | 
            -
                  [numerators, denominators].permutation do |left, right|
         | 
| 216 | 
            -
                    left.delete_if { |item| right.delete_at(right.index(item) || right.length) }
         | 
| 217 | 
            -
                  end
         | 
| 218 | 
            -
             | 
| 219 | 
            -
                  @numerators = numerators.freeze
         | 
| 220 | 
            -
                  @denominators = denominators.freeze
         | 
| 221 | 
            -
             | 
| 222 | 
            -
                  @unit = [@numerators, @denominators].freeze
         | 
| 223 | 
            -
                  @scalar.freeze
         | 
| 224 | 
            -
                end
         | 
| 225 | 
            -
             | 
| 226 204 | 
             
                # Return converted operand or raise error
         | 
| 227 205 | 
             
                #
         | 
| 228 206 | 
             
                # @param [Object] operand
         | 
| @@ -259,12 +237,37 @@ module AUOM | |
| 259 237 | 
             
                  when self
         | 
| 260 238 | 
             
                    operand
         | 
| 261 239 | 
             
                  when Fixnum, Rational
         | 
| 262 | 
            -
                     | 
| 240 | 
            +
                    new(operand)
         | 
| 263 241 | 
             
                  else
         | 
| 264 242 | 
             
                    nil
         | 
| 265 243 | 
             
                  end
         | 
| 266 244 | 
             
                end
         | 
| 267 245 |  | 
| 246 | 
            +
             | 
| 247 | 
            +
              private
         | 
| 248 | 
            +
             | 
| 249 | 
            +
                # Initialize unit
         | 
| 250 | 
            +
                #
         | 
| 251 | 
            +
                # @param [Rational] scalar
         | 
| 252 | 
            +
                # @param [Enumerable] numerators
         | 
| 253 | 
            +
                # @param [Enumerable] denominators
         | 
| 254 | 
            +
                #
         | 
| 255 | 
            +
                # @api private
         | 
| 256 | 
            +
                #
         | 
| 257 | 
            +
                def initialize(scalar, numerators, denominators)
         | 
| 258 | 
            +
                  @scalar = scalar
         | 
| 259 | 
            +
             | 
| 260 | 
            +
                  [numerators, denominators].permutation do |left, right|
         | 
| 261 | 
            +
                    left.delete_if { |item| right.delete_at(right.index(item) || right.length) }
         | 
| 262 | 
            +
                  end
         | 
| 263 | 
            +
             | 
| 264 | 
            +
                  @numerators = numerators.freeze
         | 
| 265 | 
            +
                  @denominators = denominators.freeze
         | 
| 266 | 
            +
             | 
| 267 | 
            +
                  @unit = [@numerators, @denominators].freeze
         | 
| 268 | 
            +
                  @scalar.freeze
         | 
| 269 | 
            +
                end
         | 
| 270 | 
            +
             | 
| 268 271 | 
             
                # Return rational converted from value
         | 
| 269 272 | 
             
                #
         | 
| 270 273 | 
             
                # @param [Object] value
         | 
| @@ -281,7 +284,7 @@ module AUOM | |
| 281 284 | 
             
                  when Rational
         | 
| 282 285 | 
             
                    value
         | 
| 283 286 | 
             
                  when Fixnum
         | 
| 284 | 
            -
                    Rational(value | 
| 287 | 
            +
                    Rational(value)
         | 
| 285 288 | 
             
                  else
         | 
| 286 289 | 
             
                    raise ArgumentError, "#{value.inspect} cannot be converted to rational"
         | 
| 287 290 | 
             
                  end
         | 
    
        data/lib/auom/algebra.rb
    CHANGED
    
    | @@ -23,14 +23,8 @@ module AUOM | |
| 23 23 | 
             
                def add(operand)
         | 
| 24 24 | 
             
                  klass = self.class
         | 
| 25 25 | 
             
                  operand = klass.convert(operand)
         | 
| 26 | 
            -
             | 
| 27 26 | 
             
                  assert_same_unit(operand)
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                  klass.new(
         | 
| 30 | 
            -
                    operand.scalar + scalar,
         | 
| 31 | 
            -
                    numerators.dup,
         | 
| 32 | 
            -
                    denominators.dup
         | 
| 33 | 
            -
                  )
         | 
| 27 | 
            +
                  klass.new(operand.scalar + scalar, numerators.dup, denominators.dup)
         | 
| 34 28 | 
             
                end
         | 
| 35 29 |  | 
| 36 30 | 
             
                alias_method :+, :add
         | 
| @@ -55,7 +49,7 @@ module AUOM | |
| 55 49 | 
             
                # @api public
         | 
| 56 50 | 
             
                #
         | 
| 57 51 | 
             
                def substract(operand)
         | 
| 58 | 
            -
                   | 
| 52 | 
            +
                  add(self.class.convert(operand) * -1)
         | 
| 59 53 | 
             
                end
         | 
| 60 54 |  | 
| 61 55 | 
             
                alias_method :-, :substract
         | 
    
        data/lib/auom/equalization.rb
    CHANGED
    
    | @@ -28,63 +28,5 @@ module AUOM | |
| 28 28 | 
             
                def ==(other)
         | 
| 29 29 | 
             
                  eql?(self.class.try_convert(other))
         | 
| 30 30 | 
             
                end
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                # Check for equivalent value and not try to convert
         | 
| 33 | 
            -
                #
         | 
| 34 | 
            -
                # @param [Object] other
         | 
| 35 | 
            -
                #
         | 
| 36 | 
            -
                # @example
         | 
| 37 | 
            -
                #
         | 
| 38 | 
            -
                #   u = Unit.new(1, :meter)
         | 
| 39 | 
            -
                #   u == u                   # => true
         | 
| 40 | 
            -
                #   u == 1                   # => false
         | 
| 41 | 
            -
                #   u == Unit.new(1, :meter) # => true
         | 
| 42 | 
            -
                #
         | 
| 43 | 
            -
                #   u = Unit.new(1)
         | 
| 44 | 
            -
                #   u == 1                   # => false
         | 
| 45 | 
            -
                #   u == Rational(1)         # => false
         | 
| 46 | 
            -
                #   u == 1.0                 # => false
         | 
| 47 | 
            -
                #
         | 
| 48 | 
            -
                # @return [true]
         | 
| 49 | 
            -
                #   return true if is other is a unit and scalar and unit is the same
         | 
| 50 | 
            -
                #
         | 
| 51 | 
            -
                # @return [false]
         | 
| 52 | 
            -
                #   return false otherwise
         | 
| 53 | 
            -
                #
         | 
| 54 | 
            -
                # @api public
         | 
| 55 | 
            -
                #
         | 
| 56 | 
            -
                def eql?(other)
         | 
| 57 | 
            -
                  (instance_of?(other.class) && cmp?(other))
         | 
| 58 | 
            -
                end
         | 
| 59 | 
            -
             | 
| 60 | 
            -
                # Return hash value
         | 
| 61 | 
            -
                #
         | 
| 62 | 
            -
                # @return [Fixnum]
         | 
| 63 | 
            -
                #
         | 
| 64 | 
            -
                # @example
         | 
| 65 | 
            -
                #
         | 
| 66 | 
            -
                #   Unit.new(1, :meter).to_hash # => 012345678
         | 
| 67 | 
            -
                #
         | 
| 68 | 
            -
                # @api public
         | 
| 69 | 
            -
                #
         | 
| 70 | 
            -
                def hash
         | 
| 71 | 
            -
                  scalar.hash ^ unit.hash
         | 
| 72 | 
            -
                end
         | 
| 73 | 
            -
             | 
| 74 | 
            -
              private
         | 
| 75 | 
            -
             | 
| 76 | 
            -
                # Compare with other unit instance 
         | 
| 77 | 
            -
                #
         | 
| 78 | 
            -
                # @return [true]
         | 
| 79 | 
            -
                #   returns true if unit and scalar is aequivalent
         | 
| 80 | 
            -
                # 
         | 
| 81 | 
            -
                # @return [false]
         | 
| 82 | 
            -
                #   return false otherwise
         | 
| 83 | 
            -
                #
         | 
| 84 | 
            -
                # @api private
         | 
| 85 | 
            -
                #
         | 
| 86 | 
            -
                def cmp?(other)
         | 
| 87 | 
            -
                  scalar.eql?(other.scalar) && unit.eql?(other.unit)
         | 
| 88 | 
            -
                end
         | 
| 89 31 | 
             
              end
         | 
| 90 32 | 
             
            end
         | 
    
        data/lib/auom/inspection.rb
    CHANGED
    
    | @@ -20,15 +20,33 @@ module AUOM | |
| 20 20 | 
             
                # @api private
         | 
| 21 21 | 
             
                #
         | 
| 22 22 | 
             
                def pretty_scalar
         | 
| 23 | 
            -
                  scalar = self.scalar
         | 
| 24 | 
            -
             | 
| 25 23 | 
             
                  unless fractions?
         | 
| 26 | 
            -
                     | 
| 24 | 
            +
                    integer_value
         | 
| 27 25 | 
             
                  else
         | 
| 28 | 
            -
                    '~%0.4f' %  | 
| 26 | 
            +
                    '~%0.4f' % float_value
         | 
| 29 27 | 
             
                  end
         | 
| 30 28 | 
             
                end
         | 
| 31 29 |  | 
| 30 | 
            +
                # Return float value
         | 
| 31 | 
            +
                #
         | 
| 32 | 
            +
                # @return [Float]
         | 
| 33 | 
            +
                #
         | 
| 34 | 
            +
                # @api private
         | 
| 35 | 
            +
                #
         | 
| 36 | 
            +
                def float_value
         | 
| 37 | 
            +
                  scalar.to_f
         | 
| 38 | 
            +
                end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                # Return integer value
         | 
| 41 | 
            +
                #
         | 
| 42 | 
            +
                # @return [Fixnum]
         | 
| 43 | 
            +
                #
         | 
| 44 | 
            +
                # @api private
         | 
| 45 | 
            +
                #
         | 
| 46 | 
            +
                def integer_value
         | 
| 47 | 
            +
                  scalar.to_i
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
             | 
| 32 50 | 
             
                # Return prettyfied unit part
         | 
| 33 51 | 
             
                #
         | 
| 34 52 | 
             
                # @return [String]
         | 
| @@ -62,8 +80,27 @@ module AUOM | |
| 62 80 | 
             
                # @api private
         | 
| 63 81 | 
             
                #
         | 
| 64 82 | 
             
                def fractions?
         | 
| 65 | 
            -
                   | 
| 66 | 
            -
             | 
| 83 | 
            +
                  !(scalar_numerator % scalar_denominator).zero?
         | 
| 84 | 
            +
                end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                # Return scalar numerator
         | 
| 87 | 
            +
                #
         | 
| 88 | 
            +
                # @return [Fixnum]
         | 
| 89 | 
            +
                #
         | 
| 90 | 
            +
                # @api private
         | 
| 91 | 
            +
                #
         | 
| 92 | 
            +
                def scalar_numerator
         | 
| 93 | 
            +
                  scalar.numerator
         | 
| 94 | 
            +
                end
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                # Return scalar denominator
         | 
| 97 | 
            +
                #
         | 
| 98 | 
            +
                # @return [Fixnum]
         | 
| 99 | 
            +
                #
         | 
| 100 | 
            +
                # @api private
         | 
| 101 | 
            +
                #
         | 
| 102 | 
            +
                def scalar_denominator
         | 
| 103 | 
            +
                  scalar.denominator
         | 
| 67 104 | 
             
                end
         | 
| 68 105 |  | 
| 69 106 | 
             
                # Return prettified units
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -1,13 +1,3 @@ | |
| 1 | 
            -
            begin
         | 
| 2 | 
            -
              require 'rspec'  # try for RSpec 2
         | 
| 3 | 
            -
            rescue LoadError
         | 
| 4 | 
            -
              require 'spec'   # try for RSpec 1
         | 
| 5 | 
            -
              RSpec = Spec::Runner
         | 
| 6 | 
            -
            end
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            $LOAD_PATH << File.expand_path('../lib', __FILE__)
         | 
| 9 | 
            -
             | 
| 10 | 
            -
            Dir.glob('spec/examples/**/*.rb').each { |file| require File.expand_path(file) }
         | 
| 11 | 
            -
            Dir[File.expand_path('../{support,shared}/**/*.rb', __FILE__)].each { |f| require f }
         | 
| 12 | 
            -
             | 
| 13 1 | 
             
            require 'auom'
         | 
| 2 | 
            +
            require 'devtools'
         | 
| 3 | 
            +
            Devtools.init_spec_helper
         | 
| @@ -30,7 +30,7 @@ describe AUOM::Algebra,'#add' do | |
| 30 30 | 
             
              end
         | 
| 31 31 |  | 
| 32 32 | 
             
              context 'when unit is unitful' do
         | 
| 33 | 
            -
                let(:arguments) { [1,:meter] }
         | 
| 33 | 
            +
                let(:arguments) { [1,:meter, :euro] }
         | 
| 34 34 |  | 
| 35 35 | 
             
                context 'and operand is a Fixnum' do
         | 
| 36 36 | 
             
                  let(:operand) { 1 }
         | 
| @@ -51,9 +51,9 @@ describe AUOM::Algebra,'#add' do | |
| 51 51 | 
             
                end
         | 
| 52 52 |  | 
| 53 53 | 
             
                context 'and operand is a compatible unit' do
         | 
| 54 | 
            -
                  let(:operand) { AUOM::Unit.new(1,:meter) }
         | 
| 54 | 
            +
                  let(:operand) { AUOM::Unit.new(1,:meter, :euro) }
         | 
| 55 55 |  | 
| 56 | 
            -
                  it { should eql(AUOM::Unit.new(2,:meter)) }
         | 
| 56 | 
            +
                  it { should eql(AUOM::Unit.new(2,:meter, :euro)) }
         | 
| 57 57 | 
             
                end
         | 
| 58 58 | 
             
              end
         | 
| 59 59 | 
             
            end
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| @@ -1,9 +1,9 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 |  | 
| 3 | 
            -
            describe AUOM::Unit,'#unitless?' do
         | 
| 3 | 
            +
            describe AUOM::Unit, '#unitless?' do
         | 
| 4 4 | 
             
              subject { object.unitless? }
         | 
| 5 5 |  | 
| 6 | 
            -
              let(:object) { described_class.new(1 | 
| 6 | 
            +
              let(:object) { described_class.new(1, *unit) }
         | 
| 7 7 |  | 
| 8 8 | 
             
              context 'when unit is unitless' do
         | 
| 9 9 | 
             
                let(:unit) { [] }
         | 
    
        metadata
    CHANGED
    
    | @@ -1,48 +1,62 @@ | |
| 1 | 
            -
            --- !ruby/object:Gem::Specification | 
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: auom
         | 
| 3 | 
            -
            version: !ruby/object:Gem::Version | 
| 4 | 
            -
               | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.6
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 | 
            -
              segments: 
         | 
| 7 | 
            -
              - 0
         | 
| 8 | 
            -
              - 0
         | 
| 9 | 
            -
              - 4
         | 
| 10 | 
            -
              version: 0.0.4
         | 
| 11 6 | 
             
            platform: ruby
         | 
| 12 | 
            -
            authors: | 
| 7 | 
            +
            authors:
         | 
| 13 8 | 
             
            - Markus Schirp
         | 
| 14 9 | 
             
            autorequire: 
         | 
| 15 10 | 
             
            bindir: bin
         | 
| 16 11 | 
             
            cert_chain: []
         | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 12 | 
            +
            date: 2013-03-03 00:00:00.000000000 Z
         | 
| 13 | 
            +
            dependencies:
         | 
| 14 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 21 15 | 
             
              name: backports
         | 
| 16 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 | 
            +
                none: false
         | 
| 18 | 
            +
                requirements:
         | 
| 19 | 
            +
                - - ~>
         | 
| 20 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            +
                    version: '3.0'
         | 
| 22 | 
            +
                - - ! '>='
         | 
| 23 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 24 | 
            +
                    version: 3.0.3
         | 
| 25 | 
            +
              type: :runtime
         | 
| 22 26 | 
             
              prerelease: false
         | 
| 23 | 
            -
               | 
| 27 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 28 | 
            +
                none: false
         | 
| 29 | 
            +
                requirements:
         | 
| 30 | 
            +
                - - ~>
         | 
| 31 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 32 | 
            +
                    version: '3.0'
         | 
| 33 | 
            +
                - - ! '>='
         | 
| 34 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 35 | 
            +
                    version: 3.0.3
         | 
| 36 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 37 | 
            +
              name: equalizer
         | 
| 38 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 24 39 | 
             
                none: false
         | 
| 25 | 
            -
                requirements: | 
| 40 | 
            +
                requirements:
         | 
| 26 41 | 
             
                - - ~>
         | 
| 27 | 
            -
                  - !ruby/object:Gem::Version | 
| 28 | 
            -
                     | 
| 29 | 
            -
                    segments: 
         | 
| 30 | 
            -
                    - 2
         | 
| 31 | 
            -
                    - 6
         | 
| 32 | 
            -
                    - 3
         | 
| 33 | 
            -
                    version: 2.6.3
         | 
| 42 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 43 | 
            +
                    version: 0.0.5
         | 
| 34 44 | 
             
              type: :runtime
         | 
| 35 | 
            -
               | 
| 45 | 
            +
              prerelease: false
         | 
| 46 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 47 | 
            +
                none: false
         | 
| 48 | 
            +
                requirements:
         | 
| 49 | 
            +
                - - ~>
         | 
| 50 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 51 | 
            +
                    version: 0.0.5
         | 
| 36 52 | 
             
            description: 
         | 
| 37 53 | 
             
            email: mbj@seonic.net
         | 
| 38 54 | 
             
            executables: []
         | 
| 39 | 
            -
             | 
| 40 55 | 
             
            extensions: []
         | 
| 41 | 
            -
             | 
| 42 | 
            -
            extra_rdoc_files: 
         | 
| 56 | 
            +
            extra_rdoc_files:
         | 
| 43 57 | 
             
            - TODO
         | 
| 44 58 | 
             
            - LICENSE
         | 
| 45 | 
            -
            files: | 
| 59 | 
            +
            files:
         | 
| 46 60 | 
             
            - .gitignore
         | 
| 47 61 | 
             
            - .rspec
         | 
| 48 62 | 
             
            - .travis.yml
         | 
| @@ -57,7 +71,7 @@ files: | |
| 57 71 | 
             
            - auom.gemspec
         | 
| 58 72 | 
             
            - config/flay.yml
         | 
| 59 73 | 
             
            - config/flog.yml
         | 
| 60 | 
            -
            - config/ | 
| 74 | 
            +
            - config/mutant.yml
         | 
| 61 75 | 
             
            - config/roodi.yml
         | 
| 62 76 | 
             
            - config/site.reek
         | 
| 63 77 | 
             
            - config/yardstick.yml
         | 
| @@ -66,31 +80,22 @@ files: | |
| 66 80 | 
             
            - lib/auom/equalization.rb
         | 
| 67 81 | 
             
            - lib/auom/inspection.rb
         | 
| 68 82 | 
             
            - lib/auom/relational.rb
         | 
| 69 | 
            -
            - lib/auom/version.rb
         | 
| 70 83 | 
             
            - spec/rcov.opts
         | 
| 71 | 
            -
            - spec/shared/command_method_behavior.rb
         | 
| 72 | 
            -
            - spec/shared/each_method_behaviour.rb
         | 
| 73 | 
            -
            - spec/shared/hash_method_behavior.rb
         | 
| 74 | 
            -
            - spec/shared/idempotent_method_behavior.rb
         | 
| 75 84 | 
             
            - spec/shared/incompatible_operation_behavior.rb
         | 
| 76 | 
            -
            - spec/shared/invertible_method_behaviour.rb
         | 
| 77 85 | 
             
            - spec/shared/operation_behavior.rb
         | 
| 78 86 | 
             
            - spec/shared/sunits_shared.rb
         | 
| 79 | 
            -
            - spec/spec.opts
         | 
| 80 87 | 
             
            - spec/spec_helper.rb
         | 
| 81 88 | 
             
            - spec/unit/auom/algebra/add_spec.rb
         | 
| 82 89 | 
             
            - spec/unit/auom/algebra/divide_spec.rb
         | 
| 83 90 | 
             
            - spec/unit/auom/algebra/multiply_spec.rb
         | 
| 84 91 | 
             
            - spec/unit/auom/algebra/substract_spec.rb
         | 
| 85 | 
            -
            - spec/unit/auom/equalization/ | 
| 86 | 
            -
            - spec/unit/auom/equalization/equal_value_spec.rb
         | 
| 87 | 
            -
            - spec/unit/auom/equalization/hash_spec.rb
         | 
| 92 | 
            +
            - spec/unit/auom/equalization/equality_operator_spec.rb
         | 
| 88 93 | 
             
            - spec/unit/auom/inspection/class_methods/prettify_unit_part_spec.rb
         | 
| 89 94 | 
             
            - spec/unit/auom/inspection/inspect_spec.rb
         | 
| 90 | 
            -
            - spec/unit/auom/relational/ | 
| 91 | 
            -
            - spec/unit/auom/relational/ | 
| 92 | 
            -
            - spec/unit/auom/relational/ | 
| 93 | 
            -
            - spec/unit/auom/relational/ | 
| 95 | 
            +
            - spec/unit/auom/relational/greater_than_or_equal_to_predicate_spec.rb
         | 
| 96 | 
            +
            - spec/unit/auom/relational/greater_than_predicate_spec.rb
         | 
| 97 | 
            +
            - spec/unit/auom/relational/less_than_or_equal_to_predicate_spec.rb
         | 
| 98 | 
            +
            - spec/unit/auom/relational/less_than_predicate_spec.rb
         | 
| 94 99 | 
             
            - spec/unit/auom/unit/assert_same_unit_spec.rb
         | 
| 95 100 | 
             
            - spec/unit/auom/unit/class_methods/convert_spec.rb
         | 
| 96 101 | 
             
            - spec/unit/auom/unit/class_methods/lookup_spec.rb
         | 
| @@ -99,68 +104,51 @@ files: | |
| 99 104 | 
             
            - spec/unit/auom/unit/class_methods/units_spec.rb
         | 
| 100 105 | 
             
            - spec/unit/auom/unit/denominators_spec.rb
         | 
| 101 106 | 
             
            - spec/unit/auom/unit/numerators_spec.rb
         | 
| 102 | 
            -
            - spec/unit/auom/unit/ | 
| 107 | 
            +
            - spec/unit/auom/unit/same_unit_predicate_spec.rb
         | 
| 103 108 | 
             
            - spec/unit/auom/unit/scalar_spec.rb
         | 
| 104 109 | 
             
            - spec/unit/auom/unit/unit_spec.rb
         | 
| 105 | 
            -
            - spec/unit/auom/unit/ | 
| 110 | 
            +
            - spec/unit/auom/unit/unitless_predicate_spec.rb
         | 
| 106 111 | 
             
            homepage: http://github.com/mbj/auom
         | 
| 107 112 | 
             
            licenses: []
         | 
| 108 | 
            -
             | 
| 109 113 | 
             
            post_install_message: 
         | 
| 110 114 | 
             
            rdoc_options: []
         | 
| 111 | 
            -
             | 
| 112 | 
            -
            require_paths: 
         | 
| 115 | 
            +
            require_paths:
         | 
| 113 116 | 
             
            - lib
         | 
| 114 | 
            -
            required_ruby_version: !ruby/object:Gem::Requirement | 
| 117 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 115 118 | 
             
              none: false
         | 
| 116 | 
            -
              requirements: | 
| 117 | 
            -
              - -  | 
| 118 | 
            -
                - !ruby/object:Gem::Version | 
| 119 | 
            -
                   | 
| 120 | 
            -
             | 
| 121 | 
            -
                  - 0
         | 
| 122 | 
            -
                  version: "0"
         | 
| 123 | 
            -
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 119 | 
            +
              requirements:
         | 
| 120 | 
            +
              - - ! '>='
         | 
| 121 | 
            +
                - !ruby/object:Gem::Version
         | 
| 122 | 
            +
                  version: '0'
         | 
| 123 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 124 124 | 
             
              none: false
         | 
| 125 | 
            -
              requirements: | 
| 126 | 
            -
              - -  | 
| 127 | 
            -
                - !ruby/object:Gem::Version | 
| 128 | 
            -
                   | 
| 129 | 
            -
                  segments: 
         | 
| 130 | 
            -
                  - 0
         | 
| 131 | 
            -
                  version: "0"
         | 
| 125 | 
            +
              requirements:
         | 
| 126 | 
            +
              - - ! '>='
         | 
| 127 | 
            +
                - !ruby/object:Gem::Version
         | 
| 128 | 
            +
                  version: '0'
         | 
| 132 129 | 
             
            requirements: []
         | 
| 133 | 
            -
             | 
| 134 130 | 
             
            rubyforge_project: 
         | 
| 135 | 
            -
            rubygems_version: 1.8. | 
| 131 | 
            +
            rubygems_version: 1.8.23
         | 
| 136 132 | 
             
            signing_key: 
         | 
| 137 133 | 
             
            specification_version: 3
         | 
| 138 134 | 
             
            summary: Algebra (with) Units Of Measurement
         | 
| 139 | 
            -
            test_files: | 
| 135 | 
            +
            test_files:
         | 
| 140 136 | 
             
            - spec/rcov.opts
         | 
| 141 | 
            -
            - spec/shared/command_method_behavior.rb
         | 
| 142 | 
            -
            - spec/shared/each_method_behaviour.rb
         | 
| 143 | 
            -
            - spec/shared/hash_method_behavior.rb
         | 
| 144 | 
            -
            - spec/shared/idempotent_method_behavior.rb
         | 
| 145 137 | 
             
            - spec/shared/incompatible_operation_behavior.rb
         | 
| 146 | 
            -
            - spec/shared/invertible_method_behaviour.rb
         | 
| 147 138 | 
             
            - spec/shared/operation_behavior.rb
         | 
| 148 139 | 
             
            - spec/shared/sunits_shared.rb
         | 
| 149 | 
            -
            - spec/spec.opts
         | 
| 150 140 | 
             
            - spec/spec_helper.rb
         | 
| 151 141 | 
             
            - spec/unit/auom/algebra/add_spec.rb
         | 
| 152 142 | 
             
            - spec/unit/auom/algebra/divide_spec.rb
         | 
| 153 143 | 
             
            - spec/unit/auom/algebra/multiply_spec.rb
         | 
| 154 144 | 
             
            - spec/unit/auom/algebra/substract_spec.rb
         | 
| 155 | 
            -
            - spec/unit/auom/equalization/ | 
| 156 | 
            -
            - spec/unit/auom/equalization/equal_value_spec.rb
         | 
| 157 | 
            -
            - spec/unit/auom/equalization/hash_spec.rb
         | 
| 145 | 
            +
            - spec/unit/auom/equalization/equality_operator_spec.rb
         | 
| 158 146 | 
             
            - spec/unit/auom/inspection/class_methods/prettify_unit_part_spec.rb
         | 
| 159 147 | 
             
            - spec/unit/auom/inspection/inspect_spec.rb
         | 
| 160 | 
            -
            - spec/unit/auom/relational/ | 
| 161 | 
            -
            - spec/unit/auom/relational/ | 
| 162 | 
            -
            - spec/unit/auom/relational/ | 
| 163 | 
            -
            - spec/unit/auom/relational/ | 
| 148 | 
            +
            - spec/unit/auom/relational/greater_than_or_equal_to_predicate_spec.rb
         | 
| 149 | 
            +
            - spec/unit/auom/relational/greater_than_predicate_spec.rb
         | 
| 150 | 
            +
            - spec/unit/auom/relational/less_than_or_equal_to_predicate_spec.rb
         | 
| 151 | 
            +
            - spec/unit/auom/relational/less_than_predicate_spec.rb
         | 
| 164 152 | 
             
            - spec/unit/auom/unit/assert_same_unit_spec.rb
         | 
| 165 153 | 
             
            - spec/unit/auom/unit/class_methods/convert_spec.rb
         | 
| 166 154 | 
             
            - spec/unit/auom/unit/class_methods/lookup_spec.rb
         | 
| @@ -169,8 +157,8 @@ test_files: | |
| 169 157 | 
             
            - spec/unit/auom/unit/class_methods/units_spec.rb
         | 
| 170 158 | 
             
            - spec/unit/auom/unit/denominators_spec.rb
         | 
| 171 159 | 
             
            - spec/unit/auom/unit/numerators_spec.rb
         | 
| 172 | 
            -
            - spec/unit/auom/unit/ | 
| 160 | 
            +
            - spec/unit/auom/unit/same_unit_predicate_spec.rb
         | 
| 173 161 | 
             
            - spec/unit/auom/unit/scalar_spec.rb
         | 
| 174 162 | 
             
            - spec/unit/auom/unit/unit_spec.rb
         | 
| 175 | 
            -
            - spec/unit/auom/unit/ | 
| 163 | 
            +
            - spec/unit/auom/unit/unitless_predicate_spec.rb
         | 
| 176 164 | 
             
            has_rdoc: 
         | 
    
        data/config/heckle.yml
    DELETED
    
    
    
        data/lib/auom/version.rb
    DELETED
    
    
| @@ -1,15 +0,0 @@ | |
| 1 | 
            -
            # encoding: utf-8
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            shared_examples_for 'an #each method' do
         | 
| 4 | 
            -
              it_should_behave_like 'a command method'
         | 
| 5 | 
            -
             | 
| 6 | 
            -
              context 'with no block' do
         | 
| 7 | 
            -
                subject { object.each }
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                it { should be_instance_of(to_enum.class) }
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                it 'yields the expected values' do
         | 
| 12 | 
            -
                  subject.to_a.should eql(object.to_a)
         | 
| 13 | 
            -
                end
         | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
            end
         | 
| @@ -1,17 +0,0 @@ | |
| 1 | 
            -
            # encoding: utf-8
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            shared_examples_for 'a hash method' do
         | 
| 4 | 
            -
              it_should_behave_like 'an idempotent method'
         | 
| 5 | 
            -
             | 
| 6 | 
            -
              specification = proc do
         | 
| 7 | 
            -
                should be_instance_of(Fixnum)
         | 
| 8 | 
            -
              end
         | 
| 9 | 
            -
             | 
| 10 | 
            -
              it 'is a fixnum' do
         | 
| 11 | 
            -
                instance_eval(&specification)
         | 
| 12 | 
            -
              end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
              it 'memoizes the hash code' do
         | 
| 15 | 
            -
                subject.should eql(object.memoized(:hash))
         | 
| 16 | 
            -
              end
         | 
| 17 | 
            -
            end
         | 
    
        data/spec/spec.opts
    DELETED
    
    
| @@ -1,40 +0,0 @@ | |
| 1 | 
            -
            require 'spec_helper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            describe AUOM::Equalization,'#eql?' do
         | 
| 4 | 
            -
              subject { object.eql?(other) }
         | 
| 5 | 
            -
             | 
| 6 | 
            -
              let(:object) { AUOM::Unit.new(1,:meter) }
         | 
| 7 | 
            -
             | 
| 8 | 
            -
              context 'when is other kind of object' do
         | 
| 9 | 
            -
                let(:other) { Object.new }
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                it { should be(false) }
         | 
| 12 | 
            -
              end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
              context 'when is same kind of object' do
         | 
| 15 | 
            -
                let(:other) { AUOM::Unit.new(scalar,*unit) }
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                let(:scalar) { 1 }
         | 
| 18 | 
            -
                let(:unit) { [:meter] }
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                context 'and scalar and unit are the same' do
         | 
| 21 | 
            -
                  it { should be(true) }
         | 
| 22 | 
            -
                end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
                context 'and scalar is differend' do
         | 
| 25 | 
            -
                  let(:scalar) { 2 }
         | 
| 26 | 
            -
                  it { should be(false) }
         | 
| 27 | 
            -
                end
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                context 'and unit is differend' do
         | 
| 30 | 
            -
                  let(:unit) { [:euro] }
         | 
| 31 | 
            -
                  it { should be(false) }
         | 
| 32 | 
            -
                end
         | 
| 33 | 
            -
             | 
| 34 | 
            -
                context 'and scalar and unit is differend' do
         | 
| 35 | 
            -
                  let(:scalar) { 2 }
         | 
| 36 | 
            -
                  let(:unit) { [:euro] }
         | 
| 37 | 
            -
                  it { should be(false) }
         | 
| 38 | 
            -
                end
         | 
| 39 | 
            -
              end
         | 
| 40 | 
            -
            end
         | 
| @@ -1,13 +0,0 @@ | |
| 1 | 
            -
            require 'spec_helper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            describe AUOM::Equalization, '#hash' do
         | 
| 4 | 
            -
              subject { object.hash }
         | 
| 5 | 
            -
             | 
| 6 | 
            -
              let(:object) { AUOM::Unit.new(1) }
         | 
| 7 | 
            -
             | 
| 8 | 
            -
              it { should be_a(Fixnum) }
         | 
| 9 | 
            -
             | 
| 10 | 
            -
              it_should_behave_like 'an idempotent method'
         | 
| 11 | 
            -
             | 
| 12 | 
            -
              it { should be(Rational(1).hash ^ [[],[]].hash) }
         | 
| 13 | 
            -
            end
         |