hash-utils 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,16 @@
1
+ script: "rake test"
2
+ rvm:
3
+ - 1.9.3
4
+ - 1.9.2
5
+ - jruby-18mode
6
+ - jruby-19mode
7
+ - rbx-18mode
8
+ - rbx-19mode
9
+ - ruby-head
10
+ - jruby-head
11
+ - 1.8.7
12
+ - ree
13
+ jdk:
14
+ - openjdk7
15
+ - oraclejdk7
16
+ - openjdk6
@@ -1,4 +1,10 @@
1
1
 
2
+ 2.0.2 (2012-10-06)
3
+ * String: #first compatiblity problem with 1.8 fixed
4
+ * StringIO: compatiblity problem with Rubinius 1.9 fixed
5
+ * RSpec tests
6
+ * Travis CI integration
7
+
2
8
  2.0.1 (2012-08-26)
3
9
  * Object: #enumerable?
4
10
  * Hash: #flip, #flip!
data/Gemfile CHANGED
@@ -1,12 +1,14 @@
1
1
  source "http://rubygems.org"
2
2
  # Add dependencies required to use your gem here.
3
3
  # Example:
4
- gem "ruby-version", ">= 0"
4
+ gem "ruby-version", ">= 0.4.0"
5
5
 
6
6
  # Add dependencies to develop your gem here.
7
7
  # Include everything needed to run rake, tests, features, etc.
8
8
  group :development do
9
- gem "bundler", ">= 1.0.0"
10
- gem "jeweler2", ">= 2.0.0"
11
- gem "riot", ">= 0.12.3"
9
+ gem "bundler"
10
+ gem "jeweler"
11
+ gem "rake"
12
+ gem "rspec"
13
+ gem "simplecov"
12
14
  end
@@ -1,19 +1,39 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ diff-lcs (1.1.3)
4
5
  git (1.2.5)
5
- jeweler2 (2.0.9)
6
+ jeweler (1.8.4)
7
+ bundler (~> 1.0)
6
8
  git (>= 1.2.5)
7
- riot (0.12.5)
8
- rr
9
- rr (1.0.4)
10
- ruby-version (0.3.1)
9
+ rake
10
+ rdoc
11
+ json (1.7.5)
12
+ multi_json (1.3.6)
13
+ rake (0.9.2.2)
14
+ rdoc (3.12)
15
+ json (~> 1.4)
16
+ rspec (2.11.0)
17
+ rspec-core (~> 2.11.0)
18
+ rspec-expectations (~> 2.11.0)
19
+ rspec-mocks (~> 2.11.0)
20
+ rspec-core (2.11.1)
21
+ rspec-expectations (2.11.3)
22
+ diff-lcs (~> 1.1.3)
23
+ rspec-mocks (2.11.3)
24
+ ruby-version (0.4.2)
25
+ simplecov (0.6.4)
26
+ multi_json (~> 1.0)
27
+ simplecov-html (~> 0.5.3)
28
+ simplecov-html (0.5.3)
11
29
 
12
30
  PLATFORMS
13
31
  ruby
14
32
 
15
33
  DEPENDENCIES
16
- bundler (>= 1.0.0)
17
- jeweler2 (>= 2.0.0)
18
- riot (>= 0.12.3)
19
- ruby-version
34
+ bundler
35
+ jeweler
36
+ rake
37
+ rspec
38
+ ruby-version (>= 0.4.0)
39
+ simplecov
data/README.md CHANGED
@@ -24,6 +24,7 @@ non-atomic and organized by better way.
24
24
  - `Symbol` – 8 methods.
25
25
 
26
26
  For full reference and methods lists, see **[documentation][3]**.
27
+ [![Build Status](https://secure.travis-ci.org/martinkozak/hash-utils.png)](http://travis-ci.org/martinkozak/hash-utils)
27
28
 
28
29
  ### Modularization
29
30
 
data/Rakefile CHANGED
@@ -10,8 +10,10 @@ rescue Bundler::BundlerError => e
10
10
  exit e.status_code
11
11
  end
12
12
 
13
+ ### Jeweler
14
+
13
15
  require 'rake'
14
- require 'jeweler2'
16
+ require 'jeweler'
15
17
 
16
18
  Jeweler::Tasks.new do |gem|
17
19
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
@@ -28,3 +30,13 @@ Jeweler::Tasks.new do |gem|
28
30
  # gem.add_development_dependency 'rspec', '> 1.2.3'
29
31
  end
30
32
  Jeweler::RubygemsDotOrgTasks.new
33
+
34
+
35
+ ### RSpec
36
+
37
+ require 'rspec/core/rake_task'
38
+
39
+ RSpec::Core::RakeTask.new(:test) do |t|
40
+ t.pattern = 'tests.rb'
41
+ t.rspec_opts = '--format d -c'
42
+ end
data/TODO.txt CHANGED
@@ -1,3 +1,3 @@
1
1
  * add examples to each call
2
- * write riot tests
2
+ * write remaining tests
3
3
  * integrate functions from http://rubydoc.info/gems/sane/0.25.5/frames
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.1
1
+ 2.0.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "hash-utils"
8
- s.version = "2.0.1"
8
+ s.version = "2.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Martin Koz\u{e1}k"]
12
- s.date = "2012-08-26"
12
+ s.date = "2012-10-06"
13
13
  s.email = "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
+ ".travis.yml",
20
21
  "CHANGES.txt",
21
22
  "Gemfile",
22
23
  "Gemfile.lock",
@@ -41,7 +42,7 @@ Gem::Specification.new do |s|
41
42
  "lib/hash-utils/string.rb",
42
43
  "lib/hash-utils/stringio.rb",
43
44
  "lib/hash-utils/symbol.rb",
44
- "test"
45
+ "tests.rb"
45
46
  ]
