mug 0.5.3 → 0.5.4
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/lib/mug/and-or.rb +26 -26
- data/lib/mug/any-and-all.rb +16 -16
- data/lib/mug/apply.rb +37 -37
- data/lib/mug/array/extend.rb +43 -43
- data/lib/mug/array/minus.rb +32 -32
- data/lib/mug/bool.rb +71 -71
- data/lib/mug/clamp.rb +35 -35
- data/lib/mug/counts.rb +27 -27
- data/lib/mug/fragile-method-chain.rb +42 -42
- data/lib/mug/hash/map.rb +75 -75
- data/lib/mug/hash/operations.rb +47 -47
- data/lib/mug/iterator/for.rb +7 -7
- data/lib/mug/iterator/method.rb +7 -7
- data/lib/mug/iterator_c.rb +14 -14
- data/lib/mug/loop-with.rb +30 -29
- data/lib/mug/matchdata/each.rb +40 -40
- data/lib/mug/matchdata/hash.rb +29 -29
- data/lib/mug/maybe.rb +33 -33
- data/lib/mug/negativity.rb +20 -20
- data/lib/mug/not.rb +6 -6
- data/lib/mug/rexproc.rb +6 -6
- data/lib/mug/self.rb +31 -31
- data/lib/mug/to_h.rb +2 -2
- data/lib/mug/top.rb +100 -100
- data/test/test-and-or.rb +32 -32
- data/test/test-any-and-all.rb +19 -19
- data/test/test-apply.rb +47 -47
- data/test/test-array-extend.rb +54 -54
- data/test/test-array-minus.rb +11 -11
- data/test/test-bool.rb +48 -48
- data/test/test-clamp.rb +42 -42
- data/test/test-counts.rb +21 -21
- data/test/test-fragile-method-chain.rb +56 -56
- data/test/test-hashmap.rb +14 -14
- data/test/test-hashop.rb +47 -47
- data/test/test-iterator-for.rb +12 -12
- data/test/test-loop-with.rb +117 -66
- data/test/test-matchdata_each.rb +50 -50
- data/test/test-matchdata_hash.rb +40 -40
- data/test/test-maybe.rb +76 -76
- data/test/test-negativity.rb +40 -40
- data/test/test-not.rb +53 -53
- data/test/test-rexproc.rb +6 -6
- data/test/test-self.rb +21 -21
- data/test/test-tau.rb +12 -12
- data/test/test-top.rb +100 -100
- metadata +4 -4
    
        data/test/test-rexproc.rb
    CHANGED
    
    | @@ -3,10 +3,10 @@ $VERBOSE = true | |
| 3 3 |  | 
| 4 4 | 
             
            require_relative '../lib/mug/rexproc'
         | 
| 5 5 | 
             
            class Test_rexproc < Test::Unit::TestCase
         | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 6 | 
            +
              def test_rexproc
         | 
| 7 | 
            +
                a = %w[foo bar baz]
         | 
| 8 | 
            +
                assert_equal( %w[bar baz], a.select(&/\Ab/) )
         | 
| 9 | 
            +
                assert_equal( %w[foo],     a.reject(&/\Ab/) )
         | 
| 10 | 
            +
                assert_equal(  %[bar],     a.find(  &/\Ab/) )
         | 
| 11 | 
            +
              end
         | 
| 12 12 | 
             
            end
         | 
    
        data/test/test-self.rb
    CHANGED
    
    | @@ -3,26 +3,26 @@ $VERBOSE = true | |
| 3 3 |  | 
| 4 4 | 
             
            require_relative '../lib/mug/self'
         | 
| 5 5 | 
             
            class Test_self < Test::Unit::TestCase
         | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 6 | 
            +
              def test_self
         | 
| 7 | 
            +
                obj = Object.new
         | 
| 8 | 
            +
                assert_equal( 1, 1.self )
         | 
| 9 | 
            +
                assert_equal( obj, obj.self )
         | 
| 10 | 
            +
                assert_equal( 6, 2.self{|i| i*3 } )
         | 
| 11 | 
            +
                assert_equal( {1=>[1,1], 2=>[2,2], 3=>[3]}, [1,1,2,2,3].group_by(&:self) )
         | 
| 12 12 |  | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 13 | 
            +
                assert_equal( 1, 1.itself )
         | 
| 14 | 
            +
                assert_equal( obj, obj.itself )
         | 
