mpatch 2.8.1 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/examples/array.rb +18 -0
- data/lib/mpatch/array.rb +17 -1
- data/test/test.rb +1 -29
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0777613055d38431a72ccfb7b0ff1691cdec65a1
|
4
|
+
data.tar.gz: b9d3d3b92578dd730ba5fb56c882ff8bda44619b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4facd8f4c5dfd1c18f48ed363d84192c14e9cd9863015c2d9a60ea268e96a1c8e79e2b5c94cae3d0938267ea0f83d7a64fd862d83b23ed24a5725e1828c086d
|
7
|
+
data.tar.gz: b9a51fd5843ea09ca99c25515086cf486e1d09cc9ff1ff186a50d30982be90a8fd43e63cde5fade3e293595f2e7b649c51f3020b5e7a63d695e1af713acc416e
|
data/VERSION
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
2.
|
1
|
+
2.9.0
|
2
2
|
|
data/examples/array.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
require_relative '../lib/mpatch/array'
|
3
|
+
MPatch.patch!
|
4
|
+
|
5
|
+
asd= [1,2,3,4,5]
|
6
|
+
|
7
|
+
puts asd.inspect
|
8
|
+
|
9
|
+
puts asd.skip.inspect
|
10
|
+
puts asd.inspect
|
11
|
+
asd.skip!.inspect
|
12
|
+
puts asd.inspect
|
13
|
+
|
14
|
+
puts asd.pinch.inspect
|
15
|
+
puts asd.inspect
|
16
|
+
|
17
|
+
asd.pinch!.inspect
|
18
|
+
puts asd.inspect
|
data/lib/mpatch/array.rb
CHANGED
@@ -11,7 +11,7 @@ module MPatch
|
|
11
11
|
args.dup.each do |one_element|
|
12
12
|
if one_element.class <= ::Array
|
13
13
|
args.delete_at(args.index(one_element))
|
14
|
-
args
|
14
|
+
args += one_element
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -38,18 +38,34 @@ module MPatch
|
|
38
38
|
# remove n. element from the end
|
39
39
|
# and return a new object
|
40
40
|
def pinch n=1
|
41
|
+
raise(ArgumentError) unless n.class <= Integer
|
41
42
|
return self[0..(self.count-(n+1))]
|
42
43
|
end
|
43
44
|
|
44
45
|
# remove n. element from the end
|
45
46
|
# and return the original object
|
46
47
|
def pinch! n=1
|
48
|
+
raise(ArgumentError) unless n.class <= Integer
|
47
49
|
n.times do
|
48
50
|
self.pop
|
49
51
|
end
|
50
52
|
return self
|
51
53
|
end
|
52
54
|
|
55
|
+
# shifted first element and return new array
|
56
|
+
def skip n=1
|
57
|
+
raise(ArgumentError) unless n.class <= Integer
|
58
|
+
self[1 .. (n*(-1))]
|
59
|
+
end
|
60
|
+
|
61
|
+
def skip! n=1
|
62
|
+
raise(ArgumentError) unless n.class <= Integer
|
63
|
+
n.times do
|
64
|
+
self.shift
|
65
|
+
end
|
66
|
+
return self
|
67
|
+
end
|
68
|
+
|
53
69
|
# return boolean by other array
|
54
70
|
# all element included or
|
55
71
|
# not in the target array
|
data/test/test.rb
CHANGED
@@ -1,32 +1,4 @@
|
|
1
1
|
|
2
|
-
require_relative '../lib/mpatch/
|
2
|
+
require_relative '../lib/mpatch/array'
|
3
3
|
MPatch.patch!
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
try { hello world }
|
8
|
-
catch{ "not hello world " }
|
9
|
-
#> "not hello world"
|
10
|
-
|
11
|
-
|
12
|
-
try { "hello world".asdaf }
|
13
|
-
catch( NoMethodError ) { |ex|
|
14
|
-
puts "there is and error, because #{ex}"
|
15
|
-
}
|
16
|
-
|
17
|
-
#> you can cain up multiple catch for specific error
|
18
|
-
try { "hello world".asdaf }
|
19
|
-
catch( NoMethodError ) { |ex|
|
20
|
-
puts "there is and error, because #{ex}"
|
21
|
-
}
|
22
|
-
|
23
|
-
try { "hello world".asdaf }
|
24
|
-
catch(ArgumentError) {
|
25
|
-
puts "it was and argument error"
|
26
|
-
}
|
27
|
-
|
28
|
-
catch( NoMethodError ) { |ex|
|
29
|
-
puts "bla bla #{ex}"
|
30
|
-
}
|
31
|
-
|
32
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mpatch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This is a collection of my Ruby monkey patches for making easer to use
|
14
14
|
the basic classes
|
@@ -24,6 +24,7 @@ files:
|
|
24
24
|
- VERSION
|
25
25
|
- create_folder.rb
|
26
26
|
- dump/class_and_module.rb
|
27
|
+
- examples/array.rb
|
27
28
|
- examples/privatize.rb
|
28
29
|
- examples/test.rb
|
29
30
|
- files.rb
|