46
47
  s.homepage = "http://github.com/martinkozak/hash-utils"
47
48
  s.licenses = ["MIT"]
@@ -53,21 +54,27 @@ Gem::Specification.new do |s|
53
54
  s.specification_version = 3
54
55
 
55
56
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
56
- s.add_runtime_dependency(%q<ruby-version>, [">= 0"])
57
- s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
58
- s.add_development_dependency(%q<jeweler2>, [">= 2.0.0"])
59
- s.add_development_dependency(%q<riot>, [">= 0.12.3"])
57
+ s.add_runtime_dependency(%q<ruby-version>, [">= 0.4.0"])
58
+ s.add_development_dependency(%q<bundler>, [">= 0"])
59
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
60
+ s.add_development_dependency(%q<rake>, [">= 0"])
61
+ s.add_development_dependency(%q<rspec>, [">= 0"])
62
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
60
63
  else
61
- s.add_dependency(%q<ruby-version>, [">= 0"])
62
- s.add_dependency(%q<bundler>, [">= 1.0.0"])
63
- s.add_dependency(%q<jeweler2>, [">= 2.0.0"])
64
- s.add_dependency(%q<riot>, [">= 0.12.3"])
64
+ s.add_dependency(%q<ruby-version>, [">= 0.4.0"])
65
+ s.add_dependency(%q<bundler>, [">= 0"])
66
+ s.add_dependency(%q<jeweler>, [">= 0"])
67
+ s.add_dependency(%q<rake>, [">= 0"])
68
+ s.add_dependency(%q<rspec>, [">= 0"])
69
+ s.add_dependency(%q<simplecov>, [">= 0"])
65
70
  end
66
71
  else
67
- s.add_dependency(%q<ruby-version>, [">= 0"])
68
- s.add_dependency(%q<bundler>, [">= 1.0.0"])
69
- s.add_dependency(%q<jeweler2>, [">= 2.0.0"])
70
- s.add_dependency(%q<riot>, [">= 0.12.3"])
72
+ s.add_dependency(%q<ruby-version>, [">= 0.4.0"])
73
+ s.add_dependency(%q<bundler>, [">= 0"])
74
+ s.add_dependency(%q<jeweler>, [">= 0"])
75
+ s.add_dependency(%q<rake>, [">= 0"])
76
+ s.add_dependency(%q<rspec>, [">= 0"])
77
+ s.add_dependency(%q<simplecov>, [">= 0"])
71
78
  end
72
79
  end
73
80
 
@@ -308,7 +308,7 @@ class String
308
308
 
309
309
  if not self.__hash_utils_instance_respond_to? :first
310
310
  def first
311
- self.chr
311
+ self[0].chr
312
312
  end
313
313
  end
314
314
 
@@ -7,19 +7,38 @@ require "hash-utils/object"
7
7
  # StringIO extension.
8
8
  #
9
9
 
10
- class StringIO < Data
10
+ if Ruby::Engine != :rbx
11
+ class StringIO < Data
11
12
 
12
- ##
13
- # Indicates, object is IO, so +IO+ or +StringIO+ class.
14
- #
15
- # @return [Boolean] +true+ if yes, +false+ in otherwise
16
- # @since 0.14.0
17
- #
18
-
19
- if not self.__hash_utils_instance_respond_to? :io?
20
- def io?
21
- true
13
+ ##
14
+ # Indicates, object is IO, so +IO+ or +StringIO+ class.
15
+ #
16
+ # @return [Boolean] +true+ if yes, +false+ in otherwise
17
+ # @since 0.14.0
18
+ #
19
+
20
+ if not self.__hash_utils_instance_respond_to? :io?
21
+ def io?
22
+ true
23
+ end
22
24
  end
25
+
26
+ end
27
+ else
28
+ class StringIO < Object
29
+
30
+ ##
31
+ # Indicates, object is IO, so +IO+ or +StringIO+ class.
32
+ #
33
+ # @return [Boolean] +true+ if yes, +false+ in otherwise
34
+ # @since 0.14.0
35
+ #
36
+
37
+ if not self.__hash_utils_instance_respond_to? :io?
38
+ def io?
39
+ true
40
+ end
41
+ end
42
+
23
43
  end
