nytimes-articles 0.4.0 → 0.4.1

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/HISTORY CHANGED
@@ -1,5 +1,8 @@
1
1
  HISTORY
2
2
 
3
+ = 0.4.1
4
+ - Added support for comments, dbpedia_resource, dbpedia_resource_url, and terms_facet fields
5
+
3
6
  = 0.4.0
4
7
  - Changed facet format returned from search
5
8
  - Changed default fields returned to all
data/Rakefile CHANGED
@@ -12,6 +12,7 @@ begin
12
12
  s.requirements << 'Unicode'
13
13
  s.requirements << 'The htmlentities gem'
14
14
  s.add_dependency('htmlentities')
15
+ s.add_development_dependency('fakeweb')
15
16
  end
16
17
  rescue LoadError
17
18
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
@@ -1,4 +1,5 @@
1
1
  ---
2
- :patch: 0
3
- :major: 0
4
2
  :minor: 4
3
+ :patch: 1
4
+ :major: 0
5
+ :build:
@@ -10,7 +10,7 @@ module Nytimes
10
10
  RAW_FIELDS = %w(url)
11
11
  TEXT_FIELDS = %w(abstract author body byline lead_paragraph nytd_lead_paragraph nytd_title title)
12
12
  NUMERIC_FIELDS = %w(word_count)
13
- BOOLEAN_FIELDS = %w(fee small_image)
13
+ BOOLEAN_FIELDS = %w(fee small_image comments)
14
14
  IMAGE_FIELDS = %w(small_image small_image_url small_image_height small_image_width)
15
15
  MULTIMEDIA_FIELDS = %w(multimedia related_multimedia)
16
16
 
@@ -52,6 +52,10 @@ module Nytimes
52
52
  def free?
53
53
  not(fee?)
54
54
  end
55
+
56
+ ##
57
+ # An alias for comments
58
+ alias :has_comments? comments
55
59
 
56
60
  ##
57
61
  # Creates a new Article from the a hash returned from the API. This is called on search results. You have no reason to call it.
@@ -62,6 +66,7 @@ module Nytimes
62
66
  :body => text_field(params['body']),
63
67
  :byline => text_field(params['byline']),
64
68
  :fee => boolean_field(params['fee']),
69
+ :comments => boolean_field(params['comments']),
65
70
  :lead_paragraph => text_field(params['lead_paragraph']),
66
71
  :nytd_title => text_field(params['nytd_title']),
67
72
  :nytd_lead_paragraph => text_field(params['nytd_lead_paragraph']),
@@ -87,6 +92,8 @@ module Nytimes
87
92
  # FACETS THAT RETURN ARRAYS
88
93
  :classifiers => facet_params(params, Facet::CLASSIFIERS),
89
94
  :descriptions => facet_params(params, Facet::DESCRIPTION),
95
+ :dbpedia_resources => facet_params(params, Facet::DBPEDIA_RESOURCE),
96
+ :dbpedia_urls => facet_params(params, Facet::DBPEDIA_URL),
90
97
  :geo => facet_params(params, Facet::GEO),
91
98
  :material_types => facet_params(params, Facet::MATERIAL_TYPE),
92
99
  :organizations => facet_params(params, Facet::ORGANIZATION),
@@ -143,8 +150,11 @@ module Nytimes
143
150
  # * <tt>Facet::COLUMN</tt> - A Times column title (if applicable), such as _Weddings_ or _Ideas & Trends_
144
151
  # * <tt>Facet::DATE</tt> - The publication date in YYYYMMDD format
145
152
  # * <tt>Facet::DAY_OF_WEEK</tt> - The day of the week (e.g., Monday, Tuesday) the article was published (compare <tt>PUB_DAY</tt>, which is the numeric date rather than the day of the week)
153
+ # * <tt>Facet::DBPEDIA_RESOURCE</tt> - DBpedia person names mapped to Times per_facet terms. This field is case sensitive: values must be Mixed Case.
154
+ # * <tt>Facet::DBPEDIA_URL</tt> - URLs to DBpedia person names that have been mapped to Times per_facet terms. This field is case sensitive: values must be Mixed Case.
146
155
  # * <tt>Facet::DESCRIPTION</tt> - Descriptive subject terms assigned by Times indexers (must be in UPPERCASE)
147
156
  # * <tt>Facet::DESK</tt> - The Times desk that produced the story (e.g., _Business/Financial Desk_)
