hash-utils 0.18.0 → 0.18.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +117 -0
- data/Gemfile.lock +2 -2
- data/LICENSE.txt +1 -1
- data/TODO.txt +0 -2
- data/VERSION +1 -1
- data/hash-utils.gemspec +4 -3
- data/lib/hash-utils/object.rb +6 -6
- data/lib/hash-utils/string.rb +40 -2
- data/test +14 -2
- metadata +5 -4
data/CHANGES.txt
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
|
2
|
+
0.18.1 (2011-08-22)
|
3
|
+
* String: #interlace, #interlace!
|
4
|
+
* Object#instance_of_any? and #kind_of_any? receives both class or
|
5
|
+
array of classes
|
6
|
+
* bug fix in String#unshift
|
7
|
+
|
8
|
+
0.18.0 (2011-07-13)
|
9
|
+
* Object: #proc?
|
10
|
+
* Proc: #proc?
|
11
|
+
* String: #swap_with, #cut!
|
12
|
+
* minor optimizations
|
13
|
+
|
14
|
+
0.17.1 (2011-06-24)
|
15
|
+
* Gem: #available?, #require_available
|
16
|
+
|
17
|
+
0.17.0 (2011-06-24)
|
18
|
+
* Numeric: #number?
|
19
|
+
* String: #string?
|
20
|
+
* Object: #string?, #symbol?, #number?, #boolean?, #array?, #hash?
|
21
|
+
* Symbol: #strip
|
22
|
+
* TrueClass: #boolean?, #false?, #true?
|
23
|
+
* FalseClass: #boolean?, #false?, #true?
|
24
|
+
* Hash: #hash?
|
25
|
+
* Array: #array?
|
26
|
+
|
27
|
+
0.16.0 (2011-06-23)
|
28
|
+
* Numeric: #compare, #positive?, #negative?, #negative!, #positive!
|
29
|
+
* Object: #instance_of_any?, #kind_of_any?
|
30
|
+
|
31
|
+
0.15.0 (2011-05-30)
|
32
|
+
* Hash#keys_to_sym now converts only strings
|
33
|
+
* Hash#to_h bug correction
|
34
|
+
* Hash#all? removed in favour built-in one
|
35
|
+
* Hash: #get, #get_items, #get_values
|
36
|
+
* Symbol: #split
|
37
|
+
* Array: #first, #second, #third, #fourth, #fifth, #sixth,
|
38
|
+
#seventh, #eigtht
|
39
|
+
* String: #ucfirst, #ucfirst!, #lcfirst, #lcfirst!, #first, #second,
|
40
|
+
#third, #fourth, #fifth, #sixth, #seventh, #eigtht
|
41
|
+
* Object: #true?, #false?
|
42
|
+
|
43
|
+
0.14.0 (2011-03-25)
|
44
|
+
* Object: #io?
|
45
|
+
* IO: #io?
|
46
|
+
* StringIO: #io?
|
47
|
+
|
48
|
+
0.13.1 (2011-03-24)
|
49
|
+
* Symbol: #append, #prepend
|
50
|
+
* Module: #get_module
|
51
|
+
* bug in Hash#deep_merge corrected
|
52
|
+
|
53
|
+
0.12.0 (2011-03-20)
|
54
|
+
* String: #first_lines, #first_line, #last_lines, #last_line,
|
55
|
+
#shift_lines, #shift_line, #unshift_lines, #unshift_line, #pop_lines,
|
56
|
+
#pop_line, #push_lines, #push_line, #push, #pop, #shift, #unshift
|
57
|
+
* Hash: #deep_merge, #deep_merge!, #compact, #compact!
|
58
|
+
* Object: #**
|
59
|
+
* Symbol: #*, #+, #[], #start_with?, #end_with?
|
60
|
+
|
61
|
+
0.11.1 (2011-03-09)
|
62
|
+
* binary mode support for File#write
|
63
|
+
|
64
|
+
0.11.0 (2011-03-01)
|
65
|
+
* File: #write, #touch
|
66
|
+
* String: #first, #last
|
67
|
+
* Hash: #map_values, #map_values!
|
68
|
+
|
69
|
+
0.10.0 (2011-02-22)
|
70
|
+
* overimplemented built-in methods removed
|
71
|
+
* Array: #merge!
|
72
|
+
* Hash: #combine
|
73
|
+
|
74
|
+
0.9.0 (2011-02-21)
|
75
|
+
* minor documentation corrections
|
76
|
+
* Hash: #has_all?, #has_some?
|
77
|
+
|
78
|
+
0.8.0 (2011-02-13)
|
79
|
+
* #in? method moved to Object class
|
80
|
+
* more efficient strigng to array conversion
|
81
|
+
* minor bug in central includer corrected
|
82
|
+
* String: #gsub_f, #gsub_f!
|
83
|
+
|
84
|
+
0.7.0 (2011-02-10)
|
85
|
+
* more efficient String#map
|
86
|
+
* Object: #to_b
|
87
|
+
|
88
|
+
0.6.0 (2011-02-09)
|
89
|
+
* String: #to_a, #map, #map!
|
90
|
+
|
91
|
+
0.5.0 (2011-02-08)
|
92
|
+
* Hash: #sort!, #ksort, #ksort!, #asort, #asort!, #reverse, #reverse!
|
93
|
+
|
94
|
+
0.4.1 (2011-01-27)
|
95
|
+
* String#tr -> String#strtr
|
96
|
+
|
97
|
+
0.4.0 (2011-01-27)
|
98
|
+
* String: #tr, #tr!
|
99
|
+
* Array: #to_h
|
100
|
+
* Hash: #to_h
|
101
|
+
* documentation typo changes
|
102
|
+
|
103
|
+
0.3.1 (2011-01-20)
|
104
|
+
* minor documentation corrections
|
105
|
+
|
106
|
+
0.3.0 (2011-01-12)
|
107
|
+
* extensions splitted to standalone files
|
108
|
+
* Hash: #define, #create, #recreate, #remove!
|
109
|
+
* Array: #remove!
|
110
|
+
* String: #numeric?
|
111
|
+
|
112
|
+
0.2.0 (2011-01-04)
|
113
|
+
* Hash: #some?, #all?
|
114
|
+
* Array: #some?, #all?
|
115
|
+
|
116
|
+
0.1.0 (2011-01-02)
|
117
|
+
* initial version
|
data/Gemfile.lock
CHANGED
data/LICENSE.txt
CHANGED
data/TODO.txt
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.18.
|
1
|
+
0.18.1
|
data/hash-utils.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{hash-utils}
|
8
|
-
s.version = "0.18.
|
8
|
+
s.version = "0.18.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{Martin Kozák}]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-08-22}
|
13
13
|
s.email = %q{martinkozak@martinkozak.net}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE.txt",
|
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
]
|
18
18
|
s.files = [
|
19
19
|
".document",
|
20
|
+
"CHANGES.txt",
|
20
21
|
"Gemfile",
|
21
22
|
"Gemfile.lock",
|
22
23
|
"LICENSE.txt",
|
@@ -48,7 +49,7 @@ HASH UTILS: Some methods are optimized at Ruby 1.8.7 and 1.9 or higher, but this
|
|
48
49
|
|
49
50
|
}
|
50
51
|
s.require_paths = [%q{lib}]
|
51
|
-
s.rubygems_version = %q{1.8.
|
52
|
+
s.rubygems_version = %q{1.8.8}
|
52
53
|
s.summary = %q{Adds more than 125 useful and frequently rather fundamental methods which are missing in Ruby programming language, to Array, File, Hash, Module, Object, String and Symbol classes. It tries to be similar project to Ruby Facets on principle, but less complex, more practical, non-atomic and organized by better way.}
|
53
54
|
|
54
55
|
if s.respond_to? :specification_version then
|
data/lib/hash-utils/object.rb
CHANGED
@@ -16,9 +16,9 @@ class Object
|
|
16
16
|
# @since 0.16.0
|
17
17
|
#
|
18
18
|
|
19
|
-
def instance_of_any?(classes)
|
20
|
-
if
|
21
|
-
|
19
|
+
def instance_of_any?(*classes)
|
20
|
+
if classes.first.array?
|
21
|
+
classes = classes.first
|
22
22
|
end
|
23
23
|
|
24
24
|
classes.each do |cls|
|
@@ -40,9 +40,9 @@ class Object
|
|
40
40
|
# @since 0.16.0
|
41
41
|
#
|
42
42
|
|
43
|
-
def kind_of_any?(classes)
|
44
|
-
if
|
45
|
-
|
43
|
+
def kind_of_any?(*classes)
|
44
|
+
if classes.first.array?
|
45
|
+
classes = classes.first
|
46
46
|
end
|
47
47
|
|
48
48
|
classes.each do |cls|
|
data/lib/hash-utils/string.rb
CHANGED
@@ -17,6 +17,12 @@ class String
|
|
17
17
|
|
18
18
|
NUMERIC = /^\s*-?\d+(?:\.\d+)?\s*$/
|
19
19
|
|
20
|
+
##
|
21
|
+
# Holds character interlacing matcher.
|
22
|
+
#
|
23
|
+
|
24
|
+
INTERLACING = /(.)([^$])/
|
25
|
+
|
20
26
|
##
|
21
27
|
# Indicates, string is numeric, so consists of numbers only.
|
22
28
|
#
|
@@ -515,7 +521,7 @@ class String
|
|
515
521
|
#
|
516
522
|
|
517
523
|
def unshift(string)
|
518
|
-
self.replace(string
|
524
|
+
self.replace(string + self)
|
519
525
|
end
|
520
526
|
|
521
527
|
alias :prepend :unshift
|
@@ -600,7 +606,7 @@ class String
|
|
600
606
|
alias :"swap_with!" :swap_with
|
601
607
|
|
602
608
|
##
|
603
|
-
# Cuts string
|
609
|
+
# Cuts string in place. Sets the content of #[] on place of
|
604
610
|
# the string.
|
605
611
|
#
|
606
612
|
# @param [Range] range range with from and to limits
|
@@ -611,6 +617,38 @@ class String
|
|
611
617
|
def cut!(range)
|
612
618
|
self.replace(self[range])
|
613
619
|
end
|
620
|
+
|
621
|
+
##
|
622
|
+
# Performs string interlacing. It means, it inserts given string
|
623
|
+
# between characters of the string.
|
624
|
+
#
|
625
|
+
# @example
|
626
|
+
# "abc".interlace("123") # will return "a123b123c"
|
627
|
+
#
|
628
|
+
# @param [String] string string which will interlaced to
|
629
|
+
# @return [String] new interlaced string
|
630
|
+
# @since 0.19.0
|
631
|
+
#
|
632
|
+
|
633
|
+
public
|
634
|
+
def interlace(string)
|
635
|
+
self.gsub(self.class::INTERLACING, '\1' << string << '\2' << string)
|
636
|
+
end
|
637
|
+
|
638
|
+
##
|
639
|
+
# Performs string interlacing in place.
|
640
|
+
#
|
641
|
+
# @param [String] string string which will interlaced to
|
642
|
+
# @return [String] itself
|
643
|
+
# @see #interlace
|
644
|
+
# @since 0.19.0
|
645
|
+
#
|
646
|
+
|
647
|
+
public
|
648
|
+
def interlace!(string)
|
649
|
+
self.gsub!(self.class::INTERLACING, '\1' << string << '\2' << string)
|
650
|
+
self
|
651
|
+
end
|
614
652
|
|
615
653
|
|
616
654
|
private
|
data/test
CHANGED
@@ -254,13 +254,17 @@ context "Object" do
|
|
254
254
|
5.in? 1..7 and not 9.in? 1..7
|
255
255
|
end
|
256
256
|
asserts("#instance_of_any?") do
|
257
|
-
"".instance_of_any? [String, Symbol]
|
257
|
+
"".instance_of_any? [String, Symbol] \
|
258
|
+
and not "".instance_of_any? [Integer, Float] \
|
259
|
+
and "".instance_of_any? String, Symbol
|
258
260
|
end
|
259
261
|
asserts("#io?") do
|
260
262
|
not "".io?
|
261
263
|
end
|
262
264
|
asserts("#kind_of_any?") do
|
263
|
-
"".kind_of_any? [String, Symbol]
|
265
|
+
"".kind_of_any? [String, Symbol] \
|
266
|
+
and not "".kind_of_any? [Integer, Float] \
|
267
|
+
and "".kind_of_any? String, Symbol
|
264
268
|
end
|
265
269
|
asserts("#number?") do
|
266
270
|
not :abcd.number? and 5.number?
|
@@ -325,6 +329,14 @@ context "String" do
|
|
325
329
|
res &= "a\nb".first_lines(2) == ["a\n", "b"]
|
326
330
|
res &= "a\nb\nc\n".first_lines(4) == ["a\n", "b\n", "c\n"]
|
327
331
|
end
|
332
|
+
asserts("#interlace") do
|
333
|
+
"abc".interlace("123") == "a123b123c"
|
334
|
+
end
|
335
|
+
asserts("#interlace!") do
|
336
|
+
foo = "abc"
|
337
|
+
foo.interlace! "123"
|
338
|
+
foo == "a123b123c"
|
339
|
+
end
|
328
340
|
asserts("#last") do
|
329
341
|
"abc".last == ?c
|
330
342
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: hash-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.18.
|
5
|
+
version: 0.18.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- "Martin Koz\xC3\xA1k"
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-08-22 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -56,6 +56,7 @@ extra_rdoc_files:
|
|
56
56
|
- README.md
|
57
57
|
files:
|
58
58
|
- .document
|
59
|
+
- CHANGES.txt
|
59
60
|
- Gemfile
|
60
61
|
- Gemfile.lock
|
61
62
|
- LICENSE.txt
|
@@ -93,7 +94,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
94
|
requirements:
|
94
95
|
- - ">="
|
95
96
|
- !ruby/object:Gem::Version
|
96
|
-
hash:
|
97
|
+
hash: 1233012443660528982
|
97
98
|
segments:
|
98
99
|
- 0
|
99
100
|
version: "0"
|
@@ -106,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
107
|
requirements: []
|
107
108
|
|
108
109
|
rubyforge_project:
|
109
|
-
rubygems_version: 1.8.
|
110
|
+
rubygems_version: 1.8.8
|
110
111
|
signing_key:
|
111
112
|
specification_version: 3
|
112
113
|
summary: Adds more than 125 useful and frequently rather fundamental methods which are missing in Ruby programming language, to Array, File, Hash, Module, Object, String and Symbol classes. It tries to be similar project to Ruby Facets on principle, but less complex, more practical, non-atomic and organized by better way.
|