24
-
25
44
  end
@@ -1,13 +1,17 @@
1
- #!/usr/bin/ruby
1
+ #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
- # (c) 2011 Martin Kozák (martinkozak@martinkozak.net)
3
+ # (c) 2011-2012 Martin Kozák (martinkozak@martinkozak.net)
4
4
 
5
5
  $:.push("./lib")
6
6
  $:.unshift("./lib")
7
7
 
8
+ require "rspec"
8
9
  require "stringio"
10
+
11
+ require "simplecov"
12
+ SimpleCov.start
13
+
9
14
  require "hash-utils"
10
- require "riot"
11
15
 
12
16
 
13
17
  ## ARRAY
@@ -17,208 +21,185 @@ require "riot"
17
21
  #
18
22
  # doc. Jiří Souček
19
23
 
20
- context "Array" do
21
- asserts("#second") do
24
+ describe "Array" do
25
+ specify("#second") do
22
26
  [1, 2, 3, 4, 5, 6, 7, 8].second == 2
23
27
  end
24
- asserts("#third") do
28
+ specify("#third") do
25
29
  [1, 2, 3, 4, 5, 6, 7, 8].third == 3
26
30
  end
27
- asserts("#fourth") do
31
+ specify("#fourth") do
28
32
  [1, 2, 3, 4, 5, 6, 7, 8].fourth == 4
29
33
  end
30
- asserts("#fifth") do
34
+ specify("#fifth") do
31
35
  [1, 2, 3, 4, 5, 6, 7, 8].fifth == 5
32
36
  end
33
- asserts("#sixth") do
37
+ specify("#sixth") do
34
38
  [1, 2, 3, 4, 5, 6, 7, 8].sixth == 6
35
39
  end
36
- asserts("#seventh") do
40
+ specify("#seventh") do
37
41
  [1, 2, 3, 4, 5, 6, 7, 8].seventh == 7
38
42
  end
39
- asserts("#eighth") do
43
+ specify("#eighth") do
40
44
  [1, 2, 3, 4, 5, 6, 7, 8].eighth == 8
41
45
  end
42
- asserts("#array?") do
46
+ specify("#array?") do
43
47
  [1, 2, 3].array?
44
48
  end
45
- asserts("#avg") do
49
+ specify("#avg") do
46
50
  [1, 2, 3].avg == 2
47
51
  end
48
- asserts("#clean") do
52
+ specify("#clean") do
49
53
  t = [1, nil]
50
54
  t = t.clean(1)
51
55
  t == [nil]
52
56
  end
53
- asserts("#clean!") do
57
+ specify("#clean!") do
54
58
  t = [1, nil]
55
59
  t.clean!(1)
56
60
  t == [nil]
57
61
  end
58
- asserts("#sum") do
62
+ specify("#sum") do
59
63
  [1, 2, 3].sum == 6
60
64
  end
61
- asserts("#to_set") do
65
+ specify("#to_set") do
62
66
  [1, 2, 3].to_set == Set::new([1, 2, 3])
63
67
  end
64
68
  end
65
69
 
66
70
  ## FALSECLASS
67
71
 
68
- context "FalseClass" do
69
- asserts("#boolean?") do
72
+ describe "FalseClass" do
73
+ specify("#boolean?") do
70
74
  false.boolean?
71
75
  end
72
- asserts("#convert") do
76
+ specify("#convert") do
73
77
  false.convert(:a, :b) == :b
74
78
  end
75
- asserts("#false?") do
79
+ specify("#false?") do
76
80
  false.false?
77
81
  end
78
- asserts("#to_i") do
82
+ specify("#to_i") do
79
83
  false.to_i == 0
80
84
  end
81
- asserts("#true?") do
85
+ specify("#true?") do
82
86
  not false.true?
83
87
  end
84
88
  end
85
89
 
86
90
  ## FILE
87
91
 
88
- context "File" do
89
- asserts("#touch") do
92
+ describe "File" do
93
+ specify("#touch") do
90
94
  File.touch("./~test1")
91
95
  File.exists? "./~test1"
92
96
  end
93
- asserts("#write") do
97
+ specify("#write") do
94
98
  File.write("./~test2", "some string")
95
99
  File.read("./~test2") == "some string"
96
100
  end
97
101
 
98
- teardown do
102
+ after(:all) do
99
103
  File.unlink("./~test1")
100
104
  File.unlink("./~test2")
101
105
  end
102
106
  end
103
107
 
