woefoo 0.0.9 → 0.0.10

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.
Files changed (3) hide show
  1. data/lib/woefoo/version.rb +1 -1
  2. data/lib/woefoo.rb +13 -2
  3. metadata +3 -3
@@ -1,3 +1,3 @@
1
1
  module Woefoo
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
data/lib/woefoo.rb CHANGED
@@ -56,7 +56,7 @@ module Woefoo
56
56
  if opts.include?(:query)
57
57
  s = opts[:query]
58
58
  else
59
- [:line1, :city, :region, :zip, :country_code].each do |l|
59
+ [:line1, :city, :state, :postal, :country].each do |l|
60
60
  s << "#{opts[l]} " if opts.include?(l)
61
61
  end
62
62
  end
@@ -67,7 +67,7 @@ module Woefoo
67
67
  # Build a parameterized query url
68
68
  def build_parameterized_url(opts={})
69
69
  s = ""
70
- [:line1, :city, :state, :postal, :country].each do |l|
70
+ build_query_keys(opts).each do |l|
71
71
  if opts.include?(l)
72
72
  val = ::CGI.escape(opts[l])
73
73
  s << "&#{l.to_s}=#{val} "
@@ -87,4 +87,15 @@ module Woefoo
87
87
  tr = Typhoeus::Request.get(url)
88
88
  Woefoo::Response.new(opts, tr) if tr
89
89
  end
90
+
91
+ def build_query_keys(opts={})
92
+ k = [:line1, :city, :state, :postal, :country]
93
+ if opts.include?(:country)
94
+ if opts[:country] != "US" && opts[:country] != "CA"
95
+ k.delete(:state)
96
+ k.delete(:postal)
97
+ end
98
+ end
99
+ k
100
+ end
90
101
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: woefoo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 9
10
- version: 0.0.9
9
+ - 10
10
+ version: 0.0.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - smnirven