hash-utils 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
- # (c) 2011 Martin Kozák (martinkozak@martinkozak.net)
2
+ # (c) 2011-2012 Martin Kozák (martinkozak@martinkozak.net)
3
+
4
+ require "hash-utils/object"
3
5
 
4
6
  ##
5
7
  # StringIO extension.
@@ -14,8 +16,10 @@ class StringIO < Data
14
16
  # @since 0.14.0
15
17
  #
16
18
 
17
- def io?
18
- true
19
+ if not self.__hash_utils_instance_respond_to? :io?
20
+ def io?
21
+ true
22
+ end
19
23
  end
20
24
 
21
25
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # (c) 2011 Martin Kozák (martinkozak@martinkozak.net)
2
+ # (c) 2011-2012 Martin Kozák (martinkozak@martinkozak.net)
3
3
 
4
4
  require "hash-utils/object"
5
5
 
@@ -17,8 +17,10 @@ class Symbol
17
17
  # @since 0.12.0
18
18
  #
19
19
 
20
- def *(multi)
21
- (self.to_s * multi).to_sym
20
+ if not self.__hash_utils_instance_respond_to? :*
21
+ def *(multi)
22
+ (self.to_s * multi).to_sym
23
+ end
22
24
  end
23
25
 
24
26
  ##
@@ -30,11 +32,15 @@ class Symbol
30
32
  # @since 0.12.0
31
33
  #
32
34
 
33
- def +(other_str)
34
- (self.to_s + other_str.to_s).to_sym
35
+ if not self.__hash_utils_instance_respond_to? :+
36
+ def +(other_str)
37
+ (self.to_s + other_str.to_s).to_sym
38
+ end
35
39
  end
36
40
 
37
- alias :concat :+
41
+ if not self.__hash_utils_instance_respond_to? :concat
42
+ alias :concat :+
43
+ end
38
44
 
39
45
  ##
40
46
  # Works by the same way as +String#slice on +Symbol+.
@@ -44,11 +50,16 @@ class Symbol
44
50
  # @since 0.12.0
45
51
  #
46
52
 
47
- def [](*args)
48
- self.to_s[*args]
53
+ if not self.__hash_utils_instance_respond_to? :[]
54
+ def [](*args)
55
+ self.to_s[*args]
56
+ end
49
57
  end
50
58
 
51
- alias :slice :[]
59
+
60
+ if not self.__hash_utils_instance_respond_to? :slice
61
+ alias :slice :[]
62
+ end
52
63
 
53
64
  ##
54
65
  # Returns true if +Symbol+ starts with a prefix given.
@@ -58,8 +69,10 @@ class Symbol
58
69
  # @since 0.12.0
59
70
  #
60
71
 
61
- def start_with?(*prefix)
62
- self.to_s.start_with?(*prefix)
72
+ if not self.__hash_utils_instance_respond_to? :start_with?
73
+ def start_with?(*prefix)
74
+ self.to_s.start_with?(*prefix)
75
+ end
63
76
  end
64
77
 
65
78
  ##
@@ -70,8 +83,10 @@ class Symbol
70
83
  # @since 0.12.0
71
84
  #
72
85
 
73
- def end_with?(*suffix)
74
- self.to_s.end_with?(*suffix)
86
+ if not self.__hash_utils_instance_respond_to? :end_with?
87
+ def end_with?(*suffix)
88
+ self.to_s.end_with?(*suffix)
89
+ end
75
90
  end
76
91
 
77
92
  ##
@@ -82,9 +97,11 @@ class Symbol
82
97
  # @since 0.13.0
83
98
  #
84
99
 
85
- def append(string)
86
- (self.to_s << string.to_s).to_sym
87
- end
100
+ if not self.__hash_utils_instance_respond_to? :append
101
+ def append(string)
102
+ (self.to_s << string.to_s).to_sym
103
+ end
104
+ end
88
105
 
89
106
  ##
90
107
  # Puts content to begin of symbol and returns new symbol.
@@ -94,9 +111,11 @@ class Symbol
94
111
  # @since 0.13.0
95
112
  #
96
113
 
97
- def prepend(string)
98
- (string.to_s + self.to_s).to_sym
99
- end
114
+ if not self.__hash_utils_instance_respond_to? :prepend
115
+ def prepend(string)
116
+ (string.to_s + self.to_s).to_sym
117
+ end
118
+ end
100
119
 
101
120
  ##
102
121
  # Splits symbol to more.
@@ -106,9 +125,11 @@ class Symbol
106
125
  # @since 0.15.0
107
126
  #
108
127
 