104
- ## GEM
105
-
106
- context "Gem" do
107
- asserts("#available?") do
108
- Gem::available? "hash-utils" and not Gem::available? "xxxxxxx"
109
- end
110
- asserts("#require_available") do
111
- result = Gem::require_available("hash-utils")
112
-
113
- begin
114
- require "hash-utils"
115
- rescue LoadError
116
- result = false
117
- end
118
-
119
- result and not Gem::require_available("xxxxxxx")
120
- end
121
- end
122
-
123
108
  ## HASH
124
109
 
125
- context "Hash" do
126
- setup do
127
- { :a => 1, :b => 2 }
128
- end
129
-
130
- asserts("#avg") do
131
- topic.avg == 1.5
110
+ describe "Hash" do
111
+ specify("#avg") do
112
+ { :a => 1, :b => 2 }.avg == 1.5
132
113
  end
133
- asserts("#clean") do
114
+ specify("#clean") do
134
115
  t = { :a => 1, :b => nil }
135
116
  t = t.clean(1)
136
117
  t == { :b => nil }
137
118
  end
138
- asserts("#clean!") do
119
+ specify("#clean!") do
139
120
  t = { :a => 1, :b => nil }
140
121
  t.clean!(1)
141
122
  t == { :b => nil }
142
123
  end
143
- asserts("#compact") do
124
+ specify("#compact") do
144
125
  t = { :a => 1, :b => nil }
145
126
  t = t.compact
146
127
  t == { :a => 1 }
147
128
  end
148
- asserts("#compact!") do
129
+ specify("#compact!") do
149
130
  t = { :a => 1, :b => nil }
150
131
  t.compact!
151
132
  t == { :a => 1 }
152
133
  end
153
- asserts("#flip") do
134
+ specify("#flip") do
154
135
  t = { :a => 1, :b => 2, :c => 2 }
155
136
  result = t.flip
156
137
  result == { 1 => :a, 2 => :c }
157
138
  end
158
- asserts("#flip!") do
139
+ specify("#flip!") do
159
140
  t = { :a => 1, :b => 2, :c => 2 }
160
141
  t.flip!
161
142
  t == { 1 => :a, 2 => :c }
162
143
  end
163
- asserts("#get_pairs") do
144
+ specify("#get_pairs") do
164
145
  h = { :a => 1, :b => 2, :c => 3 }
165
146
  result = [ ]
166
147
  h.get_pairs(:a, :c, :d) { |i| result << i }
167
148
  result == [[:a, 1], [:c, 3]]
168
149
  end
169
- asserts("#get_items") do
150
+ specify("#get_items") do
170
151
  h = { :a => 1, :b => 2, :c => 3 }
171
152
  h.get_items(:a, :c, :d) == { :a => 1, :c => 3 }
172
153
  end
173
- asserts("#get_values") do
154
+ specify("#get_values") do
174
155
  h = { :a => 1, :b => 2, :c => 3 }
175
156
  h.get_values(:a, :c, :d) == [1, 3]
176
157
  end
177
- asserts("#get_values") do
158
+ specify("#get_values") do
178
159
  { :a => 1, :b => 2, :c => 3 }.hash?
179
160
  end
180
- asserts("#map_values") do
181
- topic.map_values { |i| i + 1 } == { :a => 2, :b => 3 }
161
+ specify("#map_values") do
162
+ { :a => 1, :b => 2 }.map_values { |i| i + 1 } == { :a => 2, :b => 3 }
182
163
  end
183
- asserts("#map_values!") do
184
- t = topic.dup
164
+ specify("#map_values!") do
165
+ t = { :a => 1, :b => 2 }
185
166
  t.map_values! { |i| i + 1 }
186
167
  t == { :a => 2, :b => 3 }
187
168
  end
188
- asserts("#deep_merge") do
169
+ specify("#deep_merge") do
189
170
  h1 = {:a => {:b => :c, :d => :e}}
190
171
  h2 = {:a => {:d => :f, :h => :i}}
191
172
  h = h1.deep_merge(h2)
192
173
  (h == {:a => {:b => :c, :d => :f, :h => :i}}) and (h1 == {:a => {:b => :c, :d => :e}})
193
174
  end
194
- asserts("#deep_merge!") do
175
+ specify("#deep_merge!") do
195
176
  h = {:a => {:b => :c, :d => :e}}
196
177
  h.deep_merge!({:a => {:d => :f, :h => :i}})
197
178
  h == {:a => {:b => :c, :d => :f, :h => :i}}
198
179
  end
199
- asserts("#keys_to_sym") do
180
+ specify("#keys_to_sym") do
200
181
  h = {"a" => "b", 2 => "c", "d" => "e"}
201
182
  h.keys_to_sym == {:a => "b", 2 => "c", :d => "e"}
202
183
  end
203
- asserts("#keys_to_sym!") do
184
+ specify("#keys_to_sym!") do
204
185
  h = {"a" => "b", 2 => "c", "d" => "e"}
205
186
  h.keys_to_sym!
206
187
  h == {:a => "b", 2 => "c", :d => "e"}
