queryparams 0.0.1 → 0.0.2

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/README.md CHANGED
@@ -2,14 +2,14 @@
2
2
 
3
3
  A straight forward gem to convert ruby hashes and arrays to http query strings. It supports hashes, arrays, nested hashes and arrays of hashes and all combinations thereof. E.g.:
4
4
 
5
- Querystring.encode({a: 1, b: "c"})
5
+ QueryParams.encode({a: 1, b: "c"})
6
6
  => "a=1&b=c"
7
7
 
8
- Querystring.encode({a: {b: 'c', d: 'e'}, f: 'g'})
8
+ QueryParams.encode({a: {b: 'c', d: 'e'}, f: 'g'})
9
9
  => "a[b]=c&a[d]=e&f=g"
10
10
 
11
- Querystring.encode({a: ['bingo', 'hepp']})
11
+ QueryParams.encode({a: ['bingo', 'hepp']})
12
12
  => "a[0]=bingo&a[1]=hepp"
13
13
 
14
- Querystring.encode({a: [{b:'c', d:'e'}, {f:'g'}]})
14
+ QueryParams.encode({a: [{b:'c', d:'e'}, {f:'g'}]})
15
15
  => "a[0][b]=c&a[0][d]=e&a[1][f]=g"
data/lib/queryparams.rb CHANGED
@@ -10,6 +10,8 @@ module QueryParams
10
10
  value.each { |k,v| q << encode(v, append_key(key,k)) }
11
11
  when Array
12
12
  value.each_with_index { |v,i| q << encode(v, append_key(key, i)) }
13
+ when nil
14
+ return ''
13
15
  else
14
16
  return "#{key}=#{CGI.escape(value.to_s)}"
15
17
  end
@@ -1,3 +1,3 @@
1
1
  module QueryParams
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -4,6 +4,7 @@ Bundler.require
4
4
  describe QueryParams do
5
5
  it "generates nothing if need be" do
6
6
  QueryParams.encode({}).should eq ""
7
+ QueryParams.encode(nil).should eq ""
7
8
  end
8
9
 
9
10
  it "generates a straight forward query string" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: queryparams
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-10-29 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70326031061260 !ruby/object:Gem::Requirement
16
+ requirement: &70151522636860 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70326031061260
24
+ version_requirements: *70151522636860
25
25
  description: ! ' It supports hashes, arrays, nested hashes and arrays of hashes and
26
26
  all combinations thereof.'
27
27
  email: