mug 0.11.0 → 0.12.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2538a79aa41d8fc9c2d9853158e0eaf462304ca9
4
- data.tar.gz: 880a095ca3389180799b05451ffa3a88c86534b1
3
+ metadata.gz: ff9a23393c4c09db649abf58fa24b9e2dabcf1ff
4
+ data.tar.gz: e6b0b9b20a8997b0e4e90f4c1248eed93083b74c
5
5
  SHA512:
6
- metadata.gz: 1d83d1d967f680d5ed16c9c9c638b08001a924ec57d6d674ad11f64a6dbc40b3babac8077a3a0b6dda60d9b087f20b789e8693a8780e7fb894fc8cf0033d82c4
7
- data.tar.gz: 7b5731f832521b813e6fec5ad79e859f401faabebfac142b518e7bea8129e9a7154b7db6509bb5b9f23a1da1e19e252a9ec17e2fadd9169caf7ecd4f58f67b7d
6
+ metadata.gz: 85e858d8ca69133e1a5aa15526dcf3278233340314c0240d4c6e4ff48a49030f9e17977b531985d1a0d8b7b5125de03caea8ec65337aff39eb5bada3cc3a51dd
7
+ data.tar.gz: 3611a88d38acbfbfbefc03d99398b1b695636d51f7c13505448d79820c589cd5dcb595f5bee2b8abe372fd4f4d861698d92d7f8aff5e75dd01d4cc19c382bd2b
data/lib/mug.rb CHANGED
@@ -7,6 +7,7 @@ require_relative 'mug/array/delete_all'
7
7
  require_relative 'mug/array/extend'
8
8
  require_relative 'mug/array/minus'
9
9
  require_relative 'mug/array/samples'
10
+ require_relative 'mug/array/to_proc'
10
11
  require_relative 'mug/bool'
11
12
  require_relative 'mug/bittest'
12
13
  require_relative 'mug/clamp'
data/lib/mug/array.rb CHANGED
@@ -2,3 +2,4 @@ require_relative 'array/delete_all'
2
2
  require_relative 'array/extend'
3
3
  require_relative 'array/minus'
4
4
  require_relative 'array/samples'
5
+ require_relative 'array/to_proc'
@@ -0,0 +1,30 @@
1
+
2
+ class Array
3
+
4
+ #
5
+ # Returns a Proc that accepts a single argument.
6
+ #
7
+ # The Proc's parameter is used as an index into this array.
8
+ #
9
+ def to_proc
10
+ proc {|i| self[i] }
11
+ end
12
+
13
+ end
14
+
15
+ =begin
16
+ Copyright (c) 2017, Matthew Kerwin <matthew@kerwin.net.au>
17
+
18
+ Permission to use, copy, modify, and/or distribute this software for any
19
+ purpose with or without fee is hereby granted, provided that the above
20
+ copyright notice and this permission notice appear in all copies.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
23
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
24
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
25
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
26
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
27
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
28
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
29
+ =end
30
+
@@ -0,0 +1,16 @@
1
+ require 'test/unit'
2
+ $VERBOSE = true
3
+
4
+ require_relative '../lib/mug/array/to_proc'
5
+ class Test_array_to_proc < Test::Unit::TestCase
6
+ def test_to_proc
7
+ a = [:a, :b, :c]
8
+ p = a.to_proc
9
+ assert_equal( p[0], a[0] )
10
+ assert_equal( p[3], a[3] )
11
+ assert_equal( p[-1], a[-1] )
12
+ assert_equal( p[0..-1], a )
13
+ assert_raise(TypeError) { p['not-a-number'] }
14
+ end
15
+ end
16
+
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.11.0
4
+ version: 0.12.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-08-21 00:00:00.000000000 Z
11
+ date: 2017-10-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  == MUG: Matty's Ultimate Gem
@@ -32,6 +32,7 @@ files:
32
32
  - lib/mug/array/extend.rb
33
33
  - lib/mug/array/minus.rb
34
34
  - lib/mug/array/samples.rb
35
+ - lib/mug/array/to_proc.rb
35
36
  - lib/mug/bittest.rb
36
37
  - lib/mug/bool.rb
37
38
  - lib/mug/clamp.rb
@@ -69,6 +70,7 @@ files:
69
70
  - test/test-array-extend.rb
70
71
  - test/test-array-minus.rb
71
72
  - test/test-array-samples.rb
73
+ - test/test-array-to_proc.rb
72
74
  - test/test-bittest.rb
73
75
  - test/test-bool.rb
74
76
  - test/test-clamp.rb
@@ -111,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
113
  version: '0'
112
114
  requirements: []
113
115
  rubyforge_project:
114
- rubygems_version: 2.6.7
116
+ rubygems_version: 2.6.13
115
117
  signing_key:
116
118
  specification_version: 4
117
119
  summary: 'MUG: Matty''s Ultimate Gem'
@@ -130,6 +132,7 @@ test_files:
130
132
  - test/test-iterator-for.rb
131
133
  - test/test-top.rb
132
134
  - test/test-and-or.rb
135
+ - test/test-array-to_proc.rb
133
136
  - test/test-hashmerge.rb
134
137
  - test/test-any-and-all.rb
135
138
  - test/test-self.rb