| 15 | 
            +
                assert_equal( 6, 2.itself{|i| i*3 } )
         | 
| 16 | 
            +
                assert_equal( {1=>[1,1], 2=>[2,2], 3=>[3]}, [1,1,2,2,3].group_by(&:itself) )
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
              def test_revapply
         | 
| 19 | 
            +
                p = proc {|*args| args }
         | 
| 20 | 
            +
                assert_equal( [1], 1.revapply(&p) )
         | 
| 21 | 
            +
                assert_equal( [1,2,3], 1.revapply(2,3,&p) )
         | 
| 22 | 
            +
                if RUBY_VERSION.to_i >= 2
         | 
| 23 | 
            +
                  assert_equal( 3, 1.revapply(2,3).size )
         | 
| 24 | 
            +
                else
         | 
| 25 | 
            +
                  assert_equal( [1,2,3], 1.revapply(2,3).first )
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
              end
         | 
| 28 28 | 
             
            end
         | 
    
        data/test/test-tau.rb
    CHANGED
    
    | @@ -5,18 +5,18 @@ require 'bigdecimal/math' | |
| 5 5 | 
             
            $VERBOSE = true
         | 
| 6 6 | 
             
            require_relative '../lib/mug/tau'
         | 
| 7 7 | 
             
            class Test_tau < Test::Unit::TestCase
         | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 8 | 
            +
              def test_math_tau
         | 
| 9 | 
            +
                # 6.283185307179586..
         | 
| 10 | 
            +
                assert_equal(Math::TAU, Math::PI*2.0)
         | 
| 11 | 
            +
              end
         | 
| 12 12 |  | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 13 | 
            +
              include BigMath
         | 
| 14 | 
            +
              def test_TAU
         | 
| 15 | 
            +
                assert_equal(TAU(1).round(1).to_s('F'), '6.3')
         | 
| 16 | 
            +
                assert_equal(TAU(100).truncate(100).to_s('F'), '6.2831853071795864769252867665590057683943387987502116419498891846156328125724179972560696506842341359')
         | 
| 17 | 
            +
                assert_raise(ArgumentError) { TAU(0) }
         | 
| 18 | 
            +
                assert_raise(ArgumentError) { TAU(-3) }
         | 
| 19 | 
            +
                assert_raise(ArgumentError) { TAU('barf') }
         | 
| 20 | 
            +
              end
         | 
| 21 21 | 
             
            end
         | 
| 22 22 |  | 
    
        data/test/test-top.rb
    CHANGED
    
    | @@ -4,113 +4,113 @@ $VERBOSE = true | |
| 4 4 | 
             
            require_relative '../lib/mug/top'
         | 
| 5 5 | 
             
            class Test_and_or < Test::Unit::TestCase
         | 
| 6 6 |  | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 7 | 
            +
              def test_top
         | 
| 8 | 
            +
                a = [1,3,5,2,4,3]
         | 
| 9 | 
            +
                assert_equal( [5], a.top )
         | 
| 10 | 
            +
                assert_equal( [5,4,3], a.top(3) )
         | 
| 11 | 
            +
                assert_equal( [5,4,3,3,2,1], a.top(100) )
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
              def test_bottom
         | 
| 14 | 
            +
                a = [3,1,4,3,2,5]
         | 
| 15 | 
            +
                assert_equal( [1], a.bottom )
         | 
| 16 | 
            +
                assert_equal( [1,2,3], a.bottom(3) )
         | 
| 17 | 
            +
                assert_equal( [1,2,3,3,4,5], a.bottom(100) )
         | 
| 18 | 
            +
              end
         | 
| 19 19 |  | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 20 | 
            +
              def test_top__block
         | 
| 21 | 
            +
                a = [1,3,5,2,4,3]
         | 
| 22 | 
            +
                b = proc{|x,y| y<=>x }
         | 
| 23 | 
            +
                assert_equal( [1], a.top(&b) )
         | 
| 24 | 
            +
                assert_equal( [1,2,3], a.top(3,&b) )
         | 
| 25 | 
            +
                assert_equal( [1,2,3,3,4,5], a.top(100,&b) )
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
              def test_bottom__block
         | 
| 28 | 
            +
                a = [3,1,4,3,2,5]
         | 
| 29 | 
            +
                b = proc{|x,y| y<=>x }
         | 
| 30 | 
            +
                assert_equal( [5], a.bottom(&b) )
         | 
| 31 | 
            +
                assert_equal( [5,4,3], a.bottom(3,&b) )
         | 
