Library
Contributing
Contributions to PubID are welcome! Here’s how to get started.
Adding a New Publisher Schema
1. Create the Flavor Module
# lib/pubid/{flavor}/identifier.rbmodule Pubid module Myflavor class Identifier < ::Pubid::Identifier def self.parse(string) parsed = Parser.parse(string) Builder.build(parsed) end end endend2. Define the Parser
# lib/pubid/{flavor}/parser.rbmodule Pubid module Myflavor class Parser < Parslet::Parser rule(:publisher) { str("MYPUB") } rule(:number) { digits } rule(:year) { str(":") >> digits } rule(:root) { publisher >> space >> number >> year.maybe } end endend3. Define Identifier Types
# lib/pubid/{flavor}/identifiers/standard.rbmodule Pubid module Myflavor module Identifiers class Standard < ::Pubid::Identifier attribute :publisher, :string attribute :number, :string attribute :year, :integer end end endend4. Add Tests
Create fixture files in spec/fixtures/{flavor}/identifiers/pass/ and fail/:
spec/fixtures/myflavor/identifiers/pass/standard.txtEach line is one identifier to test for successful parsing.
5. Register in Main Module
# lib/pubid/{flavor}.rbrequire_relative "{flavor}/identifier"Development Setup
git clone https://github.com/pubid/pubidcd pubidbundle install
# Run all testsbundle exec rake test:all
# Run specific flavor testsbundle exec rspec spec/pubid/myflavor/
# Lintbundle exec rake rubocop:allPull Request Process
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass:
bundle exec rake - Submit a pull request
Reporting Issues
Report bugs or request features at github.com/pubid/pubid/issues.