rtopsy 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.loadpath ADDED
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <loadpath>
3
+ <pathentry path="" type="src"/>
4
+ <pathentry path="GEM_LIB/hoe-2.3.3/lib" type="var"/>
5
+ </loadpath>
data/.project ADDED
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>topsy</name>
4
+ <comment></comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>org.rubypeople.rdt.core.rubybuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ </buildSpec>
14
+ <natures>
15
+ <nature>org.rubypeople.rdt.core.rubynature</nature>
16
+ <nature>org.radrails.rails.core.railsnature</nature>
17
+ </natures>
18
+ </projectDescription>
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ === 0.0.1 2009-10-25
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/Manifest.txt ADDED
@@ -0,0 +1,27 @@
1
+ .loadpath
2
+ .project
3
+ History.txt
4
+ Manifest.txt
5
+ PostInstall.txt
6
+ README.rdoc
7
+ Rakefile
8
+ lib/rtopsy.rb
9
+ lib/rtopsy/api.rb
10
+ lib/rtopsy/author.rb
11
+ lib/rtopsy/link_search_result.rb
12
+ lib/rtopsy/linkpost.rb
13
+ lib/rtopsy/linkpost_count.rb
14
+ lib/rtopsy/page.rb
15
+ lib/rtopsy/search_count.rb
16
+ lib/rtopsy/stats.rb
17
+ lib/rtopsy/tag.rb
18
+ lib/rtopsy/target.rb
19
+ lib/rtopsy/trend.rb
20
+ lib/rtopsy/tweet.rb
21
+ lib/rtopsy/url_info.rb
22
+ rtopsy.gemspec
23
+ script/console
24
+ script/destroy
25
+ script/generate
26
+ test/test_helper.rb
27
+ test/test_rtopsy.rb
data/PostInstall.txt ADDED
@@ -0,0 +1,7 @@
1
+
2
+ For more information on topsy, see http://github.com/etagwerker/rtopsy/
3
+
4
+ NOTE: Change this information in PostInstall.txt
5
+ You can also delete it if you don't want it.
6
+
7
+
data/README.rdoc ADDED
@@ -0,0 +1,65 @@
1
+ = rtopsy
2
+
3
+ * http://github.com/etagwerker/rtopsy
4
+
5
+ == DESCRIPTION:
6
+
7
+ A ruby gem implementation of the Topsy API
8
+
9
+ == FEATURES:
10
+
11
+ rtopsy won't do your laundry, but it will do this:
12
+ 1. Topsy::Base.authorinfo('barackobama')
13
+ 2. Topsy::Base.authorsearch('programming','a')
14
+ 3. Topsy::Base.authorsearch('programming')
15
+ 4. Topsy::Base.linkposts('barackobama',page_number,per_page)
16
+ 5. Topsy::Base.linkposts('barackobama')
17
+ 6. Topsy::Base.linkpostcount('barackobama')
18
+ 7. Topsy::Base.urlinfo('http://www.aycron.com')
19
+ 8. Topsy::Base.stats('http://www.aycron.com')
20
+ 9. Topsy::Base.search('rock',window,page_number,perpage) #window can be :auto, :h, :d, :w, :m, :a
21
+ 10. Topsy::Base.search('rock') #defaults window :auto, page_number 1, perpage 10
22
+ 11. Topsy::Base.searchcount('rock')
23
+ 12. Topsy::Base.search('rock')
24
+ 13. Topsy::Base.profilesearch('Aycron+Director')
25
+ 14. Topsy::Base.profilesearch('Aycron+Director', page_number, perpage)
26
+ 15. Topsy::Base.related('http://www.hashrocket.com')
27
+ 16. Topsy::Base.related('http://www.google.com/', page_number, perpage)
28
+ 17. Topsy::Base.tags('http://twitter.com', page_number, perpage)
29
+ 18. Topsy::Base.tags('http://twitter.com')
30
+ 19. Topsy::Base.trending(page_number, perpage)
31
+ 20. Topsy::Base.trending # defaults page_number 1, perpage 10
32
+ 21. Topsy::Base.trackbacks('http://twitter.com', tracktype, contains_string, infonly_flag, page_number, perpage)
33
+
34
+ == REQUIREMENTS:
35
+
36
+ TODO list here: http://etagwerker.tadalist.com/lists/1436401/public
37
+
38
+ == INSTALL:
39
+
40
+ * NOT READY FOR THIS YET!!! (still developing this gem)
41
+
42
+ == LICENSE:
43
+
44
+ (The MIT License)
45
+
46
+ Copyright (c) 2009 Ernesto Tagwerker <etagwerker@aycron.com>
47
+
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of this software and associated documentation files (the
50
+ 'Software'), to deal in the Software without restriction, including
51
+ without limitation the rights to use, copy, modify, merge, publish,
52
+ distribute, sublicense, and/or sell copies of the Software, and to
53
+ permit persons to whom the Software is furnished to do so, subject to
54
+ the following conditions:
55
+
56
+ The above copyright notice and this permission notice shall be
57
+ included in all copies or substantial portions of the Software.
58
+
59
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
60
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
61
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
62
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
63
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
64
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
65
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/rtopsy'
6
+
7
+ Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ # Hoe.plugin :cucumberfeatures
10
+
11
+ # Generate all the Rake tasks
12
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
+ $hoe = Hoe.spec 'rtopsy' do
14
+ self.developer 'Ernesto Tagwerker', 'etagwerker@aycron.com'
15
+ self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
16
+ self.rubyforge_name = self.name # TODO this is default value
17
+ # self.extra_deps = [['activesupport','>= 2.0.2']]
18
+ self.extra_deps = [['httparty','>= 0.4.3']]
19
+ end
20
+
21
+ require 'newgem/tasks'
22
+ Dir['tasks/**/*.rake'].each { |t| load t }
23
+
24
+ # TODO - want other tests/tasks run by default? Add them to the list
25
+ # remove_task :default
26
+ # task :default => [:spec, :features]
data/lib/rtopsy/api.rb ADDED
@@ -0,0 +1,136 @@
1
+ # This is the base class for the topsy library. It makes all the requests
2
+ # to topsy, parses the json and returns ruby objects to play with.
3
+ #
4
+ # For complete documentation:
5
+ # http://groups.google.com/group/rtopsy
6
+ module Topsy
7
+
8
+ #provides all methods to the Topsy API
9
+ class API
10
+ include HTTParty
11
+
12
+ base_uri 'http://otter.topsy.com'
13
+ default_params :output => 'json'
14
+ format :json
15
+
16
+
17
+ #performs a HTTParty get
18
+ #returns the response hash
19
+ def self.get_response(api_request)
20
+ hash = get(api_request)
21
+ return hash["response"]
22
+ end
23
+
24
+ #returns the author info object according to the twitter url
25
+ #author_handle: eg. barackobama
26
+ def self.authorinfo(twitter_nick)
27
+ resp = get_response("/authorinfo.json?url=http://twitter.com/#{twitter_nick}")
28
+ Author.new(resp)
29
+ end
30
+
31
+ #returns a Page of results with a list of Author instances that match the nick, name and biography info
32
+ #parameter query eg. Barack+Obama (see: http://code.google.com/p/otterapi/wiki/QuerySyntax)
33
+ def self.profilesearch(query = '', page = 1, perpage = 10)
34
+ resp = get_response("/profilesearch.json?q=#{query}&page=#{page}&perpage=#{perpage}")
35
+ Page.new(resp, :author)
36
+ end
37
+
38
+ #returns a Page of results with a list of Author instances that talk about the query parameter
39
+ #who talk most about the query parameter (see: http://code.google.com/p/otterapi/wiki/QuerySyntax)
40
+ def self.authorsearch(query = '', window = 'a', page = 1, perpage = 10)
41
+ resp = get_response("/authorsearch.json?q=#{query}&window=#{window}&page=#{page}&perpage=#{perpage}")
42
+ Page.new(resp, :author)
43
+ end
44
+
45
+ #returns a Page of results with a list of Linkpost instances
46
+ #twitter_nick: eg. barackobama
47
+ #page: eg. 1
48
+ #perpage: eg. 12
49
+ def self.linkposts(twitter_nick = '', page = 1, perpage = 10)
50
+ resp = get_response("/linkposts.json?url=http://twitter.com/#{twitter_nick}&page=#{page}&perpage=#{perpage}")
51
+ Page.new(resp, :link_post)
52
+ end
53
+
54
+ #returns a LinkpostCount for a nick
55
+ #twitter_nick: eg. barackobama
56
+ def self.linkpostcount(twitter_nick = '')
57
+ resp = get_response("/linkpostcount.json?url=http://twitter.com/#{twitter_nick}")
58
+ LinkpostCount.new(resp)
59
+ end
60
+
61
+ #returns a UrlInfo instance for a certain url
62
+ #url: eg. http://aycron.com
63
+ def self.urlinfo(url)
64
+ resp = get_response("/urlinfo.json?url=#{url}")
65
+ UrlInfo.new(resp)
66
+ end
67
+
68
+ # returns a Page of results with a list of LinkSearchResult
69
+ # if url is nil or empty, returns nil
70
+ # if url doesn't end with '/' (eg. http://www.google.com) it adds it to the end to normalize the url
71
+ def self.related(url = '', page = 1, perpage = 10)
72
+ if !url
73
+ return nil
74
+ end
75
+
76
+ url = normalize_url(url)
77
+
78
+ resp = get_response("/related.json?url=#{url}&page=#{page}&perpage=#{perpage}")
79
+ Page.new(resp, :link_search_result)
80
+ end
81
+
82
+ # adds a trailing '/' to the string if necessary
83
+ def self.normalize_url(url)
84
+ if url[url.length-1, url.length] != '/'
85
+ url = url + "/"
86
+ end
87
+ return url
88
+ end
89
+
90
+ # returns a SearchCount instance initialized with the response
91
+ def self.searchcount(query = '')
92
+ resp = get_response("/searchcount.json?q=#{query}")
93
+ SearchCount.new(resp)
94
+ end
95
+
96
+ # returns a Page of results with a list of LinkSearchResult
97
+ # returns nil if the window parameter is not correct
98
+ def self.search(query = '', window = :auto, page = 1, perpage = 10)
99
+ if [:auto, :h, :d, :w, :m, :a].include? window
100
+ resp = get_response("/search.json?q=#{query}&window=#{window}&page=#{page}&perpage=#{perpage}")
101
+ Page.new(resp, :link_search_result)
102
+ else
103
+ nil
104
+ end
105
+ end
106
+
107
+ #returns a Stats instance for a certain url
108
+ #url: eg. http://aycron.com
109
+ def self.stats(url)
110
+ resp = get_response("/stats.json?url=#{url}")
111
+ Stats.new(resp)
112
+ end
113
+
114
+ # returns a Page of results with a list of Tag
115
+ def self.tags(url, page = 1, perpage = 10)
116
+ url = normalize_url(url)
117
+ resp = get_response("/tags.json?url=#{url}&page=#{page}&perpage=#{perpage}")
118
+ Page.new(resp, :tag)
119
+ end
120
+
121
+ # returns a Page of results with a list of Tweet
122
+ def self.trackbacks(url = '', tracktype = 'tweet', contains = '', infonly = 0, page = 1, perpage = 10)
123
+ url = normalize_url(url)
124
+ resp = get_response("/trackbacks.json?url=#{url}&tracktype=#{tracktype}&infonly=#{infonly}&contains=#{contains}&page=#{page}&perpage=#{perpage}")
125
+ Page.new(resp, :tweet)
126
+ end
127
+
128
+ # returns a Page of results with a list of Trend
129
+ def self.trending(page = 1, perpage = 10)
130
+ resp = get_response("/trending.json?page=#{page}&perpage=#{perpage}")
131
+ Page.new(resp, :trend)
132
+ end
133
+
134
+ end
135
+
136
+ end
@@ -0,0 +1,30 @@
1
+ # This is the author class for the topsy library.
2
+ # An Author has the following attributes:
3
+ # "name" : "Barack Obama"
4
+ # "url" : "http://twitter.com/barackobama",
5
+ # "type" : "twitter",
6
+ # "nick" : "barackobama",
7
+ # "description" : "44th President of the United States",
8
+ # "topsy_author_url" : "http://topsy.com/twitter/barackobama",
9
+ # "influence_level" : "5"
10
+ #
11
+ # According to the official Topsy doc: http://code.google.com/p/otterapi/wiki/Resources?tm=6#/authorinfo
12
+ #
13
+ # For complete documentation on the options, check out the topsy api docs.
14
+ # http://groups.google.com/group/rtopsy/web/api-documentation
15
+ module Topsy
16
+
17
+ class Author
18
+ attr_accessor :name, :url, :type, :nick, :description, :topsy_author_url, :influence_level, :hits
19
+
20
+ def to_s
21
+ "Topsy Author: #{name}, @#{nick}, #{topsy_author_url}"
22
+ end
23
+
24
+ def initialize(hash)
25
+ hash.each do |key, value|
26
+ instance_variable_set("@#{key}", value)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,32 @@
1
+ # This is the link_search_result class for the topsy library.
2
+ # A LinkSearchResult has the following attributes:
3
+ # "trackback_permalink" : "http://twitter.com/ewerickson/status/3562164195",
4
+ # "hits" : 38,
5
+ # "trackback_total" : 157,
6
+ # "topsy_trackback_url" : "http://topsy.com/tb/www.redstate.com/erick/2009/08/26/breaking-rumors-surface-that-leon-panetta-is-resigning/",
7
+ # "url" : "http://www.redstate.com/erick/2009/08/26/breaking-rumors-surface-that-leon-panetta-is-resigning/",
8
+ # "content" : "Panetta is rumored to have sent a resignation letter to Barack Obama today: http://bit.ly/CDMg9",
9
+ # "title" : "BREAKING: Rumors Surface That Leon Panetta is Resigning - Erick’s blog - RedState",
10
+ # "score" : 0.75521481,
11
+ # "highlight" : "Panetta is rumored to have sent a resignation letter to
12
+ # <span class=\"highlight-term\">Barack</span> <span class=\"highlight-term\">Obama</span> today: http://bit.ly/CDMg9"
13
+ # According to the official Topsy doc: http://code.google.com/p/otterapi/wiki/Resources?tm=6#/search
14
+ #
15
+ # For complete documentation on the options, check out the topsy api docs.
16
+ # http://groups.google.com/group/rtopsy
17
+ module Topsy
18
+
19
+ class LinkSearchResult
20
+ attr_accessor :trackback_permalink, :hits, :trackback_total, :topsy_trackback_url, :url, :content, :title, :score, :highlight
21
+
22
+ def to_s
23
+ "Topsy LinkSearchResult: #{url}, @#{title}, hits: #{hits}"
24
+ end
25
+
26
+ def initialize(hash)
27
+ hash.each do |key, value|
28
+ instance_variable_set("@#{key}", value)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,33 @@
1
+ # This is the linkpost class for the topsy library.
2
+ # A Linkpost has the following attributes:
3
+ # "permalink_url" : "http://twitter.com/barackobama/status/3569838653",
4
+ # "target" : target instance
5
+ # "date" : "1251337427",
6
+ # "content" : "Highlights from the tribute to Sen. Kennedy's life and
7
+ # accomplishments from last year's Democratic National Convention: http://bit.ly/TJcyr",
8
+ # "date_alpha" : "3 hours ago"
9
+ # According to the official Topsy doc: http://code.google.com/p/otterapi/wiki/Resources?tm=6#/linkposts
10
+ #
11
+ # For complete documentation on the options, check out the topsy api docs.
12
+ # http://groups.google.com/group/rtopsy
13
+ module Topsy
14
+
15
+ class Linkpost
16
+ attr_accessor :permalink_url, :target, :date, :content, :date_alpha
17
+
18
+ def to_s
19
+ "Topsy Linkpost: #{permalink_url}, @#{content}"
20
+ end
21
+
22
+ def initialize(hash)
23
+ hash.each do |key, value|
24
+ if key == 'target'
25
+ instance_variable_set("@#{key}", Target.new(value))
26
+ else
27
+ instance_variable_set("@#{key}", value)
28
+ end
29
+
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,25 @@
1
+ # This is the linkpost_count class for the topsy library.
2
+ # A LinkpostCount has the following attributes:
3
+ # "contains" : 0,
4
+ # "all" : 46
5
+ #
6
+ # According to the official Topsy doc: http://code.google.com/p/otterapi/wiki/Resources?tm=6#/linkpostcount
7
+ #
8
+ # For complete documentation on the options, check out the topsy api docs.
9
+ # http://groups.google.com/group/rtopsy
10
+ module Topsy
11
+
12
+ class LinkpostCount
13
+ attr_accessor :contains, :all
14
+
15
+ def to_s
16
+ "Topsy LinkpostCount: #{all}"
17
+ end
18
+
19
+ def initialize(hash)
20
+ hash.each do |key, value|
21
+ instance_variable_set("@#{key}", value)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,101 @@
1
+ # This is the page class for the topsy library.
2
+ # A Page has the following attributes:
3
+ # "page" : 1,
4
+ # "total" : "1139",
5
+ # "perpage" : 15,
6
+ # "list" : Array of Author instances
7
+ #
8
+ # According to the official Topsy doc: http://code.google.com/p/otterapi/wiki/Resources?tm=6#/authorsearch
9
+ #
10
+ # For complete documentation on the options, check out the rtopsy api docs.
11
+ # http://groups.google.com/group/rtopsy
12
+ module Topsy
13
+
14
+ class Page
15
+ attr_accessor :page, :total, :perpage, :list, :window
16
+
17
+ def to_s
18
+ "Topsy Page: #{page} of #{total}, #{list.size} authors"
19
+ end
20
+
21
+ #converts a list of Hash objects into Author objects
22
+ def get_authors_list(hash_list)
23
+ result = []
24
+ for hash in hash_list
25
+ result << Author.new(hash)
26
+ end
27
+ return result
28
+ end
29
+
30
+ #converts a list of Hash objects into Linkpost objects
31
+ def get_linkposts_list(hash_list)
32
+ result = []
33
+ for hash in hash_list
34
+ result << Linkpost.new(hash)
35
+ end
36
+ return result
37
+ end
38
+
39
+ #converts a list of Hash objects into LinkSearchResult objects
40
+ def get_linksearchresult_list(hash_list)
41
+ result = []
42
+ for hash in hash_list
43
+ result << LinkSearchResult.new(hash)
44
+ end
45
+ return result
46
+ end
47
+
48
+ #converts a list of Hash objects into Tag objects
49
+ def get_tags_list(hash_list)
50
+ result = []
51
+ for hash in hash_list
52
+ result << Tag.new(hash)
53
+ end
54
+ return result
55
+ end
56
+
57
+ #converts a list of Hash objects into Trend objects
58
+ def get_trends_list(hash_list)
59
+ result = []
60
+ for hash in hash_list
61
+ result << Trend.new(hash)
62
+ end
63
+ return result
64
+ end
65
+
66
+ #converts a list of Hash objects into Tweet objects
67
+ def get_tweets_list(hash_list)
68
+ result = []
69
+ for hash in hash_list
70
+ result << Tweet.new(hash)
71
+ end
72
+ return result
73
+ end
74
+
75
+ #creates a Page instance from a hash, setting attributes and a list of Author instances
76
+ #for the page
77
+ def initialize(hash, content_type)
78
+ hash.each do |key, value|
79
+ if key == 'list'
80
+ if content_type == :author
81
+ instance_variable_set("@#{key}", get_authors_list(value))
82
+ elsif content_type == :link_post
83
+ instance_variable_set("@#{key}", get_linkposts_list(value))
84
+ elsif content_type == :tag
85
+ instance_variable_set("@#{key}", get_tags_list(value))
86
+ elsif content_type == :trend
87
+ instance_variable_set("@#{key}", get_trends_list(value))
88
+ elsif content_type == :tweet
89
+ instance_variable_set("@#{key}", get_tweets_list(value))
90
+ else
91
+ instance_variable_set("@#{key}", get_linksearchresult_list(value))
92
+ end
93
+
94
+ else
95
+ instance_variable_set("@#{key}", value)
96
+ end
97
+ end
98
+ end
99
+
100
+ end
101
+ end
@@ -0,0 +1,28 @@
1
+ # This is the search_count class for the topsy library.
2
+ # A SearchCount has the following attributes:
3
+ # "w" : 2085, - weekly
4
+ # "h" : 6, - hourly
5
+ # "a" : 572027, - annually
6
+ # "d" : 330, - daily
7
+ # "m" : 9122 - monthly
8
+ #
9
+ # According to the official Topsy doc: http://code.google.com/p/otterapi/wiki/Resources?tm=6#/searchcount (?)
10
+ #
11
+ # For complete documentation on the options, check out the topsy api docs.
12
+ # http://groups.google.com/group/rtopsy
13
+ module Topsy
14
+
15
+ class SearchCount
16
+ attr_accessor :w, :h, :a, :d, :m
17
+
18
+ def to_s
19
+ "Topsy SearchCount: #{all}"
20
+ end
21
+
22
+ def initialize(hash)
23
+ hash.each do |key, value|
24
+ instance_variable_set("@#{key}", value)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,26 @@
1
+ # This is the stats class for the topsy library.
2
+ # A Stats instance has the following attributes:
3
+ # "topsy_trackback_url" : "http://topsy.com/tb/topsy.com/",
4
+ # "contains" : "1931",
5
+ # "influential" : "874",
6
+ # "all" : "1931"
7
+ # According to the official Topsy doc: http://code.google.com/p/otterapi/wiki/Resources?tm=6#/stats
8
+ #
9
+ # For complete documentation on the options, check out the topsy api docs.
10
+ # http://groups.google.com/group/rtopsy
11
+ module Topsy
12
+
13
+ class Stats
14
+ attr_accessor :topsy_trackback_url, :contains, :influential, :all
15
+
16
+ def to_s
17
+ "Topsy Stats: #{topsy_trackback_url}"
18
+ end
19
+
20
+ def initialize(hash)
21
+ hash.each do |key, value|
22
+ instance_variable_set("@#{key}", value)
23
+ end
24
+ end
25
+ end
26
+ end
data/lib/rtopsy/tag.rb ADDED
@@ -0,0 +1,24 @@
1
+ # This is the tag class for the topsy library.
2
+ # A Tag instance has the following attributes:
3
+ # "url" : "http://topsy.com/s?q=current",
4
+ # "name" : "current"
5
+ # According to the official Topsy doc: http://code.google.com/p/otterapi/wiki/Resources?tm=6#/tags
6
+ #
7
+ # For complete documentation on the options, check out the topsy api docs.
8
+ # http://groups.google.com/group/rtopsy
9
+ module Topsy
10
+
11
+ class Tag
12
+ attr_accessor :url, :name
13
+
14
+ def to_s
15
+ "Topsy Tag: #{name}"
16
+ end
17
+
18
+ def initialize(hash)
19
+ hash.each do |key, value|
20
+ instance_variable_set("@#{key}", value)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,26 @@
1
+ # This is the target class for the topsy library.
2
+ # A Target has the following attributes:
3
+ # "topsy_trackback_url" : "http://topsy.com/tb/my.barackobama.com/page/community/post/obamaforamerica/gGMPVm",
4
+ # "url" : "http://my.barackobama.com/page/community/post/obamaforamerica/gGMPVm",
5
+ # "trackback_total" : "43"
6
+ #
7
+ # According to the official Topsy doc: http://code.google.com/p/otterapi/wiki/Resources?tm=6#/linkposts
8
+ #
9
+ # For complete documentation on the options, check out the topsy api docs.
10
+ # http://groups.google.com/group/rtopsy
11
+ module Topsy
12
+
13
+ class Target
14
+ attr_accessor :topsy_trackback_url, :url, :trackback_total
15
+
16
+ def to_s
17
+ "Topsy Target: #{url}"
18
+ end
19
+
20
+ def initialize(hash)
21
+ hash.each do |key, value|
22
+ instance_variable_set("@#{key}", value)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,24 @@
1
+ # This is the trend class for the topsy library.
2
+ # A Trend instance has the following attributes:
3
+ # "url" : "http://topsy.com/s?q=dominick",
4
+ # "term" : "dominick"
5
+ # According to the official Topsy doc: http://code.google.com/p/otterapi/wiki/Resources?tm=6#/trending
6
+ #
7
+ # For complete documentation on the options, check out the topsy api docs.
8
+ # http://groups.google.com/group/rtopsy
9
+ module Topsy
10
+
11
+ class Trend
12
+ attr_accessor :url, :term
13
+
14
+ def to_s
15
+ "Topsy Trend: #{term}"
16
+ end
17
+
18
+ def initialize(hash)
19
+ hash.each do |key, value|
20
+ instance_variable_set("@#{key}", value)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,33 @@
1
+ # This is the tweet class for the topsy library.
2
+ # A Tweet instance has the following attributes:
3
+ # "permalink_url" : "http://twitter.com/imadnaffa/status/3565855201",
4
+ # "date" : "1251324809",
5
+ # "content" : "TOPSY - A search engine powered by tweets: http://topsy.com (this Search Engine can
6
+ # be powerful for sifting through Twitter- love it)!",
7
+ # "type" : "tweet",
8
+ # "author" : author instance
9
+ # "date_alpha" : "6 hours ago"
10
+ # According to the official Topsy doc: http://code.google.com/p/otterapi/wiki/Resources?tm=6#/trackbacks
11
+ #
12
+ # For complete documentation on the options, check out the topsy api docs.
13
+ # http://groups.google.com/group/rtopsy
14
+ module Topsy
15
+
16
+ class Tweet
17
+ attr_accessor :permalink_url, :date, :content, :type, :author, :date_alpha
18
+
19
+ def to_s
20
+ "Topsy Tweet: #{permalink_url}, #{content}"
21
+ end
22
+
23
+ def initialize(hash)
24
+ hash.each do |key, value|
25
+ if key == 'author'
26
+ instance_variable_set("@#{key}", Author.new(value))
27
+ else
28
+ instance_variable_set("@#{key}", value)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,29 @@
1
+ # This is the url_info class for the topsy library.
2
+ # An UrlInfo has the following attributes:
3
+ # "topsy_trackback_url" : "http://topsy.com/tb/twitter.com/",
4
+ # "oneforty" : "Twitter: What are you doing? http://twurl.nl/pd8k44",
5
+ # "url" : "http://twitter.com/",
6
+ # "title" : "Twitter: What are you doing?",
7
+ # "trackback_total" : "24152",
8
+ # "description" : "Social networking and microblogging service utilising instant messaging, SMS or a web interface.",
9
+ # "description_attribution" : "From DMOZ"
10
+ # According to the official Topsy doc: http://code.google.com/p/otterapi/wiki/Resources?tm=6#/urlinfo
11
+ #
12
+ # For complete documentation on the options, check out the topsy api docs.
13
+ # http://groups.google.com/group/rtopsy
14
+ module Topsy
15
+
16
+ class UrlInfo
17
+ attr_accessor :topsy_trackback_url, :oneforty, :url, :title, :trackback_total, :description, :description_attribution
18
+
19
+ def to_s
20
+ "Topsy UrlInfo: #{url}, @#{topsy_trackback_url}, #{trackback_total} total"
21
+ end
22
+
23
+ def initialize(hash)
24
+ hash.each do |key, value|
25
+ instance_variable_set("@#{key}", value)
26
+ end
27
+ end
28
+ end
29
+ end
data/lib/rtopsy.rb ADDED
@@ -0,0 +1,24 @@
1
+ require 'rubygems'
2
+ require 'json'
3
+ require 'HTTParty'
4
+
5
+ $:.unshift(File.dirname(__FILE__)) unless
6
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
7
+
8
+ require 'rtopsy/trend'
9
+ require 'rtopsy/tag'
10
+ require 'rtopsy/link_search_result'
11
+ require 'rtopsy/search_count'
12
+ require 'rtopsy/linkpost_count'
13
+ require 'rtopsy/author'
14
+ require 'rtopsy/url_info'
15
+ require 'rtopsy/stats'
16
+ require 'rtopsy/linkpost'
17
+ require 'rtopsy/api'
18
+ require 'rtopsy/page'
19
+ require 'rtopsy/target'
20
+ require 'rtopsy/tweet'
21
+
22
+ module Topsy
23
+ VERSION = '0.0.1'
24
+ end
data/rtopsy.gemspec ADDED
@@ -0,0 +1,38 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{rtopsy}
5
+ s.version = "0.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Ernesto Tagwerker"]
9
+ s.date = %q{2009-11-06}
10
+ s.description = %q{A ruby gem implementation of the Topsy API}
11
+ s.email = ["etagwerker@aycron.com"]
12
+ s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt"]
13
+ s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "lib/rtopsy.rb", "script/console", "script/destroy", "script/generate", "test/test_helper.rb", "test/test_rtopsy.rb"]
14
+ s.homepage = %q{http://github.com/etagwerker/rtopsy}
15
+ s.post_install_message = %q{PostInstall.txt}
16
+ s.rdoc_options = ["--main", "README.rdoc"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{rtopsy}
19
+ s.rubygems_version = %q{1.3.5}
20
+ s.summary = %q{A ruby gem implementation of the Topsy API}
21
+ s.test_files = ["test/test_helper.rb", "test/test_rtopsy.rb"]
22
+
23
+ if s.respond_to? :specification_version then
24
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
+ s.specification_version = 3
26
+
27
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
+ s.add_runtime_dependency(%q<httparty>, [">= 0.4.3"])
29
+ s.add_development_dependency(%q<hoe>, [">= 2.3.3"])
30
+ else
31
+ s.add_dependency(%q<httparty>, [">= 0.4.3"])
32
+ s.add_dependency(%q<hoe>, [">= 2.3.3"])
33
+ end
34
+ else
35
+ s.add_dependency(%q<httparty>, [">= 0.4.3"])
36
+ s.add_dependency(%q<hoe>, [">= 2.3.3"])
37
+ end
38
+ end
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/rtopsy.rb'}"
9
+ puts "Loading rtopsy gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,3 @@
1
+ require 'stringio'
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/../lib/topsy'
@@ -0,0 +1,18 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestTopsy < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def test_truth
9
+ assert true
10
+ end
11
+
12
+ #tests the urlinfo method
13
+ def test_urlinfo
14
+ puts 'testing url info'
15
+ urlinfo = Topsy::Base.urlinfo("http://www.aycron.com")
16
+ assert urlinfo.class == Topsy::UrlInfo, "Class of urlinfo method doesn't return UrlInfo"
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rtopsy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ernesto Tagwerker
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-07 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: httparty
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.4.3
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: hoe
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.3.3
34
+ version:
35
+ description: A ruby gem implementation of the Topsy API
36
+ email:
37
+ - etagwerker@aycron.com
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files:
43
+ - History.txt
44
+ - Manifest.txt
45
+ - PostInstall.txt
46
+ files:
47
+ - .loadpath
48
+ - .project
49
+ - History.txt
50
+ - Manifest.txt
51
+ - PostInstall.txt
52
+ - README.rdoc
53
+ - Rakefile
54
+ - lib/rtopsy.rb
55
+ - lib/rtopsy/api.rb
56
+ - lib/rtopsy/author.rb
57
+ - lib/rtopsy/link_search_result.rb
58
+ - lib/rtopsy/linkpost.rb
59
+ - lib/rtopsy/linkpost_count.rb
60
+ - lib/rtopsy/page.rb
61
+ - lib/rtopsy/search_count.rb
62
+ - lib/rtopsy/stats.rb
63
+ - lib/rtopsy/tag.rb
64
+ - lib/rtopsy/target.rb
65
+ - lib/rtopsy/trend.rb
66
+ - lib/rtopsy/tweet.rb
67
+ - lib/rtopsy/url_info.rb
68
+ - rtopsy.gemspec
69
+ - script/console
70
+ - script/destroy
71
+ - script/generate
72
+ - test/test_helper.rb
73
+ - test/test_rtopsy.rb
74
+ has_rdoc: true
75
+ homepage: http://github.com/etagwerker/rtopsy
76
+ licenses: []
77
+
78
+ post_install_message: PostInstall.txt
79
+ rdoc_options:
80
+ - --main
81
+ - README.rdoc
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
89
+ version:
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: "0"
95
+ version:
96
+ requirements: []
97
+
98
+ rubyforge_project: rtopsy
99
+ rubygems_version: 1.3.5
100
+ signing_key:
101
+ specification_version: 3
102
+ summary: A ruby gem implementation of the Topsy API
103
+ test_files:
104
+ - test/test_helper.rb
105
+ - test/test_rtopsy.rb