gisbn 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 513f21bca505a34739c299586d3d6f387f7c5b42
4
- data.tar.gz: 6213468089ada8589e382e00ad962eb3e73aa6f7
2
+ SHA256:
3
+ metadata.gz: 9990b687d41d939ef3179be599539c67e36ae480b8bdaf8010a247d7dfcfca87
4
+ data.tar.gz: f541a4216d099d84ca39c4ba364c7053c8de89db70b51a07305a9f363e8ad978
5
5
  SHA512:
6
- metadata.gz: c9672931fc8b09dc9eb391838a27be30f02e4095766d7fcf184389ecf84f6d3f77c8f37bde47537972fc9e94c071b1abb16b040b2621b5ab1f99da865ac9d54d
7
- data.tar.gz: 70884f43bde477cb0dd8f4c784310cae57020fc87f1e3fcaf61ffa370bcd1f5481647d64a40b3a00bd856bb8e41e3c2a74df2151cd28b633349d69ce3d499423
6
+ metadata.gz: 9db06099ce22bce004d9e377cfc933dc53778ecbd21e94952810aa79ebb41c97f31829a6892cd4310337c2138f820f0a8de289235e8725193ee5107042981281
7
+ data.tar.gz: 1c50480b5a4a76df7054b21460e8e48a552cf5874381eeb12101cabcd05158cca8963cd92c83a88489765cf0224c88268186bbfd5cf1d1aa39c3e712ac394b3b
@@ -0,0 +1,48 @@
1
+ name: Publish GISBN Gem
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - '*'
7
+ jobs:
8
+ rspec:
9
+ name: Specs
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - uses: actions/checkout@master
14
+
15
+ - name: Set up Ruby 2.6
16
+ uses: actions/setup-ruby@v1
17
+ with:
18
+ ruby-version: 2.6.x
19
+
20
+ - name: Run specs
21
+ run: |
22
+ bundle install
23
+ bundle exec rspec
24
+
25
+ publish:
26
+ name: Publish
27
+ runs-on: ubuntu-latest
28
+
29
+ needs: rspec
30
+
31
+ steps:
32
+ - uses: actions/checkout@master
33
+
34
+ - name: Set up Ruby 2.6
35
+ uses: actions/setup-ruby@v1
36
+ with:
37
+ ruby-version: 2.6.x
38
+
39
+ - name: Publish to RubyGems
40
+ run: |
41
+ mkdir -p $HOME/.gem
42
+ touch $HOME/.gem/credentials
43
+ chmod 0600 $HOME/.gem/credentials
44
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
45
+ gem build *.gemspec
46
+ gem push *.gem
47
+ env:
48
+ GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
data/.travis.yml CHANGED
@@ -2,14 +2,20 @@ language: ruby
2
2
  cache: bundler
3
3
 
4
4
  rvm:
5
- - jruby
6
5
  - 2.0.0
6
+ - 2.1.5
7
7
 
8
- script: 'bundle exec rake'
8
+ before_install:
9
+ - gem install bundler
10
+ - gem update bundler
11
+ - gem install gisbn
12
+
13
+ script:
14
+ - bundle exec rspec
9
15
 
10
16
  notifications:
11
17
  email:
12
18
  recipients:
13
19
  - eftakhairul@gmail.com
14
20
  on_failure: change
15
- on_success: never
21
+ on_success: never
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # gisbn
1
+ # gisbn GEM [![Build Status](https://travis-ci.org/eftakhairul/gisbn.svg?branch=master)](https://travis-ci.org/eftakhairul/gisbn) [![GitHub issues](https://img.shields.io/github/issues/eftakhairul/gisbn.svg)](https://github.com/eftakhairul/gisbn/issues) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/eftakhairul/gisbn/master/LICENSE.txt)
2
2
 
3
3
  It fetches book's information by ISBN number based on Google Book API.
4
4
 
@@ -14,20 +14,27 @@ You don't have to call manually Google API with ISBN number. This gem will do ev
14
14
 
15
15
 
16
16
  ### Installation
17
+ Add this line to your application's Gemfile:
17
18
 
18
- You need Gulp installed globally:
19
+ ```ruby
20
+ gem 'gisbn'
21
+ ```
22
+
23
+ And then execute:
19
24
 
20
25
  ```sh
21
- gem install gisbn
26
+ $ bundle
22
27
  ```
23
- Or, if you're using this in a project with Bundler:
28
+
29
+ Or install it yourself as globally:
24
30
 
25
31
  ```sh
26
- gem 'gisbn'
32
+ gem install gisbn
27
33
  ```
28
34
 
35
+
29
36
  ## Examples
30
- book = Gisbn::Book.new "0262033844"
37
+ book = Gisbn::Book.new "0262033844", "AIzaSyDKepjfaVBRcgsnPALw5s2UNyfOk-1FHUU", "ca"
31
38
 
32
39
  book.title
33
40
  #=> "Introduction to Algorithms"
data/lib/gisbn.rb CHANGED
@@ -14,10 +14,10 @@ module Gisbn
14
14
  private
15
15
  attr_accessor :key, :country
16
16
 
