jekyll-get-books 0.0.1 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 275194cc664d8e84e812fff3bfe8a2c52f483f5fc8e694020a7c8b88592a5035
4
- data.tar.gz: 33c95cc3a7a56e2829398b5b61055d7df91cd6c9ee09fc4cb4227e7fd6eb09ff
3
+ metadata.gz: 1970f2eabd1d1e47cae22054a10fa0c276392f4f51b373f2e9dca86a2f39c717
4
+ data.tar.gz: 478fb83d3d145e79698b52f3ab5b13365bdf8489f5c8c197b6cd35e712fe745f
5
5
  SHA512:
6
- metadata.gz: 42108614acfc215355fe489194bb58290132436f17d66d01061b2a393d76c35eb409133613090d2c33621eedd1313aee65a9bb996bd1ff8435fca3cb06a04c04
7
- data.tar.gz: 7785ce6ddf46d59e370397a6b9a1b72467b5b20e43c184dbdc049cd9f3accfb4e7bef912ba4ef7a1e45d792ca95315043bd5a13dd918fd3ec319e7f5adf6ac65
6
+ metadata.gz: 77c328483495806b45c85f150c73004a363e8b6f149e6603a0c79dee5206cbaa94edd1959dfa595f3e7ef849a1ec9517f9e31dc891dec99991eb6173bbcbaa87
7
+ data.tar.gz: dce851edef4f7e346a42b81d2b733ac9937dd4981e9df39c33f4c234a31fb253cf03b09df07b4e3b4a09e86eb29057045aa510b96cc0e411a86edccb94c2e918
data/README.md CHANGED
@@ -1,16 +1,29 @@
1
1
  # jekyll-get-books
2
2
  > 💎 Fetch and safe meta information for books from the Google Book API for a Jekyll Site.
3
3
 
4
+
5
+
6
+ ## Installation
7
+
8
+ 1. Use `bundle add jekyll-get-books` to add this to your site's Gemfile.
9
+ 2. Add this plugin to the `plugins` listed in your `_config.yml` file. For example:
10
+ ```
11
+ plugins:
12
+ - jekyll-get-books
13
+ ```
14
+
4
15
  ## Usage
5
16
 
6
17
  Add a `jekyll_get_books` section to your `_config.yml` file. This section should be an array of objects containing `data`, `json` and `file` properties:
7
18
  * The `data` property specifies where in the `site.data` you would like to put this data.
8
- * The `json` property is the remote URL of the JSON file.
19
+ * The `json` property is the remote URL of the JSON file without specific data attributes.
20
+ * The `file` property is the path to the csv file with the ISBN numbers.
9
21
 
22
+ Examples can be found in the examples folder.
10
23
 
11
24
  ## Contributing
12
25
 
13
- Bug reports and pull requests are welcome on GitHub at https://github.com/tokzk/jekyll-amazon.
26
+ Bug reports and pull requests are welcome on GitHub at https://github.com/c-leitner/jekyll-get-books.
14
27
 
15
28
  ## Credit
16
29
 
@@ -0,0 +1,9 @@
1
+ # Add this to your _config.yml file
2
+
3
+ plugins:
4
+ - jekyll-get-books
5
+
6
+ jekyll_get_books:
7
+ - data: test #arbitrary name where the data is being saved
8
+ json: 'https://www.googleapis.com/books/v1/volumes?q=isbn:' #link to a book API. In this case the Google Book API which returns a JSON
9
+ file: '_data/books.csv' # Path to the csv files with the ISBNs
@@ -0,0 +1,3 @@
1
+ isbn
2
+ 9781594484803
3
+ 9780980122787
data/examples/books.md ADDED
@@ -0,0 +1,12 @@
1
+ In your Jekyll site you will be able to use:
2
+
3
+ ```
4
+ {% for item in site.data.test.items %}
5
+ **{{item.volumeInfo.title}}** - {{item.volumeInfo.authors[0]}} <span style="float: right; ">{{item.volumeInfo.publisher}}</span><br />
6
+ {{item.volumeInfo.subtitle}}
7
+
8
+ {% endfor %}
9
+
10
+ ```
11
+
12
+
@@ -22,6 +22,7 @@ module JekyllGetBooks
22
22
 
23
23
  config.each do |d|
24
24
  begin
25
+ warn "was here1".yellow
25
26
  target = site.data[d['data']]
26
27
  source = d['json']
27
28
  file = d['file']
@@ -30,7 +31,27 @@ module JekyllGetBooks
30
31
  warn "File does not exist / Path is incorrect".yellow
31
32
  end
32
33
  CSV.foreach((file), headers: true, col_sep: ",") do |row|
33
- output = JSON.load(URI.open(source+row['isbn']))
34
+ warn "was here2".yellow
35
+ begin
36
+ warn "was here3".yellow
37
+ connection = URI.open(source+row['isbn'])
38
+ rescue => e
39
+ case e
40
+ when OpenURI::HTTPError
41
+ warn "A HTTP Error occurred while accessing the API".yellow
42
+ when SocketError
43
+ warn "A Socket Error occurred while accessing the API".yellow
44
+ end
45
+ warn e.yellow
46
+ else
47
+ meta = connection.status[1]
48
+ output = JSON.load(connection)
49
+ if meta == "OK"
50
+ warn "JSON fetched succesfully"
51
+ else
52
+ warn "An HTTP erro occurred while fetching the JSON (" +meta+")"
53
+ end
54
+ end
34
55
  results.deep_merge(output)
35
56
  end
36
57
  site.data[d['data']] = results
@@ -1,3 +1,3 @@
1
1
  module JekyllGetBooks
2
- VERSION = "0.0.1".freeze
2
+ VERSION = "0.0.4".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-get-books
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clemens Leitner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-20 00:00:00.000000000 Z
11
+ date: 2022-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -48,6 +48,9 @@ files:
48
48
  - ".gitignore"
49
49
  - LICENSE
50
50
  - README.md
51
+ - examples/_config.yml
52
+ - examples/_data/books.csv
53
+ - examples/books.md
51
54
  - jekyll-get-books.gemspec
52
55
  - lib/jekyll-get-books.rb
53
56
  - lib/jekyll-get-books/converter.rb
@@ -71,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
74
  - !ruby/object:Gem::Version
72
75
  version: '0'
73
76
  requirements: []
74
- rubygems_version: 3.2.18
77
+ rubygems_version: 3.3.5
75
78
  signing_key:
76
79
  specification_version: 4
77
80
  summary: Fetch and safe meta information for books from the Google Book API for a