207
188
  end
208
- asserts("#sum") do
209
- topic.sum == 3
189
+ specify("#sum") do
190
+ { :a => 1, :b => 2 }.sum == 3
210
191
  end
211
- asserts("#take_pairs") do
192
+ specify("#take_pairs") do
212
193
  h = { :a => 1, :b => 2, :c => 3 }
213
194
  result = [ ]
214
195
  h.take_pairs(:a, :c, :d) { |i| result << i }
215
196
  result == [[:a, 1], [:c, 3], [:d, nil]]
216
197
  end
217
- asserts("#take_items") do
198
+ specify("#take_items") do
218
199
  h = { :a => 1, :b => 2, :c => 3 }
219
200
  h.take_items(:a, :c, :d) == { :a => 1, :c => 3, :d => nil }
220
201
  end
221
- asserts("#take_values") do
202
+ specify("#take_values") do
222
203
  h = { :a => 1, :b => 2, :c => 3 }
223
204
  h.take_values(:a, :c, :d) == [1, 3, nil]
224
205
  end
@@ -227,22 +208,22 @@ end
227
208
 
228
209
  ## IO
229
210
 
230
- context "IO" do
231
- asserts("#io?") do
211
+ describe "IO" do
212
+ specify("#io?") do
232
213
  io = File::open("./~test", "w")
233
214
  result = io.io?
234
215
  io.close()
235
216
  result
236
217
  end
237
- teardown do
218
+ after(:all) do
238
219
  File.unlink("./~test")
239
220
  end
240
221
  end
241
222
 
242
223
  ## MODULE
243
224
 
244
- context "Module" do
245
- asserts("#get_module") do
225
+ describe "Module" do
226
+ specify("#get_module") do
246
227
  require "zlib"
247
228
  Kernel.get_module("Zlib::Inflate") == Zlib::Inflate
248
229
  end
@@ -250,169 +231,169 @@ end
250
231
 
251
232
  ## NILCLASS
252
233
 
253
- context "NilClass" do
254
- asserts("#to_boolean") do
234
+ describe "NilClass" do
235
+ specify("#to_boolean") do
255
236
  nil.to_boolean("xyz") === false
256
237
  end
257
238
  end
258
239
 
259
240
  ## NUMERIC
260
241
 
261
- context "Numeric" do
262
- asserts("#compare") do
242
+ describe "Numeric" do
243
+ specify("#compare") do
263
244
  5.compare(1) == 1 and 5.compare(5) == 0 and 5.compare(7) == -1
264
245
  end
265
- asserts("#negative?") do
246
+ specify("#negative?") do
266
247
  not 5.negative? and -2.negative?
267
248
  end
268
- asserts("#negative!") do
249
+ specify("#negative!") do
269
250
  5.negative! == -5 and -5.negative! == -5
270
251
  end
271
- asserts("#number?") do
252
+ specify("#number?") do
272
253
  5.number?
273
254
  end
274
- asserts("#positive?") do
255
+ specify("#positive?") do
275
256
  5.positive? and not -2.positive?
276
257
  end
277
- asserts("#positive!") do
258
+ specify("#positive!") do
278
259
  5.positive! == 5 and -5.positive! == 5
279
260
  end
280
261
  end
281
262
 
282
263
  ## OBJECT
283
264
 
284
- context "Object" do
285
- asserts("#**") do
265
+ describe "Object" do
266
+ specify("#**") do
286
267
  "ab" ** 5 == ["ab", "ab", "ab", "ab", "ab"]
287
268
  end
288
- asserts("#array?") do
269
+ specify("#array?") do
289
270
  not "".array? and [].array?
290
271
  end
291
- asserts("#boolean?") do
272
+ specify("#boolean?") do
292
273
  true.boolean? and false.boolean? and not "".boolean?
293
274
  end
294
- asserts("#enumerable?") do
275
+ specify("#enumerable?") do
295
276
  [].enumerable? and not 5.enumerable?
296
277
  end
297
- asserts("#false?") do
278
+ specify("#false?") do
298
279
  (false.false? == true) and ("string".false? == false)
299
280
  end
300
- asserts("#hash?") do
281
+ specify("#hash?") do
301
282
  not "".hash? and {}.hash?
302
283
  end
303
- asserts("#in?") do
284
+ specify("#in?") do
304
285
  5.in? 1..7 and not 9.in? 1..7
305
286
  end
306
- asserts("#instance_of_any?") do
287
+ specify("#instance_of_any?") do
307
288
  "".instance_of_any? [String, Symbol] \
308
289
  and not "".instance_of_any? [Integer, Float] \
309
290
  and "".instance_of_any? String, Symbol
310
291
  end
311
- asserts("#io?") do
292
+ specify("#io?") do
312
293
  not "".io?
313
294
  end
314
- asserts("#kind_of_any?") do
295
+ specify("#kind_of_any?") do
315
296
  "".kind_of_any? [String, Symbol] \