17
- BASE_URL = 'https://www.googleapis.com/books/v1/volumes?q=isbn:'
17
+ BASE_URL = 'https://www.googleapis.com/books/v1/volumes?q=isbn:'.freeze
18
18
 
19
19
  public
20
- # Initialize a new Book object by ISBN (either ten or thirteen digits ISBN number)
20
+ # Initialize a new Book object by ISBN (either ten or thirteen digit ISBN numbers)
21
21
  #
22
22
  # At Interactive Ruby Shell...
23
23
  # require 'gisbn'
@@ -68,8 +68,12 @@ module Gisbn
68
68
  @result = nil if @result["totalItems"] == 0
69
69
  end
70
70
 
71
+
71
72
  # Set ISBN for new request
72
73
  #
74
+ # Arguments:
75
+ # isbn: (String)
76
+ #
73
77
  # Example:
74
78
  # >> gisbn.isbn = 0262033844
75
79
  #
@@ -79,6 +83,7 @@ module Gisbn
79
83
  isbn.strip! || isbn
80
84
  end
81
85
 
86
+
82
87
  # Description of the book
83
88
  #
84
89
  # Example:
@@ -90,9 +95,10 @@ module Gisbn
90
95
  # String
91
96
  def description
92
97
  return nil if @result.nil?
93
- @result["items"][0]["description"]
98
+ @result["items"][0]["volumeInfo"]["description"]
94
99
  end
95
100
 
101
+
96
102
  # Title of the book
97
103
  # Example:
98
104
  # >> gisbn.title
@@ -105,6 +111,7 @@ module Gisbn
105
111
  @result["items"][0]["volumeInfo"]["title"]
106
112
  end
107
113
 
114
+
108
115
  # It returns all authors' name as comma separated string
109
116
  #
110
117
  # Example:
@@ -118,6 +125,7 @@ module Gisbn
118
125
  @result["items"][0]["volumeInfo"]["authors"].join(", ")
119
126
  end
120
127
 
128
+
121
129
  # It returns all authors' name as array
122
130
  #
123
131
  # Example:
@@ -131,6 +139,7 @@ module Gisbn
131
139
  @result["items"][0]["volumeInfo"]["authors"]
132
140
  end
133
141
 
142
+
134
143
  # It returns publisher name
135
144
  #
136
145
  # Example:
@@ -159,7 +168,7 @@ module Gisbn
159
168
  isbn_array = @result["items"][0]["volumeInfo"]["industryIdentifiers"]
160
169
 
161
170
  isbn_array.each do |isbn|
162
- if isbn["type"] == "ISBN_13"
171
+ if isbn["type"] == "ISBN_10"
163
172
  return isbn["identifier"]
164
173
  end
165
174
  end
@@ -186,6 +195,7 @@ module Gisbn
186
195
  end
187
196
  end
188
197
 
198
+
189
199
  # It returns categories of book
190
200
  #
191
201
  # Example:
@@ -241,6 +251,7 @@ module Gisbn
241
251
  @result["items"][0]["volumeInfo"]["imageLinks"]["thumbnail"]
242
252
  end
243
253
 
254
+
244
255
  # It returns the preview link of book
245
256
  #
246
257
  # Example:
@@ -278,7 +289,11 @@ module Gisbn
278
289
  # Date
279
290
  def published_date
280
291
  return nil if @result.nil?
281
- Date.parse(@result["items"][0]["volumeInfo"]["publishedDate"])
292
+ begin
293
+ Date.parse(@result["items"][0]["volumeInfo"]["publishedDate"])
294
+ rescue ArgumentError
295
+ @result["items"][0]["volumeInfo"]["publishedDate"]
296
+ end
282
297
  end
283
298
  end
284
299
  end
data/lib/gisbn/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gisbn
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/spec/gisbn_spec.rb CHANGED
@@ -1,7 +1,8 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "gisbn" do
4
- subject { Gisbn::Book.new "0262033844" }
5
+ subject { Gisbn::Book.new "0262033844", "AIzaSyDKepjfaVBRcgsnPALw5s2UNyfOk-1FHUU", "ca" }
5
6
 
6
7
  describe '#process' do
7
8
  let(:output) { "Introduction to Algorithms" }
@@ -11,7 +12,7 @@ describe "gisbn" do
11
12
  end
12
13
 
13
14
  it 'book page count' do
14
- expect(output).to eq subject.page_count
15
+ expect(1292).to eq subject.page_count.to_i
15
16
  end
16
17
  end
17
18
  end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  ##All
2
- require 'gisbn'
3
2
  require 'rspec'
4
3
  require 'net/http'
5
4
  require 'json'
5
+
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
7
+ require 'gisbn'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gisbn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eftakhairul Islam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-07 00:00:00.000000000 Z
11
+ date: 2021-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,6 +73,7 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - ".github/workflows/publish.yml"
76
77
  - ".gitignore"
77
78
  - ".travis.yml"
78
79
  - Gemfile
@@ -103,8 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
104
  - !ruby/object:Gem::Version
104
105
  version: '0'
105
106
  requirements: []
106
- rubyforge_project:
107
- rubygems_version: 2.4.3
107
+ rubygems_version: 3.0.3.1
108
108
  signing_key:
109
109
  specification_version: 4
110
110
  summary: Book information from ISBN by Google Book API.