| 32 | 
            +
                assert_equal( [5,4,3,3,2,1], a.bottom(100,&b) )
         | 
| 33 | 
            +
              end
         | 
| 34 34 |  | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 43 | 
            -
             | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 35 | 
            +
              def test_top_by
         | 
| 36 | 
            +
                a = [1,3,5,2,4,3]
         | 
| 37 | 
            +
                b = proc{|x| x % 3 }
         | 
| 38 | 
            +
                assert_equal( [5], a.top_by(&b) )
         | 
| 39 | 
            +
                assert_equal( [5,2,1], a.top_by(3, &b) )
         | 
| 40 | 
            +
                assert_equal( [5,2,1,4,3,3], a.top_by(100, &b) )
         | 
| 41 | 
            +
              end
         | 
| 42 | 
            +
              def test_bottom_by
         | 
| 43 | 
            +
                a = [3,1,4,3,2,5]
         | 
| 44 | 
            +
                b = proc{|x| x % 3 }
         | 
| 45 | 
            +
                assert_equal( [3], a.bottom_by(&b) )
         | 
| 46 | 
            +
                assert_equal( [3,3,1], a.bottom_by(3, &b) )
         | 
| 47 | 
            +
                assert_equal( [3,3,1,4,2,5], a.bottom_by(100, &b) )
         | 
| 48 | 
            +
              end
         | 
| 49 49 |  | 
| 50 | 
            -
             | 
| 51 | 
            -
             | 
| 52 | 
            -
             | 
| 53 | 
            -
             | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 56 | 
            -
             | 
| 57 | 
            -
             | 
| 58 | 
            -
             | 
| 59 | 
            -
             | 
| 60 | 
            -
             | 
| 61 | 
            -
             | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 50 | 
            +
              def test_top_by__noblock
         | 
| 51 | 
            +
                a = [1,3,5,2,4,3]
         | 
| 52 | 
            +
                b = proc{|x| x % 3 }
         | 
| 53 | 
            +
                assert_equal( [5], a.top_by.each(&b) )
         | 
| 54 | 
            +
                assert_equal( [5,2,1], a.top_by(3).each(&b) )
         | 
| 55 | 
            +
                assert_equal( [5,2,1,4,3,3], a.top_by(100).each(&b) )
         | 
| 56 | 
            +
              end
         | 
| 57 | 
            +
              def test_bottom_by__noblock
         | 
| 58 | 
            +
                a = [3,1,4,3,2,5]
         | 
| 59 | 
            +
                b = proc{|x| x % 3 }
         | 
| 60 | 
            +
                assert_equal( [3], a.bottom_by.each(&b) )
         | 
| 61 | 
            +
                assert_equal( [3,3,1], a.bottom_by(3).each(&b) )
         | 
| 62 | 
            +
                assert_equal( [3,3,1,4,2,5], a.bottom_by(100).each(&b) )
         | 
| 63 | 
            +
              end
         | 
| 64 64 |  | 
| 65 | 
            -
             | 
| 66 | 
            -
             | 
| 67 | 
            -
             | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 72 | 
            -
             | 
| 73 | 
            -
             | 
| 74 | 
            -
             | 
| 65 | 
            +
              def test_topBANG
         | 
| 66 | 
            +
                a = [1,3,5,2,4,3]
         | 
| 67 | 
            +
                a.top!(3)
         | 
| 68 | 
            +
                assert_equal( [5,4,3], a )
         | 
| 69 | 
            +
              end
         | 
| 70 | 
            +
              def test_bottomBANG
         | 
| 71 | 
            +
                a = [3,1,4,3,2,5]
         | 
| 72 | 
            +
                a.bottom!(3)
         | 
| 73 | 
            +
                assert_equal( [1,2,3], a )
         | 
| 74 | 
            +
              end
         | 
| 75 75 |  | 
| 76 | 
            -
             | 
| 77 | 
            -
             | 
| 78 | 
            -
             | 
| 79 | 
            -
             | 
| 80 | 
            -
             | 
| 81 | 
            -
             | 
| 82 | 
            -
             | 
| 83 | 
            -
             | 
| 84 | 
            -
             | 
| 85 | 
            -
             | 
| 86 | 
            -
             | 
| 87 | 
            -
             | 
| 76 | 
            +
              def test_topBANG__block
         | 
| 77 | 
            +
                a = [1,3,5,2,4,3]
         | 
