Coder Social home page Coder Social logo

isbn's Issues

Fix regex in ISBN.from_string

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!

invalid gemspec error when using rubygems 1.8.5

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.

Exclude false positives from ISBN.from_string

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. Filter for "Fax" etc.; Drawback: this is not generic enough
  2. Ensure that there are not more than 13 numbers (+X) directly adjacent to each other.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.