mug 0.2.9 → 0.3.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.
@@ -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
@@ -16,6 +16,5 @@ require_relative 'mug/negativity'
16
16
  require_relative 'mug/rexproc'
17
17
  require_relative 'mug/self'
18
18
  require_relative 'mug/tau'
19
- require_relative 'mug/to_h'
20
19
  require_relative 'mug/top'
21
20
 
@@ -13,19 +13,21 @@ class Proc
13
13
  end
14
14
 
15
15
  class Method
16
- #
17
- # Returns a curried proc. If the optional arity argument is given,
18
- # it determines the number of arguments. A curried proc receives
19
- # some arguments. If a sufficient number of arguments are supplied,
20
- # it passes the supplied arguments to the original proc and returns
21
- # the result. Otherwise, returns another curried proc that takes the
22
- # rest of arguments.
23
- #
24
- def curry(n=nil)
25
- if n
26
- to_proc.curry n
27
- else
28
- to_proc.curry
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
 
@@ -46,7 +46,7 @@ class Array
46
46
 
47
47
  # @see #extend!
48
48
  def extend *args, &block
49
- dup.extend! *args, &block
49
+ dup.extend!( *args, &block )
50
50
  end
51
51
 
52
52
  end
@@ -1,12 +1,14 @@
1
1
 
2
2
  class Numeric
3
3
 
4
- def negative?
5
- self < 0 ? self : nil
6
- end
7
-
8
- def positive?
9
- self > 0 ? self : nil
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
- undef :negative?
24
- undef :positive?
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
@@ -1,37 +1,12 @@
1
1
 
2
- if 0.to_enum.respond_to? :to_h
3
- warn %|Warning: "mug/to_h" may conflict with built-in Enumerable#to_h functionality|
4
- end
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) 2013,2014, Matthew Kerwin <matthew@kerwin.net.au>
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
@@ -8,7 +8,7 @@ class Foo
8
8
  end
9
9
 
10
10
  require_relative '../lib/mug/apply'
11
- class Test_self < Test::Unit::TestCase
11
+ class Test_apply < Test::Unit::TestCase
12
12
  def test_apply_proc
13
13
  prc = proc{|a,b,*c| (a||0) + (b||0) + c.inject(0, &:+) }
14
14
  p1 = prc.apply(1)
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.2.9
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-05-14 00:00:00.000000000 Z
11
+ date: 2015-12-10 00:00:00.000000000 Z
13
12
  dependencies: []
14
- description: ! '== MUG: Matty''s Ultimate Gem
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/iterator/for.rb
30
- - lib/mug/iterator/method.rb
31
- - lib/mug/self.rb
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/to_h.rb
36
- - lib/mug/iterator_c.rb
37
- - lib/mug/negativity.rb
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/top.rb
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/array/extend.rb
45
- - lib/mug/hash.rb
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/counts.rb
48
- - lib/mug/clamp.rb
49
- - lib/mug/apply.rb
44
+ - lib/mug/maybe.rb
45
+ - lib/mug/negativity.rb
50
46
  - lib/mug/rexproc.rb
51
- - lib/mug/and-or.rb
47
+ - lib/mug/self.rb
52
48
  - lib/mug/tau.rb
53
- - lib/mug/maybe.rb
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-self.rb
63
- - test/test-counts.rb
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-fragile-method-chain.rb
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 License
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: 1.8.23
89
+ rubygems_version: 2.5.0
96
90
  signing_key:
97
- specification_version: 3
98
- summary: ! 'MUG: Matty''s Ultimate Gem'
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
@@ -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
-