157
+ # * <tt>Facet::FACET_TERM</tt> - Combines des_facet, geo_facet, org_facet and per_facet. Search facet_terms to find your query in any of those facets (essentially a combined OR search).
148
158
  # * <tt>Facet::GEO</tt> - Standardized names of geographic locations, assigned by Times indexers (must be in UPPERCASE)
149
159
  # * <tt>Facet::MATERIAL_TYPE</tt> - The general article type, such as Biography, Editorial or Review
150
160
  # * <tt>Facet::ORGANIZATION</tt> - Standardized names of people, assigned by Times indexers (must be UPPERCASE)
@@ -179,6 +189,7 @@ module Nytimes
179
189
  # * <tt>:fee</tt> - if set to true, only returns articles that must be purchased. If false, returns only free articles. If not specified, returns all articles
180
190
  # * <tt>:has_thumbnail</tt> - returns only articles that have thumbnail images associated. Note that to see the thumbnails, you must specify either <tt>:thumbnail</tt> or <tt>:all</tt> in the <tt>:fields</tt> argument).
181
191
  # * <tt>:has_multimedia</tt> - to be implemented
192
+ # * <tt>:comments</tt> - set to true to return articles that have comments
182
193
  #
183
194
  # == FACET SUMMARIES
184
195
  #
@@ -382,6 +393,10 @@ module Nytimes
382
393
  bool_params << "#{'-' unless in_params[:fee]}fee:Y"
383
394
  end
384
395
 
396
+ unless in_params[:comments].nil?
397
+ bool_params << "#{'-' unless in_params[:comments]}comments:Y"
398
+ end
399
+
385
400
  unless in_params[:has_multimedia].nil?
386
401
  bool_params << "#{'-' unless in_params[:has_multimedia]}related_multimedia:Y"
387
402
  end
@@ -25,8 +25,11 @@ module Nytimes
25
25
  COLUMN = 'column_facet'
26
26
  DATE = 'date'
27
27
  DAY_OF_WEEK = 'day_of_week_facet'
28
+ DBPEDIA_RESOURCE = 'dbpedia_resource'
29
+ DBPEDIA_URL = 'dbpedia_resource_url'
28
30
  DESCRIPTION = 'des_facet'
29
31
  DESK = 'desk_facet'
32
+ FACET_TERM = 'facet_terms'
30
33
  GEO = 'geo_facet'
31
34
  MATERIAL_TYPE = 'material_type_facet'
32
35
  ORGANIZATION = 'org_facet'
@@ -51,9 +54,9 @@ module Nytimes
51
54
  # The default 5 facets to return
52
55
  DEFAULT_RETURN_FACETS = [DESCRIPTION, GEO, ORGANIZATION, PERSON, DESK]
53
56
 
54
- ALL_FACETS = [CLASSIFIERS, COLUMN, DATE, DAY_OF_WEEK, DESCRIPTION, DESK, GEO, MATERIAL_TYPE, ORGANIZATION, PAGE, PERSON, PUB_DAY,
55
- PUB_MONTH, PUB_YEAR, SECTION_PAGE, SOURCE, WORKS_MENTIONED, NYTD_BYLINE, NYTD_DESCRIPTION, NYTD_GEO,
56
- NYTD_ORGANIZATION, NYTD_PERSON, NYTD_SECTION, NYTD_WORKS_MENTIONED]
57
+ ALL_FACETS = [CLASSIFIERS, COLUMN, DATE, DAY_OF_WEEK, DESCRIPTION, DBPEDIA_RESOURCE, DBPEDIA_URL, DESK, GEO, MATERIAL_TYPE, ORGANIZATION, PAGE, PERSON, PUB_DAY,
58
+ PUB_MONTH, PUB_YEAR, SECTION_PAGE, SOURCE, WORKS_MENTIONED, NYTD_BYLINE, NYTD_DESCRIPTION, NYTD_GEO,
59
+ NYTD_ORGANIZATION, NYTD_PERSON, NYTD_SECTION, NYTD_WORKS_MENTIONED]
57
60
 
58
61
  ##
59
62
  # Initializes the facet. There is seldom a reason for you to call this.
@@ -90,6 +93,12 @@ module Nytimes
90
93
  NYTD_ORGANIZATION
91
94
  when :nytd_people
92
95
  NYTD_PERSON
96
+ when :dbpedia, :dbpedia_res
97
+ DBPEDIA_RESOURCE
98
+ when :dbpedia_url, :dbpedia_resource_url
99
+ DBPEDIA_URL
100
+ when :term, :terms, :facet_terms, :facet_term
101
+ FACET_TERM
93
102
  else
