booksr 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b2cdb3639defb32deae580bd104db190ea815ada
4
- data.tar.gz: a60ceb1c3269a6edc0495f62f250b7ba1f3da4bf
3
+ metadata.gz: 0c2d48d541899a45dff72b8d6c8c509177bca705
4
+ data.tar.gz: 2d7981d27c9791a435c8348a152aa49073cf5367
5
5
  SHA512:
6
- metadata.gz: 99d4b18b59e352efbd922e68697b9e260f1e5f4a86d6322dd5b550a5c384474b4089ec131aa42f647f22d0302bb50a145b8c3bebac184425cf912b3e2a7eac3e
7
- data.tar.gz: a616d81e16d849087558a9794b8adc39ee96d01df726c7ccad37076ce4d8ae232f8f7220b494e27e6de06fa2a21e05c12f429b2c9b70941fba05a1f4f6478c0a
6
+ metadata.gz: fbfde4174c5479e83378e5ba3be4d78c5c84c1210b9bd0f7dc8e954808cd52b7206d046c9388888e6b5c66206b1a0b74afde4fdd8af97b6bf33359bb88cf027f
7
+ data.tar.gz: f73855cfb02f5f78842dfd9e5a530bb7284fe86261a7676f20dcbb149c07a5dfdd350df4636b01042ebebb33b8e605fcd6efd3e7504627c12f01f9be119b3714
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'http://rubygems.org'
2
+ gemspec
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # Booksr #
2
+
3
+ A simple book searcher in Ruby.
4
+
5
+
6
+ ## Installation ##
7
+
8
+ `gem install booksr`
9
+
10
+
11
+ ## Usage ##
12
+
13
+ `books = Booksr.search(query_string, query_type)`
14
+
15
+ `query_type` can be:
16
+
17
+ * `:title`
18
+ * `:author`
19
+ * `:isbn`
20
+ * `:keyword`
21
+
22
+ default is `:keyword`.
23
+
24
+ `query_string` of `:isbn` can be ISBN10 or ISBN13.
25
+
26
+ Return value is array of `Book` which can retrieve book information.
27
+
28
+ Attributes of class `Book`:
29
+
30
+ * title
31
+ * subtitle
32
+ * authors: array
33
+ * publisher
34
+ * published_date
35
+ * description
36
+ * isbn10
37
+ * isbn13
38
+ * page_count
39
+ * lang
40
+
41
+
42
+ ## Example ##
43
+
44
+ ```ruby
45
+ require 'booksr'
46
+
47
+ books = Booksr.search('Ruby on Rails', :title)
48
+ book = books[0]
49
+
50
+ puts book.title
51
+ puts book.authors # authors is a array
52
+ puts book.subtitle
53
+ ```
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.test_files = FileList["test/ts_*.rb"]
5
+ t.verbose = true
6
+ end
7
+
8
+ desc "Run tests"
9
+ task :default => :test
data/booksr.gemspec ADDED
@@ -0,0 +1,17 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'booksr'
3
+ s.version = '0.1.1'
4
+ s.date = '2015-01-25'
5
+ s.summary = 'A simple book searcher'
6
+ s.description = 'Search book with title, author, isbn or keyword by Google Book API.'
7
+ s.authors = ['cjwind']
8
+ s.email = 'cwentsai@gmail.com'
9
+ s.files = Dir['lib/*.rb', 'lib/booksr/*.rb', 'Gemfile', 'README.md', 'Rakefile', '*.gemspec', 'test/*.rb']
10
+ s.homepage = 'https://github.com/cjwind/booksr'
11
+ s.license = 'MIT'
12
+
13
+ s.add_runtime_dependency 'bundler'
14
+ s.add_runtime_dependency 'rest-client'
15
+
16
+ s.add_development_dependency 'test-unit'
17
+ end
@@ -0,0 +1,59 @@
1
+ #encoding: utf-8
2
+
3
+ require 'test/unit'
4
+ require 'booksr'
5
+
6
+ class TestSearchIsbnByGoogleApi1 < Test::Unit::TestCase
7
+ def setup # will be called before run each member function
8
+ @books = Booksr.search("0131230522", :isbn)
9
+ end
10
+
11
+ def test_result
12
+ assert_equal(1, @books.size)
13
+
14
+ @book = @books[0]
15
+
16
+ assert_equal("Unix Network Programming Volume 1: the Sockets Networking API", @book.title)
17
+ assert_equal("International Edition", @book.subtitle)
18
+
19
+ assert_equal(4, @book.authors.size)
20
+ assert(@book.authors.include?("Stevens Richard"))
21
+ assert(@book.authors.include?("W. Richard Stevens"))
22
+ assert(@book.authors.include?("Bill Fenner"))
23
+ assert(@book.authors.include?("Andrew M. Rudoff"))
24
+
25
+ assert_equal(nil, @book.publisher)
26
+ assert_equal("2004", @book.published_date)
27
+ assert_equal(nil, @book.description)
28
+ assert_equal("0131230522", @book.isbn10)
29
+ assert_equal("9780131230521", @book.isbn13)
30
+ assert_equal(991, @book.page_count)
31
+ assert_equal("en", @book.lang)
32
+ end
33
+ end
34
+
35
+ class TestSearchIsbnByGoogleApi2 < Test::Unit::TestCase
36
+ def setup # will be called before run each member function
37
+ @books = Booksr.search("9789866841590", :isbn)
38
+ end
39
+
40
+ def test_result
41
+ assert_equal(1, @books.size)
42
+
43
+ @book = @books[0]
44
+
45
+ assert_equal("你的孩子不是你的孩子", @book.title)
46
+ assert_equal("被考試綁架的家庭故事──一位家教老師的見證", @book.subtitle)
47
+
48
+ assert_equal(1, @book.authors.size)
49
+ assert_equal("吳曉樂", @book.authors[0])
50
+
51
+ assert_equal("英屬蓋曼群島商網路與書出版股份有限公司臺灣分公司", @book.publisher)
52
+ assert_equal("2014-11-01", @book.published_date)
53
+ assert_equal("沒有一篇是普羅大眾樂見的教育神話。 沒有一篇看了會感到喜悅。 沒有一篇看了心中不會亂糟糟的,甚至覺得煩。 然而,這些事情確實發生過。 不僅確實發生過,極可能仍在發生⋯⋯ 說故事的人,是個證人。她花了七年時間,打開一扇又一扇的大門,走進不同的家庭。在門的背後,她見證了各色光怪陸離的景象:一個每日給兒子準備雞精、維他命的母親,在收到兒子成績單的當下,卻也毫不猶豫地甩出一記耳光;為了安撫雙親,躲在衣櫃裡欺騙別人也傷害自己的兒子;也或許,她看見一種用鈔票堆疊起來的親情⋯⋯她以為她是家教,只需帶給學生知識,沒想到學生及他們的家庭帶給她更多的衝擊。 什麼是教育的本質?愛是有條件的嗎? 本書沒有給家長教條式的叮嚀與建議,只有一個個震撼人心的故事。這些故事之所以存在,是期待我們去凝視一個初衷,靜下來,好好想想,把小孩帶到這世界上的初衷。 ■ 被考試綁架的家庭故事——《你的孩子不是你的孩子》新書座談會 講者:吳曉樂(本書作者) 時間:2014年11月29日(六)11:00~12:00 地點:水牛書店 ■ 每個孩子都是獨立的個體——《你的孩子不是你的孩子》新書座談會 講者:吳曉樂(本書作者)、唐光華(樂觀書院創辦人) 時間:2014年12月4日(四)19:30~21:00 地點:誠品信義店3F Mini-Forum", @book.description)
54
+ assert_equal("9866841596", @book.isbn10)
55
+ assert_equal("9789866841590", @book.isbn13)
56
+ assert_equal(328, @book.page_count)
57
+ assert_equal("zh-TW", @book.lang)
58
+ end
59
+ end
@@ -0,0 +1,15 @@
1
+ #encoding: utf-8
2
+
3
+ require 'test/unit'
4
+ require 'booksr'
5
+
6
+ class TestSearchTitleByGoogleApi < Test::Unit::TestCase
7
+ def setup
8
+ @title = "Ruby on Rails"
9
+ @books = Booksr.search(@title, :title)
10
+ end
11
+
12
+ def test_result_count_over_40
13
+ assert_operator(40, :<=, @books.size)
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ # Search by Google Book API test suite
2
+
3
+ require 'rubygems'
4
+ require 'bundler/setup'
5
+ require 'test/unit/testsuite'
6
+ require './test/tc_search_isbn'
7
+ require './test/tc_search_title'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: booksr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - cjwind
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-21 00:00:00.000000000 Z
11
+ date: 2015-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,10 +58,17 @@ executables: []
58
58
  extensions: []
59
59
  extra_rdoc_files: []
60
60
  files:
61
+ - Gemfile
62
+ - README.md
63
+ - Rakefile
64
+ - booksr.gemspec
61
65
  - lib/booksr.rb
62
66
  - lib/booksr/api_handler.rb
63
67
  - lib/booksr/book.rb
64
68
  - lib/booksr/parser.rb
69
+ - test/tc_search_isbn.rb
70
+ - test/tc_search_title.rb
71
+ - test/ts_google_api.rb
65
72
  homepage: https://github.com/cjwind/booksr
66
73
  licenses:
67
74
  - MIT