109
- def split(separator = " ", count = 0)
110
- self.to_s.split(separator, count).map! do |i|
111
- i.to_sym
128
+ if not self.__hash_utils_instance_respond_to? :split
129
+ def split(separator = " ", count = 0)
130
+ self.to_s.split(separator, count).map! do |i|
131
+ i.to_sym
132
+ end
112
133
  end
113
134
  end
114
135
 
@@ -121,8 +142,10 @@ class Symbol
121
142
  # @since 0.17.0
122
143
  #
123
144
 
124
- def strip
125
- self.to_s.strip!.to_sym
145
+ if not self.__hash_utils_instance_respond_to? :strip
146
+ def strip
147
+ self.to_s.strip!.to_sym
148
+ end
126
149
  end
127
150
 
128
151
  end
data/test CHANGED
@@ -52,12 +52,15 @@ context "Array" do
52
52
  end
53
53
  asserts("#clean!") do
54
54
  t = [1, nil]
55
- t.clean(1)
55
+ t.clean!(1)
56
56
  t == [nil]
57
57
  end
58
58
  asserts("#sum") do
59
59
  [1, 2, 3].sum == 6
60
60
  end
61
+ asserts("#to_set") do
62
+ [1, 2, 3].to_set == Set::new([1, 2, 3])
63
+ end
61
64
  end
62
65
 
63
66
  ## FALSECLASS
@@ -316,6 +319,9 @@ context "Object" do
316
319
  asserts("#to_b") do
317
320
  (nil.to_b === false) and ("ab".to_b === true)
318
321
  end
322
+ asserts("#to_sym") do
323
+ (nil.to_sym === :"") and ("ab".to_sym === :ab) and (12.to_sym == :"12")
324
+ end
319
325
  asserts("#true?") do
320
326
  (true.true? == true) and ("string".true? == false)
321
327
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-17 00:00:00.000000000 Z
12
+ date: 2012-03-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby-version
16
- requirement: &19826500 !ruby/object:Gem::Requirement
16
+ requirement: &22439060 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *19826500
24
+ version_requirements: *22439060
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &19825240 !ruby/object:Gem::Requirement
27
+ requirement: &22434460 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,21 +32,21 @@ dependencies:
32
32
  version: 1.0.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *19825240
35
+ version_requirements: *22434460
36
36
  - !ruby/object:Gem::Dependency
37
- name: jeweler
38
- requirement: &19823780 !ruby/object:Gem::Requirement
37
+ name: jeweler2
38
+ requirement: &22431720 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
42
42
  - !ruby/object:Gem::Version
43
- version: 1.5.2
43
+ version: 2.0.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *19823780
46
+ version_requirements: *22431720
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: riot
49
- requirement: &19820080 !ruby/object:Gem::Requirement
49
+ requirement: &22448700 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 0.12.3
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *19820080
57
+ version_requirements: *22448700
58
58
  description:
59
59
  email: martinkozak@martinkozak.net
60
60
  executables: []
@@ -92,13 +92,10 @@ files:
92
92
  homepage: http://github.com/martinkozak/hash-utils
93
93
  licenses:
94
94
  - MIT
95
- post_install_message: ! '
96
-
97
- HASH UTILS: File#write now works non-binary again. Binary writing were moved to
98
- File#binwrite.
99
-
100
-
101
- '
95
+ post_install_message: ! "\nHASH UTILS: The 2.0 version avoids the method overwriting
96
+ conflicts by not performing overwriting of already implemented methods. By this
97
+ way, it can damage your existing applications based on older versions although it's
98
+ very improbable. \n\n"
102
99
  rdoc_options: []
103
100
  require_paths:
104
101
  - lib
@@ -110,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
107
  version: '0'
111
108
  segments:
112
109
  - 0
113
- hash: 2411575543871344535
110
+ hash: -641600196593062307
114
111
  required_rubygems_version: !ruby/object:Gem::Requirement
115
112
  none: false
116
113
  requirements:
@@ -119,11 +116,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
116
  version: '0'
120
117
  requirements: []
121
118
  rubyforge_project:
122
- rubygems_version: 1.8.11
119
+ rubygems_version: 1.8.17
123
120
  signing_key:
124
121
  specification_version: 3
125
122
  summary: Adds more than 125 useful and frequently rather fundamental methods which
126
123
  are missing in Ruby programming language, to Array, File, Hash, Module, Object,
127
124
  String and Symbol classes. It tries to be similar project to Ruby Facets on principle,
128
- but less complex, more practical, non-atomic and organized by better way.
125
+ but less complex, more practical, non-atomic and organized by better way. Thanks
126
+ to defensive and careful patching it should be compatible with all other libraries.
129
127
  test_files: []