94
103
  name = facet.to_s.upcase
95
104
 
@@ -1,12 +1,15 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{nytimes-articles}
5
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
6
9
 
7
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
11
  s.authors = ["Jacob Harris"]
9
- s.date = %q{2009-07-23}
12
+ s.date = %q{2009-12-13}
10
13
  s.description = %q{A gem for accessing the New York Times Article Search API}
11
14
  s.email = %q{jharris@nytimes.com}
12
15
  s.extra_rdoc_files = [
@@ -64,10 +67,14 @@ Gem::Specification.new do |s|
64
67
 
65
68
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
66
69
  s.add_runtime_dependency(%q<htmlentities>, [">= 0"])
70
+ s.add_development_dependency(%q<fakeweb>, [">= 0"])
67
71
  else
68
72
  s.add_dependency(%q<htmlentities>, [">= 0"])
73
+ s.add_dependency(%q<fakeweb>, [">= 0"])
69
74
  end
70
75
  else
71
76
  s.add_dependency(%q<htmlentities>, [">= 0"])
77
+ s.add_dependency(%q<fakeweb>, [">= 0"])
72
78
  end
73
79
  end
80
+
@@ -247,6 +247,18 @@ class TestNytimes::TestArticles::TestArticle < Test::Unit::TestCase
247
247
  Article.search "ice cream", :fee => false
248
248
  end
249
249
  end
250
+
251
+ context ":comments" do
252
+ should "send through as comments:Y if set to true" do
253
+ Article.expects(:invoke).with(has_entry("query", "ice cream comments:Y"))
254
+ Article.search "ice cream", :comments => true
255
+ end
256
+
257
+ should "send through as -comments:Y if set to false" do
258
+ Article.expects(:invoke).with(has_entry("query", "ice cream -comments:Y"))
259
+ Article.search "ice cream", :comments => false
260
+ end
261
+ end
250
262
 
251
263
  context ":fields" do
252
264
  context "when not specified at all" do
@@ -81,6 +81,24 @@ class TestNytimes::TestArticles::TestFacet < Test::Unit::TestCase
81
81
  end
82
82
  end
83
83
 
84
+ [:dbpedia, :dbpedia_res, :dbpedia_resource].each do |sym|
85
+ should "return Facet::DBPEDIA_RESOURCE for #{sym}" do
86
+ assert_equal Facet::DBPEDIA_RESOURCE, Facet.symbol_name(sym)
87
+ end
88
+ end
89
+
90
+ [:dbpedia_url, :dbpedia_resource_url].each do |sym|
91
+ should "return Facet::DBPEDIA_URL for #{sym}" do
92
+ assert_equal Facet::DBPEDIA_URL, Facet.symbol_name(sym)
93
+ end
94
+ end
95
+
96
+ [:term, :terms, :facet_terms, :facet_term].each do |sym|
97
+ should "return Facet::FACET_TERM for #{sym}" do
98
+ assert_equal Facet::FACET_TERM, Facet.symbol_name(sym)
99
+ end
100
+ end
101
+
84
102
  should "look for a matching constant and use that value" do
85
103
  assert_equal Facet::SOURCE, Facet.symbol_name(:source)
86
104
  end
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'test/unit'
3
3
  require 'shoulda'
4
4
  require 'mocha'
5
- gem 'chrisk-fakeweb'
5
+ gem 'fakeweb'
6
6
  require 'fake_web'
7
7
 
8
8
  FakeWeb.allow_net_connect = false
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nytimes-articles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Harris
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-23 00:00:00 -04:00
12
+ date: 2009-12-13 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,6 +22,16 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: "0"
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: fakeweb
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
25
35
  description: A gem for accessing the New York Times Article Search API
26
36
  email: jharris@nytimes.com
27
37
  executables: []
@@ -59,7 +69,7 @@ files:
59
69
  - test/nytimes/articles/test_result_set.rb
60
70
  - test/nytimes/articles/test_thumbnail.rb
61
71
  - test/test_helper.rb
62
- has_rdoc: false
72
+ has_rdoc: true
63
73
  homepage: http://github.com/harrisj/nytimes-articles
64
74
  licenses: []
65
75
 
@@ -84,7 +94,7 @@ requirements:
84
94
  - Unicode
85
95
  - The htmlentities gem
86
96
  rubyforge_project:
87
- rubygems_version: 1.3.2
97
+ rubygems_version: 1.3.5
88
98
  signing_key:
89
99
  specification_version: 3
90
100
  summary: A gem for accessing the NYTimes Article Search API