mug 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/mug.rb +14 -13
- data/lib/mug/and-or.rb +48 -48
- data/lib/mug/apply.rb +58 -58
- data/lib/mug/array.rb +1 -0
- data/lib/mug/array/extend.rb +69 -0
- data/lib/mug/bool.rb +128 -128
- data/lib/mug/fragile-method-chain.rb +70 -70
- data/lib/mug/hash.rb +2 -0
- data/lib/mug/hash/map.rb +100 -0
- data/lib/mug/hash/operations.rb +54 -0
- data/lib/mug/hashmap.rb +2 -100
- data/lib/mug/hashop.rb +2 -54
- data/lib/mug/iterator.rb +2 -2
- data/lib/mug/iterator/for.rb +29 -29
- data/lib/mug/iterator/method.rb +29 -29
- data/lib/mug/iterator_c.rb +44 -44
- data/lib/mug/maybe.rb +59 -59
- data/lib/mug/self.rb +33 -33
- data/lib/mug/tau.rb +44 -44
- data/lib/mug/to_h.rb +48 -44
- data/test/test-and-or.rb +41 -41
- data/test/test-array-extend.rb +67 -0
- data/test/test-bool.rb +70 -70
- data/test/test-fragile-method-chain.rb +65 -65
- data/test/test-hashmap.rb +24 -24
- data/test/test-hashop.rb +62 -62
- data/test/test-iterator-for.rb +18 -18
- data/test/test-iterator-method.rb +18 -18
- data/test/test-maybe.rb +90 -90
- data/test/test-self.rb +13 -13
- data/test/test-tau.rb +22 -22
- data/test/test-to_h.rb +16 -16
- data/test/test_apply.rb +56 -56
- metadata +50 -36
- checksums.yaml +0 -7
data/test/test-tau.rb
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
require 'test/unit'
|
|
2
|
-
require 'bigdecimal'
|
|
3
|
-
require 'bigdecimal/math'
|
|
4
|
-
|
|
5
|
-
$VERBOSE = true
|
|
6
|
-
require_relative '../lib/mug/tau'
|
|
7
|
-
class Test_tau < Test::Unit::TestCase
|
|
8
|
-
def test_math_tau
|
|
9
|
-
# 6.283185307179586..
|
|
10
|
-
assert_equal(Math::TAU, Math::PI*2.0)
|
|
11
|
-
end
|
|
12
|
-
|
|
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
|
-
end
|
|
22
|
-
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'bigdecimal'
|
|
3
|
+
require 'bigdecimal/math'
|
|
4
|
+
|
|
5
|
+
$VERBOSE = true
|
|
6
|
+
require_relative '../lib/mug/tau'
|
|
7
|
+
class Test_tau < Test::Unit::TestCase
|
|
8
|
+
def test_math_tau
|
|
9
|
+
# 6.283185307179586..
|
|
10
|
+
assert_equal(Math::TAU, Math::PI*2.0)
|
|
11
|
+
end
|
|
12
|
+
|
|
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
|
+
end
|
|
22
|
+
|
data/test/test-to_h.rb
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
require 'test/unit'
|
|
2
|
-
|
|
3
|
-
$VERBOSE = true
|
|
4
|
-
$ruby_2_1 = RUBY_VERSION.to_f >= 2.1
|
|
5
|
-
require_relative '../lib/mug/to_h'
|
|
6
|
-
class Test_enum_to_h < Test::Unit::TestCase
|
|
7
|
-
def test_enum_to_h
|
|
8
|
-
assert_equal( {}, [].to_h )
|
|
9
|
-
assert_equal( {1=>nil,2=>nil}, [1,2].to_h ) unless $ruby_2_1
|
|
10
|
-
assert_equal( {1=>nil,2=>nil}, (1..2).to_h ) unless $ruby_2_1
|
|
11
|
-
assert_equal( {1=>2,3=>4}, [[1,2],[3,4]].to_h )
|
|
12
|
-
assert_equal( {1=>4}, [[1,2],[1,4]].to_h )
|
|
13
|
-
assert_raise(ArgumentError) { [[1,2,3]].to_h }
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
|
|
3
|
+
$VERBOSE = true
|
|
4
|
+
$ruby_2_1 = RUBY_VERSION.to_f >= 2.1
|
|
5
|
+
require_relative '../lib/mug/to_h'
|
|
6
|
+
class Test_enum_to_h < Test::Unit::TestCase
|
|
7
|
+
def test_enum_to_h
|
|
8
|
+
assert_equal( {}, [].to_h )
|
|
9
|
+
assert_equal( {1=>nil,2=>nil}, [1,2].to_h ) unless $ruby_2_1
|
|
10
|
+
assert_equal( {1=>nil,2=>nil}, (1..2).to_h ) unless $ruby_2_1
|
|
11
|
+
assert_equal( {1=>2,3=>4}, [[1,2],[3,4]].to_h )
|
|
12
|
+
assert_equal( {1=>4}, [[1,2],[1,4]].to_h )
|
|
13
|
+
assert_raise(ArgumentError) { [[1,2,3]].to_h }
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
data/test/test_apply.rb
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
require 'test/unit'
|
|
2
|
-
$VERBOSE = true
|
|
3
|
-
|
|
4
|
-
class Foo
|
|
5
|
-
def bar a, b
|
|
6
|
-
(a||0) + (b||0)
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
require_relative '../lib/mug/apply'
|
|
11
|
-
class Test_self < Test::Unit::TestCase
|
|
12
|
-
def test_apply_proc
|
|
13
|
-
prc = proc{|a,b,*c| (a||0) + (b||0) + c.inject(0, &:+) }
|
|
14
|
-
p1 = prc.apply(1)
|
|
15
|
-
assert( p1.is_a? Proc )
|
|
16
|
-
assert_equal( 3, p1.apply(2) )
|
|
17
|
-
assert_equal( 3, prc.apply(1,2) )
|
|
18
|
-
assert_equal( 15, prc.apply(1,2,3,4,5) )
|
|
19
|
-
end
|
|
20
|
-
def test_apply_lambda
|
|
21
|
-
lmb = lambda{|a,b,c| (a||0) + (b||0) + (c||0) }
|
|
22
|
-
|
|
23
|
-
l1 = lmb.apply(1)
|
|
24
|
-
assert( l1.is_a? Proc )
|
|
25
|
-
|
|
26
|
-
l2 = l1.apply(2)
|
|
27
|
-
assert( l2.is_a? Proc )
|
|
28
|
-
|
|
29
|
-
assert_equal( 6, l2.apply(3) )
|
|
30
|
-
assert_equal( 6, l1.apply(2,3) )
|
|
31
|
-
|
|
32
|
-
assert_raise( ArgumentError ){ l2.apply(3, 4) }
|
|
33
|
-
assert_raise( ArgumentError ){ lmb.apply(1, 2, 3, 4) }
|
|
34
|
-
end
|
|
35
|
-
def test_apply_method
|
|
36
|
-
m1 = 1.method :+
|
|
37
|
-
assert_equal( 3, m1.apply(2) )
|
|
38
|
-
assert_raise( ArgumentError ){ m1.apply(2,3) }
|
|
39
|
-
|
|
40
|
-
m2 = Foo.new.method :bar
|
|
41
|
-
l1 = m2.apply(1)
|
|
42
|
-
assert( l1.is_a? Proc )
|
|
43
|
-
|
|
44
|
-
assert_equal( 3, l1.apply(2) )
|
|
45
|
-
assert_equal( 3, m2.apply(1,2) )
|
|
46
|
-
|
|
47
|
-
assert_raise( ArgumentError ){ l1.apply(2, 3) }
|
|
48
|
-
assert_raise( ArgumentError ){ m2.apply(1, 2, 3) }
|
|
49
|
-
end
|
|
50
|
-
def test_curry_method
|
|
51
|
-
m1 = 1.method :+
|
|
52
|
-
assert( m1.curry.is_a? Proc )
|
|
53
|
-
assert( m1.curry(1).is_a? Proc )
|
|
54
|
-
assert_raise( ArgumentError ){ m1.curry(2) }
|
|
55
|
-
end
|
|
56
|
-
end
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
$VERBOSE = true
|
|
3
|
+
|
|
4
|
+
class Foo
|
|
5
|
+
def bar a, b
|
|
6
|
+
(a||0) + (b||0)
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
require_relative '../lib/mug/apply'
|
|
11
|
+
class Test_self < Test::Unit::TestCase
|
|
12
|
+
def test_apply_proc
|
|
13
|
+
prc = proc{|a,b,*c| (a||0) + (b||0) + c.inject(0, &:+) }
|
|
14
|
+
p1 = prc.apply(1)
|
|
15
|
+
assert( p1.is_a? Proc )
|
|
16
|
+
assert_equal( 3, p1.apply(2) )
|
|
17
|
+
assert_equal( 3, prc.apply(1,2) )
|
|
18
|
+
assert_equal( 15, prc.apply(1,2,3,4,5) )
|
|
19
|
+
end
|
|
20
|
+
def test_apply_lambda
|
|
21
|
+
lmb = lambda{|a,b,c| (a||0) + (b||0) + (c||0) }
|
|
22
|
+
|
|
23
|
+
l1 = lmb.apply(1)
|
|
24
|
+
assert( l1.is_a? Proc )
|
|
25
|
+
|
|
26
|
+
l2 = l1.apply(2)
|
|
27
|
+
assert( l2.is_a? Proc )
|
|
28
|
+
|
|
29
|
+
assert_equal( 6, l2.apply(3) )
|
|
30
|
+
assert_equal( 6, l1.apply(2,3) )
|
|
31
|
+
|
|
32
|
+
assert_raise( ArgumentError ){ l2.apply(3, 4) }
|
|
33
|
+
assert_raise( ArgumentError ){ lmb.apply(1, 2, 3, 4) }
|
|
34
|
+
end
|
|
35
|
+
def test_apply_method
|
|
36
|
+
m1 = 1.method :+
|
|
37
|
+
assert_equal( 3, m1.apply(2) )
|
|
38
|
+
assert_raise( ArgumentError ){ m1.apply(2,3) }
|
|
39
|
+
|
|
40
|
+
m2 = Foo.new.method :bar
|
|
41
|
+
l1 = m2.apply(1)
|
|
42
|
+
assert( l1.is_a? Proc )
|
|
43
|
+
|
|
44
|
+
assert_equal( 3, l1.apply(2) )
|
|
45
|
+
assert_equal( 3, m2.apply(1,2) )
|
|
46
|
+
|
|
47
|
+
assert_raise( ArgumentError ){ l1.apply(2, 3) }
|
|
48
|
+
assert_raise( ArgumentError ){ m2.apply(1, 2, 3) }
|
|
49
|
+
end
|
|
50
|
+
def test_curry_method
|
|
51
|
+
m1 = 1.method :+
|
|
52
|
+
assert( m1.curry.is_a? Proc )
|
|
53
|
+
assert( m1.curry(1).is_a? Proc )
|
|
54
|
+
assert_raise( ArgumentError ){ m1.curry(2) }
|
|
55
|
+
end
|
|
56
|
+
end
|
metadata
CHANGED
|
@@ -1,86 +1,100 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mug
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
|
+
prerelease:
|
|
5
6
|
platform: ruby
|
|
6
7
|
authors:
|
|
7
8
|
- Matthew Kerwin
|
|
8
9
|
autorequire:
|
|
9
10
|
bindir: bin
|
|
10
11
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
12
|
+
date: 2014-03-14 00:00:00.000000000 Z
|
|
12
13
|
dependencies: []
|
|
13
|
-
description:
|
|
14
|
-
|
|
14
|
+
description: ! '== MUG: Matty''s Ultimate Gem
|
|
15
|
+
|
|
15
16
|
|
|
16
17
|
A collection of wonders to astound the mind!!
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
See the documentation at [github](https://github.com/phluid61/mug).
|
|
21
|
+
|
|
22
|
+
'
|
|
17
23
|
email:
|
|
18
24
|
- matthew@kerwin.net.au
|
|
19
25
|
executables: []
|
|
20
26
|
extensions: []
|
|
21
27
|
extra_rdoc_files: []
|
|
22
28
|
files:
|
|
23
|
-
- lib/mug
|
|
24
|
-
- lib/mug/apply.rb
|
|
25
|
-
- lib/mug/bool.rb
|
|
26
|
-
- lib/mug/fragile-method-chain.rb
|
|
29
|
+
- lib/mug.rb
|
|
27
30
|
- lib/mug/hashmap.rb
|
|
31
|
+
- lib/mug/tau.rb
|
|
32
|
+
- lib/mug/to_h.rb
|
|
33
|
+
- lib/mug/fragile-method-chain.rb
|
|
34
|
+
- lib/mug/hash.rb
|
|
35
|
+
- lib/mug/self.rb
|
|
36
|
+
- lib/mug/iterator.rb
|
|
37
|
+
- lib/mug/and-or.rb
|
|
38
|
+
- lib/mug/hash/operations.rb
|
|
39
|
+
- lib/mug/hash/map.rb
|
|
28
40
|
- lib/mug/hashop.rb
|
|
41
|
+
- lib/mug/apply.rb
|
|
42
|
+
- lib/mug/array.rb
|
|
29
43
|
- lib/mug/iterator/for.rb
|
|
30
44
|
- lib/mug/iterator/method.rb
|
|
31
|
-
- lib/mug/
|
|
32
|
-
- lib/mug/iterator_c.rb
|
|
45
|
+
- lib/mug/array/extend.rb
|
|
33
46
|
- lib/mug/maybe.rb
|
|
34
|
-
- lib/mug/
|
|
35
|
-
- lib/mug/
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
- test/test-and-or.rb
|
|
47
|
+
- lib/mug/iterator_c.rb
|
|
48
|
+
- lib/mug/bool.rb
|
|
49
|
+
- test/test-tau.rb
|
|
50
|
+
- test/test-self.rb
|
|
39
51
|
- test/test-bool.rb
|
|
52
|
+
- test/test_apply.rb
|
|
53
|
+
- test/test-to_h.rb
|
|
54
|
+
- test/test-array-extend.rb
|
|
40
55
|
- test/test-fragile-method-chain.rb
|
|
41
|
-
- test/test-
|
|
42
|
-
- test/test-hashop.rb
|
|
43
|
-
- test/test-iterator-for.rb
|
|
56
|
+
- test/test-and-or.rb
|
|
44
57
|
- test/test-iterator-method.rb
|
|
58
|
+
- test/test-iterator-for.rb
|
|
45
59
|
- test/test-maybe.rb
|
|
46
|
-
- test/test-
|
|
47
|
-
- test/test-
|
|
48
|
-
- test/test-to_h.rb
|
|
49
|
-
- test/test_apply.rb
|
|
60
|
+
- test/test-hashmap.rb
|
|
61
|
+
- test/test-hashop.rb
|
|
50
62
|
homepage: http://phluid61.github.com/mug
|
|
51
63
|
licenses:
|
|
52
64
|
- ISC License
|
|
53
|
-
metadata: {}
|
|
54
65
|
post_install_message:
|
|
55
66
|
rdoc_options: []
|
|
56
67
|
require_paths:
|
|
57
68
|
- lib
|
|
58
69
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
70
|
+
none: false
|
|
59
71
|
requirements:
|
|
60
|
-
- - '>='
|
|
72
|
+
- - ! '>='
|
|
61
73
|
- !ruby/object:Gem::Version
|
|
62
74
|
version: '0'
|
|
63
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
|
+
none: false
|
|
64
77
|
requirements:
|
|
65
|
-
- - '>='
|
|
78
|
+
- - ! '>='
|
|
66
79
|
- !ruby/object:Gem::Version
|
|
67
80
|
version: '0'
|
|
68
81
|
requirements: []
|
|
69
82
|
rubyforge_project:
|
|
70
|
-
rubygems_version:
|
|
83
|
+
rubygems_version: 1.8.23.2
|
|
71
84
|
signing_key:
|
|
72
|
-
specification_version:
|
|
73
|
-
summary: 'MUG: Matty''s Ultimate Gem'
|
|
85
|
+
specification_version: 3
|
|
86
|
+
summary: ! 'MUG: Matty''s Ultimate Gem'
|
|
74
87
|
test_files:
|
|
75
|
-
- test/test-
|
|
88
|
+
- test/test-tau.rb
|
|
89
|
+
- test/test-self.rb
|
|
76
90
|
- test/test-bool.rb
|
|
91
|
+
- test/test_apply.rb
|
|
92
|
+
- test/test-to_h.rb
|
|
93
|
+
- test/test-array-extend.rb
|
|
77
94
|
- test/test-fragile-method-chain.rb
|
|
78
|
-
- test/test-
|
|
79
|
-
- test/test-hashop.rb
|
|
80
|
-
- test/test-iterator-for.rb
|
|
95
|
+
- test/test-and-or.rb
|
|
81
96
|
- test/test-iterator-method.rb
|
|
97
|
+
- test/test-iterator-for.rb
|
|
82
98
|
- test/test-maybe.rb
|
|
83
|
-
- test/test-
|
|
84
|
-
- test/test-
|
|
85
|
-
- test/test-to_h.rb
|
|
86
|
-
- test/test_apply.rb
|
|
99
|
+
- test/test-hashmap.rb
|
|
100
|
+
- test/test-hashop.rb
|
checksums.yaml
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
SHA1:
|
|
3
|
-
metadata.gz: caac6c79133f87c320e088fe7273c80e440a00e1
|
|
4
|
-
data.tar.gz: 25ba29b491cdaf310e65803e854fefd855df6120
|
|
5
|
-
SHA512:
|
|
6
|
-
metadata.gz: 7268ec06de0aff1c765b3e911e577746fbdd17a2c8b198e0c99fcd76a0e46530a4d4829c4b3cde41b5188f916548ec273c00c9c828e705f508d2dabcc241a305
|
|
7
|
-
data.tar.gz: 728948939a043370bd502776f4905387afab60224ccee6b1e03cf1eef96bd4f66ab9cfab3b60921139e7253283091d8fee40f9f1d8259dd09c239f1c3baa2567
|