book_worm 0.0.3 → 0.0.4

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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- book_worm (0.0.2)
4
+ book_worm (0.0.3)
5
5
  httparty
6
6
 
7
7
  GEM
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ ## Usage
2
+ gem install book_worm
3
+
4
+ ## Indices
5
+
6
+ ### Isbn
7
+ Search on ISBN, value is set the ISBN you are interested in.
8
+
9
+ #### Example
10
+ BookWorm.find(:isbn, "1234567890")
11
+
12
+ ### Title
13
+ Keywords search on book title, long title, and latin-ized title for unicode titles.
14
+
15
+ #### Example
16
+ BookWorm.find(:title, "Programming Ruby")
17
+
18
+ ### Combined
19
+ Search index that combines titles, authors, and publisher name.
20
+
21
+ ### Full
22
+ Search index that includes titles, authors, publisher name, summary, notes, awards information, etc -- practically every bit of textual information ISBNdb.com has about books.
23
+
24
+ ## Configuration
25
+
26
+ BookWorm::Configuration.configure do |settings|
27
+ settings[:api_key] = "YOUR_ISBNDB_API_KEY"
28
+ end
29
+
@@ -1,4 +1,8 @@
1
1
  module BookWorm
2
+
3
+ # == Book
4
+ #
5
+ # Book is used to store the xml data that is returned from ISBNDB
2
6
  class Book
3
7
  attr_accessor :publisher, :authors, :isbn,
4
8
  :isbn13, :title, :long_title,
@@ -1,10 +1,21 @@
1
1
  module BookWorm
2
+
3
+ # == Configuration
4
+ #
5
+ # Module for storing configuration settings
2
6
  module Configuration
3
7
  extend self
4
8
 
5
9
  attr_accessor :config
6
10
  @config = {}
7
11
 
12
+ # Provides a method client to specify their ISBNDB API key.
13
+ #
14
+ # == Example
15
+ #
16
+ # BookWorm::Configuration.configure do |c|
17
+ # c[:api_key] = YOUR_ISBNDB_API_KEY
18
+ # end
8
19
  def configure
9
20
  yield @config
10
21
  end
@@ -1,5 +1,4 @@
1
1
  module BookWorm
2
- require 'book_worm/configuration'
3
2
  require 'book_worm/book'
4
3
  require 'httparty'
5
4
 
@@ -7,10 +6,32 @@ module BookWorm
7
6
  format :xml
8
7
  base_uri 'http://isbndb.com'
9
8
 
9
+ # == Searchable
10
+ #
11
+ # A module that implements the basic finder methods for accessing the ISBNdb API
12
+ #
10
13
  module Searchable
11
14
 
15
+ # == Searchable indices
16
+ #
17
+ # These indices represent the BookWorm supported searching methods
18
+ #
12
19
  INDICES = [:isbn, :title, :combined, :full]
13
20
 
21
+ # Define convenience methods for #find and #find_all.
22
+ #
23
+ # == Example Usage
24
+ #
25
+ # BookWorm.find_by_isbn("1234567890")
26
+ # BookWorm.find_by_title("Programming Ruby")
27
+ # BookWorm.find_by_combined_index("Programming Ruby")
28
+ # BookWorm.find_by_full_index("Programming Ruby")
29
+ #
30
+ # BookWorm.find_all_by_isbn("1234567890")
31
+ # BookWorm.find_all_by_title("Programming Ruby")
32
+ # BookWorm.find_all_by_combined_index("Programming Ruby")
33
+ # BookWorm.find_all_by_full_index("Programming Ruby")
34
+ #
14
35
  INDICES.each do |index|
15
36
  index_name = (index.to_s =~ /full|combined/ ? "#{index}_index" : index)
16
37
 
@@ -23,6 +44,32 @@ module BookWorm
23
44
  end
24
45
  end
25
46
 
