vigetlabs-radarb 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +9 -0
- data/Manifest.txt +15 -0
- data/README.txt +75 -0
- data/Rakefile +26 -0
- data/lib/radarb/collectable.rb +15 -0
- data/lib/radarb/fetch.rb +7 -0
- data/lib/radarb/place.rb +10 -0
- data/lib/radarb/radar.rb +23 -0
- data/lib/radarb/tag.rb +9 -0
- data/lib/radarb.rb +58 -0
- data/radarb.gemspec +29 -0
- data/test/radarb/collectable_test.rb +30 -0
- data/test/radarb/radar_test.rb +26 -0
- data/test/radarb_test.rb +9 -0
- data/test/test_helper.rb +5 -0
- metadata +86 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.txt
|
4
|
+
Rakefile
|
5
|
+
lib/radarb.rb
|
6
|
+
lib/radarb/collectable.rb
|
7
|
+
lib/radarb/fetch.rb
|
8
|
+
lib/radarb/place.rb
|
9
|
+
lib/radarb/radar.rb
|
10
|
+
lib/radarb/tag.rb
|
11
|
+
radarb.gemspec
|
12
|
+
test/radarb/collectable_test.rb
|
13
|
+
test/radarb/radar_test.rb
|
14
|
+
test/radarb_test.rb
|
15
|
+
test/test_helper.rb
|
data/README.txt
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
radarb
|
2
|
+
by Justin Marney
|
3
|
+
http://github.com/vigetlabs/radarb
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
A ruby gem that makes using the http://outside.in/ API simple.
|
8
|
+
|
9
|
+
== SYNOPSIS:
|
10
|
+
|
11
|
+
require 'radarb'
|
12
|
+
|
13
|
+
blips = Radarb::Radar.scan('40.714550', '-74.007124')
|
14
|
+
|
15
|
+
blips.each do |blip|
|
16
|
+
puts blip.author
|
17
|
+
puts blip.url
|
18
|
+
puts blip.type
|
19
|
+
end
|
20
|
+
|
21
|
+
blips.stories.each do |story|
|
22
|
+
puts story.title
|
23
|
+
puts story.body
|
24
|
+
end
|
25
|
+
|
26
|
+
blips.tweets.each do |story|
|
27
|
+
puts story.author
|
28
|
+
puts story.body
|
29
|
+
end
|
30
|
+
|
31
|
+
story = blips.stories.first
|
32
|
+
|
33
|
+
story.places.each do |place|
|
34
|
+
puts place.name
|
35
|
+
puts place.url
|
36
|
+
end
|
37
|
+
|
38
|
+
story.tags.each do |tag|
|
39
|
+
puts tag.name
|
40
|
+
puts tag.url
|
41
|
+
end
|
42
|
+
|
43
|
+
== REQUIREMENTS:
|
44
|
+
|
45
|
+
sudo gem install curb
|
46
|
+
sudo gem install gotascii-happymapper -s http://gems.github.com
|
47
|
+
|
48
|
+
== INSTALL:
|
49
|
+
|
50
|
+
sudo gem install vigetlabs-radarb -s http://gems.github.com
|
51
|
+
|
52
|
+
== LICENSE:
|
53
|
+
|
54
|
+
(The MIT License)
|
55
|
+
|
56
|
+
Copyright (c) 2008 FIXME (different license?)
|
57
|
+
|
58
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
59
|
+
a copy of this software and associated documentation files (the
|
60
|
+
'Software'), to deal in the Software without restriction, including
|
61
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
62
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
63
|
+
permit persons to whom the Software is furnished to do so, subject to
|
64
|
+
the following conditions:
|
65
|
+
|
66
|
+
The above copyright notice and this permission notice shall be
|
67
|
+
included in all copies or substantial portions of the Software.
|
68
|
+
|
69
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
70
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
71
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
72
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
73
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
74
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
75
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Look in the tasks/setup.rb file for the various options that can be
|
2
|
+
# configured in this Rakefile. The .rake files in the tasks directory
|
3
|
+
# are where the options are used.
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'bones'
|
7
|
+
Bones.setup
|
8
|
+
rescue LoadError
|
9
|
+
load 'tasks/setup.rb'
|
10
|
+
end
|
11
|
+
|
12
|
+
ensure_in_path 'lib'
|
13
|
+
require 'radarb'
|
14
|
+
|
15
|
+
task :default => 'test'
|
16
|
+
|
17
|
+
PROJ.name = 'radarb'
|
18
|
+
PROJ.authors = 'Justin Marney'
|
19
|
+
PROJ.email = 'justin.marney@viget.com'
|
20
|
+
PROJ.url = 'http://github.com/vigetlabs/radarb'
|
21
|
+
PROJ.version = Radarb::VERSION
|
22
|
+
PROJ.rubyforge.name = 'radarb'
|
23
|
+
PROJ.test.files = FileList['test/**/*_test.rb']
|
24
|
+
PROJ.spec.opts << '--color'
|
25
|
+
|
26
|
+
# EOF
|
data/lib/radarb/fetch.rb
ADDED
data/lib/radarb/place.rb
ADDED
data/lib/radarb/radar.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Radarb
|
2
|
+
class Radar
|
3
|
+
include HappyMapper
|
4
|
+
|
5
|
+
tag 'radar'
|
6
|
+
element :item_id, Integer
|
7
|
+
element :icon_path, String
|
8
|
+
element :author, String
|
9
|
+
element :author_url, String
|
10
|
+
element :published_at, DateTime
|
11
|
+
element :title, String
|
12
|
+
element :body, String
|
13
|
+
element :url, String
|
14
|
+
element :image_url, String
|
15
|
+
attribute :type, String
|
16
|
+
|
17
|
+
def self.scan(lat = '40.755970', lng='-73.986702')
|
18
|
+
url = "#{API}?lat=#{lat}&lng=#{lng}"
|
19
|
+
xml = Fetch::fetch_url(url)
|
20
|
+
parse(xml).extend(Collectable)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/radarb/tag.rb
ADDED
data/lib/radarb.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'curb'
|
3
|
+
require 'happymapper'
|
4
|
+
|
5
|
+
module Radarb
|
6
|
+
|
7
|
+
API = "http://api.outside.in/radar.xml"
|
8
|
+
|
9
|
+
# :stopdoc:
|
10
|
+
VERSION = '1.1.0'
|
11
|
+
LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
|
12
|
+
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
|
13
|
+
# :startdoc:
|
14
|
+
|
15
|
+
# Returns the version string for the library.
|
16
|
+
#
|
17
|
+
def self.version
|
18
|
+
VERSION
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns the library path for the module. If any arguments are given,
|
22
|
+
# they will be joined to the end of the libray path using
|
23
|
+
# <tt>File.join</tt>.
|
24
|
+
#
|
25
|
+
def self.libpath( *args )
|
26
|
+
args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns the lpath for the module. If any arguments are given,
|
30
|
+
# they will be joined to the end of the path using
|
31
|
+
# <tt>File.join</tt>.
|
32
|
+
#
|
33
|
+
def self.path( *args )
|
34
|
+
args.empty? ? PATH : ::File.join(PATH, args.flatten)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Utility method used to rquire all files ending in .rb that lie in the
|
38
|
+
# directory below this file that has the same name as the filename passed
|
39
|
+
# in. Optionally, a specific _directory_ name can be passed in such that
|
40
|
+
# the _filename_ does not have to be equivalent to the directory.
|
41
|
+
#
|
42
|
+
def self.require_all_libs_relative_to( fname, dir = nil )
|
43
|
+
dir ||= ::File.basename(fname, '.*')
|
44
|
+
search_me = ::File.expand_path(
|
45
|
+
::File.join(::File.dirname(fname), dir, '*', '*.rb'))
|
46
|
+
|
47
|
+
Dir.glob(search_me).sort.each {|rb| require rb}
|
48
|
+
end
|
49
|
+
|
50
|
+
end # module Radarb
|
51
|
+
|
52
|
+
require 'radarb/fetch'
|
53
|
+
require 'radarb/collectable'
|
54
|
+
require 'radarb/tag'
|
55
|
+
require 'radarb/place'
|
56
|
+
require 'radarb/radar'
|
57
|
+
|
58
|
+
# EOF
|
data/radarb.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "radarb"
|
3
|
+
s.version = "1.1.0"
|
4
|
+
s.date = "2008-01-15"
|
5
|
+
s.summary = "outside.in radar API wrapper."
|
6
|
+
s.email = "justin.marney@viget.com"
|
7
|
+
s.homepage = "http://github.com/vigetlabs/radarb"
|
8
|
+
s.description = "A ruby gem that makes using the http://outside.in/ API simple."
|
9
|
+
s.has_rdoc = true
|
10
|
+
s.authors = ["Justin Marney"]
|
11
|
+
s.files = ["History.txt",
|
12
|
+
"README.txt",
|
13
|
+
"Rakefile",
|
14
|
+
"radarb.gemspec",
|
15
|
+
"lib/radarb.rb",
|
16
|
+
"lib/radarb/collectable.rb",
|
17
|
+
"lib/radarb/fetch.rb",
|
18
|
+
"lib/radarb/place.rb",
|
19
|
+
"lib/radarb/radar.rb",
|
20
|
+
"lib/radarb/tag.rb"]
|
21
|
+
s.test_files = ["test/test_helper.rb",
|
22
|
+
"test/radarb_test.rb",
|
23
|
+
"test/radarb/radar_test.rb",
|
24
|
+
"test/radarb/collectable_test.rb"]
|
25
|
+
s.rdoc_options = ["--main", "README.txt"]
|
26
|
+
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
|
27
|
+
s.add_dependency("gotascii-happymapper", ["> 0.0.0"])
|
28
|
+
s.add_dependency("curb", ["> 0.0.0"])
|
29
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
2
|
+
|
3
|
+
module Radarb
|
4
|
+
class ColelctableTest < Test::Unit::TestCase
|
5
|
+
context "An object extended by the Collectable module" do
|
6
|
+
setup do
|
7
|
+
@collectable = [].extend(Collectable)
|
8
|
+
end
|
9
|
+
|
10
|
+
should "return all items with type Tweet" do
|
11
|
+
@collectable.expects(:find_by_type).with('Tweet').returns('tweet!')
|
12
|
+
assert_equal 'tweet!', @collectable.tweets
|
13
|
+
end
|
14
|
+
|
15
|
+
should "return all items with type Story" do
|
16
|
+
@collectable.expects(:find_by_type).with('Story').returns('story!')
|
17
|
+
assert_equal 'story!', @collectable.stories
|
18
|
+
end
|
19
|
+
|
20
|
+
should "return all items with specified type" do
|
21
|
+
tweet = stub(:type => 'Tweet')
|
22
|
+
story = stub(:type => 'Story')
|
23
|
+
@collectable << tweet
|
24
|
+
@collectable << story
|
25
|
+
@collectable.find_by_type('Tweet')
|
26
|
+
assert_equal [tweet], @collectable.find_by_type('Tweet')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
2
|
+
|
3
|
+
module Radarb
|
4
|
+
class RadarTest < Test::Unit::TestCase
|
5
|
+
context "The Radar class" do
|
6
|
+
should "make the api call and fetch the response xml when created" do
|
7
|
+
Radar.stubs(:parse)
|
8
|
+
Fetch.expects(:fetch_url).with("#{API}?lat=123&lng=456")
|
9
|
+
Radar.scan('123', '456')
|
10
|
+
end
|
11
|
+
|
12
|
+
should "parse the api xml response" do
|
13
|
+
Fetch.stubs(:fetch_url).returns('xml')
|
14
|
+
Radar.expects(:parse).with('xml').returns('parsed_xml')
|
15
|
+
assert_equal 'parsed_xml', Radar.scan('123', '456')
|
16
|
+
end
|
17
|
+
|
18
|
+
should "extend the parsed xml with Collectable" do
|
19
|
+
Fetch.stubs(:fetch_url).returns('xml')
|
20
|
+
parsed_xml = mock {|m| m.expects(:extend).with(Collectable) }
|
21
|
+
Radar.stubs(:parse).with('xml').returns(parsed_xml)
|
22
|
+
Radar.scan('123', '456')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/test/radarb_test.rb
ADDED
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vigetlabs-radarb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Justin Marney
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-01-15 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: gotascii-happymapper
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.0.0
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: curb
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">"
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 0.0.0
|
32
|
+
version:
|
33
|
+
description: A ruby gem that makes using the http://outside.in/ API simple.
|
34
|
+
email: justin.marney@viget.com
|
35
|
+
executables: []
|
36
|
+
|
37
|
+
extensions: []
|
38
|
+
|
39
|
+
extra_rdoc_files:
|
40
|
+
- History.txt
|
41
|
+
- Manifest.txt
|
42
|
+
- README.txt
|
43
|
+
files:
|
44
|
+
- History.txt
|
45
|
+
- README.txt
|
46
|
+
- Rakefile
|
47
|
+
- radarb.gemspec
|
48
|
+
- lib/radarb.rb
|
49
|
+
- lib/radarb/collectable.rb
|
50
|
+
- lib/radarb/fetch.rb
|
51
|
+
- lib/radarb/place.rb
|
52
|
+
- lib/radarb/radar.rb
|
53
|
+
- lib/radarb/tag.rb
|
54
|
+
- Manifest.txt
|
55
|
+
has_rdoc: true
|
56
|
+
homepage: http://github.com/vigetlabs/radarb
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options:
|
59
|
+
- --main
|
60
|
+
- README.txt
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
version:
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
74
|
+
version:
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.2.0
|
79
|
+
signing_key:
|
80
|
+
specification_version: 2
|
81
|
+
summary: outside.in radar API wrapper.
|
82
|
+
test_files:
|
83
|
+
- test/test_helper.rb
|
84
|
+
- test/radarb_test.rb
|
85
|
+
- test/radarb/radar_test.rb
|
86
|
+
- test/radarb/collectable_test.rb
|