teleportd 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -7
- data/lib/teleportd.rb +1 -0
- data/lib/teleportd/search.rb +13 -4
- data/lib/teleportd/search_result.rb +110 -0
- data/lib/teleportd/version.rb +1 -1
- metadata +39 -13
data/README.md
CHANGED
@@ -25,13 +25,9 @@ NOTE: You must set an ENV variable 'TELEPORTD_API_KEY' for your Teleportd API ke
|
|
25
25
|
|
26
26
|
$ export TELEPORTD_API_KEY=$APIKEY
|
27
27
|
|
28
|
-
Create an instance of a Teleportd::Search with optional filters.
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
Basic Query Without Filters:
|
33
|
-
|
34
|
-
$ search = Teleportd::Search.new
|
28
|
+
Create an instance of a Teleportd::Search with optional filters. The
|
29
|
+
Search returns an enumerable collection of Teleportd::SearchResult
|
30
|
+
objects
|
35
31
|
|
36
32
|
Query With Locations:
|
37
33
|
|
data/lib/teleportd.rb
CHANGED
data/lib/teleportd/search.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module Teleportd
|
2
2
|
class Search
|
3
|
+
include Enumerable
|
3
4
|
|
4
5
|
class << self
|
5
6
|
def potential_available_filters
|
@@ -10,15 +11,23 @@ module Teleportd
|
|
10
11
|
attr_reader :opts
|
11
12
|
|
12
13
|
def initialize opts={}
|
13
|
-
@opts
|
14
|
+
@opts = opts
|
14
15
|
@request = Request.new(request_uri)
|
15
16
|
end
|
16
17
|
|
17
|
-
def
|
18
|
-
@
|
18
|
+
def results
|
19
|
+
@results ||= parsed_response["hits"].map{|r|SearchResult.new(r)}
|
20
|
+
end
|
21
|
+
|
22
|
+
def each
|
23
|
+
results.each {|member| yield member}
|
19
24
|
end
|
20
25
|
|
21
26
|
private
|
27
|
+
def parsed_response
|
28
|
+
@request.parsed_response
|
29
|
+
end
|
30
|
+
|
22
31
|
def request_uri
|
23
32
|
available_filters.each_with_object(base_request_uri) do |filter, uri|
|
24
33
|
uri << "&#{self.send(filter)}"
|
@@ -63,7 +72,7 @@ module Teleportd
|
|
63
72
|
def time_period
|
64
73
|
return nil unless has_time_search?
|
65
74
|
begin_period = opts[:time_period][:start_time].to_i
|
66
|
-
end_period
|
75
|
+
end_period = opts[:time_period][:end_time].to_i
|
67
76
|
"period=[#{begin_period},#{end_period}]"
|
68
77
|
end
|
69
78
|
|
@@ -0,0 +1,110 @@
|
|
1
|
+
module Teleportd
|
2
|
+
# Represents an individual image returned from a Search call
|
3
|
+
class SearchResult
|
4
|
+
|
5
|
+
# @api private
|
6
|
+
attr_reader :result_hash
|
7
|
+
|
8
|
+
# Accepts a hash from a Teleportd::Search and returns an instance of Teleportd::SearchResult
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# Teleportd::SearchResult.new(result_hash)
|
12
|
+
# > #<Teleportd::SearchResult...>
|
13
|
+
#
|
14
|
+
# @param [Hash]
|
15
|
+
# @return [Teleportd::SearchResult]
|
16
|
+
def initialize result_hash={}
|
17
|
+
@result_hash = result_hash
|
18
|
+
end
|
19
|
+
|
20
|
+
# Returns a Hash with the results latitude and longitude values
|
21
|
+
#
|
22
|
+
# @return [Hash]
|
23
|
+
def location
|
24
|
+
result_hash['loc']
|
25
|
+
end
|
26
|
+
|
27
|
+
# Returns a String representing the search result type (usually "image")
|
28
|
+
#
|
29
|
+
# @return [String]
|
30
|
+
def type
|
31
|
+
result_hash['typ']
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns a String representing the search result SHA hash
|
35
|
+
#
|
36
|
+
# @return [String]
|
37
|
+
def sha
|
38
|
+
result_hash['sha']
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns the result's time as seconds from the epoch
|
42
|
+
#
|
43
|
+
# @return [Fixnum]
|
44
|
+
def date
|
45
|
+
result_hash['dte']
|
46
|
+
end
|
47
|
+
|
48
|
+
# Returns the source of the result ("twimg", "instagram", etc.)
|
49
|
+
#
|
50
|
+
# @return [String]
|
51
|
+
def source
|
52
|
+
result_hash['src']
|
53
|
+
end
|
54
|
+
|
55
|
+
# Returns the thumbnail image url for the result
|
56
|
+
#
|
57
|
+
# @return [String]
|
58
|
+
def thumbnail_url
|
59
|
+
result_hash['thb']
|
60
|
+
end
|
61
|
+
|
62
|
+
# Returns the full resolution image url for the result
|
63
|
+
#
|
64
|
+
# @return [String]
|
65
|
+
def full_resolution_url
|
66
|
+
result_hash['fll']
|
67
|
+
end
|
68
|
+
|
69
|
+
# Returns the author handles identified from the result
|
70
|
+
# NOTE: Will return nil unless you have an enterprise account
|
71
|
+
#
|
72
|
+
# @return [Array]
|
73
|
+
def users
|
74
|
+
result_hash['usr']
|
75
|
+
end
|
76
|
+
|
77
|
+
# Returns the user's profile pic url from the respective service account
|
78
|
+
# NOTE: Will return nil unless you have an enterprise account
|
79
|
+
#
|
80
|
+
# @return [String]
|
81
|
+
def profile_pic_url
|
82
|
+
result_hash['pic']
|
83
|
+
end
|
84
|
+
|
85
|
+
# Returns the comments or title of the search result in an Array
|
86
|
+
# NOTE: Will return nil unless you have an enterprise account
|
87
|
+
#
|
88
|
+
# @return [Array]
|
89
|
+
def text
|
90
|
+
result_hash['text']
|
91
|
+
end
|
92
|
+
|
93
|
+
# Returns the hashtags of the search result in an Array
|
94
|
+
# NOTE: Will return nil unless you have an enterprise account
|
95
|
+
#
|
96
|
+
# @return [Array]
|
97
|
+
def hashtags
|
98
|
+
result_hash['hashtag']
|
99
|
+
end
|
100
|
+
|
101
|
+
# Returns the mentions of the search result in an Array
|
102
|
+
# NOTE: Will return nil unless you have an enterprise account
|
103
|
+
#
|
104
|
+
# @return [Array]
|
105
|
+
def mentions
|
106
|
+
result_hash['mention']
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
end
|
data/lib/teleportd/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teleportd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: 1.7.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.7.1
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: activesupport
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: i18n
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: curb
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :runtime
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: pry
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,7 +85,12 @@ dependencies:
|
|
65
85
|
version: '0'
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
69
94
|
description: Ruby Wrapper Library for Teleportd API
|
70
95
|
email:
|
71
96
|
- nicholas.fine@gmail.com
|
@@ -82,6 +107,7 @@ files:
|
|
82
107
|
- lib/teleportd/config.rb
|
83
108
|
- lib/teleportd/request.rb
|
84
109
|
- lib/teleportd/search.rb
|
110
|
+
- lib/teleportd/search_result.rb
|
85
111
|
- lib/teleportd/version.rb
|
86
112
|
- teleportd.gemspec
|
87
113
|
homepage: ''
|
@@ -104,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
130
|
version: '0'
|
105
131
|
requirements: []
|
106
132
|
rubyforge_project:
|
107
|
-
rubygems_version: 1.8.
|
133
|
+
rubygems_version: 1.8.24
|
108
134
|
signing_key:
|
109
135
|
specification_version: 3
|
110
136
|
summary: Ruby Wrapper Library for Teleportd API
|