mug 0.2.9 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/mug.rb +0 -1
- data/lib/mug/apply.rb +15 -13
- data/lib/mug/array/extend.rb +1 -1
- data/lib/mug/negativity.rb +12 -8
- data/lib/mug/to_h.rb +5 -30
- data/test/{test_apply.rb → test-apply.rb} +1 -1
- metadata +44 -51
- data/test/test-to_h.rb +0 -16
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a680e04d5c29c884b04891e5eb68f49031b5da89
|
4
|
+
data.tar.gz: 66be632c27b4545430f5e933bf650bf162416b65
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bbc20885684541c3a151978abac35a887123da92496e9a0d5ad6e411a744da70a8099e98d5b325dc03de9ea199e78fa665998c092b4a9f115e2d6d80c6bff308
|
7
|
+
data.tar.gz: ac32f2802b3277a2cc70c83320ba08f976d482e95bcef2760743a629016c40d2a392e0461b4634e3d3f046036398e661ef634fab0fcea1ecc5c2b6cacaa4e2eb
|
data/lib/mug.rb
CHANGED
data/lib/mug/apply.rb
CHANGED
@@ -13,19 +13,21 @@ class Proc
|
|
13
13
|
end
|
14
14
|
|
15
15
|
class Method
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
16
|
+
if RUBY_VERSION < '2.2'
|
17
|
+
#
|
18
|
+
# Returns a curried proc. If the optional arity argument is given,
|
19
|
+
# it determines the number of arguments. A curried proc receives
|
20
|
+
# some arguments. If a sufficient number of arguments are supplied,
|
21
|
+
# it passes the supplied arguments to the original proc and returns
|
22
|
+
# the result. Otherwise, returns another curried proc that takes the
|
23
|
+
# rest of arguments.
|
24
|
+
#
|
25
|
+
def curry(n=nil)
|
26
|
+
if n
|
27
|
+
to_proc.curry n
|
28
|
+
else
|
29
|
+
to_proc.curry
|
30
|
+
end
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
data/lib/mug/array/extend.rb
CHANGED
data/lib/mug/negativity.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
|
2
2
|
class Numeric
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
if RUBY_VERSION < '2.3'
|
5
|
+
def negative?
|
6
|
+
self < 0 ? self : nil
|
7
|
+
end
|
8
|
+
|
9
|
+
def positive?
|
10
|
+
self > 0 ? self : nil
|
11
|
+
end
|
10
12
|
end
|
11
13
|
|
12
14
|
def nonnegative?
|
@@ -20,8 +22,10 @@ class Numeric
|
|
20
22
|
end
|
21
23
|
|
22
24
|
class Complex
|
23
|
-
|
24
|
-
|
25
|
+
if RUBY_VERSION < '2.3'
|
26
|
+
undef :negative?
|
27
|
+
undef :positive?
|
28
|
+
end
|
25
29
|
undef :nonnegative?
|
26
30
|
undef :nonpositive?
|
27
31
|
end
|
data/lib/mug/to_h.rb
CHANGED
@@ -1,37 +1,12 @@
|
|
1
1
|
|
2
|
-
if
|
3
|
-
warn %|Warning: "mug/to_h"
|
4
|
-
|
5
|
-
|
6
|
-
unless {}.respond_to? :to_h
|
7
|
-
warn %|Warning: "mug/to_h" does not make much sense without "to_h" (https://rubygems.org/gems/to_h)|
|
8
|
-
end
|
9
|
-
|
10
|
-
module Enumerable
|
11
|
-
#
|
12
|
-
# Converts +enum+ to a Hash.
|
13
|
-
#
|
14
|
-
# Each element of +enum+ must be a single item, or an array of two items.
|
15
|
-
# Duplicate keys are overwritten in order.
|
16
|
-
#
|
17
|
-
# [].to_h #=> {}
|
18
|
-
# [1,2].to_h #=> {1=>nil, 2=>nil}
|
19
|
-
# (1..2).to_h #=> {1=>nil, 2=>nil}
|
20
|
-
# [[1,2],[3,4]].to_h #=> {1=>2, 3=>4}
|
21
|
-
# [[1,2],[1,4]].to_h #=> {1=>4}
|
22
|
-
#
|
23
|
-
def to_h
|
24
|
-
hsh = {}
|
25
|
-
each do |k,v,*x|
|
26
|
-
raise ArgumentError, "invalid number of elements (#{x.length+2} for 1..2)" if x.any?
|
27
|
-
hsh[k] = v
|
28
|
-
end
|
29
|
-
hsh
|
30
|
-
end
|
2
|
+
if {}.respond_to? :to_h
|
3
|
+
warn %|Warning: "mug/to_h" has been removed as it conflicts with core to_h behaviour|
|
4
|
+
else
|
5
|
+
warn %|Warning: "mug/to_h" has been removed; see the "to_h" gem (https://rubygems.org/gems/to_h)|
|
31
6
|
end
|
32
7
|
|
33
8
|
=begin
|
34
|
-
Copyright (c)
|
9
|
+
Copyright (c) 2015, Matthew Kerwin <matthew@kerwin.net.au>
|
35
10
|
|
36
11
|
Permission to use, copy, modify, and/or distribute this software for any
|
37
12
|
purpose with or without fee is hereby granted, provided that the above
|
metadata
CHANGED
@@ -1,101 +1,95 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Matthew Kerwin
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2015-
|
11
|
+
date: 2015-12-10 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
|
-
description:
|
15
|
-
|
13
|
+
description: |
|
14
|
+
== MUG: Matty's Ultimate Gem
|
16
15
|
|
17
16
|
A collection of wonders to astound the mind!!
|
18
17
|
|
19
|
-
|
20
18
|
See the documentation at <https://github.com/phluid61/mug>.
|
21
|
-
|
22
|
-
'
|
23
19
|
email:
|
24
20
|
- matthew@kerwin.net.au
|
25
21
|
executables: []
|
26
22
|
extensions: []
|
27
23
|
extra_rdoc_files: []
|
28
24
|
files:
|
29
|
-
- lib/mug
|
30
|
-
- lib/mug/
|
31
|
-
- lib/mug/
|
32
|
-
- lib/mug/bool.rb
|
33
|
-
- lib/mug/hashop.rb
|
25
|
+
- lib/mug.rb
|
26
|
+
- lib/mug/and-or.rb
|
27
|
+
- lib/mug/apply.rb
|
34
28
|
- lib/mug/array.rb
|
35
|
-
- lib/mug/
|
36
|
-
- lib/mug/
|
37
|
-
- lib/mug/
|
29
|
+
- lib/mug/array/extend.rb
|
30
|
+
- lib/mug/bool.rb
|
31
|
+
- lib/mug/clamp.rb
|
32
|
+
- lib/mug/counts.rb
|
38
33
|
- lib/mug/fragile-method-chain.rb
|
39
|
-
- lib/mug/
|
40
|
-
- lib/mug/iterator.rb
|
41
|
-
- lib/mug/hashmap.rb
|
34
|
+
- lib/mug/hash.rb
|
42
35
|
- lib/mug/hash/map.rb
|
43
36
|
- lib/mug/hash/operations.rb
|
44
|
-
- lib/mug/
|
45
|
-
- lib/mug/
|
37
|
+
- lib/mug/hashmap.rb
|
38
|
+
- lib/mug/hashop.rb
|
39
|
+
- lib/mug/iterator.rb
|
40
|
+
- lib/mug/iterator/for.rb
|
41
|
+
- lib/mug/iterator/method.rb
|
42
|
+
- lib/mug/iterator_c.rb
|
46
43
|
- lib/mug/loop-with.rb
|
47
|
-
- lib/mug/
|
48
|
-
- lib/mug/
|
49
|
-
- lib/mug/apply.rb
|
44
|
+
- lib/mug/maybe.rb
|
45
|
+
- lib/mug/negativity.rb
|
50
46
|
- lib/mug/rexproc.rb
|
51
|
-
- lib/mug/
|
47
|
+
- lib/mug/self.rb
|
52
48
|
- lib/mug/tau.rb
|
53
|
-
- lib/mug/
|
54
|
-
- lib/mug.rb
|
55
|
-
- test/test-clamp.rb
|
56
|
-
- test/test-rexproc.rb
|
57
|
-
- test/test-tau.rb
|
58
|
-
- test/test-array-extend.rb
|
59
|
-
- test/test-iterator-for.rb
|
60
|
-
- test/test-top.rb
|
49
|
+
- lib/mug/to_h.rb
|
50
|
+
- lib/mug/top.rb
|
61
51
|
- test/test-and-or.rb
|
62
|
-
- test/test-
|
63
|
-
- test/test-
|
64
|
-
- test/test-negativity.rb
|
52
|
+
- test/test-apply.rb
|
53
|
+
- test/test-array-extend.rb
|
65
54
|
- test/test-bool.rb
|
55
|
+
- test/test-clamp.rb
|
56
|
+
- test/test-counts.rb
|
57
|
+
- test/test-fragile-method-chain.rb
|
66
58
|
- test/test-hashmap.rb
|
67
|
-
- test/test_apply.rb
|
68
|
-
- test/test-loop-with.rb
|
69
|
-
- test/test-maybe.rb
|
70
|
-
- test/test-to_h.rb
|
71
59
|
- test/test-hashop.rb
|
60
|
+
- test/test-iterator-for.rb
|
72
61
|
- test/test-iterator-method.rb
|
73
|
-
- test/test-
|
62
|
+
- test/test-loop-with.rb
|
63
|
+
- test/test-maybe.rb
|
64
|
+
- test/test-negativity.rb
|
65
|
+
- test/test-rexproc.rb
|
66
|
+
- test/test-self.rb
|
67
|
+
- test/test-tau.rb
|
68
|
+
- test/test-top.rb
|
74
69
|
homepage: http://phluid61.github.com/mug
|
75
70
|
licenses:
|
76
|
-
- ISC
|
71
|
+
- ISC
|
72
|
+
metadata: {}
|
77
73
|
post_install_message:
|
78
74
|
rdoc_options: []
|
79
75
|
require_paths:
|
80
76
|
- lib
|
81
77
|
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
78
|
requirements:
|
84
|
-
- -
|
79
|
+
- - ">="
|
85
80
|
- !ruby/object:Gem::Version
|
86
81
|
version: '0'
|
87
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
-
none: false
|
89
83
|
requirements:
|
90
|
-
- -
|
84
|
+
- - ">="
|
91
85
|
- !ruby/object:Gem::Version
|
92
86
|
version: '0'
|
93
87
|
requirements: []
|
94
88
|
rubyforge_project:
|
95
|
-
rubygems_version:
|
89
|
+
rubygems_version: 2.5.0
|
96
90
|
signing_key:
|
97
|
-
specification_version:
|
98
|
-
summary:
|
91
|
+
specification_version: 4
|
92
|
+
summary: 'MUG: Matty''s Ultimate Gem'
|
99
93
|
test_files:
|
100
94
|
- test/test-clamp.rb
|
101
95
|
- test/test-rexproc.rb
|
@@ -109,10 +103,9 @@ test_files:
|
|
109
103
|
- test/test-negativity.rb
|
110
104
|
- test/test-bool.rb
|
111
105
|
- test/test-hashmap.rb
|
112
|
-
- test/test_apply.rb
|
113
106
|
- test/test-loop-with.rb
|
114
107
|
- test/test-maybe.rb
|
115
|
-
- test/test-to_h.rb
|
116
108
|
- test/test-hashop.rb
|
117
109
|
- test/test-iterator-method.rb
|
110
|
+
- test/test-apply.rb
|
118
111
|
- test/test-fragile-method-chain.rb
|
data/test/test-to_h.rb
DELETED
@@ -1,16 +0,0 @@
|
|
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
|
-
|