ideaoforder-goodreads 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +27 -0
- data/Rakefile +60 -0
- data/VERSION +1 -0
- data/goodreads.gemspec +51 -0
- data/lib/goodreads.rb +65 -0
- data/test/goodreads_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +74 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Mark Dickson
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
= goodreads
|
2
|
+
|
3
|
+
This gem allows you to connect to your goodreads bookshelves and reviews. Currently, no write write operations are supported--it's just meant to grab your books/reviews to display them on your website/blog. It is in no way meant to be exhaustive--fork away!
|
4
|
+
|
5
|
+
== Configuration
|
6
|
+
You'll need a goodreads.yml file in config, with:
|
7
|
+
:user_id:
|
8
|
+
and optionally
|
9
|
+
:api_key:
|
10
|
+
which you'll have to apply for. The developer key allows you to perform actions which require authentication, none of which are currently used in this plugin. If you'd like more functionality, check out: http://www.goodreads.com/api and fork the project.
|
11
|
+
|
12
|
+
Cheers!
|
13
|
+
|
14
|
+
== Note on Patches/Pull Requests
|
15
|
+
|
16
|
+
* Fork the project.
|
17
|
+
* Make your feature addition or bug fix.
|
18
|
+
* Add tests for it. This is important so I don't break it in a
|
19
|
+
future version unintentionally.
|
20
|
+
* Commit, do not mess with rakefile, version, or history.
|
21
|
+
(if you want to have your own version, that is fine but
|
22
|
+
bump version in a commit by itself I can ignore when I pull)
|
23
|
+
* Send me a pull request. Bonus points for topic branches.
|
24
|
+
|
25
|
+
== Copyright
|
26
|
+
|
27
|
+
Copyright (c) 2009 Mark Dickson. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "goodreads"
|
8
|
+
gem.summary = "Uses the Goodreads API to grab your book reviews"
|
9
|
+
gem.description = "Uses the Goodreads API to grab your book reviews. Takes all the standard Goodreads arguments. This gem is currently just a baby, and will may include more features over time. For now, it's mainly meant to allow folks to show their books and reviews on a website/blog."
|
10
|
+
gem.email = "mark@sitesteaders.com"
|
11
|
+
gem.homepage = "http://github.com/ideaoforder/goodreads"
|
12
|
+
gem.authors = ["Mark Dickson"]
|
13
|
+
gem.add_dependency('httparty', '>= 0.4.4')
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'rake/testtask'
|
22
|
+
Rake::TestTask.new(:test) do |test|
|
23
|
+
test.libs << 'lib' << 'test'
|
24
|
+
test.pattern = 'test/**/*_test.rb'
|
25
|
+
test.verbose = true
|
26
|
+
end
|
27
|
+
|
28
|
+
begin
|
29
|
+
require 'rcov/rcovtask'
|
30
|
+
Rcov::RcovTask.new do |test|
|
31
|
+
test.libs << 'test'
|
32
|
+
test.pattern = 'test/**/*_test.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
rescue LoadError
|
36
|
+
task :rcov do
|
37
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
task :default => :test
|
45
|
+
|
46
|
+
require 'rake/rdoctask'
|
47
|
+
Rake::RDocTask.new do |rdoc|
|
48
|
+
if File.exist?('VERSION.yml')
|
49
|
+
config = YAML.load(File.read('VERSION.yml'))
|
50
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
51
|
+
else
|
52
|
+
version = ""
|
53
|
+
end
|
54
|
+
|
55
|
+
rdoc.rdoc_dir = 'rdoc'
|
56
|
+
rdoc.title = "goodreads #{version}"
|
57
|
+
rdoc.rdoc_files.include('README*')
|
58
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
59
|
+
end
|
60
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.1
|
data/goodreads.gemspec
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{goodreads}
|
5
|
+
s.version = "0.1.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Mark Dickson"]
|
9
|
+
s.date = %q{2009-08-11}
|
10
|
+
s.description = %q{Uses the Goodreads API to grab your book reviews. Takes all the standard Goodreads arguments. This gem is currently just a baby, and will may include more features over time. For now, it's mainly meant to allow folks to show their books and reviews on a website/blog.}
|
11
|
+
s.email = %q{mark@sitesteaders.com}
|
12
|
+
s.extra_rdoc_files = [
|
13
|
+
"LICENSE",
|
14
|
+
"README.rdoc"
|
15
|
+
]
|
16
|
+
s.files = [
|
17
|
+
".document",
|
18
|
+
".gitignore",
|
19
|
+
"LICENSE",
|
20
|
+
"README.rdoc",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"goodreads.gemspec",
|
24
|
+
"lib/goodreads.rb",
|
25
|
+
"test/goodreads_test.rb",
|
26
|
+
"test/test_helper.rb"
|
27
|
+
]
|
28
|
+
s.has_rdoc = true
|
29
|
+
s.homepage = %q{http://github.com/ideaoforder/goodreads}
|
30
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
31
|
+
s.require_paths = ["lib"]
|
32
|
+
s.rubygems_version = %q{1.3.1}
|
33
|
+
s.summary = %q{Uses the Goodreads API to grab your book reviews}
|
34
|
+
s.test_files = [
|
35
|
+
"test/goodreads_test.rb",
|
36
|
+
"test/test_helper.rb"
|
37
|
+
]
|
38
|
+
|
39
|
+
if s.respond_to? :specification_version then
|
40
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
41
|
+
s.specification_version = 2
|
42
|
+
|
43
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
44
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0.4.4"])
|
45
|
+
else
|
46
|
+
s.add_dependency(%q<httparty>, [">= 0.4.4"])
|
47
|
+
end
|
48
|
+
else
|
49
|
+
s.add_dependency(%q<httparty>, [">= 0.4.4"])
|
50
|
+
end
|
51
|
+
end
|
data/lib/goodreads.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'httparty'
|
3
|
+
|
4
|
+
module Goodreads
|
5
|
+
include HTTParty
|
6
|
+
|
7
|
+
@defaults = YAML::load(File.open("#{RAILS_ROOT}/config/goodreads.yml")) if File.exist? "#{RAILS_ROOT}/config/goodreads.yml"
|
8
|
+
base_uri 'http://www.goodreads.com'
|
9
|
+
default_params :key => @defaults[:api_key] if (@defaults and @defaults[:api_key])
|
10
|
+
format :xml
|
11
|
+
|
12
|
+
@@user_id = @defaults[:user_id] if (@defaults and @defaults[:user_id])
|
13
|
+
|
14
|
+
# page: 1
|
15
|
+
# per_page: 1-200
|
16
|
+
# shelf: read, currently-reading, to-read, etc
|
17
|
+
# key: Needed for private profiles. Different from developer key, and is unique to each member. Obtained from the member's rss link on the "my books page" or the lookup via email method.
|
18
|
+
# order: a, d
|
19
|
+
# sort: position, votes, rating, shelves, avg_rating, isbn, comments, author, title, notes, cover, review, random, date_read, year_pub, date_added, num_ratings, date_updated
|
20
|
+
def self.reviews(opts={})
|
21
|
+
defaults = {:page => 1, :per_page => 10, :shelf => 'read', :sort => 'date_read', :order => 'd'}
|
22
|
+
opts = defaults.merge(opts)
|
23
|
+
user_id = opts[:user_id] || @@user_id
|
24
|
+
opts.delete(:user_id)
|
25
|
+
result = self.get("/review/list_rss/#{user_id}", :query => opts)
|
26
|
+
result["rss"]["channel"]["item"].map { |data| Goodreads::Review.new(data) }
|
27
|
+
# now...what to do with these...
|
28
|
+
end
|
29
|
+
|
30
|
+
class Review
|
31
|
+
attr_accessor :book_small_image_url,
|
32
|
+
:user_date_created,
|
33
|
+
:user_shelves,
|
34
|
+
:average_rating,
|
35
|
+
:book_image_url,
|
36
|
+
:book_medium_image_url,
|
37
|
+
:user_read_at,
|
38
|
+
:guid,
|
39
|
+
:pubDate,
|
40
|
+
:title,
|
41
|
+
:author_name,
|
42
|
+
:isbn,
|
43
|
+
:book_published,
|
44
|
+
:user_review,
|
45
|
+
:user_name,
|
46
|
+
:user_date_added,
|
47
|
+
:link,
|
48
|
+
:book_id,
|
49
|
+
:book_description,
|
50
|
+
:description,
|
51
|
+
:book,
|
52
|
+
:book_large_image_url,
|
53
|
+
:user_rating
|
54
|
+
def initialize(data)
|
55
|
+
data.each do |k, v|
|
56
|
+
if v and v.is_a? String
|
57
|
+
val = v.gsub(/\n/, '').gsub(/\t/, '').strip
|
58
|
+
else
|
59
|
+
val = v
|
60
|
+
end
|
61
|
+
send(:"#{k}=", val)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ideaoforder-goodreads
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mark Dickson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-11 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: httparty
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.4.4
|
24
|
+
version:
|
25
|
+
description: Uses the Goodreads API to grab your book reviews. Takes all the standard Goodreads arguments. This gem is currently just a baby, and will may include more features over time. For now, it's mainly meant to allow folks to show their books and reviews on a website/blog.
|
26
|
+
email: mark@sitesteaders.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- LICENSE
|
33
|
+
- README.rdoc
|
34
|
+
files:
|
35
|
+
- .document
|
36
|
+
- .gitignore
|
37
|
+
- LICENSE
|
38
|
+
- README.rdoc
|
39
|
+
- Rakefile
|
40
|
+
- VERSION
|
41
|
+
- goodreads.gemspec
|
42
|
+
- lib/goodreads.rb
|
43
|
+
- test/goodreads_test.rb
|
44
|
+
- test/test_helper.rb
|
45
|
+
has_rdoc: true
|
46
|
+
homepage: http://github.com/ideaoforder/goodreads
|
47
|
+
licenses:
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options:
|
50
|
+
- --charset=UTF-8
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
version:
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
requirements: []
|
66
|
+
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 1.3.5
|
69
|
+
signing_key:
|
70
|
+
specification_version: 2
|
71
|
+
summary: Uses the Goodreads API to grab your book reviews
|
72
|
+
test_files:
|
73
|
+
- test/goodreads_test.rb
|
74
|
+
- test/test_helper.rb
|