times_topics 0.2.0 → 0.3.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/README.rdoc +19 -19
- data/VERSION +1 -1
- data/lib/times_topics.rb +2 -1
- data/test/test_times_topics.rb +3 -0
- data/times_topics.gemspec +2 -2
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -13,34 +13,34 @@ api_key: 123456abcde
|
|
13
13
|
|
14
14
|
You can then interact with Times Topics:
|
15
15
|
|
16
|
-
require 'times_topics'
|
16
|
+
require 'times_topics'
|
17
17
|
|
18
|
-
tt = TimesTopics.new("Al Qaeda", "organization")
|
19
|
-
# => #<TimesTopics:0x10220b798 @url="http://topics.nytimes.com/top/reference/timestopics/organizations/a/al_qaeda/index.html", @related_results=["Al Qaeda in Mesopotamia (Org)", "Al Qaeda in the Islamic Maghreb (Org)"], @query="Al Qaeda", @type="organization", @result={"results"=>["Al Qaeda in Mesopotamia (Org)", "Al Qaeda in the Islamic Maghreb (Org)"], "filter"=>"(Org)", "num_results"=>3, "query"=>"Al Qaeda"}>
|
18
|
+
tt = TimesTopics.new("Al Qaeda", "organization")
|
19
|
+
# => #<TimesTopics:0x10220b798 @url="http://topics.nytimes.com/top/reference/timestopics/organizations/a/al_qaeda/index.html", @related_results=["Al Qaeda in Mesopotamia (Org)", "Al Qaeda in the Islamic Maghreb (Org)"], @query="Al Qaeda", @type="organization", @result={"results"=>["Al Qaeda in Mesopotamia (Org)", "Al Qaeda in the Islamic Maghreb (Org)"], "filter"=>"(Org)", "num_results"=>3, "query"=>"Al Qaeda"}>
|
20
20
|
|
21
|
-
tt.url
|
22
|
-
# => "http://topics.nytimes.com/top/reference/timestopics/organizations/a/al_qaeda/index.html"
|
21
|
+
tt.url
|
22
|
+
# => "http://topics.nytimes.com/top/reference/timestopics/organizations/a/al_qaeda/index.html"
|
23
23
|
|
24
|
-
tt.page_exists?
|
25
|
-
# => true
|
24
|
+
tt.page_exists?
|
25
|
+
# => true
|
26
26
|
|
27
|
-
tt.related_results
|
28
|
-
# => ["Al Qaeda in Mesopotamia (Org)", "Al Qaeda in the Islamic Maghreb (Org)"]
|
27
|
+
tt.related_results
|
28
|
+
# => ["Al Qaeda in Mesopotamia (Org)", "Al Qaeda in the Islamic Maghreb (Org)"]
|
29
29
|
|
30
|
-
tt.related_result_urls
|
31
|
-
# => ["http://topics.nytimes.com/top/reference/timestopics/organizations/a/al_qaeda_in_mesopotamia/index.html", "http://topics.nytimes.com/top/reference/timestopics/organizations/a/al_qaeda_in_the_islamic_maghreb/index.html"]
|
30
|
+
tt.related_result_urls
|
31
|
+
# => ["http://topics.nytimes.com/top/reference/timestopics/organizations/a/al_qaeda_in_mesopotamia/index.html", "http://topics.nytimes.com/top/reference/timestopics/organizations/a/al_qaeda_in_the_islamic_maghreb/index.html"]
|
32
32
|
|
33
|
-
tt = TimesTopics.new("Osama bin Laden") ## defaults type to 'person'
|
34
|
-
# => #<TimesTopics:0x10154ff18 @url="http://topics.nytimes.com/top/reference/timestopics/people/b/osama_bin_laden/index.html", @query="Osama bin Laden", @type="person", @result={"results"=>[], "filter"=>"(Per)", "num_results"=>1, "query"=>"Osama bin Laden"}>
|
33
|
+
tt = TimesTopics.new("Osama bin Laden") ## defaults type to 'person'
|
34
|
+
# => #<TimesTopics:0x10154ff18 @url="http://topics.nytimes.com/top/reference/timestopics/people/b/osama_bin_laden/index.html", @query="Osama bin Laden", @type="person", @result={"results"=>[], "filter"=>"(Per)", "num_results"=>1, "query"=>"Osama bin Laden"}>
|
35
35
|
|
36
|
-
tt.url
|
37
|
-
# => "http://topics.nytimes.com/top/reference/timestopics/people/b/osama_bin_laden/index.html"
|
36
|
+
tt.url
|
37
|
+
# => "http://topics.nytimes.com/top/reference/timestopics/people/b/osama_bin_laden/index.html"
|
38
38
|
|
39
|
-
tt.page_exists?
|
40
|
-
# => true
|
39
|
+
tt.page_exists?
|
40
|
+
# => true
|
41
41
|
|
42
|
-
tt.related_results
|
43
|
-
# => nil
|
42
|
+
tt.related_results
|
43
|
+
# => nil
|
44
44
|
|
45
45
|
== Note on Patches/Pull Requests
|
46
46
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/times_topics.rb
CHANGED
@@ -2,7 +2,7 @@ require 'times_tags'
|
|
2
2
|
|
3
3
|
class TimesTopics
|
4
4
|
BASE_URI = 'http://topics.nytimes.com/top/reference/timestopics/'
|
5
|
-
attr_accessor :query, :type, :url, :result, :related_results, :num_results
|
5
|
+
attr_accessor :query, :type, :url, :result, :related_results, :num_results, :tag
|
6
6
|
|
7
7
|
def initialize(query, type = 'person')
|
8
8
|
@type = type
|
@@ -12,6 +12,7 @@ class TimesTopics
|
|
12
12
|
@num_results = @result["num_results"]
|
13
13
|
if @num_results > 0
|
14
14
|
top_result = @result["results"].shift
|
15
|
+
@tag = top_result
|
15
16
|
case @type
|
16
17
|
when /person/
|
17
18
|
@url = build_person_url(top_result)
|
data/test/test_times_topics.rb
CHANGED
@@ -26,6 +26,9 @@ class TestTimesTopics < Test::Unit::TestCase
|
|
26
26
|
should "page_exists?" do
|
27
27
|
assert @topic.page_exists?
|
28
28
|
end
|
29
|
+
should "tag" do
|
30
|
+
assert_equal "bin Laden, Osama (Per)", @topic.tag
|
31
|
+
end
|
29
32
|
should "url" do
|
30
33
|
assert_equal "http://topics.nytimes.com/top/reference/timestopics/people/b/osama_bin_laden/index.html", @topic.url
|
31
34
|
end
|
data/times_topics.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{times_topics}
|
8
|
-
s.version = "0.
|
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 = ["Jacqui Maher"]
|
12
|
-
s.date = %q{2010-06
|
12
|
+
s.date = %q{2010-07-06}
|
13
13
|
s.description = %q{Interact with the TimesTags API (http://developer.nytimes.com/docs/timestags_api) with this rubygem. Find people, organizations, locations, and subjects matching queries. Find Times Topics pages for query matches along with related topics, when applicable.}
|
14
14
|
s.email = %q{jacqui.maher@nytimes.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 3
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.3.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jacqui Maher
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-06
|
17
|
+
date: 2010-07-06 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|