times_topics 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +38 -1
- data/VERSION +1 -1
- data/lib/times_tags.rb +4 -4
- data/lib/times_topics.rb +2 -0
- data/times_topics.gemspec +1 -1
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -5,8 +5,45 @@
|
|
5
5
|
|
6
6
|
= Usage
|
7
7
|
|
8
|
+
First, ensure you have an API key. You may request one here: http://developer.nytimes.com/apps/register/
|
9
|
+
|
10
|
+
Once you have an API key, save it in a file in RAILS_ROOT/config/times_topics.yml like so:
|
11
|
+
|
12
|
+
api_key: 123456abcde
|
13
|
+
|
14
|
+
You can then interact with Times Topics:
|
15
|
+
|
16
|
+
require 'times_topics'
|
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"}>
|
20
|
+
|
21
|
+
tt.url
|
22
|
+
# => "http://topics.nytimes.com/top/reference/timestopics/organizations/a/al_qaeda/index.html"
|
23
|
+
|
24
|
+
tt.page_exists?
|
25
|
+
# => true
|
26
|
+
|
27
|
+
tt.related_results
|
28
|
+
# => ["Al Qaeda in Mesopotamia (Org)", "Al Qaeda in the Islamic Maghreb (Org)"]
|
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"]
|
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"}>
|
35
|
+
|
36
|
+
tt.url
|
37
|
+
# => "http://topics.nytimes.com/top/reference/timestopics/people/b/osama_bin_laden/index.html"
|
38
|
+
|
39
|
+
tt.page_exists?
|
40
|
+
# => true
|
41
|
+
|
42
|
+
tt.related_results
|
43
|
+
# => nil
|
44
|
+
|
8
45
|
== Note on Patches/Pull Requests
|
9
|
-
|
46
|
+
|
10
47
|
* Fork the project.
|
11
48
|
* Make your feature addition or bug fix.
|
12
49
|
* Add tests for it. This is important so I don't break it in a
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/times_tags.rb
CHANGED
@@ -29,19 +29,19 @@ class TimesTags
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.person_search(name)
|
32
|
-
get('/suggest', :query => { :query => name, :filter => '(Per)'})
|
32
|
+
get('/suggest', :query => { :query => name, :filter => '(Per)', 'api-key' => api_key})
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.organization_search(name)
|
36
|
-
get('/suggest', :query => { :query => name, :filter => '(Org)'})
|
36
|
+
get('/suggest', :query => { :query => name, :filter => '(Org)', 'api-key' => api_key})
|
37
37
|
end
|
38
38
|
|
39
39
|
def self.geographic_search(name)
|
40
|
-
get('/suggest', :query => { :query => name, :filter => '(Geo)'})
|
40
|
+
get('/suggest', :query => { :query => name, :filter => '(Geo)', 'api-key' => api_key})
|
41
41
|
end
|
42
42
|
|
43
43
|
def self.subject_search(name)
|
44
|
-
get('/suggest', :query => { :query => name, :filter => '(Des)'})
|
44
|
+
get('/suggest', :query => { :query => name, :filter => '(Des)', 'api-key' => api_key})
|
45
45
|
end
|
46
46
|
|
47
47
|
def self.search(query, type)
|
data/lib/times_topics.rb
CHANGED
data/times_topics.gemspec
CHANGED