316
297
  and not "".kind_of_any? [Integer, Float] \
317
298
  and "".kind_of_any? String, Symbol
318
299
  end
319
- asserts("#number?") do
300
+ specify("#number?") do
320
301
  not :abcd.number? and 5.number?
321
302
  end
322
- asserts("#proc?") do
303
+ specify("#proc?") do
323
304
  proc = Proc::new { }
324
305
  not :abcd.proc? and proc.proc?
325
306
  end
326
- asserts("#string?") do
307
+ specify("#string?") do
327
308
  "".string? and not 5.string?
328
309
  end
329
- asserts("#symbol?") do
310
+ specify("#symbol?") do
330
311
  :abcd.symbol? and not 5.symbol?
331
312
  end
332
- asserts("#to_b") do
313
+ specify("#to_b") do
333
314
  (nil.to_b === false) and ("ab".to_b === true)
334
315
  end
335
- asserts("#to_sym") do
336
- (nil.to_sym === :"") and ("ab".to_sym === :ab) and (12.to_sym == :"12")
316
+ specify("#to_sym") do
317
+ ("ab".to_sym === :ab) and (12.to_sym == :"12")
337
318
  end
338
- asserts("#true?") do
319
+ specify("#true?") do
339
320
  (true.true? == true) and ("string".true? == false)
340
321
  end
341
322
  end
342
323
 
343
324
  ## STRING
344
325
 
345
- context "String" do
346
- asserts("#first") do
326
+ describe "String" do
327
+ specify("#first") do
347
328
  "abcdefgh".first == ?a
348
329
  end
349
- asserts("#second") do
330
+ specify("#second") do
350
331
  "abcdefgh".second == ?b
351
332
  end
352
- asserts("#third") do
333
+ specify("#third") do
353
334
  "abcdefgh".third == ?c
354
335
  end
355
- asserts("#fourth") do
336
+ specify("#fourth") do
356
337
  "abcdefgh".fourth == ?d
357
338
  end
358
- asserts("#fifth") do
339
+ specify("#fifth") do
359
340
  "abcdefgh".fifth == ?e
360
341
  end
361
- asserts("#sixth") do
342
+ specify("#sixth") do
362
343
  "abcdefgh".sixth == ?f
363
344
  end
364
- asserts("#seventh") do
345
+ specify("#seventh") do
365
346
  "abcdefgh".seventh == ?g
366
347
  end
367
- asserts("#eighth") do
348
+ specify("#eighth") do
368
349
  "abcdefgh".eighth == ?h
369
350
  end
370
- asserts("#cut!") do
351
+ specify("#cut!") do
371
352
  foo = "0123456789"
372
353
  foo.cut! 3..5
373
354
  foo == "345"
374
355
  end
375
- asserts("#first_line") do
356
+ specify("#first_line") do
376
357
  res = true
377
358
  res &= "a\nb\nc\n".first_line == "a\n"
378
359
  res &= "a".first_line == "a"
379
360
  end
380
- asserts("#first_lines") do
361
+ specify("#first_lines") do
381
362
  res = true
382
363
  res &= "a\nb".first_lines(2) == ["a\n", "b"]
383
364
  res &= "a\nb\nc\n".first_lines(4) == ["a\n", "b\n", "c\n"]
384
365
  end
385
- asserts("#interlace") do
366
+ specify("#interlace") do
386
367
  "abc".interlace("123") == "a123b123c"
387
368
  end
388
- asserts("#interlace!") do
369
+ specify("#interlace!") do
389
370
  foo = "abc"
390
371
  foo.interlace! "123"
391
372
  foo == "a123b123c"
392
373
  end
393
- asserts("#last") do
374
+ specify("#last") do
394
375
  "abc".last == ?c
395
376
  end
396
- asserts("#last_line") do
377
+ specify("#last_line") do
397
378
  res = true
398
379
  res &= "a\nb\nc\n".last_line == ""
399
380
  res &= "a\nb\nc".last_line == "c"
400
381
  res &= "a".last_line == "a"
401
382
  end
402
- asserts("#last_lines") do
383
+ specify("#last_lines") do
403
384
  res = true
404
385
  res &= "a\nb".last_lines(2) == ["a\n", "b"]
405
386
  res &= "a\nb\nc\n".last_lines(4) == ["a\n", "b\n", "c\n", ""]
406
387
  end
407
- asserts("#lcfirst") do
388
+ specify("#lcfirst") do
408
389
  str = "ABCD"
409
390
  str.lcfirst == "aBCD" and str == "ABCD"
410
391
  end
411
- asserts("#lcfirst!") do
392
+ specify("#lcfirst!") do
412
393
  str = "ABCD"
413
394
  str.lcfirst! == "aBCD" and str == "aBCD"
414
395
  end
415
- asserts("#pop") do
396
+ specify("#pop") do
416
397
  res = true
