threetaps-client 1.0.10 → 1.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.10
1
+ 1.0.11
data/lib/client/client.rb CHANGED
@@ -2,6 +2,7 @@
2
2
  class Client
3
3
  DEFAULT_URL = 'http://3taps.net'
4
4
  DEFAULT_API_PORT = 80
5
+ TIMEOUT = 15
5
6
  # Initializes Client class with +baseUrl+ and +port+ parameters. By default
6
7
  # DEFAULT_URL and DEFAULT_API_PORT are used. Examples:
7
8
  # Client.new
@@ -31,7 +32,11 @@ class Client
31
32
  #
32
33
  # execute_post("search", "data=data")
33
34
  def execute_post( path, params = nil )
34
- c = Curl::Easy.http_post("#{@baseURL}:#{@port}/#{path}", params)
35
+ c = Curl::Easy.new("#{@baseURL}:#{@port}/#{path}")
36
+ param, data = params.split("=",2)
37
+ c.http_post(param.to_s + '=' + c.escape(data.to_s))
38
+ c.timeout = TIMEOUT
39
+ c.perform
35
40
  c.body_str
36
41
  end
37
42
 
@@ -36,7 +36,9 @@ class GeocoderClient < Client
36
36
  params = "data=["
37
37
  params << geocoder_requests.collect{|request| "#{request.to_params}"}.join(',')
38
38
  params << "]"
39
+ p params
39
40
  response = execute_post('geocoder/geocode', params)
41
+ p response
40
42
  p decode(response)
41
43
  GeocoderResponse.from_array(decode(response))
42
44
  end
@@ -2,14 +2,14 @@ class GeocoderRequest < Struct.new(:latitude, :longitude, :country, :state, :cit
2
2
 
3
3
  def to_params
4
4
  result = []
5
- result << "\"latitude\":#{CGI.escape latitude}" unless latitude.nil?
6
- result << "\"longitude\":#{CGI.escape longitude}" unless longitude.nil?
7
- result << "\"country\":\"#{CGI.escape country}\"" unless country.nil?
8
- result << "\"state\":\"#{CGI.escape state}\"" unless state.nil?
9
- result << "\"city\":\"#{CGI.escape city}\"" unless city.nil?
10
- result << "\"locality\":\"#{CGI.escape locality}\"" unless locality.nil?
11
- result << "\"postal\":\"#{CGI.escape postal}\"" unless postal.nil?
12
- result << "\"text\":\"#{CGI.escape text}\"" unless text.nil?
5
+ result << "\"latitude\":#{latitude}" unless latitude.nil?
6
+ result << "\"longitude\":#{longitude}" unless longitude.nil?
7
+ result << "\"country\":\"#{country}\"" unless country.nil?
8
+ result << "\"state\":\"#{state}\"" unless state.nil?
9
+ result << "\"city\":\"#{city}\"" unless city.nil?
10
+ result << "\"locality\":\"#{locality}\"" unless locality.nil?
11
+ result << "\"postal\":\"#{postal}\"" unless postal.nil?
12
+ result << "\"text\":\"#{text}\"" unless text.nil?
13
13
  '{' + result.join(", ") + '}'
14
14
  end
15
15
 
@@ -54,6 +54,7 @@ class Posting < SuperModel::Base
54
54
  posting << ',images:' + "[#{images.collect{ |image| "'#{image}'"}.join(',')}]"
55
55
  unless self.body.blank?
56
56
  self.body.gsub!(/[&']/,"")
57
+ #self.body.gsub!(/\s*<[^>]*>/,"")
57
58
  posting << ',body:' + "'#{ActiveSupport::JSON.encode(self.body)}'"
58
59
  end
59
60
  posting << ',price:' + "#{self.price.to_f}"
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{threetaps-client}
8
- s.version = "1.0.10"
8
+ s.version = "1.0.11"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["3taps.com"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: threetaps-client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 10
10
- version: 1.0.10
9
+ - 11
10
+ version: 1.0.11
11
11
  platform: ruby
12
12
  authors:
13
13
  - 3taps.com