extlib 0.9.15 → 0.9.16

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Dan Kubb
1
+ Copyright (c) 2010 Dan Kubb
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -14,4 +14,4 @@ Support library for DataMapper and Merb.
14
14
 
15
15
  == Copyright
16
16
 
17
- Copyright (c) 2009 Dan Kubb. See LICENSE for details.
17
+ Copyright (c) 2010 Dan Kubb. See LICENSE for details.
data/Rakefile CHANGED
@@ -2,12 +2,12 @@ require 'rubygems'
2
2
  require 'rake'
3
3
 
4
4
  begin
5
- gem 'jeweler', '~> 1.4'
5
+ gem 'jeweler', '~> 1.8.4'
6
6
  require 'jeweler'
7
7
 
8
8
  Jeweler::Tasks.new do |gem|
9
9
  gem.name = 'extlib'
10
- gem.summary = 'Support library for DataMapper and Merb'
10
+ gem.summary = 'Support library for Merb'
11
11
  gem.description = gem.summary
12
12
  gem.email = 'dan.kubb@gmail.com'
13
13
  gem.homepage = 'http://github.com/datamapper/extlib'
@@ -23,5 +23,5 @@ begin
23
23
 
24
24
  FileList['tasks/**/*.rake'].each { |task| load task }
25
25
  rescue LoadError
26
- puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler'
26
+ puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler -v 1.8.4'
27
27
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.15
1
+ 0.9.16
@@ -1,136 +1,105 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{extlib}
8
- s.version = "0.9.15"
7
+ s.name = "extlib"
8
+ s.version = "0.9.16"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dan Kubb"]
12
- s.date = %q{2010-05-18}
13
- s.description = %q{Support library for DataMapper and Merb}
14
- s.email = %q{dan.kubb@gmail.com}
12
+ s.date = "2013-01-08"
13
+ s.description = "Support library for Merb"
14
+ s.email = "dan.kubb@gmail.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.rdoc"
17
+ "README.rdoc"
18
18
  ]
19
19
  s.files = [
20
20
  ".autotest",
21
- ".document",
22
- ".gitignore",
23
- "LICENSE",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "extlib.gemspec",
28
- "lib/extlib.rb",
29
- "lib/extlib/array.rb",
30
- "lib/extlib/assertions.rb",
31
- "lib/extlib/blank.rb",
32
- "lib/extlib/boolean.rb",
33
- "lib/extlib/byte_array.rb",
34
- "lib/extlib/class.rb",
35
- "lib/extlib/datetime.rb",
36
- "lib/extlib/dictionary.rb",
37
- "lib/extlib/hash.rb",
38
- "lib/extlib/hook.rb",
39
- "lib/extlib/inflection.rb",
40
- "lib/extlib/lazy_array.rb",
41
- "lib/extlib/lazy_module.rb",
42
- "lib/extlib/local_object_space.rb",
43
- "lib/extlib/logger.rb",
44
- "lib/extlib/mash.rb",
45
- "lib/extlib/module.rb",
46
- "lib/extlib/nil.rb",
47
- "lib/extlib/numeric.rb",
48
- "lib/extlib/object.rb",
49
- "lib/extlib/object_space.rb",
50
- "lib/extlib/pathname.rb",
51
- "lib/extlib/pooling.rb",
52
- "lib/extlib/rubygems.rb",
53
- "lib/extlib/simple_set.rb",
54
- "lib/extlib/string.rb",
55
- "lib/extlib/struct.rb",
56
- "lib/extlib/symbol.rb",
57
- "lib/extlib/time.rb",
58
- "lib/extlib/try_dup.rb",
59
- "lib/extlib/virtual_file.rb",
60
- "spec/array_spec.rb",
61
- "spec/blank_spec.rb",
62
- "spec/byte_array_spec.rb",
63
- "spec/class_spec.rb",
64
- "spec/datetime_spec.rb",
65
- "spec/hash_spec.rb",
66
- "spec/hook_spec.rb",
67
- "spec/inflection/plural_spec.rb",
68
- "spec/inflection/singular_spec.rb",
69
- "spec/inflection_extras_spec.rb",
70
- "spec/lazy_array_spec.rb",
71
- "spec/lazy_module_spec.rb",
72
- "spec/mash_spec.rb",
73
- "spec/module_spec.rb",
74
- "spec/object_space_spec.rb",
75
- "spec/object_spec.rb",
76
- "spec/pooling_spec.rb",
77
- "spec/rcov.opts",
78
- "spec/simple_set_spec.rb",
79
- "spec/spec.opts",
80
- "spec/spec_helper.rb",
81
- "spec/string_spec.rb",
82
- "spec/struct_spec.rb",
83
- "spec/symbol_spec.rb",
84
- "spec/time_spec.rb",
85
- "spec/try_call_spec.rb",
86
- "spec/try_dup_spec.rb",
87
- "spec/virtual_file_spec.rb",
88
- "tasks/ci.rake",
89
- "tasks/metrics.rake",
90
- "tasks/spec.rake",
91
- "tasks/yard.rake",
92
- "tasks/yardstick.rake"
93
- ]
94
- s.homepage = %q{http://github.com/datamapper/extlib}
95
- s.rdoc_options = ["--charset=UTF-8"]
96
- s.require_paths = ["lib"]
97
- s.rubyforge_project = %q{extlib}
98
- s.rubygems_version = %q{1.3.6}
99
- s.summary = %q{Support library for DataMapper and Merb}
100
- s.test_files = [
21
+ ".document",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "extlib.gemspec",
27
+ "lib/extlib.rb",
28
+ "lib/extlib/array.rb",
29
+ "lib/extlib/assertions.rb",
30
+ "lib/extlib/blank.rb",
31
+ "lib/extlib/boolean.rb",
32
+ "lib/extlib/byte_array.rb",
33
+ "lib/extlib/class.rb",
34
+ "lib/extlib/datetime.rb",
35
+ "lib/extlib/dictionary.rb",
36
+ "lib/extlib/hash.rb",
37
+ "lib/extlib/hook.rb",
38
+ "lib/extlib/inflection.rb",
39
+ "lib/extlib/lazy_array.rb",
40
+ "lib/extlib/lazy_module.rb",
41
+ "lib/extlib/local_object_space.rb",
42
+ "lib/extlib/logger.rb",
43
+ "lib/extlib/mash.rb",
44
+ "lib/extlib/module.rb",
45
+ "lib/extlib/nil.rb",
46
+ "lib/extlib/numeric.rb",
47
+ "lib/extlib/object.rb",
48
+ "lib/extlib/object_space.rb",
49
+ "lib/extlib/pathname.rb",
50
+ "lib/extlib/pooling.rb",
51
+ "lib/extlib/rubygems.rb",
52
+ "lib/extlib/simple_set.rb",
53
+ "lib/extlib/string.rb",
54
+ "lib/extlib/struct.rb",
55
+ "lib/extlib/symbol.rb",
56
+ "lib/extlib/time.rb",
57
+ "lib/extlib/try_dup.rb",
58
+ "lib/extlib/virtual_file.rb",
101
59
  "spec/array_spec.rb",
102
- "spec/blank_spec.rb",
103
- "spec/byte_array_spec.rb",
104
- "spec/class_spec.rb",
105
- "spec/datetime_spec.rb",
106
- "spec/hash_spec.rb",
107
- "spec/hook_spec.rb",
108
- "spec/inflection/plural_spec.rb",
109
- "spec/inflection/singular_spec.rb",
110
- "spec/inflection_extras_spec.rb",
111
- "spec/lazy_array_spec.rb",
112
- "spec/lazy_module_spec.rb",
113
- "spec/mash_spec.rb",
114
- "spec/module_spec.rb",
115
- "spec/object_space_spec.rb",
116
- "spec/object_spec.rb",
117
- "spec/pooling_spec.rb",
118
- "spec/simple_set_spec.rb",
119
- "spec/spec_helper.rb",
120
- "spec/string_spec.rb",
121
- "spec/struct_spec.rb",
122
- "spec/symbol_spec.rb",
123
- "spec/time_spec.rb",
124
- "spec/try_call_spec.rb",
125
- "spec/try_dup_spec.rb",
126
- "spec/virtual_file_spec.rb"
60
+ "spec/blank_spec.rb",
61
+ "spec/byte_array_spec.rb",
62
+ "spec/class_spec.rb",
63
+ "spec/datetime_spec.rb",
64
+ "spec/hash_spec.rb",
65
+ "spec/hook_spec.rb",
66
+ "spec/inflection/plural_spec.rb",
67
+ "spec/inflection/singular_spec.rb",
68
+ "spec/inflection_extras_spec.rb",
69
+ "spec/lazy_array_spec.rb",
70
+ "spec/lazy_module_spec.rb",
71
+ "spec/mash_spec.rb",
72
+ "spec/module_spec.rb",
73
+ "spec/object_space_spec.rb",
74
+ "spec/object_spec.rb",
75
+ "spec/pooling_spec.rb",
76
+ "spec/rcov.opts",
77
+ "spec/simple_set_spec.rb",
78
+ "spec/spec.opts",
79
+ "spec/spec_helper.rb",
80
+ "spec/string_spec.rb",
81
+ "spec/struct_spec.rb",
82
+ "spec/symbol_spec.rb",
83
+ "spec/time_spec.rb",
84
+ "spec/try_call_spec.rb",
85
+ "spec/try_dup_spec.rb",
86
+ "spec/virtual_file_spec.rb",
87
+ "tasks/ci.rake",
88
+ "tasks/metrics.rake",
89
+ "tasks/spec.rake",
90
+ "tasks/yard.rake",
91
+ "tasks/yardstick.rake"
127
92
  ]
93
+ s.homepage = "http://github.com/datamapper/extlib"
94
+ s.require_paths = ["lib"]
95
+ s.rubyforge_project = "extlib"
96
+ s.rubygems_version = "1.8.24"
97
+ s.summary = "Support library for Merb"
128
98
 
129
99
  if s.respond_to? :specification_version then
130
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
131
100
  s.specification_version = 3
132
101
 
133
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
102
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
134
103
  s.add_development_dependency(%q<json_pure>, ["~> 1.4"])
135
104
  s.add_development_dependency(%q<rspec>, ["~> 1.3"])
136
105
  else
@@ -1,5 +1,6 @@
1
- require "time"
2
1
  require 'bigdecimal'
2
+ require 'time'
3
+ require 'uri'
3
4
 
4
5
  require 'extlib/object'
5
6
  require 'extlib/mash'
@@ -7,6 +8,8 @@ require 'extlib/class'
7
8
  require 'extlib/string'
8
9
 
9
10
  class Hash
11
+ URI_ENCODE_PATTERN = Regexp.new("[^#{URI::PATTERN::UNRESERVED}]").freeze
12
+
10
13
  class << self
11
14
  # Converts valid XML into a Ruby Hash structure.
12
15
  #
@@ -135,7 +138,7 @@ class Hash
135
138
  elsif value.is_a?(Hash)
136
139
  stack << [key,value]
137
140
  else
138
- param << "#{key}=#{value}&"
141
+ param << [key,value].map {|v| URI.encode(v.to_s, URI_ENCODE_PATTERN)}.join('=') + '&'
139
142
  end
140
143
 
141
144
  stack.each do |parent, hash|
@@ -279,9 +282,7 @@ class REXMLUtilityNode
279
282
  self.typecasts["decimal"] = lambda{|v| BigDecimal(v)}
280
283
  self.typecasts["double"] = lambda{|v| v.nil? ? nil : v.to_f}
281
284
  self.typecasts["float"] = lambda{|v| v.nil? ? nil : v.to_f}
282
- self.typecasts["symbol"] = lambda{|v| v.to_sym}
283
285
  self.typecasts["string"] = lambda{|v| v.to_s}
284
- self.typecasts["yaml"] = lambda{|v| v.nil? ? nil : YAML.load(v)}
285
286
  self.typecasts["base64Binary"] = lambda{|v| v.unpack('m').first }
286
287
 
287
288
  self.available_typecasts = self.typecasts.keys
@@ -322,96 +322,97 @@ module Extlib
322
322
  # One argument means singular and plural are the same.
323
323
 
324
324
  word 'equipment'
325
- word 'information'
326
- word 'money'
327
- word 'species'
328
- word 'series'
329
325
  word 'fish'
330
- word 'sheep'
331
- word 'moose'
332
- word 'hovercraft'
333
326
  word 'grass'
334
- word 'rain'
327
+ word 'hovercraft'
328
+ word 'information'
335
329
  word 'milk'
336
- word 'rice'
330
+ word 'money'
331
+ word 'moose'
337
332
  word 'plurals'
338
333
  word 'postgres'
334
+ word 'rain'
335
+ word 'rice'
336
+ word 'series'
337
+ word 'sheep'
338
+ word 'species'
339
339
  word 'status'
340
340
 
341
341
  # Two arguments defines a singular and plural exception.
342
- word 'status' , 'status'
343
- word 'Swiss' , 'Swiss'
344
- word 'life' , 'lives'
345
- word 'wife' , 'wives'
346
- word 'goose' , 'geese'
347
- word 'criterion' , 'criteria'
348
- word 'alias' , 'aliases'
349
- word 'status' , 'statuses'
350
- word 'axis' , 'axes'
351
- word 'crisis' , 'crises'
352
- word 'testis' , 'testes'
353
- word 'potato' , 'potatoes'
354
- word 'tomato' , 'tomatoes'
355
- word 'buffalo' , 'buffaloes'
356
- word 'torpedo' , 'torpedoes'
357
- word 'quiz' , 'quizzes'
358
- word 'matrix' , 'matrices'
359
- word 'vertex' , 'vertices'
360
- word 'index' , 'indices'
361
- word 'ox' , 'oxen'
362
- word 'mouse' , 'mice'
363
- word 'louse' , 'lice'
364
- word 'thesis' , 'theses'
365
- word 'thief' , 'thieves'
366
- word 'analysis' , 'analyses'
367
- word 'erratum' , 'errata'
368
- word 'phenomenon', 'phenomena'
369
- word 'octopus' , 'octopi'
370
- word 'thesaurus' , 'thesauri'
371
- word 'movie' , 'movies'
372
- word 'cactus' , 'cacti'
373
- word 'plus' , 'plusses'
374
- word 'cross' , 'crosses'
375
- word 'medium' , 'media'
376
- word 'datum' , 'data'
377
- word 'basis' , 'bases'
378
- word 'diagnosis' , 'diagnoses'
342
+ word 'alias' , 'aliases'
343
+ word 'analysis' , 'analyses'
344
+ word 'axis' , 'axes'
345
+ word 'basis' , 'bases'
346
+ word 'buffalo' , 'buffaloes'
347
+ word 'cactus' , 'cacti'
348
+ word 'crisis' , 'crises'
349
+ word 'criterion' , 'criteria'
350
+ word 'cross' , 'crosses'
351
+ word 'datum' , 'data'
352
+ word 'diagnosis' , 'diagnoses'
353
+ word 'drive' , 'drives'
354
+ word 'erratum' , 'errata'
355
+ word 'goose' , 'geese'
356
+ word 'index' , 'indices'
357
+ word 'life' , 'lives'
358
+ word 'louse' , 'lice'
359
+ word 'matrix' , 'matrices'
360
+ word 'medium' , 'media'
361
+ word 'mouse' , 'mice'
362
+ word 'movie' , 'movies'
363
+ word 'octopus' , 'octopi'
364
+ word 'ox' , 'oxen'
365
+ word 'phenomenon' , 'phenomena'
366
+ word 'plus' , 'plusses'
367
+ word 'potato' , 'potatoes'
368
+ word 'quiz' , 'quizzes'
369
+ word 'status' , 'status'
370
+ word 'status' , 'statuses'
371
+ word 'Swiss' , 'Swiss'
372
+ word 'testis' , 'testes'
373
+ word 'thesaurus' , 'thesauri'
374
+ word 'thesis' , 'theses'
375
+ word 'thief' , 'thieves'
376
+ word 'tomato' , 'tomatoes'
377
+ word 'torpedo' , 'torpedoes'
378
+ word 'vertex' , 'vertices'
379
+ word 'wife' , 'wives'
379
380
 
380
381
  # One-way singularization exception (convert plural to singular).
381
382
 
382
383
  # General rules.
383
- rule 'person' , 'people', true
384
- rule 'shoe' , 'shoes', true
385
- rule 'hive' , 'hives', true
386
- rule 'man' , 'men', true
384
+ rule 'person' , 'people', true
385
+ rule 'shoe' , 'shoes', true
386
+ rule 'hive' , 'hives', true
387
+ rule 'man' , 'men', true
387
388
  rule 'child' , 'children', true
388
- rule 'news' , 'news', true
389
- rule 'rf' , 'rves'
390
- rule 'af' , 'aves'
391
- rule 'ero' , 'eroes'
392
- rule 'man' , 'men'
393
- rule 'ch' , 'ches'
394
- rule 'sh' , 'shes'
395
- rule 'ss' , 'sses'
396
- rule 'ta' , 'tum'
397
- rule 'ia' , 'ium'
398
- rule 'ra' , 'rum'
399
- rule 'ay' , 'ays'
400
- rule 'ey' , 'eys'
401
- rule 'oy' , 'oys'
402
- rule 'uy' , 'uys'
403
- rule 'y' , 'ies'
404
- rule 'x' , 'xes'
405
- rule 'lf' , 'lves'
406
- rule 'ffe' , 'ffes'
407
- rule 'afe' , 'aves'
408
- rule 'ouse' , 'ouses'
389
+ rule 'news' , 'news', true
390
+ rule 'rf' , 'rves'
391
+ rule 'af' , 'aves'
392
+ rule 'ero' , 'eroes'
393
+ rule 'man' , 'men'
394
+ rule 'ch' , 'ches'
395
+ rule 'sh' , 'shes'
396
+ rule 'ss' , 'sses'
397
+ rule 'ta' , 'tum'
398
+ rule 'ia' , 'ium'
399
+ rule 'ra' , 'rum'
400
+ rule 'ay' , 'ays'
401
+ rule 'ey' , 'eys'
402
+ rule 'oy' , 'oys'
403
+ rule 'uy' , 'uys'
404
+ rule 'y' , 'ies'
405
+ rule 'x' , 'xes'
406
+ rule 'lf' , 'lves'
407
+ rule 'ffe' , 'ffes'
408
+ rule 'afe' , 'aves'
409
+ rule 'ouse' , 'ouses'
409
410
  # more cases of words ending in -oses not being singularized properly
410
411
  # than cases of words ending in -osis
411
- # rule 'osis' , 'oses'
412
- rule 'ox' , 'oxes'
413
- rule 'us' , 'uses'
414
- rule '' , 's'
412
+ # rule 'osis' , 'oses'
413
+ rule 'ox' , 'oxes'
414
+ rule 'us' , 'uses'
415
+ rule '' , 's'
415
416
 
416
417
  # One-way singular rules.
417
418
 
@@ -426,7 +427,6 @@ module Extlib
426
427
  plural_rule 'ive' , 'ives' # don't want to snag wife
427
428
  plural_rule 'fe' , 'ves' # don't want to snag perspectives
428
429
 
429
-
430
430
  end
431
431
  end
432
432
 
@@ -141,12 +141,12 @@ describe Hash, "from_xml" do
141
141
 
142
142
  it "should typecast a true boolean" do
143
143
  xml = "<tag type='boolean'>true</tag>"
144
- Hash.from_xml(xml)['tag'].should be_true
144
+ Hash.from_xml(xml)['tag'].should be(true)
145
145
  end
146
146
 
147
147
  it "should typecast a false boolean" do
148
148
  ["false"].each do |w|
149
- Hash.from_xml("<tag type='boolean'>#{w}</tag>")['tag'].should be_false
149
+ Hash.from_xml("<tag type='boolean'>#{w}</tag>")['tag'].should be(false)
150
150
  end
151
151
  end
152
152
 
@@ -254,7 +254,7 @@ describe Hash, "from_xml" do
254
254
  'approved' => nil,
255
255
  'written_on' => nil,
256
256
  'viewed_at' => nil,
257
- 'content' => nil,
257
+ 'content' => { 'type' => 'yaml' },
258
258
  'parent_id' => nil
259
259
  }
