https://github.com/ankane/barkick
Barcodes made easy
https://github.com/ankane/barkick
Last synced: 7 months ago
JSON representation
Barcodes made easy
- Host: GitHub
- URL: https://github.com/ankane/barkick
- Owner: ankane
- License: mit
- Created: 2013-09-20T06:32:22.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2025-06-09T17:38:31.000Z (about 1 year ago)
- Last Synced: 2025-10-30T15:36:27.991Z (7 months ago)
- Language: Ruby
- Homepage:
- Size: 41 KB
- Stars: 144
- Watchers: 5
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Barkick
Barcodes made easy
Works with:
- [UPC](https://en.wikipedia.org/wiki/Universal_Product_Code) (UPC-A and UPC-E)
- [EAN](https://en.wikipedia.org/wiki/International_Article_Number_%28EAN%29) (EAN-13 and EAN-8)
- [GTIN](https://en.wikipedia.org/wiki/Global_Trade_Item_Number)
- [ISBN](https://en.wikipedia.org/wiki/International_Standard_Book_Number)
For PLU codes, check out the [plu gem](https://github.com/ankane/plu)
[](https://github.com/ankane/barkick/actions)
## Installation
Add this line to your Gemfile:
```ruby
gem "barkick"
```
## How To Use
```ruby
gtin = Barkick::GTIN.new("016000275263")
gtin.valid? # true
gtin.gtin14 # "00016000275263"
gtin.ean13 # "0016000275263"
gtin.upc # "016000275263"
gtin.prefix # "001"
gtin.prefix_name # "GS1 US"
gtin.country_code # "US"
```
Variable items
```ruby
gtin = Barkick::GTIN.new("299265108631")
gtin.variable? # true
gtin.restricted? # true
gtin.price # 8.63
gtin.base_gtin14 # "00299265000003"
```
UPC-E
```ruby
gtin = Barkick::GTIN.new("03744806", type: :upc_e)
gtin.base_gtin14 # "00037000004486"
```
EAN-8
```ruby
gtin = Barkick::GTIN.new("01234565", type: :ean8)
gtin.base_gtin14 # "00000001234565"
```
Calculate check digit
```ruby
Barkick::GTIN.check_digit("01600027526") # "3"
```
> For UPC-E, convert to UPC-A before passing to this method
## Resources
- [GS1 General Specifications](https://www.gs1.org/docs/barcodes/GS1_General_Specifications.pdf)
## History
View the [changelog](https://github.com/ankane/barkick/blob/master/CHANGELOG.md)
## Contributing
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- [Report bugs](https://github.com/ankane/barkick/issues)
- Fix bugs and [submit pull requests](https://github.com/ankane/barkick/pulls)
- Write, clarify, or fix documentation
- Suggest or add new features
To get started with development:
```sh
git clone https://github.com/ankane/barkick.git
cd barkick
bundle install
bundle exec rake test
```