README.md in sqlserver-sequence-0.1.1 vs README.md in sqlserver-sequence-0.2.0

- old
+ new

@@ -1,21 +1,29 @@ -# Sqlserver::Sequence [![Gem Version](https://badge.fury.io/rb/sqlserver-sequence.svg)](https://badge.fury.io/rb/sqlserver-sequence) +# Sqlserver::Sequence +[![Code Climate](https://codeclimate.com/github/zacharywelch/sqlserver-sequence/badges/gpa.svg)](https://codeclimate.com/github/zacharywelch/sqlserver-sequence) +[![Issue Count](https://codeclimate.com/github/zacharywelch/sqlserver-sequence/badges/issue_count.svg)](https://codeclimate.com/github/zacharywelch/sqlserver-sequence) +[![Gem Version](https://badge.fury.io/rb/sqlserver-sequence.svg)](https://badge.fury.io/rb/sqlserver-sequence) + A Rails plugin for SQL Server sequences. ## Installation Add this line to your application's Gemfile: ```ruby -gem 'sqlserver-sequence', git: 'git@cagit.careerbuilder.com:CorpAppsCB/sqlserver-sequence.git' +gem 'sqlserver-sequence' ``` And then execute: $ bundle +Or install it yourself as: + + $ gem install sqlserver-sequence + ## Usage Specify the attribute you'd like to sequence ```ruby @@ -45,11 +53,11 @@ ### Options ###### name -By default `sqlserver-sequence` will look for a row in `sys.sequences` with the same `name` as the attribute. You can use the `name` option if the sequence is named differently. +By default `sqlserver-sequence` will look for a row in `sys.sequences` with the same `sequence_name` as the attribute. You can use the `name` option if the sequence is named differently. ```ruby class Supplier < ActiveRecord::Base sequence :number, name: 'next_supplier_number' end @@ -71,20 +79,21 @@ $ supplier.number > S-10 ###### format -Pass a lambda to the `format` option if you need more control over the assigned sequence value. +Pass a lambda to the `format` option if you need more control over the assigned sequence value, for example to assign a fixed length string. ```ruby class Supplier < ActiveRecord::Base - sequence :number, format: lambda { |num| num.rjust(10, 0) } + sequence :number, prefix: 'S-', + format: lambda { |num| num.rjust(10, 0) } end ``` $ supplier = Supplier.create $ supplier.number - > 0000000010 + > S-0000000010 ## Testing with SQLite If your test suite uses SQLite you'll need to turn off sequence generation or provide a stub for `next_sequence_value`. @@ -94,12 +103,12 @@ end ``` ## Contributing -1. Fork it ( https://github.com/CorpAppsCB/sqlserver-sequence/fork ) +1. Fork it ( https://github.com/zacharywelch/sqlserver-sequence/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create a new Pull Request -See the [Running Tests](RUNNING_TESTS.md) guide for details on how to run the test suite on SQL Server. \ No newline at end of file +See the [Running Tests](RUNNING_TESTS.md) guide for details on how to run the test suite on SQL Server.