260
260
  Hash.from_xml(topic_xml)["topic"].should == expected_topic_hash
@@ -292,12 +292,12 @@ describe Hash, "from_xml" do
292
292
  # Changed this line where the key is :message. The yaml specifies this as a symbol, and who am I to change what you specify
293
293
  # The line in ActiveSupport is
294
294
  # 'content' => { 'message' => "Have a nice day", 1 => "should be an integer", "array" => [{ "should-have-dashes" => true, "should_have_underscores" => true }] },
295
- 'content' => { :message => "Have a nice day", 1 => "should be an integer", "array" => [{ "should-have-dashes" => true, "should_have_underscores" => true }] },
295
+ 'content' => "--- \n1: should be an integer\n:message: Have a nice day\narray: \n- should-have-dashes: true\n should_have_underscores: true\n",
296
296
  'author_email_address' => "david@loudthinking.com",
297
297
  'parent_id' => nil,
298
298
  'ad_revenue' => BigDecimal("1.50"),
299
299
  'optimum_viewing_angle' => 135.0,
300
- 'resident' => :yes
300
+ 'resident' => 'yes'
301
301
  }
302
302
 
303
303
  Hash.from_xml(topic_xml)["topic"].each do |k,v|
@@ -509,10 +509,10 @@ end
509
509
  describe Hash, 'to_params' do
