nytimes-bestsellers 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62ef4d25e237bdc6d28445e742d51e8b80d5c8b8
4
- data.tar.gz: ba50cdb4811ecf0083b7cb15090b3a75dca96020
3
+ metadata.gz: 432218d26fbcf904836f7e7ae5104219db6f4c83
4
+ data.tar.gz: 2c8a6db6ebd3d8768ae4b13e5a6998569b8c2b65
5
5
  SHA512:
6
- metadata.gz: 6875cd69164943cbdf426bdcf6b8ee703f323678357c30e0764de2f49a5684ffb008330f820c33092125801c56c285516fd1f872770eee40b536b7594331cc94
7
- data.tar.gz: 9aa2f1360be38010167758a6a5e7b9b0ba354c928962978e90730913cd5ea3f80bf99ca21f1fee5959deb401226a72dfdafacebe3986a1791fe68eabade75d70
6
+ metadata.gz: e5864550aba3422292fe826cf19047cf65f9e377d6f7814011e6a507f951c18578d74031c829be179d9c1a18429ad461a99efd06d0acf6a8fab2543eede95bfa
7
+ data.tar.gz: 1ffcae12805299a1d75c612d8b3e60816b20b46dcf17dd21ea4aa4d1f764a904f1ec266f8c275bcc5ea459fe0a501bafaa16861ddf0207aad86c6b6ea71f635e
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # New York Times Bestsellers
4
4
 
5
- A Ruby gem for accessing the [New York Times Bestsellers API](http://developer.nytimes.com/docs/best_sellers_api).
5
+ A Ruby gem for accessing the [New York Times Best Sellers API](http://developer.nytimes.com/docs/best_sellers_api) that gathers data from the [Best Sellers List](http://www.nytimes.com/best-sellers-books/).
6
6
 
7
7
  ## Install
8
8
 
@@ -31,7 +31,7 @@ Setup a new instance:
31
31
  end
32
32
  ```
33
33
 
34
- and do your thing!
34
+ Heads up! If you're not using Rails, note that when requiring the gem in your files you'll need to use `require nytimes_bestsellers` with the underscore rather than a dash.
35
35
 
36
36
  ## Methods
37
37
 
@@ -39,17 +39,17 @@ Six requests are available: get a bestseller list, get an overview of all of the
39
39
 
40
40
  ### get_list(list_name, o = {})
41
41
 
42
- This method has a required parameter of list name(see lists below or call the find_list_names method to find them for yourself) and takes an optional parameter of date, as a string in YYYY-MM-DD format. It also takes an optional parameter of response format and if none is specified it defaults to json.
42
+ This method has a required parameter of list name(see lists below or call the find_list_names method to find them for yourself) and takes optional parameters of date(as a string in YYYY-MM-DD format), offset, sort_by, and sort_order.
43
43
 
44
44
  with no optional parameters it gets the most recent list
45
45
  `@client.get_list('hardcover-nonfiction')`
46
46
 
47
47
  it can take optional parameters
48
- `@client.get_list('hardcover-nonfiction', date: '2012-04-12', response: 'xml')`
48
+ `@client.get_list('hardcover-nonfiction', date: '2012-04-12', offset: 20)`
49
49
 
50
50
  ### bestseller_lists_overview()
51
51
 
52
- Returns an overview of Times best-seller lists for a single week. Takes an optional parameter of date in YYYY-MM-DD format. If you do not specify a published_date the most recent week's best-seller list will be returned.
52
+ Returns an overview of Times best-seller lists for a single week. Takes an optional parameter of date in YYYY-MM-DD format. If you do not specify a date the most recent week's best-seller list will be returned.
53
53
 
54
54
  `@client.bestseller_lists_overview`
55
55
  `@client.bestseller_lists_overview(date: '2012-04-12')`
@@ -57,13 +57,13 @@ Returns an overview of Times best-seller lists for a single week. Takes an optio
57
57
 
58
58
  ### search_list(list_name, o = {})
59
59
 
60
- Allows for a filtered search of a specific list. Optional parameters are date, isbn, published_date, rank, rank_last_week, and weeks_on_list.
60
+ Allows for a filtered search of a specific list. Optional parameters are date, isbn, published_date, rank, rank_last_week, and weeks_on_list. Has additional parameters of offset, sort_by, and sort_order.
61
61
 
62
62
  `@client.search_list('hardcover-nonfiction', published_date: "2013-04-12")`
63
63
 
64
64
  ### single_history()
65
65
 
66
- Returns up to 20 weeks of history for a bestseller (its rank and number of weeks on the various Times best-seller lists). Takes one or more of the following parameters: , author, contributor, isbn, price, publisher, title, age_group(see below for age group options).
66
+ Returns up to 20 weeks of history for a bestseller (its rank and number of weeks on the various Times best-seller lists). Takes one or more of the following parameters: author, contributor, isbn, price, publisher, title, age_group(see below for age group options). Has additional parameters of sort_by and sort_order.
67
67
 
68
68
  `@client.single_history(author: 'rachel maddow')`
69
69
 
@@ -18,7 +18,7 @@ module Bestsellers
18
18
 
19
19
  def set_urlparam(url, name, options)
20
20
  return unless options[name]
21
- url << "&#{name.to_s.gsub('_','-')}=#{options[name]}"
21
+ url << "&#{name.to_s.gsub('_','-')}=#{options[name].gsub(/ /, '-')}"
22
22
  end
23
23
 
24
24
  def get_list(list_name, o = {})
@@ -29,7 +29,7 @@ module Bestsellers
29
29
  url << "/#{date}"
30
30
  end
31
31
 
32
- url << "/#{list_name}?"
32
+ url << "/#{list_name.gsub(/ /, '-')}?"
33
33
 
34
34
  [:offset, :sort_by, :sort_order].each do |thing|
35
35
  set_urlparam(url, thing, o)
@@ -42,7 +42,7 @@ module Bestsellers
42
42
 
43
43
  def search_list(list_name, o = {})
44
44
 
45
- url = BOOKS_URL.clone + "?list-name=#{list_name}"
45
+ url = BOOKS_URL.clone + "?list-name=#{list_name.gsub(/ /, '-')}"
46
46
 
47
47
  date = if o[:date]
48
48
  Date.parse(o[:date])
@@ -51,7 +51,7 @@ module Bestsellers
51
51
  end.strftime('%Y-%m-%e')
52
52
  url << "&date=#{date}"
53
53
 
54
- [:isbn, :published_date, :rank, :rank_last_week, :weeks_on_list].each do |thing|
54
+ [:isbn, :published_date, :rank, :rank_last_week, :weeks_on_list, :offset, :sort_by, :sort_order].each do |thing|
55
55
  set_urlparam(url, thing, o)
56
56
  end
57
57
 
@@ -72,7 +72,7 @@ module Bestsellers
72
72
 
73
73
  url << "?"
74
74
 
75
- [:author, :publisher, :title, :age_group, :contributor, :isbn, :price].each do |thing|
75
+ [:author, :publisher, :title, :age_group, :contributor, :isbn, :price, :sort_by, :sort_order].each do |thing|
76
76
  set_urlparam(url, thing, o)
77
77
  end
78
78
 
@@ -1,3 +1,3 @@
1
1
  module Bestsellers
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nytimes-bestsellers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emma