Module: Topsy

Defined in:
lib/topsy/tag.rb,
lib/topsy.rb,
lib/topsy/page.rb,
lib/topsy/stats.rb,
lib/topsy/trend.rb,
lib/topsy/tweet.rb,
lib/topsy/author.rb,
lib/topsy/client.rb,
lib/topsy/target.rb,
lib/topsy/version.rb,
lib/topsy/linkpost.rb,
lib/topsy/url_info.rb,
lib/topsy/search_counts.rb,
lib/topsy/linkpost_count.rb,
lib/topsy/rate_limit_info.rb,
lib/topsy/search_histogram.rb,
lib/topsy/link_search_result.rb

Overview

This is the link_search_result class for the topsy library. A LinkSearchResult has the following attributes:

"trackback_permalink" : "http://twitter.com/ewerickson/status/3562164195",
"hits" : 38,
"trackback_total" : 157,
"topsy_trackback_url" : "http://topsy.com/tb/www.redstate.com/erick/2009/08/26/breaking-rumors-surface-that-leon-panetta-is-resigning/",
"url" : "http://www.redstate.com/erick/2009/08/26/breaking-rumors-surface-that-leon-panetta-is-resigning/",
"content" : "Panetta is rumored to have sent a resignation letter to Barack Obama today:  http://bit.ly/CDMg9",
"title" : "BREAKING: Rumors Surface That Leon Panetta is Resigning - Erick’s blog - RedState",
"score" : 0.75521481,
"highlight" : "Panetta is rumored to have sent a resignation letter to 
    <span class=\"highlight-term\">Barack</span> <span class=\"highlight-term\">Obama</span> today:  http://bit.ly/CDMg9"

According to the official Topsy doc: code.google.com/p/otterapi/wiki/Resources?tm=6#/search

Defined Under Namespace

Classes: Author, Client, General, InformTopsy, LinkSearchResult, Linkpost, LinkpostCount, NotFound, Page, RateLimitExceeded, RateLimitInfo, SearchCounts, SearchHistogram, Stats, Tag, Target, TopsyError, Trend, Tweet, Unauthorized, Unavailable, UrlInfo

Constant Summary collapse

VERSION =
'0.6.0'

Class Method Summary collapse

Class Method Details

.author_info(url) ⇒ Topsy::Author

Returns profile information for an author (a twitter profile indexed by Topsy). The response contains the name, description (biography) and the influence level of the author

Parameters:

  • url (String)

    URL string for the author.

Returns:



31
32
33
# File 'lib/topsy.rb', line 31

def self.author_info(url)
  Topsy::Client.new.author_info(url)
end

.creditTopsy::RateLimitInfo

Returns info about API rate limiting



181
182
183
# File 'lib/topsy.rb', line 181

def self.credit
  Topsy::Client.new.credit
end

.experts(q, options = {}) ⇒ Topsy::Page

Returns list of authors that talk about the query. The list is sorted by frequency of posts and the influence of authors.

Parameters:

  • q (String)

    the search query string

  • options (Hash) (defaults to: {})

    method options

Options Hash (options):

  • :window (Symbol)

    Time window for results. (default: :auto) Options: :auto - automatically pick the most recent and relevant window. :hour last hour, :day last day, :week last week, :month last month, :all all time

  • :page (Integer)

    page number of the result set. (default: 1, max: 10)

  • :perpage (Integer)

    limit number of results per page. (default: 10, max: 50)

Returns:



44
45
46
47
# File 'lib/topsy.rb', line 44

def self.experts(q, options={})
  result = Topsy::Client.new.experts(q, options)
  Topsy::Page.new(result, Topsy::Author)
end

.link_post_count(url, options = {}) ⇒ Topsy::LinkpostCount

Returns count of links posted by an author. This is the efficient, count-only version of /linkposts

Parameters:

  • url (String)

    URL string for the author.

  • options (Hash) (defaults to: {})

    method options

Options Hash (options):

  • :contains (String)

    Query string to filter results

Returns:



67
68
69
70
# File 'lib/topsy.rb', line 67

def self.link_post_count(url, options={})
  response = Topsy::Client.new.link_post_count(url, options)
  Topsy::LinkpostCount.new(response)
end

Returns list of URLs posted by an author

Parameters:

  • url (String)

    URL string for the author.

  • options (Hash) (defaults to: {})

    method options

Options Hash (options):

  • :contains (String)

    Query string to filter results

  • :page (Integer)

    page number of the result set. (default: 1, max: 10)

  • :perpage (Integer)

    limit number of results per page. (default: 10, max: 50)

Returns:



57
58
59
# File 'lib/topsy.rb', line 57

def self.link_posts(url, options={})
  Topsy::Client.new.link_posts(url, options)
end

.profile_search(q, options = {}) ⇒ Topsy::Page

Returns list list of author profiles that match the query. The query is matched against the nick, name and biography information and the results are sorted by closeness of match and the influence of authors.

Parameters:

  • q (String)

    the search query string

  • options (Hash) (defaults to: {})

    method options