510
510
  {
511
511
  { "foo" => "bar", "baz" => "bat" } => "foo=bar&baz=bat",
512
- { "foo" => [ "bar", "baz" ] } => "foo[]=bar&foo[]=baz",
513
- { "foo" => [ {"bar" => "1"}, {"bar" => 2} ] } => "foo[][bar]=1&foo[][bar]=2",
514
- { "foo" => { "bar" => [ {"baz" => 1}, {"baz" => "2"} ] } } => "foo[bar][][baz]=1&foo[bar][][baz]=2",
515
- { "foo" => {"1" => "bar", "2" => "baz"} } => "foo[1]=bar&foo[2]=baz"
512
+ { "foo" => [ "bar", "baz" ] } => "foo%5B%5D=bar&foo%5B%5D=baz",
513
+ { "foo" => [ {"bar" => "1"}, {"bar" => 2} ] } => "foo%5B%5D%5Bbar%5D=1&foo%5B%5D%5Bbar%5D=2",
514
+ { "foo" => { "bar" => [ {"baz" => 1}, {"baz" => "2"} ] } } => "foo%5Bbar%5D%5B%5D%5Bbaz%5D=1&foo%5Bbar%5D%5B%5D%5Bbaz%5D=2",
515
+ { "foo" => {"1" => "bar", "2" => "baz"} } => "foo%5B1%5D=bar&foo%5B2%5D=baz"
516
516
  }.each do |hash, params|
