Skip to content

masko-p/identify_it

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IdentifyIt

Adds easy to use identifier creation mechanism.

Installation

Add this line to your application's Gemfile:

gem 'identify_it'

And then execute:

$ bundle

Or install it yourself as:

$ gem install identify_it

Usage

Add migration to your project

class YourModelName < ActiveRecord::Migration
  def up
    add_column :your_model_name, :string
  end

  def down
    remove_column :your_model_name, :string
  end
end

Just add to your ActiveRecord model a DSL instuction:

has_identifier(format, options)

format - string
options - hash of symbols

With format you are defining how identifier will look like. Main syntax is that a curly brackets you are defining how long each literal would be.

{4}:{5} -> ABCD:ABCDE

In options you can specify:

  1. alphabet (:letters, :numbers, :mix)
  2. case (:upper, :lower, :mix)

##Examples

has_identifier('AA:{2}-{4}', alphabet: :numbers)
> 'AA:34-1324'
has_identifier('{3}:{3}', alphabet: :mix, case: :upper)
> 'A22:8BS'
has_identifier('{8}', alphabet: :mix, case: :mix)
> '1s5DFG67'

License

The gem is available as open source under the terms of the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published