bookshark 1.0.0.alpha.2 → 1.0.0.alpha.3
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 +4 -4
- data/README.md +12 -9
- data/lib/bookshark.rb +4 -4
- data/lib/bookshark/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1a505294880b3816fc6382b9d48035d0e780e85
|
4
|
+
data.tar.gz: 5cc5432c462fea9ab4781bf91bfa9cef9ffa2e2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aeee746c931f9171c58c1594145cdaa91d89fda5de4671a4e9a5cf92b3e3d09bffaea863b555326b2224594b901b3859ffff8eacc0a078acd600fc9fee005a7c
|
7
|
+
data.tar.gz: f6f5061c6a636e4eb558508000cb572fd2cd34a59802146a45f6f9bea89f6fa30e14e13a1de54e49a067bae8217b6b9685bc6d124a0d1ac31c3fbb800ea738ab
|
data/README.md
CHANGED
@@ -21,10 +21,12 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
$ gem install bookshark --pre
|
23
23
|
|
24
|
-
|
25
|
-
Include bookshark in your class/module.
|
24
|
+
Require and include bookshark in your class/module.
|
26
25
|
```ruby
|
27
|
-
|
26
|
+
require 'bookshark'
|
27
|
+
class Foo
|
28
|
+
include Bookshark
|
29
|
+
end
|
28
30
|
```
|
29
31
|
Alternatively you can use this syntax
|
30
32
|
```ruby
|
@@ -35,7 +37,8 @@ include Bookshark
|
|
35
37
|
Extractor.new
|
36
38
|
```
|
37
39
|
|
38
|
-
|
40
|
+
## Extractor
|
41
|
+
An extractor object must be created in order to perform any metadata extractions.
|
39
42
|
|
40
43
|
Create an extractor object
|
41
44
|
```ruby
|
@@ -52,7 +55,7 @@ Extractor.new(format: 'hash', site: 'biblionet')
|
|
52
55
|
* site : The site from where the metadata will be extracted
|
53
56
|
* biblionet (default and currently the only available, so it can be skipped)
|
54
57
|
|
55
|
-
|
58
|
+
### Extract Book Data
|
56
59
|
|
57
60
|
You need book's id on biblionet website or its uri.
|
58
61
|
Currently more advanced search functions based on title and author are not available, but they will be until the stable version 1.0.0 release.
|
@@ -86,7 +89,7 @@ extractor.book(id: 103788, local: true)
|
|
86
89
|
* pretty_json
|
87
90
|
* eager : Perform eager extraction? (Boolean - default is false)
|
88
91
|
|
89
|
-
|
92
|
+
#### Eager Extraction
|
90
93
|
|
91
94
|
Each book has some attributes such as authors, contributors, categories etc which are actually references to other objects.
|
92
95
|
By default when extracting a book, you get only names of these objects and references to their pages.
|
@@ -153,7 +156,7 @@ The expected result of a book extraction is something like this:
|
|
153
156
|
```
|
154
157
|
Here is a [Book Sample](https://gist.github.com/dklisiaris/a6f3d6f37806186f3c79) extracted with eager option enabled.
|
155
158
|
|
156
|
-
|
159
|
+
### Extract Author Data
|
157
160
|
|
158
161
|
You need author's id on biblionet website or his uri
|
159
162
|
```ruby
|
@@ -195,7 +198,7 @@ The expected result of an author extraction is something like this:
|
|
195
198
|
The convention here is that there is never just a single author, but instead the author hash is stored inside an array.
|
196
199
|
So, it is easy to include metadata for multiple authors or even for multiple types of entities such as publishers or books on the same json file.
|
197
200
|
|
198
|
-
|
201
|
+
### Extract Publisher Data
|
199
202
|
Methods are pretty same as author:
|
200
203
|
```ruby
|
201
204
|
# Create a new extractor object with pretty json format.
|
@@ -266,7 +269,7 @@ The expected result of an author extraction is something like this:
|
|
266
269
|
]
|
267
270
|
}
|
268
271
|
```
|
269
|
-
|
272
|
+
### Extract Categories
|
270
273
|
Biblionet's categories are based on [Dewey Decimal Classification](http://en.wikipedia.org/wiki/Dewey_Decimal_Classification). It is possible to extract these categories also as seen below.
|
271
274
|
```ruby
|
272
275
|
# Create a new extractor object with pretty json format.
|
data/lib/bookshark.rb
CHANGED
@@ -43,7 +43,7 @@ module Bookshark
|
|
43
43
|
author = author_extractor.load_and_extract_author(uri)
|
44
44
|
|
45
45
|
response = {}
|
46
|
-
response[:author] = [author]
|
46
|
+
response[:author] = !author.nil? ? [author] : []
|
47
47
|
response = change_format(response, options[:format])
|
48
48
|
return response
|
49
49
|
end
|
@@ -56,7 +56,7 @@ module Bookshark
|
|
56
56
|
publisher = publisher_extractor.load_and_extract_publisher(uri)
|
57
57
|
|
58
58
|
response = {}
|
59
|
-
response[:publisher] = [publisher]
|
59
|
+
response[:publisher] = !publisher.nil? ? [publisher] : []
|
60
60
|
response = change_format(response, options[:format])
|
61
61
|
response = publisher_extractor.decode_text(response)
|
62
62
|
|
@@ -78,7 +78,7 @@ module Bookshark
|
|
78
78
|
end
|
79
79
|
|
80
80
|
response = {}
|
81
|
-
response[:book] = [book]
|
81
|
+
response[:book] = !book.nil? ? [book] : []
|
82
82
|
response = change_format(response, options[:format])
|
83
83
|
response = book_extractor.decode_text(response)
|
84
84
|
|
@@ -93,7 +93,7 @@ module Bookshark
|
|
93
93
|
category = category_extractor.extract_categories_from(uri)
|
94
94
|
|
95
95
|
response = {}
|
96
|
-
response[:category] = [category]
|
96
|
+
response[:category] = !category.nil? ? [category] : []
|
97
97
|
response = change_format(response, options[:format])
|
98
98
|
|
99
99
|
return response
|
data/lib/bookshark/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bookshark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.alpha.
|
4
|
+
version: 1.0.0.alpha.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitris Klisiaris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|