gogoodreads 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,5 +1,7 @@
1
1
  source :rubygems
2
2
 
3
+ gem 'nokogiri'
4
+
3
5
  group :development do
4
6
  gem 'rspec', '~> 2.3.0'
5
7
  gem 'yard', '~> 0.6.0'
@@ -9,3 +11,5 @@ group :development do
9
11
  gem 'webmock'
10
12
  gem 'rcov', '>= 0'
11
13
  end
14
+
15
+ gem 'ruby-debug19'
data/README.rdoc CHANGED
@@ -4,13 +4,13 @@ Goodreads API Ruby Interface
4
4
 
5
5
  == Basics (So Far)
6
6
 
7
- require 'gogoodreads'
7
+ require 'gogoodreads'
8
8
 
9
- GoGoodreads.configure do |config|
10
- config.api_key = "somesecretapi"
11
- end
9
+ GoGoodreads.configure do |config|
10
+ config.api_key = "somesecretapi"
11
+ end
12
12
 
13
- GoGoodreads::Book.show_by_isbn('isbnhere')
13
+ GoGoodreads::Book.show_by_isbn('isbnhere')
14
14
 
15
15
  == Contributing to gogoodreads
16
16
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
data/gogoodreads.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gogoodreads}
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tim Medina"]
12
- s.date = %q{2011-03-24}
12
+ s.date = %q{2011-03-25}
13
13
  s.description = %q{Allows you to progammatically pull book reviews from Goodreads using its API.}
