times_topics 0.1.0 → 0.2.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 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
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
@@ -1,3 +1,5 @@
1
+ require 'times_tags'
2
+
1
3
  class TimesTopics
2
4
  BASE_URI = 'http://topics.nytimes.com/top/reference/timestopics/'
3
5
  attr_accessor :query, :type, :url, :result, :related_results, :num_results
data/times_topics.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{times_topics}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.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"]
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jacqui Maher