47
+ # Given a valid index and a value, this method returns the first match found
48
+ # after querying ISBNdb. The default index, :isbn, will be used
49
+ # in the event that you only supply one argument
50
+ #
51
+ # == Example Usage
52
+ #
53
+ # Query ISBNdb with an isbn-10
54
+ # BookWorm.find(:isbn, "1234567890")
55
+ # BookWorm.find("1234567890")
56
+ #
57
+ # Query ISBNdb with an isbn-13
58
+ # BookWorm.find(:isbn, "1234567890123")
59
+ # BookWorm.find("1234567890123")
60
+ #
61
+ # Query ISBNdb with a title
62
+ # BookWorm.find(:title, "Programming Ruby")
63
+ #
64
+ # Query ISBNdb with a combined index. Search index that combines titles, authors, and
65
+ # publisher name.
66
+ # BookWorm.find(:combined, "Programming Ruby")
67
+ #
68
+ # Query ISBNdb with a full index. A full index includes titles, authors, publisher
69
+ # name, summary, notes, awards information, etc -- practically every bit of textual
70
+ # information ISBNdb.com has about books.
71
+ # BookWorm.find(:full, "Programming Ruby")
72
+ #
26
73
  def find(*args)
27
74
  if args.size == 1
28
75
  index = :isbn
@@ -34,6 +81,31 @@ module BookWorm
34
81
  normalize(query_isbndb(index, value))[0]
35
82
  end
36
83
 
84
+ # Given a valid index and a value, this method returns the all matches found
85
+ # after querying ISBNdb. The default index, :full, will be used
86
+ # in the event that you only supply one argument
87
+ #
88
+ # == Example Usage
89
+ #
90
+ # Query ISBNdb with an isbn-10
91
+ # BookWorm.find_all(:isbn, "1234567890")
92
+ #
93
+ # Query ISBNdb with an isbn-13
94
+ # BookWorm.find_all(:isbn, "1234567890123")
95
+ #
96
+ # Query ISBNdb with a title
97
+ # BookWorm.find_all(:title, "Programming Ruby")
98
+ #
99
+ # Query ISBNdb with a combined index. Search index that combines titles, authors, and
100
+ # publisher name.
101
+ # BookWorm.find_all(:combined, "Programming Ruby")
102
+ #
103
+ # Query ISBNdb with a full index. A full index includes titles, authors, publisher
104
+ # name, summary, notes, awards information, etc -- practically every bit of textual
105
+ # information ISBNdb.com has about books.
106
+ # BookWorm.find_all(:full, "Programming Ruby")
107
+ # BookWorm.find("Programming Ruby")
108
+ #
37
109
  def find_all(*args)
38
110
  if args.size == 1
39
111
  index = :full
@@ -47,16 +119,19 @@ module BookWorm
47
119
 
48
120
  private
49
121
 
122
+ # :nodoc:
50
123
  def query_base
51
124
  "/api/books.xml"
52
125
  end
53
126
 
127
+ # :nodoc:
54
128
  def query_isbndb(index, value)
55
129
  get(query_base, :query => { :index1 => index,
56
130
  :value1 => value,
57
131
  :access_key => Configuration.config[:api_key], })
58
132
  end
59
133
 
134
+ # :nodoc:
60
135
  def normalize(results)
61
136
  begin
62
137
  [results['ISBNdb']['BookList']['BookData']].flatten.collect do |book|
@@ -1,3 +1,3 @@
1
1
  module BookWorm
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/book_worm.rb CHANGED
@@ -1,3 +1,6 @@
1
+ # == BookWorm
2
+ #
3
+ # A module that interacts with the ISBN Database at isbndb.com
1
4
  module BookWorm
2
5
  require 'book_worm/configuration'
3
6
  require 'book_worm/searchable'
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Tony Schneider
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-02-12 00:00:00 -05:00
17
+ date: 2011-02-14 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -58,6 +58,7 @@ files:
58
58
  - .rvmrc
59
59
  - Gemfile
60
60
  - Gemfile.lock
61
+ - README.md
61
62
  - Rakefile
62
63
  - book_worm.gemspec
63
64
  - lib/book_worm.rb