topsy 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.3.0
@@ -1,16 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ### 0.2.1 February, 14, 2010
4
-
5
- * Added site: option to search method
6
-
7
- Topsy.search('riak', :site => 'thechangelog.com')
8
-
9
- ### 0.2.0 January 6, 2010
3
+ ## 0.2.0 January 6, 2010
10
4
 
11
5
  * Ernesto implemented biz objects for all return types, thanks!
12
6
  * Added rate_limit info
13
7
 
14
- ### 0.1.0 January 1, 2010
8
+ ## 0.1.0 January 1, 2010
15
9
 
16
10
  * Initial version
@@ -58,9 +58,7 @@ module Topsy
58
58
  Topsy::LinkpostCount.new(count)
59
59
  end
60
60
 
61
- # Returns list list of author profiles that match the query.
62
- # The query is matched against the nick, name and biography
63
- # information and the results are sorted by closeness of match and the influence of authors.
61
+ # 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.
64
62
  #
65
63
  # @param [String] q the search query string
66
64
  # @param [Hash] options method options
@@ -91,15 +89,8 @@ module Topsy
91
89
  # @option options [Symbol] :window 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
92
90
  # @option options [Integer] :page page number of the result set. (default: 1, max: 10)
93
91
  # @option options [Integer] :perpage limit number of results per page. (default: 10, max: 50)
94
- # @option options [String] :site narrow results to a domain
95
92
  # @return [Topsy::Page]
96
93
  def search(q, options={})
97
- if q.is_a?(Hash)
98
- options = q
99
- q = "site:#{options.delete(:site)}" if options[:site]
100
- else
101
- q += " site:#{options.delete(:site)}" if options[:site]
102
- end
103
94
  options[:window] = @@windows[options[:window]] if options[:window]
104
95
  results = handle_response(self.class.get("/search.json", :query => {:q => q}.merge(options)))
105
96
  Topsy::Page.new(results,Topsy::LinkSearchResult)
@@ -106,46 +106,25 @@ class TestTopsy < Test::Unit::TestCase
106
106
  results.list.first.url.should == "http://update.gemcutter.org/"
107
107
  end
108
108
 
109
- context "when searching" do
110
-
111
- should "handle string queries" do
112
- stub_get("/search.json?q=NYE&window=m", "search.json")
113
- results = Topsy.search("NYE", :window => :month)
114
- end
115
-
116
- should "handle hash queries" do
117
- stub_get("/search.json?q=site%3Athechangelog.com&window=h", "search.json")
118
- results = Topsy.search(:site => 'thechangelog.com', :window => :hour)
119
- end
120
-
121
- should "handle combined queries" do
122
- stub_get("/search.json?q=riak%20site%3Athechangelog.com&window=h", "search.json")
123
- results = Topsy.search('riak', :site => 'thechangelog.com', :window => :hour)
124
- end
125
-
126
- should "return a page with a list of link search results for a query" do
127
- stub_get("/search.json?q=NYE&window=m", "search.json")
128
- results = Topsy.search("NYE", :window => :month)
129
- results.class.should == Topsy::Page
130
- results.total.should == 117731
131
- results.page.should == 1
132
- results.perpage.should == 10
133
- results.window.should == :month
134
- results.list.first.class.should == Topsy::LinkSearchResult
135
- results.list.first.score.should == 4.70643044
136
- results.list.first.trackback_permalink.should == "http://twitter.com/spin/status/5164154014"
137
- results.list.first.hits.should == 397
138
- results.list.first.trackback_total.should == 2268
139
- results.list.first.topsy_trackback_url.should == "http://topsy.com/trackback?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DXGK84Poeynk"
140
- results.list.first.url.should == "http://www.youtube.com/watch?v=XGK84Poeynk"
141
- results.list.first.content.should == "Science, autotuned, with Sagan, Bill Nye, Tyson, Feynman http://bit.ly/2tDk4y win!"
142
- results.list.first.title.should == "YouTube - Symphony of Science - 'We Are All Connected' (ft. Sagan, Feynman, deGrasse Tyson & Bill Nye)"
143
- results.list.first.highlight.should == "Science, autotuned, with Sagan, Bill <span class=\"highlight-term\">Nye</span>, Tyson, Feynman http://bit.ly/2tDk4y win! "
144
- end
109
+ should "return a page with a list of link search results for a query" do
110
+ stub_get("/search.json?q=NYE&window=m", "search.json")
111
+ results = Topsy.search("NYE", :window => :month)
112
+ results.class.should == Topsy::Page
113
+ results.total.should == 117731
114
+ results.page.should == 1
115
+ results.perpage.should == 10
116
+ results.window.should == :month
117
+ results.list.first.class.should == Topsy::LinkSearchResult
118
+ results.list.first.score.should == 4.70643044
119
+ results.list.first.trackback_permalink.should == "http://twitter.com/spin/status/5164154014"
120
+ results.list.first.hits.should == 397
121
+ results.list.first.trackback_total.should == 2268
122
+ results.list.first.topsy_trackback_url.should == "http://topsy.com/trackback?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DXGK84Poeynk"
123
+ results.list.first.url.should == "http://www.youtube.com/watch?v=XGK84Poeynk"
124
+ results.list.first.content.should == "Science, autotuned, with Sagan, Bill Nye, Tyson, Feynman http://bit.ly/2tDk4y win!"
125
+ results.list.first.title.should == "YouTube - Symphony of Science - 'We Are All Connected' (ft. Sagan, Feynman, deGrasse Tyson & Bill Nye)"
126
+ results.list.first.highlight.should == "Science, autotuned, with Sagan, Bill <span class=\"highlight-term\">Nye</span>, Tyson, Feynman http://bit.ly/2tDk4y win! "
145
127
  end
146
-
147
-
148
-
149
128
 
150
129
  should "return search counts for a term" do
151
130
  stub_get("/searchcount.json?q=Balloon%20Boy", "searchcount.json")
@@ -5,16 +5,17 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{topsy}
8
- s.version = "0.2.1"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Wynn Netherland", "Ernesto Tagwerker"]
12
- s.date = %q{2010-02-14}
12
+ s.date = %q{2010-01-11}
13
13
  s.description = %q{Ruby wrapper for the Topsy otterapi}
14
14
  s.email = %q{wynn.netherland@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.markdown"
17
+ "README.markdown",
18
+ "TODO"
18
19
  ]
19
20
  s.files = [
20
21
  ".gitignore",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: topsy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wynn Netherland
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-02-14 00:00:00 -06:00
13
+ date: 2010-01-11 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -82,6 +82,7 @@ extensions: []
82
82
  extra_rdoc_files:
83
83
  - LICENSE
84
84
  - README.markdown
85
+ - TODO
85
86
  files:
86
87
  - .gitignore
87
88
  - LICENSE