517
517
  it "should covert hash: #{hash.inspect} to params: #{params.inspect}" do
518
518
  hash.to_params.split('&').sort.should == params.split('&').sort
@@ -522,6 +522,14 @@ describe Hash, 'to_params' do
522
522
  it 'should not leave a trailing &' do
523
523
  { :name => 'Bob', :address => { :street => '111 Ruby Ave.', :city => 'Ruby Central', :phones => ['111-111-1111', '222-222-2222'] } }.to_params.should_not match(/&$/)
524
524
  end
525
+
526
+ it 'should encode query keys' do
527
+ { 'First & Last' => 'Alice Smith' }.to_params.should == "First%20%26%20Last=Alice%20Smith"
528
+ end
529
+
530
+ it 'should encode query values' do
531
+ { :name => 'Alice & Bob' }.to_params.should == "name=Alice%20%26%20Bob"
532
+ end
525
533
  end
526
534
 
527
535
  describe Hash, 'to_mash' do
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'extlib/inflection'
3
3
 
4
- describe Extlib::Inflection, "#singular" do
4
+ describe Extlib::Inflection, "#plural" do
5
5
  it "pluralizes equipment => equipment" do
6
6
  "equipment".plural.should == "equipment"
7
7
  end
@@ -50,7 +50,7 @@ describe Extlib::Inflection, "#singular" do
50
50
  "hovercraft".plural.should == "hovercraft"
51
51
  end
52
52
 
53
- it "pluralizes cacti => cactus" do
53
+ it "pluralizes cactus => cacti" do
54
54
  "cactus".plural.should == "cacti"
55
55
  end
56
56
 
@@ -176,16 +176,12 @@ describe Extlib::Inflection, "#singular" do
176
176
  "phenomenon".plural.should == "phenomena"
177
177
  end
178
178
 
179
-
180
-
181
-
179
+ it "pluralizes drive => drives" do
180
+ "drive".plural.should == "drives"
181
+ end
182
182
 
183
183
  # ==== bugs, typos and reported issues
184
184
 
185
-
186
-
187
-
188
-
189
185
  # ==== rules and most common cases
190
186
 
191
187
  it "pluralizes forum => forums" do
@@ -60,10 +60,14 @@ describe Extlib::Inflection, "#singular" do
60
60
  "hovercraft".singular.should == "hovercraft"
61
61
  end
62
62
 
63
- it "singularizes cactus => cacti" do
63
+ it "singularizes cacti => cactus" do
64
64
  "cacti".singular.should == "cactus"
65
65
  end
66
66
 
67
+ it "singularizes cactuses => cactus" do
68
+ "cactuses".singular.should == "cactus"
69
+ end
70
+
67
71
  it "singularizes thesauri => thesaurus" do
68
72
  "thesauri".singular.should == "thesaurus"
69
73
  end
@@ -150,6 +154,10 @@ describe Extlib::Inflection, "#singular" do
150
154
  "indices".singular.should == "index"
151
155
  end
152
156
 
157
+ it "singularizes indexes => index" do
158
+ "indexes".singular.should == "index"
159
+ end
160
+
153
161
  it "singularizes oxen => ox" do
154
162
  "oxen".singular.should == "ox"
155
163
  end
@@ -186,16 +194,12 @@ describe Extlib::Inflection, "#singular" do
186
194
  "phenomena".singular.should == "phenomenon"
187
195
  end
188
196
 
189
-
190
-
191
-
197
+ it "singularizes drives => drive" do
198
+ "drives".singular.should == "drive"
199
+ end
192
200
 
193
201
  # ==== bugs, typos and reported issues
194
202
 
195
-
196
-
197
-
198
-
199
203
  # ==== rules
200
204
 
201
205
  it "singularizes forums => forum" do
@@ -54,13 +54,13 @@ module LazyArraySpec
54
54
 
55
55
  def should_return_true
56
56
  it 'should return true' do
57
- action.should be_true
57
+ action.should be(true)
58
58
  end
59
59
  end
60
60
 
61
61
  def should_return_false
62
62
  it 'should return false' do
63
- action.should be_false
63
+ action.should be(false)
64
64
  end
65
65
  end
66
66
 
@@ -151,7 +151,7 @@ end
151
151
  subject { @lazy_array }
152
152
 
153
153
  it 'should be an Enumerable' do
154
- (Enumerable === subject).should be_true
154
+ (Enumerable === subject).should be(true)
155
155
  end
156
156
 
157
157
  describe 'when frozen', state do
@@ -1948,7 +1948,7 @@ end
1948
1948
  end
