outside-in 0.1.0
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/.gitignore +1 -0
- data/LICENSE +21 -0
- data/README +9 -0
- data/Rakefile +14 -0
- data/VERSION +1 -0
- data/lib/outside_in/place.rb +21 -0
- data/lib/outside_in/radar.rb +48 -0
- data/lib/outside_in/story.rb +34 -0
- data/lib/outside_in/tag.rb +10 -0
- data/lib/outside_in/tweet.rb +26 -0
- data/lib/outside_in.rb +19 -0
- data/outside-in.gemspec +49 -0
- metadata +74 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg/
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2010 Doug Petkanics
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |gemspec|
|
4
|
+
gemspec.name = "outside-in"
|
5
|
+
gemspec.summary = "Ruby wrapper on the Outside.In API"
|
6
|
+
gemspec.description = "The Outside.IN Radar API provides hyperlocal news, tweets, and commentary based around a given latitude and longitude. This is a ruby wrapper around that API."
|
7
|
+
gemspec.email = "petkanics@gmail.com"
|
8
|
+
gemspec.homepage = "http://github.com/dob/outsidein"
|
9
|
+
gemspec.authors = ["Doug Petkanics"]
|
10
|
+
end
|
11
|
+
Jeweler::GemcutterTasks.new
|
12
|
+
rescue LoadError
|
13
|
+
puts "Jeweler not available. Install it with: gem install jeweler"
|
14
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module OutsideIn
|
2
|
+
|
3
|
+
class Point
|
4
|
+
attr_reader :lat, :lng
|
5
|
+
|
6
|
+
def initialize(point_string)
|
7
|
+
@lat, @lng = point_string.split(' ')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class Place
|
12
|
+
attr_reader :id, :name, :url, :point
|
13
|
+
|
14
|
+
def initialize(place_hash)
|
15
|
+
@id = place_hash['id']
|
16
|
+
@name = place_hash['name']
|
17
|
+
@url = place_hash['url']
|
18
|
+
@point = Point.new(place_hash['georss:point'])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module OutsideIn
|
2
|
+
|
3
|
+
class Radar
|
4
|
+
attr_accessor :stories, :tweets
|
5
|
+
|
6
|
+
def initialize(lat, lng, radius=nil, only=nil, except=nil)
|
7
|
+
@lat = lat
|
8
|
+
@lng = lng
|
9
|
+
@radius = radius
|
10
|
+
@only = only
|
11
|
+
@except = except
|
12
|
+
@stories = []
|
13
|
+
@tweets = []
|
14
|
+
hit_api
|
15
|
+
end
|
16
|
+
|
17
|
+
def hit_api
|
18
|
+
res = JSON.parse(request)
|
19
|
+
populate_stories_and_tweets(res)
|
20
|
+
end
|
21
|
+
|
22
|
+
def populate_stories_and_tweets(radars)
|
23
|
+
radars.each do |radar|
|
24
|
+
if radar["type"] == "Story"
|
25
|
+
@stories << OutsideIn::Story.new(radar)
|
26
|
+
elsif radar["type"] == "Tweet"
|
27
|
+
@tweets << OutsideIn::Tweet.new(radar)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def construct_url
|
33
|
+
url = "#{OutsideIn::JSON_ENDPOINT}?lat=#{@lat}&lng=#{@lng}"
|
34
|
+
url += "&radius=#{@radius}" if @radius
|
35
|
+
url += "&only=#{@only}" if @only
|
36
|
+
url += "&except=#{@except}" if @except
|
37
|
+
url
|
38
|
+
end
|
39
|
+
|
40
|
+
def request
|
41
|
+
url = URI.parse(construct_url)
|
42
|
+
res = Net::HTTP.get(url)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module OutsideIn
|
2
|
+
class Story
|
3
|
+
attr_reader :item_id, :icon_path, :author, :author_url, :published_at, :title, :body, :url, :tags, :places
|
4
|
+
|
5
|
+
def initialize(story_hash)
|
6
|
+
@item_id = story_hash['item_id']
|
7
|
+
@icon_path = story_hash['icon_path']
|
8
|
+
@author = story_hash['author']
|
9
|
+
@author_url = story_hash['author_url']
|
10
|
+
@published_at = story_hash['published_at']
|
11
|
+
@title = story_hash['title']
|
12
|
+
@body = story_hash['body']
|
13
|
+
@url = story_hash['url']
|
14
|
+
@tags = []
|
15
|
+
@places = []
|
16
|
+
populate_tags(story_hash)
|
17
|
+
populate_places(story_hash)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def populate_tags(story_hash)
|
22
|
+
story_hash["tags"].each do |tag|
|
23
|
+
@tags << OutsideIn::Tag.new(tag)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def populate_places(story_hash)
|
28
|
+
story_hash["places"].each do |place|
|
29
|
+
@places << OutsideIn::Place.new(place)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module OutsideIn
|
2
|
+
class Tweet
|
3
|
+
attr_reader :item_id, :icon_path, :author, :author_url, :published_at, :body, :url, :image_url, :places
|
4
|
+
|
5
|
+
def initialize(tweet_hash)
|
6
|
+
@item_id = tweet_hash['item_id']
|
7
|
+
@icon_path = tweet_hash['icon_path']
|
8
|
+
@author = tweet_hash['author']
|
9
|
+
@author_url = tweet_hash['author_url']
|
10
|
+
@published_at = tweet_hash['published_at']
|
11
|
+
@body = tweet_hash['body']
|
12
|
+
@url = tweet_hash['url']
|
13
|
+
@image_url = tweet_hash['image_url']
|
14
|
+
@places = []
|
15
|
+
populate_places(tweet_hash)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def populate_places(tweet_hash)
|
20
|
+
tweet_hash["places"].each do |place|
|
21
|
+
@places << OutsideIn::Place.new(place)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
data/lib/outside_in.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'json'
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
module OutsideIn
|
6
|
+
|
7
|
+
ENDPOINT = "http://api.outside.in/radar"
|
8
|
+
JSON_ENDPOINT = "#{ENDPOINT}.json"
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
directory = File.expand_path(File.dirname(__FILE__))
|
13
|
+
|
14
|
+
require File.join(directory, 'outside_in', 'radar')
|
15
|
+
require File.join(directory, 'outside_in', 'tweet')
|
16
|
+
require File.join(directory, 'outside_in', 'place')
|
17
|
+
require File.join(directory, 'outside_in', 'tag')
|
18
|
+
require File.join(directory, 'outside_in', 'story')
|
19
|
+
|
data/outside-in.gemspec
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{outside-in}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Doug Petkanics"]
|
12
|
+
s.date = %q{2010-06-23}
|
13
|
+
s.description = %q{The Outside.IN Radar API provides hyperlocal news, tweets, and commentary based around a given latitude and longitude. This is a ruby wrapper around that API.}
|
14
|
+
s.email = %q{petkanics@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".gitignore",
|
21
|
+
"LICENSE",
|
22
|
+
"README",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"lib/outside_in.rb",
|
26
|
+
"lib/outside_in/place.rb",
|
27
|
+
"lib/outside_in/radar.rb",
|
28
|
+
"lib/outside_in/story.rb",
|
29
|
+
"lib/outside_in/tag.rb",
|
30
|
+
"lib/outside_in/tweet.rb",
|
31
|
+
"outside-in.gemspec"
|
32
|
+
]
|
33
|
+
s.homepage = %q{http://github.com/dob/outsidein}
|
34
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
35
|
+
s.require_paths = ["lib"]
|
36
|
+
s.rubygems_version = %q{1.3.6}
|
37
|
+
s.summary = %q{Ruby wrapper on the Outside.In API}
|
38
|
+
|
39
|
+
if s.respond_to? :specification_version then
|
40
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
41
|
+
s.specification_version = 3
|
42
|
+
|
43
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
44
|
+
else
|
45
|
+
end
|
46
|
+
else
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: outside-in
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Doug Petkanics
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-06-23 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: The Outside.IN Radar API provides hyperlocal news, tweets, and commentary based around a given latitude and longitude. This is a ruby wrapper around that API.
|
22
|
+
email: petkanics@gmail.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- LICENSE
|
29
|
+
- README
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- LICENSE
|
33
|
+
- README
|
34
|
+
- Rakefile
|
35
|
+
- VERSION
|
36
|
+
- lib/outside_in.rb
|
37
|
+
- lib/outside_in/place.rb
|
38
|
+
- lib/outside_in/radar.rb
|
39
|
+
- lib/outside_in/story.rb
|
40
|
+
- lib/outside_in/tag.rb
|
41
|
+
- lib/outside_in/tweet.rb
|
42
|
+
- outside-in.gemspec
|
43
|
+
has_rdoc: true
|
44
|
+
homepage: http://github.com/dob/outsidein
|
45
|
+
licenses: []
|
46
|
+
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options:
|
49
|
+
- --charset=UTF-8
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
version: "0"
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
segments:
|
64
|
+
- 0
|
65
|
+
version: "0"
|
66
|
+
requirements: []
|
67
|
+
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 1.3.6
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: Ruby wrapper on the Outside.In API
|
73
|
+
test_files: []
|
74
|
+
|