417
398
  str = "abcd"
418
399
  res &= str.pop == "d"
@@ -421,37 +402,37 @@ context "String" do
421
402
  res &= str.pop(2) == "cd"
422
403
  res &= str == "ab"
423
404
  end
424
- asserts("#pop_line") do
405
+ specify("#pop_line") do
425
406
  res = true
426
407
  str = "a\nb\nc\nd"
427
408
  res &= str.pop_line == "d"
428
409
  res &= str = "a\nb\nc\n"
429
410
  end
430
- asserts("#pop_lines") do
411
+ specify("#pop_lines") do
431
412
  res = true
432
413
  str = "a\nb\nc\nd\n"
433
414
  res &= str.pop_lines(2) == ["d\n", ""]
434
415
  res &= str = "a\nb\nc\n"
435
416
  end
436
- asserts("#push_line") do
417
+ specify("#push_line") do
437
418
  res = true
438
419
  str = "a\nb\nc\nd"
439
420
  res &= str.push_line("1") == "a\nb\nc\nd\n1"
440
421
  res &= str == "a\nb\nc\nd\n1"
441
422
  end
442
- asserts("#push_lines") do
423
+ specify("#push_lines") do
443
424
  res = true
444
425
  str = "a\nb\nc\nd"
445
426
  res &= str.push_lines("1", "2") == "a\nb\nc\nd\n1\n2"
446
427
  res &= str == "a\nb\nc\nd\n1\n2"
447
428
  end
448
- asserts("#random") do
429
+ specify("#random") do
449
430
  str1 = String::random(30)
450
431
  str2 = String::random(30)
451
432
 
452
433
  str1 != str2
453
434
  end
454
- asserts("#shift") do
435
+ specify("#shift") do
455
436
  res = true
456
437
  str = "abcd"
457
438
  res &= str.shift == "a"
@@ -460,51 +441,51 @@ context "String" do
460
441
  res &= str.shift(2) == "ab"
461
442
  res &= str == "cd"
462
443
  end
463
- asserts("#shift_line") do
444
+ specify("#shift_line") do
464
445
  res = true
465
446
  str = "a\nb\nc\nd\n"
466
447
  res &= str.shift_line == "a\n"
467
448
  res &= str = "b\nc\nd\n"
468
449
  end
469
- asserts("#shift_lines") do
450
+ specify("#shift_lines") do
470
451
  res = true
471
452
  str = "a\nb\nc\nd\n"
472
453
  res &= str.shift_lines(2) == ["a\n", "b\n"]
473
454
  res &= str = "c\nd\n"
474
455
  end
475
- asserts("#string?") do
456
+ specify("#string?") do
476
457
  "abcd".string?
477
458
  end
478
- asserts("#swap_with") do
459
+ specify("#swap_with") do
479
460
  foo = "abc"
480
461
  bar = "123"
481
462
  foo.swap_with(bar)
482
463
  foo = "123" and bar = "abc"
483
464
  end
484
- asserts("#to_boolean") do
465
+ specify("#to_boolean") do
485
466
  "alfa".to_boolean("alfa") == true
486
467
  end
487
- asserts("#ucfirst") do
468
+ specify("#ucfirst") do
488
469
  str = "abcd"
489
470
  str.ucfirst == "Abcd" and str == "abcd"
490
471
  end
491
- asserts("#ucfirst!") do
472
+ specify("#ucfirst!") do
492
473
  str = "abcd"
493
474
  str.ucfirst! == "Abcd" and str == "Abcd"
494
475
  end
495
- asserts("#unshift") do
476
+ specify("#unshift") do
496
477
  res = true
497
478
  str = "abcd"
498
479
  res &= str.unshift("123") == "123abcd"
499
480
  res &= str == "123abcd"
500
481
  end
501
- asserts("#unshift_line") do
482
+ specify("#unshift_line") do
502
483
  res = true
503
484
  str = "a\nb\nc\nd\n"
504
485
  res &= str.unshift_line("1") == "1\na\nb\nc\nd\n"
505
486
  res &= str == "1\na\nb\nc\nd\n"
506
487
  end
507
- asserts("#unshift_lines") do
488
+ specify("#unshift_lines") do
508
489
  res = true
509
490
  str = "a\nb\nc\nd\n"
510
491
  res &= str.unshift_lines("1", "2") == "1\n2\na\nb\nc\nd\n"
@@ -515,60 +496,61 @@ end
515
496
 
516
497
  ## STRINGIO
517
498
 
518
- context "StringIO" do
519
- asserts("#io?") do
499
+ describe "StringIO" do
500
+ specify("#io?") do
520
501
  StringIO::new.io?
521
502
  end
522
503
  end
523
504
 
524
505
  ## SYMBOL
525
506
 
526
- context "Symbol" do
527
- asserts("#*") do
507
+ describe "Symbol" do
508
+ specify("#*") do
528
509
  :a * 5 == :aaaaa
