mug 0.4.0 → 0.4.1
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/fragile-method-chain.rb +19 -12
- data/lib/mug/matchdata/each.rb +6 -0
- data/lib/mug/matchdata/hash.rb +6 -0
- data/test/test-fragile-method-chain.rb +6 -0
- metadata +18 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1d1008a00d350eb456faeba3099fa1f4ef91319
|
4
|
+
data.tar.gz: a9acb854fcfb95e52f3b057524ee55113c5c424a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1811cbb8b2476aaf45d4d79535788da251b1da359d908d8893e42aae36a68f54807ddbf64794c2704b0ef1560411bd0e1cb55b9beb128ab8bfa9f4bdfc64379c
|
7
|
+
data.tar.gz: 0263bd5cf6aa93bcc181684a8a7b7f1b21fbaede2c1d46de2c015d7064bac723e54ba0a6bbf9a01472d6b4b61fa3b688304de6cd374e6c63e430a20d66779bf9
|
@@ -11,9 +11,9 @@ class FragileMethodChain
|
|
11
11
|
#
|
12
12
|
# Creates a FragileMethodChain which will send its first method to +o+
|
13
13
|
#
|
14
|
-
def initialize o
|
14
|
+
def initialize o, falsy: true
|
15
15
|
@o = o
|
16
|
-
@
|
16
|
+
@falsy = falsy
|
17
17
|
end
|
18
18
|
|
19
19
|
#
|
@@ -23,24 +23,31 @@ class FragileMethodChain
|
|
23
23
|
# returned in the chain, or its end result.
|
24
24
|
#
|
25
25
|
def _!
|
26
|
-
@
|
27
|
-
a,b = x
|
28
|
-
break o unless o
|
29
|
-
o.__send__(*a, &b)
|
30
|
-
end
|
26
|
+
@o
|
31
27
|
end
|
32
28
|
|
33
|
-
#
|
29
|
+
# Delegate the method args/block
|
34
30
|
def method_missing *a, &b #:nodoc:
|
35
|
-
|
31
|
+
if __defer?
|
32
|
+
@o = @o.__send__(*a, &b)
|
33
|
+
end
|
36
34
|
self
|
37
35
|
end
|
38
36
|
|
39
|
-
# Explicitly
|
37
|
+
# Explicitly invoke :_? as a method in the chain.
|
40
38
|
def _? #:nodoc:
|
41
|
-
|
39
|
+
# Unconditionally invoke it, so the eventual _! doesn't fail
|
40
|
+
#if __defer?
|
41
|
+
@o = @o.__send__(:_?)
|
42
|
+
#end
|
42
43
|
self
|
43
44
|
end
|
45
|
+
|
46
|
+
# Return true iff @o is deferable.
|
47
|
+
def __defer?
|
48
|
+
return @o if @falsy
|
49
|
+
! @o.nil?
|
50
|
+
end
|
44
51
|
end
|
45
52
|
|
46
53
|
class Object
|
@@ -53,7 +60,7 @@ class Object
|
|
53
60
|
end
|
54
61
|
|
55
62
|
=begin
|
56
|
-
Copyright (c) 2013, Matthew Kerwin <matthew@kerwin.net.au>
|
63
|
+
Copyright (c) 2013,2016, Matthew Kerwin <matthew@kerwin.net.au>
|
57
64
|
|
58
65
|
Permission to use, copy, modify, and/or distribute this software for any
|
59
66
|
purpose with or without fee is hereby granted, provided that the above
|
data/lib/mug/matchdata/each.rb
CHANGED
@@ -54,6 +54,12 @@ Permission to use, copy, modify, and/or distribute this software for any
|
|
54
54
|
purpose with or without fee is hereby granted, provided that the above
|
55
55
|
copyright notice and this permission notice appear in all copies.
|
56
56
|
|
57
|
+
Additional license is granted to the Ruby Core Team to use this software
|
58
|
+
in the ruby core or ruby standard libraries without including the above
|
59
|
+
copyright notice nor this permission notice. Subsequently, such a copy
|
60
|
+
of this software becomes wholly subject to the relevant licensing terms
|
61
|
+
of the ruby core or ruby standard libraries.
|
62
|
+
|
57
63
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
58
64
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
59
65
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
data/lib/mug/matchdata/hash.rb
CHANGED
@@ -40,6 +40,12 @@ Permission to use, copy, modify, and/or distribute this software for any
|
|
40
40
|
purpose with or without fee is hereby granted, provided that the above
|
41
41
|
copyright notice and this permission notice appear in all copies.
|
42
42
|
|
43
|
+
Additional license is granted to the Ruby Core Team to use this software
|
44
|
+
in the ruby core or ruby standard libraries without including the above
|
45
|
+
copyright notice nor this permission notice. Subsequently, such a copy
|
46
|
+
of this software becomes wholly subject to the relevant licensing terms
|
47
|
+
of the ruby core or ruby standard libraries.
|
48
|
+
|
43
49
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
44
50
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
45
51
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
@@ -60,6 +60,12 @@ class Test_fmc < Test::Unit::TestCase
|
|
60
60
|
def test_fmc_nested
|
61
61
|
a = FMCTest::A.new
|
62
62
|
assert_equal( 1, a._?.b._?.c._!.to_i._! )
|
63
|
+
a.b.c = false
|
64
|
+
assert_equal( false, a._?.b._?.c._!.to_i._! )
|
65
|
+
a.b = false
|
66
|
+
assert_equal( false, a._?.b._?.c._!.to_i._! )
|
67
|
+
a = false
|
68
|
+
assert_equal( false, a._?.b._?.c._!.to_i._! )
|
63
69
|
end
|
64
70
|
end
|
65
71
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
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-01-
|
11
|
+
date: 2016-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
== MUG: Matty's Ultimate Gem
|
@@ -93,29 +93,29 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
95
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.5
|
96
|
+
rubygems_version: 2.4.5
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: 'MUG: Matty''s Ultimate Gem'
|
100
100
|
test_files:
|
101
|
-
- test/test-
|
101
|
+
- test/test-fragile-method-chain.rb
|
102
|
+
- test/test-maybe.rb
|
103
|
+
- test/test-hashop.rb
|
104
|
+
- test/test-loop-with.rb
|
105
|
+
- test/test-counts.rb
|
106
|
+
- test/test-array-minus.rb
|
107
|
+
- test/test-bool.rb
|
102
108
|
- test/test-rexproc.rb
|
103
109
|
- test/test-tau.rb
|
104
|
-
- test/test-
|
105
|
-
- test/test-
|
106
|
-
- test/test-array-extend.rb
|
110
|
+
- test/test-apply.rb
|
111
|
+
- test/test-clamp.rb
|
107
112
|
- test/test-iterator-for.rb
|
108
|
-
- test/test-top.rb
|
109
|
-
- test/test-and-or.rb
|
110
|
-
- test/test-self.rb
|
111
|
-
- test/test-counts.rb
|
112
113
|
- test/test-negativity.rb
|
113
|
-
- test/test-
|
114
|
+
- test/test-matchdata_hash.rb
|
115
|
+
- test/test-self.rb
|
116
|
+
- test/test-and-or.rb
|
114
117
|
- test/test-hashmap.rb
|
115
|
-
- test/test-
|
116
|
-
- test/test-maybe.rb
|
117
|
-
- test/test-hashop.rb
|
118
|
+
- test/test-matchdata_each.rb
|
118
119
|
- test/test-iterator-method.rb
|
119
|
-
- test/test-
|
120
|
-
- test/test-
|
121
|
-
- test/test-fragile-method-chain.rb
|
120
|
+
- test/test-array-extend.rb
|
121
|
+
- test/test-top.rb
|