1949
1949
 
1950
1950
  it 'should delegate to the Array' do
1951
- subject.lazy_spec.should be_true
1951
+ subject.lazy_spec.should be(true)
1952
1952
  end
1953
1953
  end
1954
1954
 
@@ -14,7 +14,7 @@ describe Mash do
14
14
  it 'converts all keys into strings when param is a Hash' do
15
15
  mash = Mash.new(@hash)
16
16
 
17
- mash.keys.any? { |key| key.is_a?(Symbol) }.should be_false
17
+ mash.keys.any? { |key| key.is_a?(Symbol) }.should be(false)
18
18
  end
19
19
 
20
20
  it 'converts all pure Hash values into Mashes if param is a Hash' do
@@ -53,7 +53,7 @@ describe Mash do
53
53
  mash = Mash.new(@hash)
54
54
  mash.update("starry" => "night")
55
55
 
56
- mash.keys.any? { |key| key.is_a?(Symbol) }.should be_false
56
+ mash.keys.any? { |key| key.is_a?(Symbol) }.should be(false)
57
57
  end
58
58
 
59
59
  it 'converts all Hash values into Mashes if param is a Hash' do
@@ -71,7 +71,7 @@ describe Mash do
71
71
  mash = Mash.new(@hash)
72
72
  mash[:hash] = { "starry" => "night" }
73
73
 
74
- mash.keys.any? { |key| key.is_a?(Symbol) }.should be_false
74
+ mash.keys.any? { |key| key.is_a?(Symbol) }.should be(false)
75
75
  end
76
76
 
77
77
  it 'converts all Hash value into Mash' do
@@ -90,36 +90,36 @@ describe Mash do
90
90
  end
91
91
 
92
92
  it 'converts key before lookup' do
93
- @mash.key?("mash").should be_true
94
- @mash.key?(:mash).should be_true
93
+ @mash.key?("mash").should be(true)
94
+ @mash.key?(:mash).should be(true)
95
95
 
96
- @mash.key?("hash").should be_true
97
- @mash.key?(:hash).should be_true
96
+ @mash.key?("hash").should be(true)
97
+ @mash.key?(:hash).should be(true)
98
98
 
99
- @mash.key?(:rainclouds).should be_false
100
- @mash.key?("rainclouds").should be_false
99
+ @mash.key?(:rainclouds).should be(false)
100
+ @mash.key?("rainclouds").should be(false)
101
101
  end
102
102
 
103
103
  it 'is aliased as include?' do
104
- @mash.include?("mash").should be_true
105
- @mash.include?(:mash).should be_true
104
+ @mash.include?("mash").should be(true)
105
+ @mash.include?(:mash).should be(true)
106
106
 
107
- @mash.include?("hash").should be_true
108
- @mash.include?(:hash).should be_true
107
+ @mash.include?("hash").should be(true)
108
+ @mash.include?(:hash).should be(true)
109
109
 
110
- @mash.include?(:rainclouds).should be_false
111
- @mash.include?("rainclouds").should be_false
110
+ @mash.include?(:rainclouds).should be(false)
111
+ @mash.include?("rainclouds").should be(false)
112
112
  end
113
113
 
114
114
  it 'is aliased as member?' do
115
- @mash.member?("mash").should be_true
116
- @mash.member?(:mash).should be_true
115
+ @mash.member?("mash").should be(true)
116
+ @mash.member?(:mash).should be(true)
117
117
 
118
- @mash.member?("hash").should be_true
119
- @mash.member?(:hash).should be_true
118
+ @mash.member?("hash").should be(true)
119
+ @mash.member?(:hash).should be(true)
120
120
 
121
- @mash.member?(:rainclouds).should be_false
122
- @mash.member?("rainclouds").should be_false
121
+ @mash.member?(:rainclouds).should be(false)
122
+ @mash.member?("rainclouds").should be(false)
123
123
  end
124
124
  end # describe "#key?"
125
125
 
@@ -198,14 +198,14 @@ describe Mash do
198
198
  mash = Mash.new(@hash)
199
199
 
200
200
  mash.delete(:hash)
201
- mash.key?("hash").should be_false
201
+ mash.key?("hash").should be(false)
202
202
  end
203
203
 
204
204
  it 'works with String keys as well' do
205
205
  mash = Mash.new(@hash)
206
206
 
207
207
  mash.delete("mash")
208
- mash.key?("mash").should be_false
208
+ mash.key?("mash").should be(false)
209
209
  end
210
210
  end
211
211
 
@@ -216,22 +216,22 @@ describe Mash do
216
216
  mash = Mash.new(@hash)
217
217
 
218
218
  hashless_mash = mash.except(:hash)
219
- hashless_mash.key?("hash").should be_false
219
+ hashless_mash.key?("hash").should be(false)
220
220
  end
221
221
 
222
222
  it "works with String keys as well" do
223
223
  mash = Mash.new(@hash)
224
224
 
225
225
  mashless_mash = mash.except("mash")
226
- mashless_mash.key?("mash").should be_false
226
+ mashless_mash.key?("mash").should be(false)
227
227
  end
228
228
 
229
229
  it "works with multiple keys" do
230
230
  mash = Mash.new(@hash)
231
231
 
232
232
  mashless = mash.except("hash", :mash)
233
- mashless.key?(:hash).should be_false
234
- mashless.key?("mash").should be_false
233
+ mashless.key?(:hash).should be(false)
234
+ mashless.key?("mash").should be(false)
235
235
  end
236
236
 
237
237
  it "should return a mash" do
@@ -62,35 +62,35 @@ describe Object do
62
62
 
