tkersey / isbn Goto Github PK
View Code? Open in Web Editor NEWThis library provides methods to manipulate isbns.
Home Page: https://rubygems.org/gems/isbn
License: MIT License
This library provides methods to manipulate isbns.
Home Page: https://rubygems.org/gems/isbn
License: MIT License
private method `delete' called for nil:NilClass
.../isbn-2.0.6/lib/isbn.rb:68:in `valid?'
I would expect it to be returning false
instead. I can put together a pull request request with tests as needed for this later.
1.9.3-p286 :001 > require "isbn"
=> true
1.9.3-p286 :002 > ISBN.valid? "3-540-49698-x"
=> false
But this book exists
https://portal.dnb.de/opac.htm?method=simpleSearch&query=3-540-49698-x
Given the following strings:
fax: +1 213 413 0950.
Fax +1 213 413 0950
FAX: +1-213-413-0950
ISBN.from_string
gets the ISBN number 1-213-413-095
This is actually not an ISBN number
I see two options how to improve the regex:
1.9.3p125 :001 > ISBN.thirteen "978-0131103627"
ISBN::Invalid13DigitISBN: ISBN::Invalid13DigitISBN
1.9.3p125 :002 > ISBN.thirteen "978-0131103627".delete "-"
=> "9780131103627"
after upgrading to rubygems 1.8.5 I started encountering the following error:
Invalid gemspec in [/Users/fharbec/.rvm/gems/ruby-1.8.7-p334@bigmama/specifications/isbn-2.0.6.gemspec]: invalid date format in specification: "2011-04-15 00:00:00.000000000Z"
I had to revert back to rubygems 1.4.2 to fix this problem.
Let's say we have the following ISBN:
isbn = "9-780230-104143"
=> "9-780230-104143"
Checking if that is a valid ISBN, returns true
:
ISBN.valid?(isbn)
=> true
However, if we try to extract it from a string, it throws an exception:
ISBN.thirteen(ISBN.from_string(isbn))
=> ISBN::InvalidSourceString: ISBN::InvalidSourceString
The reason for that is because the regex requires the -
to be after 978
.
Since spaces and hyphens in the ISBN do not matter, is it possible to fix the regex in from_string
so that the positioning of the hyphen doesn't matter?
Something like:
/(?:ISBN[- ]*13|ISBN[- ]*10|)\s*((?:(?:9[\s-]*7[\s-]*[89])?[ -]?(?:[0-9][ -]*){9})[ -]*(?:[0-9xX]))/
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.