Options Hash (options):

  • :page (Integer)

    page number of the result set. (default: 1, max: 10)

  • :perpage (Integer)

    limit number of results per page. (default: 10, max: 50)

Returns:



79
80
81
# File 'lib/topsy.rb', line 79

def self.profile_search(q, options={})
  Topsy::Client.new.profile_search(q, options)
end

.rate_limitObject



186
187
188
189
# File 'lib/topsy.rb', line 186

def self.rate_limit
  self.credit if @rate_limit_info.nil?
  @rate_limit_info
end

.rate_limit=(info) ⇒ Object



191
192
193
# File 'lib/topsy.rb', line 191

def self.rate_limit=(info)
  @rate_limit_info = Topsy::RateLimitInfo.new(info)
end

Returns list of URLs related to a given URL

Parameters:

  • url (String)

    URL string for the author.

  • options (Hash) (defaults to: {})

    method options

Options Hash (options):

  • :page (Integer)

    page number of the result set. (default: 1, max: 10)

  • :perpage (Integer)

    limit number of results per page. (default: 10, max: 50)

Returns:



90
91
92
# File 'lib/topsy.rb', line 90

def self.related(url, options={})
  Topsy::Client.new.related(url, options)
end

.search(q, options = {}) ⇒ Topsy::Page

Returns list of results for a query.

Parameters:

  • q (String)

    the search query string

  • options (Hash) (defaults to: {})

    method options

Options Hash (options):

  • :window (Symbol)

    Time window for results. (default: :auto) Options: :auto - automatically pick the most recent and relevant window. :hour last hour, :day last day, :week last week, :month last month, :realtime, :all all time

  • :page (Integer)

    page number of the result set. (default: 1, max: 10)

  • :perpage (Integer)

    limit number of results per page. (default: 10, max: 50)

Returns:



102
103
104
# File 'lib/topsy.rb', line 102

def self.search(q, options={})
  Topsy::Client.new.search(q, options)
end

.search_count(q) ⇒ Topsy::SearchCounts

Returns count of results for a search query.

Parameters:

  • q (String)

    the search query string

Returns:



110
111
112
# File 'lib/topsy.rb', line 110

def self.search_count(q)
  Topsy::Client.new.search_count(q)
end

.search_histogram(query, count_method = "target", slice = 86400, period = 30) ⇒ Topsy::SearchHistogram

Returns data on the volume of tweets

Parameters:

  • the (String)

    query

Returns:



121
122
123
# File 'lib/topsy.rb', line 121

def self.search_histogram( query , count_method = "target" , slice = 86400 , period = 30 )
  Topsy::Client.new.search_histogram( query , count_method , slice , period  )
end

.stats(url, options = {}) ⇒ Topsy::Stats

Returns counts of tweets for a URL

Parameters:

  • url (String)

    the url to look up

  • options (Hash) (defaults to: {})

    method options

Options Hash (options):

  • :contains (String)

    Query string to filter results

Returns:



131
132
133
# File 'lib/topsy.rb', line 131

def self.stats(url, options={})
  Topsy::Client.new.stats(url, options)
end

.tags(url, options = {}) ⇒ Topsy::Page

Returns list of tags for a URL.

Parameters:

  • url (String)

    the search query string

  • options (Hash) (defaults to: {})

    method options

Options Hash (options):

  • :page (Integer)

    page number of the result set. (default: 1, max: 10)

  • :perpage (Integer)

    limit number of results per page. (default: 10, max: 50)

Returns:



142
143
144
# File 'lib/topsy.rb', line 142

def self.tags(url, options={})
  Topsy::Client.new.tags(url, options)
end

.trackbacks(url, options = {}) ⇒ Topsy::Page

Returns list of tweets (trackbacks) that mention the query URL, most recent first.

Parameters:

  • url (String)

    URL string for the author.

  • options (Hash) (defaults to: {})

    method options

Options Hash (options):

  • :contains (String)

    Query string to filter results

  • :infonly (Boolean)

    filters trackbacks to influential only (default 0)

  • :page (Integer)

    page number of the result set. (default: 1, max: 10)

  • :perpage (Integer)

    limit number of results per page. (default: 10, max: 50)

Returns:



155
156
157
# File 'lib/topsy.rb', line 155

def self.trackbacks(url, options={})
  Topsy::Client.new.trackbacks(url, options)
end

Returns list of trending terms

Parameters:

  • options (Hash) (defaults to: {})

    method options

Options Hash (options):

  • :page (Integer)

    page number of the result set. (default: 1, max: 10)

  • :perpage (Integer)

    limit number of results per page. (default: 10, max: 50)

Returns:



166
167
168
# File 'lib/topsy.rb', line 166

def self.trending(options={})
  Topsy::Client.new.trending(options)
end

.url_info(url) ⇒ Topsy::UrlInfo

Returns info about a URL

Parameters:

  • url (String)

    the url to look up

Returns:



174
175
176
# File 'lib/topsy.rb', line 174

def self.url_info(url)
  Topsy::Client.new.url_info(url)
end