| 78 | 
            +
                b = proc{|x,y| y<=>x }
         | 
| 79 | 
            +
                a.top!(3, &b)
         | 
| 80 | 
            +
                assert_equal( [1,2,3], a )
         | 
| 81 | 
            +
              end
         | 
| 82 | 
            +
              def test_bottomBANG__block
         | 
| 83 | 
            +
                a = [3,1,4,3,2,5]
         | 
| 84 | 
            +
                b = proc{|x,y| y<=>x }
         | 
| 85 | 
            +
                a.bottom!(3, &b)
         | 
| 86 | 
            +
                assert_equal( [5,4,3], a )
         | 
| 87 | 
            +
              end
         | 
| 88 88 |  | 
| 89 | 
            -
             | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 98 | 
            -
             | 
| 99 | 
            -
             | 
| 100 | 
            -
             | 
| 89 | 
            +
              def test_top_byBANG
         | 
| 90 | 
            +
                a = [1,3,5,2,4,3]
         | 
| 91 | 
            +
                b = proc{|x| x % 3 }
         | 
| 92 | 
            +
                a.top_by!(3, &b)
         | 
| 93 | 
            +
                assert_equal( [5,2,1], a )
         | 
| 94 | 
            +
              end
         | 
| 95 | 
            +
              def test_bottom_byBANG
         | 
| 96 | 
            +
                a = [3,1,4,3,2,5]
         | 
| 97 | 
            +
                b = proc{|x| x % 3 }
         | 
| 98 | 
            +
                a.bottom_by!(3, &b)
         | 
| 99 | 
            +
                assert_equal( [3,3,1], a )
         | 
| 100 | 
            +
              end
         | 
| 101 101 |  | 
| 102 | 
            -
             | 
| 103 | 
            -
             | 
| 104 | 
            -
             | 
| 105 | 
            -
             | 
| 106 | 
            -
             | 
| 107 | 
            -
             | 
| 108 | 
            -
             | 
| 109 | 
            -
             | 
| 110 | 
            -
             | 
| 111 | 
            -
             | 
| 112 | 
            -
             | 
| 113 | 
            -
             | 
| 102 | 
            +
              def test_top_byBANG__noblock
         | 
| 103 | 
            +
                a = [1,3,5,2,4,3]
         | 
| 104 | 
            +
                b = proc{|x| x % 3 }
         | 
| 105 | 
            +
                a.top_by!(3).each(&b)
         | 
| 106 | 
            +
                assert_equal( [5,2,1], a )
         | 
| 107 | 
            +
              end
         | 
| 108 | 
            +
              def test_bottom_byBANG__noblock
         | 
| 109 | 
            +
                a = [3,1,4,3,2,5]
         | 
| 110 | 
            +
                b = proc{|x| x % 3 }
         | 
| 111 | 
            +
                a.bottom_by!(3).each(&b)
         | 
| 112 | 
            +
                assert_equal( [3,3,1], a )
         | 
| 113 | 
            +
              end
         | 
| 114 114 |  | 
| 115 115 | 
             
            end
         | 
| 116 116 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,21 +1,21 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: mug
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.5. | 
| 4 | 
            +
              version: 0.5.4
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Matthew Kerwin
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2016- | 
| 11 | 
            +
            date: 2016-11-01 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies: []
         | 
| 13 13 | 
             
            description: |
         | 
| 14 14 | 
             
              == MUG: Matty's Ultimate Gem
         | 
| 15 15 |  | 
| 16 16 | 
             
              A collection of wonders to astound the mind!!
         | 
| 17 17 |  | 
| 18 | 
            -
              See the documentation at  | 
| 18 | 
            +
              See the documentation at http://phluid61.github.io/mug/
         | 
| 19 19 | 
             
            email:
         | 
| 20 20 | 
             
            - matthew@kerwin.net.au
         | 
| 21 21 | 
             
            executables: []
         | 
| @@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 103 103 | 
             
                  version: '0'
         | 
| 104 104 | 
             
            requirements: []
         | 
| 105 105 | 
             
            rubyforge_project: 
         | 
| 106 | 
            -
            rubygems_version: 2.6. | 
| 106 | 
            +
            rubygems_version: 2.6.7
         | 
| 107 107 | 
             
            signing_key: 
         | 
| 108 108 | 
             
            specification_version: 4
         | 
| 109 109 | 
             
            summary: 'MUG: Matty''s Ultimate Gem'
         |