529
510
  end
530
- asserts("#+") do
511
+ specify("#+") do
531
512
  :a + :b == :ab
532
513
  end
533
- asserts("#[]") do
514
+ specify("#[]") do
534
515
  :abcde[0...3] == "abc"
535
516
  end
536
- asserts("#append") do
517
+ specify("#append") do
537
518
  :abcd.append("efg") == :abcdefg
538
519
  end
539
- asserts("#end_with?") do
520
+ specify("#end_with?") do
540
521
  :abcde.end_with? "ghi", "cde"
541
522
  end
542
- asserts("#prepend") do
523
+ specify("#prepend") do
543
524
  :abcd.prepend("012") == :"012abcd"
544
525
  end
545
- asserts("#split") do
526
+ specify("#split") do
546
527
  :ab_cd_ef.split("_", 2) == [:ab, :cd_ef]
547
528
  end
548
- asserts("#start_with?") do
529
+ specify("#start_with?") do
549
530
  :abcde.start_with? "ghi", "abc"
550
531
  end
551
- asserts("#strip") do
532
+ specify("#strip") do
552
533
  :" a ".strip == :a
553
534
  end
554
535
  end
555
536
 
556
537
  ## TRUECLASS
557
538
 
558
- context "TrueClass" do
559
- asserts("#boolean?") do
539
+ describe "TrueClass" do
540
+ specify("#boolean?") do
560
541
  true.boolean?
561
542
  end
562
- asserts("#convert") do
543
+ specify("#convert") do
563
544
  true.convert(:a, :b) == :a
564
545
  end
565
- asserts("#false?") do
546
+ specify("#false?") do
566
547
  not true.false?
567
548
  end
568
- asserts("#to_i") do
549
+ specify("#to_i") do
569
550
  true.to_i == 1
570
551
  end
571
- asserts("#true?") do
552
+ specify("#true?") do
572
553
  true.true?
573
554
  end
574
555
  end
556
+
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: 2.0.1
4
+ version: 2.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-26 00:00:00.000000000 Z
12
+ date: 2012-10-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby-version
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: 0.4.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: '0'
29
+ version: 0.4.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: bundler
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -34,7 +34,39 @@ dependencies:
34
34
  requirements:
35
35
  - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: 1.0.0
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: jeweler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
38
70
  type: :development
39
71
  prerelease: false
40
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,15 +74,15 @@ dependencies:
42
74
  requirements:
43
75
  - - ! '>='
44
76
  - !ruby/object:Gem::Version
45
- version: 1.0.0
77
+ version: '0'
46
78
  - !ruby/object:Gem::Dependency
47
- name: jeweler2
79
+ name: rspec
48
80
  requirement: !ruby/object:Gem::Requirement
49
81
  none: false
50
82
  requirements:
51
83
  - - ! '>='
52
84
  - !ruby/object:Gem::Version
53
- version: 2.0.0
85
+ version: '0'
54
86
  type: :development
55
87
  prerelease: false
56
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,15 +90,15 @@ dependencies:
58
90
  requirements:
59
91
  - - ! '>='
60
92
  - !ruby/object:Gem::Version
61
- version: 2.0.0
93
+ version: '0'
62
94
  - !ruby/object:Gem::Dependency
63
- name: riot
95
+ name: simplecov
64
96
  requirement: !ruby/object:Gem::Requirement
65
97
  none: false
66
98
  requirements:
67
99
  - - ! '>='
68
100
  - !ruby/object:Gem::Version
69
- version: 0.12.3
101
+ version: '0'
70
102
  type: :development
71
103
  prerelease: false
72
104
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +106,7 @@ dependencies:
74
106
  requirements:
75
107
  - - ! '>='
76
108
  - !ruby/object:Gem::Version
77
- version: 0.12.3
109
+ version: '0'
78
110
  description:
79
111
  email: martinkozak@martinkozak.net
80
112
  executables: []
@@ -84,6 +116,7 @@ extra_rdoc_files:
84
116
  - README.md
85
117
  files:
86
118
  - .document
119
+ - .travis.yml
87
120
  - CHANGES.txt
88
121
  - Gemfile
89
122
  - Gemfile.lock
@@ -108,7 +141,7 @@ files:
108
141
  - lib/hash-utils/string.rb
109
142
  - lib/hash-utils/stringio.rb
110
143
  - lib/hash-utils/symbol.rb
111
- - test
144
+ - tests.rb
112
145
  homepage: http://github.com/martinkozak/hash-utils
113
146
  licenses:
114
147
  - MIT
@@ -124,7 +157,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
124
157
  version: '0'
125
158
  segments:
126
159
  - 0
127
- hash: -4026465352187069690
160
+ hash: 4436198451928549294
128
161
  required_rubygems_version: !ruby/object:Gem::Requirement
129
162
  none: false
130
163
  requirements: