epitools 0.4.28 → 0.4.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.28
1
+ 0.4.29
data/epitools.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{epitools}
8
- s.version = "0.4.28"
8
+ s.version = "0.4.29"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["epitron"]
12
- s.date = %q{2011-04-27}
12
+ s.date = %q{2011-05-06}
13
13
  s.description = %q{Miscellaneous utility libraries to make my life easier.}
14
14
  s.email = %q{chris@ill-logic.com}
15
15
  s.extra_rdoc_files = [
@@ -66,21 +66,6 @@ Gem::Specification.new do |s|
66
66
  s.require_paths = ["lib"]
67
67
  s.rubygems_version = %q{1.5.2}
68
68
  s.summary = %q{NOT UTILS... METILS!}
69
- s.test_files = [
70
- "spec/basetypes_spec.rb",
71
- "spec/browser_spec.rb",
72
- "spec/clitools_spec.rb",
73
- "spec/lcs_spec.rb",
74
- "spec/metaclass_spec.rb",
75
- "spec/numwords_spec.rb",
76
- "spec/path_spec.rb",
77
- "spec/permutations_spec.rb",
78
- "spec/rash_spec.rb",
79
- "spec/ratio_spec.rb",
80
- "spec/spec_helper.rb",
81
- "spec/sys_spec.rb",
82
- "spec/zopen_spec.rb"
83
- ]
84
69
 
85
70
  if s.respond_to? :specification_version then
86
71
  s.specification_version = 3
@@ -1,4 +1,5 @@
1
1
  require 'pp'
2
+ require 'uri'
2
3
 
3
4
  # Alias "Enumerator" to "Enum"
4
5
 
@@ -117,6 +118,20 @@ class String
117
118
  tr('n-za-mN-ZA-M', 'a-zA-Z')
118
119
  end
119
120
 
121
+ #
122
+ # Convert non-URI characters into %XXes.
123
+ #
124
+ def urlencode
125
+ URI.escape(self)
126
+ end
127
+
128
+ #
129
+ # Convert an URI's %XXes into regular characters.
130
+ #
131
+ def urldecode
132
+ URI.unescape(self)
133
+ end
134
+
120
135
  end
121
136
 
122
137
 
@@ -639,6 +654,35 @@ class Hash
639
654
  nil
640
655
  end
641
656
 
657
+ #
658
+ # Convert the hash into a GET query.
659
+ #
660
+ def to_query
661
+ params = ''
662
+ stack = []
663
+
664
+ each do |k, v|
665
+ if v.is_a?(Hash)
666
+ stack << [k,v]
667
+ else
668
+ params << "#{k}=#{v}&"
669
+ end
670
+ end
671
+
672
+ stack.each do |parent, hash|
673
+ hash.each do |k, v|
674
+ if v.is_a?(Hash)
675
+ stack << ["#{parent}[#{k}]", v]
676
+ else
677
+ params << "#{parent}[#{k}]=#{v}&"
678
+ end
679
+ end
680
+ end
681
+
682
+ params.chop! # trailing &
683
+ params
684
+ end
685
+
642
686
  end
643
687
 
644
688
  unless defined?(BasicObject)
@@ -120,6 +120,25 @@ describe String do
120
120
  message.rot13.rot13.should == message
121
121
  end
122
122
 
123
+ it "tightens" do
124
+ " hi there".tighten.should == "hi there"
125
+ end
126
+
127
+ it "dewhitespaces" do
128
+ "\nso there i \n was, eating my cookies".dewhitespace.should == "so there i was, eating my cookies"
129
+ end
130
+
131
+ it "nice_lineses" do
132
+ "\n\n\nblah\n\n\nblah\n\n\n".nice_lines.should == ["blah", "blah"]
133
+ end
134
+
135
+ it "urlencodes/decodes" do
136
+ s = "hi + there & mom + !!!!! I AM ON RSPEC"
137
+ s.urlencode.should_not == s
138
+ s.urlencode.should == "hi%20+%20there%20&%20mom%20+%20!!!!!%20I%20AM%20ON%20RSPEC"
139
+ s.urlencode.urldecode.should == s
140
+ end
141
+
123
142
  end
124
143
 
125
144
 
@@ -280,6 +299,11 @@ describe Hash do
280
299
  }.should_not raise_error
281
300
  end
282
301
 
302
+ it "to_querys" do
303
+ # this will probably fail half the time in Ruby 1.8 because the hash order is random
304
+ {:donkeys=>7, :stubborn=>true}.to_query.should == "donkeys=7&stubborn=true"
305
+ end
306
+
283
307
  end
284
308
 
285
309
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: epitools
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.28
5
+ version: 0.4.29
6
6
  platform: ruby
7
7
  authors:
8
8
  - epitron
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-27 00:00:00 -04:00
13
+ date: 2011-05-06 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -127,17 +127,5 @@ rubygems_version: 1.5.2
127
127
  signing_key:
128
128
  specification_version: 3
129
129
  summary: NOT UTILS... METILS!
130
- test_files:
131
- - spec/basetypes_spec.rb
132
- - spec/browser_spec.rb
133
- - spec/clitools_spec.rb
134
- - spec/lcs_spec.rb
135
- - spec/metaclass_spec.rb
136
- - spec/numwords_spec.rb
137
- - spec/path_spec.rb
138
- - spec/permutations_spec.rb
139
- - spec/rash_spec.rb
140
- - spec/ratio_spec.rb
141
- - spec/spec_helper.rb
142
- - spec/sys_spec.rb
143
- - spec/zopen_spec.rb
130
+ test_files: []
131
+