oodle 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,35 @@
1
- # Oodle Ruby API (v1.0)
1
+ # Oodle Ruby API
2
2
  ---
3
3
 
4
- ## This software is licensed using the MIT License (see LICENSE for details)
4
+ ## Description
5
5
 
6
- ## Description of use
6
+ Oodle is an online classifieds service. By using this client for the [Oodle
7
+ API](http://developer.oodle.com/), you can add classified listings to your own site. You can filter
8
+ listings by category, region, and keywords. You will need to request an [API
9
+ key](http://developer.oodle.com/request-api-key) to get started.
7
10
 
8
- This is a wrapper api for the Oodle API (http://developer.oodle.com/). It follows very tightly against the documentation provided by oodle and it works like this:
11
+ ## Installation
9
12
 
13
+ gem install oodle
14
+
15
+ ## Example
16
+
17
+ require 'rubygems'
18
+ require 'oodle'
19
+
20
+ API_KEY = '??????' # Request your API key at http://developer.oodle.com/request-api-key
21
+
22
+ oodle = Oodle::API.new(API_KEY, :v2)
23
+ oodle.region = 'chicago'
24
+ oodle.category = 'personals'
25
+ oodle.fetch_listings(:json)['listings'][0]['body']
26
+ oodle.fetch_listings['listings'][1]['body']
27
+
28
+ ## Dependencies
29
+
30
+ * xml-simple gem
31
+ * json gem
32
+
33
+ ## License
34
+
35
+ This software is licensed using the MIT License (see LICENSE for details).
@@ -5,6 +5,7 @@
5
5
  require 'net/http'
6
6
  require 'xmlsimple'
7
7
  require 'cgi'
8
+ require 'json'
8
9
 
9
10
  # Oodle Module
10
11
  module Oodle
@@ -40,8 +41,6 @@ module Oodle
40
41
  # Oodle Class
41
42
  #
42
43
  class API
43
- logger.debug "Oodle::API is loaded." if logger
44
-
45
44
  attr_accessor :key, :region, :q, :category, :attributes, :location, :radius, :start, :num, :sort, :refinements, :ctime_low, :ctime_high, :exclude_sources, :assisted_search, :format, :jsoncallback, :fetched, :version
46
45
 
47
46
  def initialize(key,version)
@@ -57,17 +56,8 @@ module Oodle
57
56
  # A convience method to do actual http pulls
58
57
  # Notice that there is not any exception trapping
59
58
  def http_pull(dest_url)
60
- logger.debug "Pulling from url: #{dest_url}" if logger
61
- url = URI.parse(dest_url)
62
- logger.debug "URL: #{url} -- PATH: #{url.path} -- URI: #{url.path}?#{url.query}" if logger
63
-
64
- res = Net::HTTP.get_response( url )
65
- if res.code == '200'
66
- self.fetched = res.body
67
- return self.fetched
68
- else
69
- nil
70
- end
59
+ res = Net::HTTP.get_response(URI.parse(dest_url))
60
+ self.fetched = res.body
71
61
  end
72
62
 
73
63
  # Requires version be set
@@ -91,8 +81,7 @@ module Oodle
91
81
  url = "#{url}&ctime_high=#{CGI::escape(self.ctime_high)}" if self.ctime_high
92
82
  url = "#{url}&exclude_sources=#{CGI::escape(self.exclude_sources_as_string)}" if self.exclude_sources.size > 0
93
83
  url = "#{url}&assisted_search=#{CGI::escape(self.assisted_search)}" if self.assisted_search
94
- url = "#{url}&format=#{CGI::escape(self.format)}" if self.format
95
- logger.debug "#{__FILE__}:#{__LINE__} [#{__method__}] -- URL CONSTRUCTED: #{url}" if logger
84
+ url = "#{url}&format=#{CGI::escape(self.format)}&jsoncallback=none" if self.format
96
85
  url
97
86
  end
98
87
 
@@ -139,7 +128,7 @@ module Oodle
139
128
  # parse xml raw
140
129
  result = XmlSimple.xml_in raw, { 'ForceArray' => false, 'AttrPrefix' => true }
141
130
  when 'json'
142
- # TODO parse json raw
131
+ result = JSON.parse(raw)
143
132
  when 'php_serial'
144
133
  # return raw
145
134
  when 'php_export'
@@ -0,0 +1,3 @@
1
+ require File.dirname(__FILE__) + '/test-helper'
2
+
3
+ require File.dirname(__FILE__) + '/oodle_api_test'
metadata CHANGED
@@ -1,19 +1,48 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oodle
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 1
8
+ - 0
9
+ version: 1.1.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Kristan 'Krispy' Uccello
13
+ - Albert Vernon
8
14
  autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-11-06 00:00:00 -05:00
18
+ date: 2010-03-18 00:00:00 -04:00
13
19
  default_executable:
14
- dependencies: []
15
-
16
- description: Provides a ruby wrapper around the Oodle api
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: xml-simple
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: json
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ segments:
41
+ - 0
42
+ version: "0"
43
+ type: :runtime
44
+ version_requirements: *id002
45
+ description: Provides a Ruby wrapper around the Oodle API
17
46
  email: kaptiankrispy@soldierofcode.com
18
47
  executables: []
19
48
 
@@ -23,12 +52,10 @@ extra_rdoc_files: []
23
52
 
24
53
  files:
25
54
  - README.markdown
26
- - Changelog
27
55
  - LICENSE
28
56
  - lib/oodle.rb
29
- - INSTALL
30
57
  has_rdoc: true
31
- homepage: http://soldierofcode.com/projects/oodle-api
58
+ homepage: http://github.com/kuccello/Oodle-API-Ruby
32
59
  licenses: []
33
60
 
34
61
  post_install_message:
@@ -40,20 +67,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
40
67
  requirements:
41
68
  - - ">="
42
69
  - !ruby/object:Gem::Version
70
+ segments:
71
+ - 0
43
72
  version: "0"
44
- version:
45
73
  required_rubygems_version: !ruby/object:Gem::Requirement
46
74
  requirements:
47
75
  - - ">="
48
76
  - !ruby/object:Gem::Version
77
+ segments:
78
+ - 0
49
79
  version: "0"
50
- version:
51
80
  requirements: []
52
81
 
53
82
  rubyforge_project:
54
- rubygems_version: 1.3.5
83
+ rubygems_version: 1.3.6
55
84
  signing_key:
56
85
  specification_version: 3
57
- summary: Provides a ruby wrapper around the Oodle api
58
- test_files: []
59
-
86
+ summary: Provides a Ruby wrapper around the Oodle API
87
+ test_files:
88
+ - test/oodle_tests.rb
data/Changelog DELETED
@@ -1 +0,0 @@
1
- - Nov. 6 - 2009 - fixed the issue with the url being generated wrong
data/INSTALL DELETED
File without changes