mug 0.6.0 → 0.8.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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mug.rb +1 -0
  3. data/lib/mug/alias.rb +26 -0
  4. data/test/test-alias.rb +36 -0
  5. metadata +26 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '099f5dcdef17223ed727bdb9bbada095e03e50b1'
4
- data.tar.gz: 6fc2e5c009d42588a4f67dc58a70296f901a85da
3
+ metadata.gz: 9842c1c25a062fb45ffa2b2a423085d22ad0fe65
4
+ data.tar.gz: 5d3175507442566932a3abf26299d2416e02edc6
5
5
  SHA512:
6
- metadata.gz: 9ba248b6dd8eb1e107c0b4deeeef20cbc7d0084ef6395b5ddc8cc9a80e17b47f6d27da3b075aedb80b67a1505a26e8051da5c66f40b63d852e74d1882b037e25
7
- data.tar.gz: 31d95dead76d1da9a6bbeec45ecef85260d45f6d651396e2adb4ade8a5a78ff404a77587c6077bbfab5c024152f98a05ed2477e911cf259a650930211bd7a81b
6
+ metadata.gz: 54dbd9e5a2797b30a021e3662ec10658252569aab519d82702e697ed7c48762f141e6e879c8c62de96c72dd269293b39d6f93a7b7884cbc699cc4bbe4f7736c7
7
+ data.tar.gz: 0fab0b208c811fa4635174c60b969a23add8e6804506f3f6af5b81183b35effbdfeeafeb7270b943f8c4735b3092518714ab4cb019cc57c90fd7fefc68123e02
data/lib/mug.rb CHANGED
@@ -1,4 +1,5 @@
1
1
 
2
+ require_relative 'mug/alias'
2
3
  require_relative 'mug/and-or'
3
4
  require_relative 'mug/any-and-all'
4
5
  require_relative 'mug/apply'
data/lib/mug/alias.rb ADDED
@@ -0,0 +1,26 @@
1
+
2
+ class Module
3
+
4
+ def alias_singleton_method new_name, old_name
5
+ singleton_class.class_exec { alias_method new_name, old_name }
6
+ self
7
+ end
8
+ private :alias_singleton_method
9
+
10
+ end
11
+
12
+ =begin
13
+ Copyright (c) 2017, Matthew Kerwin <matthew@kerwin.net.au>
14
+
15
+ Permission to use, copy, modify, and/or distribute this software for any
16
+ purpose with or without fee is hereby granted, provided that the above
17
+ copyright notice and this permission notice appear in all copies.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
20
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
21
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
22
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
23
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
24
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
25
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26
+ =end
@@ -0,0 +1,36 @@
1
+ require 'test/unit'
2
+ $VERBOSE = true
3
+
4
+ class ::DummyClass
5
+ def self.dummy_method
6
+ :ok
7
+ end
8
+ end
9
+
10
+ require_relative '../lib/mug/alias'
11
+ class Test_alias < Test::Unit::TestCase
12
+
13
+ def test_alias
14
+ assert_equal( :ok, ::DummyClass.dummy_method )
15
+ assert_raise(NoMethodError) { ::DummyClass.aliased_method }
16
+
17
+ ::DummyClass.instance_eval do
18
+ alias_singleton_method :aliased_method, :dummy_method
19
+ end
20
+ assert_equal( :ok, ::DummyClass.dummy_method )
21
+ assert_equal( :ok, ::DummyClass.aliased_method )
22
+ end
23
+
24
+ def test_alias_return
25
+ result = ::DummyClass.instance_eval do
26
+ alias_singleton_method :aliased_method2, :dummy_method
27
+ end
28
+ assert_equal( ::DummyClass, result )
29
+ end
30
+
31
+ def test_alias_private
32
+ assert_raise(NoMethodError) { ::DummyClass.alias_singleton_method :aliased_method3, :dummy_method }
33
+ end
34
+
35
+ end
36
+
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.6.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Kerwin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-08 00:00:00.000000000 Z
11
+ date: 2017-05-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  == MUG: Matty's Ultimate Gem
@@ -23,6 +23,7 @@ extensions: []
23
23
  extra_rdoc_files: []
24
24
  files:
25
25
  - lib/mug.rb
26
+ - lib/mug/alias.rb
26
27
  - lib/mug/and-or.rb
27
28
  - lib/mug/any-and-all.rb
28
29
  - lib/mug/apply.rb
@@ -59,6 +60,7 @@ files:
59
60
  - lib/mug/time.rb
60
61
  - lib/mug/to_h.rb
61
62
  - lib/mug/top.rb
63
+ - test/test-alias.rb
62
64
  - test/test-and-or.rb
63
65
  - test/test-any-and-all.rb
64
66
  - test/test-apply.rb
@@ -107,36 +109,37 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
109
  version: '0'
108
110
  requirements: []
109
111
  rubyforge_project:
110
- rubygems_version: 2.6.8
112
+ rubygems_version: 2.6.7
111
113
  signing_key:
112
114
  specification_version: 4
113
115
  summary: 'MUG: Matty''s Ultimate Gem'
114
116
  test_files:
115
- - test/test-fragile-method-chain.rb
116
- - test/test-maybe.rb
117
- - test/test-hashop.rb
118
- - test/test-not.rb
119
- - test/test-loop-with.rb
120
- - test/test-counts.rb
121
- - test/test-array-minus.rb
122
- - test/test-bool.rb
117
+ - test/test-clamp.rb
123
118
  - test/test-rexproc.rb
124
- - test/test-hashmerge.rb
125
- - test/test-array-samples.rb
126
119
  - test/test-tau.rb
127
- - test/test-apply.rb
128
- - test/test-any-and-all.rb
129
- - test/test-clamp.rb
130
- - test/test-iterator-for.rb
120
+ - test/test-matchdata_each.rb
121
+ - test/test-alias.rb
131
122
  - test/test-bittest.rb
132
123
  - test/test-hashwhen.rb
133
- - test/test-negativity.rb
134
124
  - test/test-matchdata_hash.rb
135
- - test/test-self.rb
125
+ - test/test-not.rb
126
+ - test/test-array-extend.rb
127
+ - test/test-iterator-for.rb
128
+ - test/test-top.rb
136
129
  - test/test-and-or.rb
137
- - test/test-hashmap.rb
130
+ - test/test-hashmerge.rb
131
+ - test/test-any-and-all.rb
132
+ - test/test-self.rb
138
133
  - test/test-time.rb
139
- - test/test-matchdata_each.rb
134
+ - test/test-counts.rb
135
+ - test/test-negativity.rb
136
+ - test/test-bool.rb
137
+ - test/test-hashmap.rb
138
+ - test/test-loop-with.rb
139
+ - test/test-maybe.rb
140
+ - test/test-array-samples.rb
141
+ - test/test-hashop.rb
140
142
  - test/test-iterator-method.rb
141
- - test/test-array-extend.rb
142
- - test/test-top.rb
143
+ - test/test-apply.rb
144
+ - test/test-array-minus.rb
145
+ - test/test-fragile-method-chain.rb