63
63
  describe "#quacks_like?" do
64
64
  it 'returns true if duck is a Symbol and receiver responds to it' do
65
- SymbolicDuck.new.quacks_like?(:quack).should be_true
65
+ SymbolicDuck.new.quacks_like?(:quack).should be(true)
66
66
  end
67
67
 
68
68
  it 'returns false if duck is a Symbol and receiver DOES NOT respond to it' do
69
- SymbolicDuck.new.quacks_like?(:wtf).should be_false
69
+ SymbolicDuck.new.quacks_like?(:wtf).should be(false)
70
70
  end
71
71
 
72
72
  it 'returns true if duck is a class and receiver is its instance' do
73
73
  receiver = ClassyDuck.new
74
- receiver.quacks_like?(ClassyDuck).should be_true
74
+ receiver.quacks_like?(ClassyDuck).should be(true)
75
75
  end
76
76
 
77
77
  it 'returns false if duck is a class and receiver IS NOT its instance' do
78
78
  receiver = ClassyDuck.new
79
- receiver.quacks_like?(SymbolicDuck).should be_false
79
+ receiver.quacks_like?(SymbolicDuck).should be(false)
80
80
  end
81
81
 
82
82
  it 'returns true if duck is an array and at least one of its members quacks like this duck' do
83
83
  receiver = ClassyDuck.new
84
84
  ary = [ClassyDuck, SymbolicDuck]
85
85
 
86
- receiver.quacks_like?(ary).should be_true
86
+ receiver.quacks_like?(ary).should be(true)
87
87
  end
88
88
 
89
89
  it 'returns false if duck is an array and none of its members quacks like this duck' do
90
90
  receiver = ClassyDuck.new
91
91
  ary = [SymbolicDuck.new, SymbolicDuck]
92
92
 
93
- receiver.quacks_like?(ary).should be_false
93
+ receiver.quacks_like?(ary).should be(false)
94
94
  end
95
95
  end
96
96
 
@@ -99,16 +99,16 @@ describe Object do
99
99
  @ary = [1, 2, 3]
100
100
  @set = Set.new([2, 3, 5])
101
101
 
102
- 1.in?(@ary).should be_true
103
- 2.in?(@ary).should be_true
104
- 3.in?(@ary).should be_true
105
- 4.in?(@ary).should be_false
102
+ 1.in?(@ary).should be(true)
103
+ 2.in?(@ary).should be(true)
104
+ 3.in?(@ary).should be(true)
105
+ 4.in?(@ary).should be(false)
106
106
 
107
- 1.in?(@set).should be_false
108
- 2.in?(@set).should be_true
109
- 3.in?(@set).should be_true
110
- 4.in?(@set).should be_false
111
- 5.in?(@set).should be_true
107
+ 1.in?(@set).should be(false)
108
+ 2.in?(@set).should be(true)
109
+ 3.in?(@set).should be(true)
110
+ 4.in?(@set).should be(false)
111
+ 5.in?(@set).should be(true)
112
112
  end
113
113
  end
114
114
  end
@@ -156,7 +156,7 @@ describe "Extlib::Pooling" do
156
156
  bob.release
157
157
  Extlib.exiting = true
158
158
  sleep(0.1)
159
- Extlib::Pooling.scavenger?.should be_false
159
+ Extlib::Pooling.scavenger?.should be(false)
160
160
  end
161
161
 
162
162
  it "should be able to detach an instance from the pool" do
@@ -431,7 +431,7 @@ end
431
431
  # it "acquires new instances from pool" do
432
432
  # @instance_one = DisposableResource.new
433
433
  #
434
- # DisposableResource.pool.acquired?(@instance_one).should be_true
434
+ # DisposableResource.pool.acquired?(@instance_one).should be(true)
435
435
  # end
436
436
  #
437
437
  # it "flushed existing pool on re-initialization" do
@@ -483,10 +483,10 @@ end
483
483
  #
484
484
  # it "returns true when object's last aquisition time is greater than limit" do
485
485
  # @t1 = DisposableResource.new
486
- # DisposableResource.pool.time_to_release?(@t1).should be_false
486
+ # DisposableResource.pool.time_to_release?(@t1).should be(false)
487
487
  #
488
488
  # sleep 3
489
- # DisposableResource.pool.time_to_release?(@t1).should be_true
489
+ # DisposableResource.pool.time_to_release?(@t1).should be(true)
490
490
  # end
491
491
  # end
492
492
  #
@@ -1,4 +1,4 @@
1
- --exclude "spec"
1
+ --exclude "spec,^/"
2
2
  --sort coverage
3
3
  --callsites
4
4
  --xrefs
@@ -25,7 +25,7 @@ describe Extlib::SimpleSet do
25
25
 
26
26
  it 'sets true mark on the key' do
27
27
  @s << "Fun"
28
- @s["Fun"].should be_true
28
+ @s["Fun"].should be(true)
29
29
  end
30
30
  end
31
31
 
@@ -1,22 +1,38 @@
1
- require 'spec/rake/spectask'
2
- require 'spec/rake/verify_rcov'
3
-
4
1
  spec_defaults = lambda do |spec|
5
2
  spec.pattern = 'spec/**/*_spec.rb'
6
3
  spec.libs << 'lib' << 'spec'
7
4
  spec.spec_opts << '--options' << 'spec/spec.opts'
8
5
  end
9
6
 
10
- Spec::Rake::SpecTask.new(:spec, &spec_defaults)
7
+ begin
8
+ require 'spec/rake/spectask'
11
9
 
12
- Spec::Rake::SpecTask.new(:rcov) do |rcov|
13
- spec_defaults.call(rcov)
14
- rcov.rcov = true
15
- rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/)
10
+ Spec::Rake::SpecTask.new(:spec, &spec_defaults)
11
+ rescue LoadError
12
+ task :spec do
13
+ abort 'rspec is not available. In order to run spec, you must: gem install rspec'
14
+ end
16
15
  end
17
16
 
18
- RCov::VerifyTask.new(:verify_rcov => :rcov) do |rcov|
19
- rcov.threshold = 100
17
+ begin
18
+ require 'rcov'
19
+ require 'spec/rake/verify_rcov'
20
+
21
+ Spec::Rake::SpecTask.new(:rcov) do |rcov|
22
+ spec_defaults.call(rcov)
23
+ rcov.rcov = true
24
+ rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/)
25
+ end
26
+
27
+ RCov::VerifyTask.new(:verify_rcov => :rcov) do |rcov|
28
+ rcov.threshold = 100
29
+ end
30
+ rescue LoadError
31
+ %w[ rcov verify_rcov ].each do |name|
32
+ task name do
33
+ abort "rcov is not available. In order to run #{name}, you must: gem install rcov"
34
+ end
35
+ end
20
36
  end
21
37
 
22
38
  task :spec => :check_dependencies
metadata CHANGED
@@ -1,61 +1,58 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: extlib
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 9
8
- - 15
9
- version: 0.9.15
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.16
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Dan Kubb
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2010-05-18 00:00:00 -07:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-01-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: json_pure
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
25
19
  - - ~>
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 1
29
- - 4
30
- version: "1.4"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.4'
31
22
  type: :development
32
- version_requirements: *id001
33
- - !ruby/object:Gem::Dependency
34
- name: rspec
35
23
  prerelease: false
36
- requirement: &id002 !ruby/object:Gem::Requirement
37
- requirements:
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.4'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
38
35
  - - ~>
39
- - !ruby/object:Gem::Version
40
- segments:
41
- - 1
42
- - 3
43
- version: "1.3"
36
+ - !ruby/object:Gem::Version
37
+ version: '1.3'
44
38
  type: :development
45
- version_requirements: *id002
46
- description: Support library for DataMapper and Merb
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.3'
46
+ description: Support library for Merb
47
47
  email: dan.kubb@gmail.com
48
48
  executables: []
49
-
50
49
  extensions: []
51
-
52
- extra_rdoc_files:
50
+ extra_rdoc_files:
53
51
  - LICENSE
54
52
  - README.rdoc
55
- files:
53
+ files:
56
54
  - .autotest
57
55
  - .document
58
- - .gitignore
59
56
  - LICENSE
60
57
  - README.rdoc
61
58
  - Rakefile
@@ -126,60 +123,28 @@ files:
126
123
  - tasks/spec.rake
127
124
  - tasks/yard.rake
128
125
  - tasks/yardstick.rake
129
- has_rdoc: true
130
126
  homepage: http://github.com/datamapper/extlib
131
127
  licenses: []
132
-
133
128
  post_install_message:
134
- rdoc_options:
135
- - --charset=UTF-8
136
- require_paths:
129
+ rdoc_options: []
130
+ require_paths:
137
131
  - lib
138
- required_ruby_version: !ruby/object:Gem::Requirement
139
- requirements:
140
- - - ">="
141
- - !ruby/object:Gem::Version
142
- segments:
143
- - 0
144
- version: "0"
145
- required_rubygems_version: !ruby/object:Gem::Requirement
146
- requirements:
147
- - - ">="
148
- - !ruby/object:Gem::Version
149
- segments:
150
- - 0
151
- version: "0"
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ! '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
152
144
  requirements: []
153
-
154
145
  rubyforge_project: extlib
155
- rubygems_version: 1.3.6
146
+ rubygems_version: 1.8.24
156
147
  signing_key:
157
148
  specification_version: 3
158
- summary: Support library for DataMapper and Merb
159
- test_files:
160
- - spec/array_spec.rb
161
- - spec/blank_spec.rb
162
- - spec/byte_array_spec.rb
163
- - spec/class_spec.rb
164
- - spec/datetime_spec.rb
165
- - spec/hash_spec.rb
166
- - spec/hook_spec.rb
167
- - spec/inflection/plural_spec.rb
168
- - spec/inflection/singular_spec.rb
169
- - spec/inflection_extras_spec.rb
170
- - spec/lazy_array_spec.rb
171
- - spec/lazy_module_spec.rb
172
- - spec/mash_spec.rb
173
- - spec/module_spec.rb
174
- - spec/object_space_spec.rb
175
- - spec/object_spec.rb
176
- - spec/pooling_spec.rb
177
- - spec/simple_set_spec.rb
178
- - spec/spec_helper.rb
179
- - spec/string_spec.rb
180
- - spec/struct_spec.rb
181
- - spec/symbol_spec.rb
182
- - spec/time_spec.rb
183
- - spec/try_call_spec.rb
184
- - spec/try_dup_spec.rb
185
- - spec/virtual_file_spec.rb
149
+ summary: Support library for Merb
150
+ test_files: []
data/.gitignore DELETED
@@ -1,35 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## Rubinius
17
- *.rbc
18
-
19
- ## PROJECT::GENERAL
20
- *.gem
21
- coverage
22
- rdoc
23
- pkg
24
- tmp
25
- doc
26
- log
27
- .yardoc
28
- measurements
29
-
30
- ## BUNDLER
31
- .bundle
32
- Gemfile.local
33
- Gemfile.lock
34
-
35
- ## PROJECT::SPECIFIC