14
14
  s.email = %q{iamteem@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -66,6 +66,8 @@ Gem::Specification.new do |s|
66
66
  s.specification_version = 3
67
67
 
68
68
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
69
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
70
+ s.add_runtime_dependency(%q<ruby-debug19>, [">= 0"])
69
71
  s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
70
72
  s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
71
73
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
@@ -75,6 +77,8 @@ Gem::Specification.new do |s|
75
77
  s.add_development_dependency(%q<rcov>, [">= 0"])
76
78
  s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
77
79
  else
80
+ s.add_dependency(%q<nokogiri>, [">= 0"])
81
+ s.add_dependency(%q<ruby-debug19>, [">= 0"])
78
82
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
79
83
  s.add_dependency(%q<yard>, ["~> 0.6.0"])
80
84
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
@@ -85,6 +89,8 @@ Gem::Specification.new do |s|
85
89
  s.add_dependency(%q<nokogiri>, [">= 0"])
86
90
  end
87
91
  else
92
+ s.add_dependency(%q<nokogiri>, [">= 0"])
93
+ s.add_dependency(%q<ruby-debug19>, [">= 0"])
88
94
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
89
95
  s.add_dependency(%q<yard>, ["~> 0.6.0"])
90
96
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
@@ -14,7 +14,7 @@ module GoGoodreads
14
14
  def attribute(name, options = {})
15
15
  default_options = { :type => String, :map_from => name }
16
16
  opts = default_options.merge(options)
17
- opts[:using] ||= lambda {|xml, from| xml.at(from).text }
17
+ opts[:using] ||= lambda {|xml, from| (xml > from.to_s).text }
18
18
  @attributes ||= {}
19
19
  @attributes[name] = opts
20
20
  attr name
@@ -13,22 +13,28 @@ module GoGoodreads
13
13
  attribute :url
14
14
  attribute :link
15
15
  attribute :num_pages, :type => Integer
16
+ attribute :text_reviews_count, :type => Integer
17
+ attribute :average_rating, :type => Float
18
+
16
19
  attr :authors, :reviews
17
20
 
18
21
  attr_accessor :current_page
19
22
 
23
+ # @param String isbn ISBN of the book
24
+ # @param Hash option Options
25
+ # @option option Integer page Page number (default: 1)
26
+ # @returns GoGoodreads::Book
20
27
  def self.show_by_isbn(isbn, options = {})
21
28
  params = { :isbn => isbn }
22
29
  params.merge!(options)
23
30
 
24
31
  request('/book/isbn', params) do |xml|
25
- book = initialize_with_node(xml)
32
+ book = initialize_with_node(xml.root.at('book'))
26
33
  book.current_page = params[:page] || 1
27
34
  book
28
35
  end
29
36
  end
30
37
 
31
-
32
38
  def self.initialize_with_node(xml)
33
39
  attrs = to_attributes!(xml)
34
40
  attrs.delete_if { |k,v| v.respond_to?(:empty?) && v.empty? }
data/spec/book_spec.rb CHANGED
@@ -13,18 +13,20 @@ describe GoGoodreads::Book do
13
13
  context "isbn is 0441172717" do
14
14
  subject { GoGoodreads::Book.show_by_isbn("0441172717") }
15
15
 
16
- its(:title) { should == "Dune (Dune Chronicles, #1)" }
17
- its(:isbn) { should == "0441172717" }
18
- its(:isbn13) { should == "9780441172719" }
19
- its(:asin) { should be_nil }
20
- its(:image_url) { should == "http://photo.goodreads.com/books/1170430859m/53732.jpg" }
21
- its(:small_image_url) { should == "http://photo.goodreads.com/books/1170430859s/53732.jpg" }
22
- its(:description) { should == %(This Hugo and Nebula Award winner tells the sweeping tale of a desert planet called Arrakis, the focus of an intricate power struggle in a byzantine interstellar empire. Arrakis is the sole source of Melange, the &quot;spice of spices.&quot; Melange is necessary for interstellar travel and grants psychic powers and longevity, so whoever controls it wields great influence. The troubles begin when stewardship of Arrakis is transferred by the Emperor from the Harkonnen Noble House to House Atreides. The Harkonnens don't want to give up their privilege, though, and through sabotage and treachery they cast young Duke Paul Atreides out into the planet's harsh environment to die. There he falls in with the Fremen, a tribe of desert dwellers who become the basis of the army with which he will reclaim what's rightfully his. Paul Atreides, though, is far more than just a usurped duke. He might be the end product of a very long-term genetic experiment designed to breed a super human; he might be a messiah. His struggle is at the center of a nexus of powerful people and events, and the repercussions will be felt throughout the Imperium. Dune is one of the most famous science fiction novels ever written, and deservedly so. The setting is elaborate and ornate, the plot labyrinthine, the adventures exciting. Five sequels follow. --Brooks Peck) }
23
- its(:num_pages) { should == 535 }
24
- its(:authors) { should have(1).items }
25
- its(:url) { should == "http://www.goodreads.com/book/show/53732.Dune" }
26
- its(:link) { should == "http://www.goodreads.com/book/show/53732.Dune" }
27
- its(:reviews) { should have(28).items }
16
+ its(:title) { should == "Dune (Dune Chronicles, #1)" }
17
+ its(:isbn) { should == "0441172717" }
18
+ its(:isbn13) { should == "9780441172719" }
19
+ its(:asin) { should be_nil }
20
+ its(:image_url) { should == "http://photo.goodreads.com/books/1170430859m/53732.jpg" }
21
+ its(:small_image_url) { should == "http://photo.goodreads.com/books/1170430859s/53732.jpg" }
22
+ its(:description) { should == %(This Hugo and Nebula Award winner tells the sweeping tale of a desert planet called Arrakis, the focus of an intricate power struggle in a byzantine interstellar empire. Arrakis is the sole source of Melange, the &quot;spice of spices.&quot; Melange is necessary for interstellar travel and grants psychic powers and longevity, so whoever controls it wields great influence. The troubles begin when stewardship of Arrakis is transferred by the Emperor from the Harkonnen Noble House to House Atreides. The Harkonnens don't want to give up their privilege, though, and through sabotage and treachery they cast young Duke Paul Atreides out into the planet's harsh environment to die. There he falls in with the Fremen, a tribe of desert dwellers who become the basis of the army with which he will reclaim what's rightfully his. Paul Atreides, though, is far more than just a usurped duke. He might be the end product of a very long-term genetic experiment designed to breed a super human; he might be a messiah. His struggle is at the center of a nexus of powerful people and events, and the repercussions will be felt throughout the Imperium. Dune is one of the most famous science fiction novels ever written, and deservedly so. The setting is elaborate and ornate, the plot labyrinthine, the adventures exciting. Five sequels follow. --Brooks Peck) }
23
+ its(:num_pages) { should == 535 }
24
+ its(:authors) { should have(1).items }
25
+ its(:url) { should == "http://www.goodreads.com/book/show/53732.Dune" }
26
+ its(:link) { should == "http://www.goodreads.com/book/show/53732.Dune" }
27
+ its(:reviews) { should have(28).items }
28
+ its(:average_rating) { should == 3.93 }
29
+ its(:text_reviews_count) { should == 345 }
28
30
  end
29
31
  end
30
32
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gogoodreads
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Tim Medina
@@ -10,12 +10,34 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-24 00:00:00 +08:00
13
+ date: 2011-03-25 00:00:00 +08:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
- name: rspec
17
+ name: nokogiri
18
18
  requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: ruby-debug19
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: rspec
40
+ requirement: &id003 !ruby/object:Gem::Requirement
19
41
  none: false
20
42
  requirements:
21
43
  - - ~>
@@ -23,10 +45,10 @@ dependencies:
23
45
  version: 2.3.0
24
46
  type: :development
25
47
  prerelease: false
26
- version_requirements: *id001
48
+ version_requirements: *id003
27
49
  - !ruby/object:Gem::Dependency
28
50
  name: yard
29
- requirement: &id002 !ruby/object:Gem::Requirement
51
+ requirement: &id004 !ruby/object:Gem::Requirement
30
52
  none: false
31
53
  requirements:
32
54
  - - ~>
@@ -34,10 +56,10 @@ dependencies:
34
56
  version: 0.6.0
35
57
  type: :development
36
58
  prerelease: false
37
- version_requirements: *id002
59
+ version_requirements: *id004
38
60
  - !ruby/object:Gem::Dependency
39
61
  name: bundler
40
- requirement: &id003 !ruby/object:Gem::Requirement
62
+ requirement: &id005 !ruby/object:Gem::Requirement
41
63
  none: false
42
64
  requirements:
43
65
  - - ~>
@@ -45,10 +67,10 @@ dependencies:
45
67
  version: 1.0.0
46
68
  type: :development
47
69
  prerelease: false
48
- version_requirements: *id003
70
+ version_requirements: *id005
49
71
  - !ruby/object:Gem::Dependency
50
72
  name: jeweler
51
- requirement: &id004 !ruby/object:Gem::Requirement
73
+ requirement: &id006 !ruby/object:Gem::Requirement
52
74
  none: false
53
75
  requirements:
54
76
  - - ~>
@@ -56,10 +78,10 @@ dependencies:
56
78
  version: 1.5.2
57
79
  type: :development
58
80
  prerelease: false
59
- version_requirements: *id004
81
+ version_requirements: *id006
60
82
  - !ruby/object:Gem::Dependency
61
83
  name: vcr
62
- requirement: &id005 !ruby/object:Gem::Requirement
84
+ requirement: &id007 !ruby/object:Gem::Requirement
63
85
  none: false
64
86
  requirements:
65
87
  - - ">="
@@ -67,10 +89,10 @@ dependencies:
67
89
  version: "0"
68
90
  type: :development
69
91
  prerelease: false
70
- version_requirements: *id005
92
+ version_requirements: *id007
71
93
  - !ruby/object:Gem::Dependency
72
94
  name: webmock
73
- requirement: &id006 !ruby/object:Gem::Requirement
95
+ requirement: &id008 !ruby/object:Gem::Requirement
74
96
  none: false
75
97
  requirements:
76
98
  - - ">="
@@ -78,10 +100,10 @@ dependencies:
78
100
  version: "0"
79
101
  type: :development
80
102
  prerelease: false
81
- version_requirements: *id006
103
+ version_requirements: *id008
82
104
  - !ruby/object:Gem::Dependency
83
105
  name: rcov
84
- requirement: &id007 !ruby/object:Gem::Requirement
106
+ requirement: &id009 !ruby/object:Gem::Requirement
85
107
  none: false
86
108
  requirements:
87
109
  - - ">="
@@ -89,10 +111,10 @@ dependencies:
89
111
  version: "0"
90
112
  type: :development
91
113
  prerelease: false
92
- version_requirements: *id007
114
+ version_requirements: *id009
93
115
  - !ruby/object:Gem::Dependency
94
116
  name: nokogiri
95
- requirement: &id008 !ruby/object:Gem::Requirement
117
+ requirement: &id010 !ruby/object:Gem::Requirement
96
118
  none: false
97
119
  requirements:
98
120
  - - ">="
@@ -100,7 +122,7 @@ dependencies:
100
122
  version: "0"
101
123
  type: :runtime
102
124
  prerelease: false
103
- version_requirements: *id008
125
+ version_requirements: *id010
104
126
  description: Allows you to progammatically pull book reviews from Goodreads using its API.
105
127
  email: iamteem@gmail.com
106
128
  executables: []
@@ -157,7 +179,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
157
179
  requirements:
158
180
  - - ">="
159
181
  - !ruby/object:Gem::Version
160
- hash: -184150397033762058
182
+ hash: -3427812180245513622
161
183
  segments:
162
184
  - 0
163
185
  version: "0"