sqlserver-sequence 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -8
- data/lib/sqlserver/sequence.rb +1 -1
- data/lib/sqlserver/sequence/version.rb +1 -1
- data/spec/sequence_spec.rb +1 -1
- data/sqlserver-sequence.gemspec +3 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea055f44adbc2fdc216305cab3d9fca8d158f947
|
4
|
+
data.tar.gz: 648a4d03260ab26bc7437bc61196687d8142e638
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd6eabfe7c6a303167b62fadf6af2caf87d42ee3564187657b627dd7ea5b50a1196a8d97fe573186832a6ab175d296c45a3f8814dec6400d5c53c39f4e91627e
|
7
|
+
data.tar.gz: 158697f35073a7f5068307cbf03706643f7e51d6136bbda21154d5a50434c8dd275650921e84bddc9ba71b7b859df480bdbf147d53dffbea16e1a56559ea0591
|
data/README.md
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
# Sqlserver::Sequence
|
1
|
+
# Sqlserver::Sequence
|
2
|
+
|
3
|
+
[![Code Climate](https://codeclimate.com/github/zacharywelch/sqlserver-sequence/badges/gpa.svg)](https://codeclimate.com/github/zacharywelch/sqlserver-sequence)
|
4
|
+
[![Issue Count](https://codeclimate.com/github/zacharywelch/sqlserver-sequence/badges/issue_count.svg)](https://codeclimate.com/github/zacharywelch/sqlserver-sequence)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/sqlserver-sequence.svg)](https://badge.fury.io/rb/sqlserver-sequence)
|
2
6
|
|
3
7
|
A Rails plugin for SQL Server sequences.
|
4
8
|
|
@@ -7,13 +11,17 @@ A Rails plugin for SQL Server sequences.
|
|
7
11
|
Add this line to your application's Gemfile:
|
8
12
|
|
9
13
|
```ruby
|
10
|
-
gem 'sqlserver-sequence'
|
14
|
+
gem 'sqlserver-sequence'
|
11
15
|
```
|
12
16
|
|
13
17
|
And then execute:
|
14
18
|
|
15
19
|
$ bundle
|
16
20
|
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install sqlserver-sequence
|
24
|
+
|
17
25
|
## Usage
|
18
26
|
|
19
27
|
Specify the attribute you'd like to sequence
|
@@ -47,7 +55,7 @@ end
|
|
47
55
|
|
48
56
|
###### name
|
49
57
|
|
50
|
-
By default `sqlserver-sequence` will look for a row in `sys.sequences` with the same `
|
58
|
+
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.
|
51
59
|
|
52
60
|
```ruby
|
53
61
|
class Supplier < ActiveRecord::Base
|
@@ -73,16 +81,17 @@ end
|
|
73
81
|
|
74
82
|
###### format
|
75
83
|
|
76
|
-
Pass a lambda to the `format` option if you need more control over the assigned sequence value.
|
84
|
+
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.
|
77
85
|
|
78
86
|
```ruby
|
79
87
|
class Supplier < ActiveRecord::Base
|
80
|
-
sequence :number,
|
88
|
+
sequence :number, prefix: 'S-',
|
89
|
+
format: lambda { |num| num.rjust(10, 0) }
|
81
90
|
end
|
82
91
|
```
|
83
92
|
$ supplier = Supplier.create
|
84
93
|
$ supplier.number
|
85
|
-
> 0000000010
|
94
|
+
> S-0000000010
|
86
95
|
|
87
96
|
## Testing with SQLite
|
88
97
|
|
@@ -96,10 +105,10 @@ end
|
|
96
105
|
|
97
106
|
## Contributing
|
98
107
|
|
99
|
-
1. Fork it ( https://github.com/
|
108
|
+
1. Fork it ( https://github.com/zacharywelch/sqlserver-sequence/fork )
|
100
109
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
101
110
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
102
111
|
4. Push to the branch (`git push origin my-new-feature`)
|
103
112
|
5. Create a new Pull Request
|
104
113
|
|
105
|
-
See the [Running Tests](RUNNING_TESTS.md) guide for details on how to run the test suite on SQL Server.
|
114
|
+
See the [Running Tests](RUNNING_TESTS.md) guide for details on how to run the test suite on SQL Server.
|
data/lib/sqlserver/sequence.rb
CHANGED
@@ -37,7 +37,7 @@ module Sqlserver
|
|
37
37
|
prefix = options[:prefix]
|
38
38
|
format = options[:format]
|
39
39
|
|
40
|
-
value = next_sequence_value(name)
|
40
|
+
value = next_sequence_value(name).to_s
|
41
41
|
value = format.call(value) if format.respond_to?(:call)
|
42
42
|
send "#{field}=", [prefix, value].join
|
43
43
|
end
|
data/spec/sequence_spec.rb
CHANGED
data/sqlserver-sequence.gemspec
CHANGED
@@ -6,9 +6,9 @@ require 'sqlserver/sequence/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "sqlserver-sequence"
|
8
8
|
spec.version = Sqlserver::Sequence::VERSION
|
9
|
-
spec.authors = ["
|
10
|
-
spec.email = ["
|
11
|
-
"
|
9
|
+
spec.authors = ["Zac", "Ram"]
|
10
|
+
spec.email = ["zachary.welch@careerbuilder.com",
|
11
|
+
"ramanathan.tirunellaisubramanian@careerbuilder.com"]
|
12
12
|
|
13
13
|
spec.summary = %q{Sequence number generation in Rails}
|
14
14
|
spec.description = %q{Sequence number generation in Rails}
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqlserver-sequence
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Ram
|
8
7
|
- Zac
|
8
|
+
- Ram
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-07-
|
12
|
+
date: 2016-07-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -111,8 +111,8 @@ dependencies:
|
|
111
111
|
version: '0'
|
112
112
|
description: Sequence number generation in Rails
|
113
113
|
email:
|
114
|
-
- ramanathan.tirunellaisubramanian@careerbuilder.com
|
115
114
|
- zachary.welch@careerbuilder.com
|
115
|
+
- ramanathan.tirunellaisubramanian@careerbuilder.com
|
116
116
|
executables: []
|
117
117
|
extensions: []
|
118
118
|
extra_rdoc_files: []
|