db_binary_search 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/db_binary_search.gemspec +4 -1
- data/lib/db_binary_search.rb +2 -2
- data/lib/db_binary_search/version.rb +1 -1
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7344d69362e835f84a56f046bdc3711c9fb578a6
|
4
|
+
data.tar.gz: 367024ece1a37954ffc6c51c09981fa55c0e37b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c887e3c72bc884f7240e38e0ed21db59f8c41677d083d33bad081ee66e76fbc2810959684f806d3d53b2af4c5970279c7739397c08363336ecae63c048a28f7
|
7
|
+
data.tar.gz: 9c65aeff3195a6d30cf1d44d16e9a4e4519e2d38582be7d77ca1b1099b94f5a80e3841f3dfa057359b84abc014feb031909245dbde8a66a9a3010c83af67d87e
|
data/README.md
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|

|
4
4
|
[](https://travis-ci.org/acrookston/db_binary_search)
|
5
|
-
[](https://codeclimate.com/github/acrookston/db_binary_search)
|
6
6
|
[](https://codecov.io/gh/acrookston/db_binary_search)
|
7
7
|
|
8
8
|
|
9
9
|
An Active Support concern extending Active Record with the ability to binary
|
10
|
-
search a table for use with non-indexed,
|
10
|
+
search a table for use with non-indexed, sorted tables.
|
11
11
|
|
12
12
|
The gem allows you to avoid slow database scans if you have an
|
13
13
|
auto-incrementing primary key running in parallel with a column which
|
@@ -59,8 +59,8 @@ binary_search(column, value, lower_id=nil, upper_id=nil)
|
|
59
59
|
|
60
60
|
- `column` a symbol, is the table column to search for.
|
61
61
|
- `value` a comparable value of same type as `column`, the value you are searching for.
|
62
|
-
- `lower_id` optional primary key value to start searching lower bound at.
|
63
|
-
- `upper_id` optional primary key value to start searching upper bound at.
|
62
|
+
- `lower_id` optional primary key value to start searching lower bound at. Defaults to `model.first.id`.
|
63
|
+
- `upper_id` optional primary key value to start searching upper bound at. Defaults to `model.last.id`.
|
64
64
|
|
65
65
|
Full example:
|
66
66
|
|
@@ -81,7 +81,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
81
81
|
|
82
82
|
## Contributing
|
83
83
|
|
84
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
84
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/acrookston/db_binary_search.
|
85
85
|
|
86
86
|
If you're making a big change, please open an Issue first, so we can discuss. Otherwise:
|
87
87
|
|
data/db_binary_search.gemspec
CHANGED
@@ -9,8 +9,11 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Andrew Crookston"]
|
10
10
|
spec.email = ["andrew@caoos.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{An Active Support concern extending Active Record with the ability to binary search a table for use with non-indexed,
|
12
|
+
spec.summary = %q{An Active Support concern extending Active Record with the ability to binary search a table for use with non-indexed, sorted tables.}
|
13
13
|
spec.description = %q{
|
14
|
+
An Active Support concern extending Active Record with the ability to binary
|
15
|
+
search a table for use with non-indexed, sorted tables.
|
16
|
+
|
14
17
|
The gem allows you to avoid slow database scans if you have an
|
15
18
|
auto-incrementing primary key running in parallel with a column which
|
16
19
|
you want to search.
|
data/lib/db_binary_search.rb
CHANGED
@@ -4,8 +4,8 @@ require 'active_record'
|
|
4
4
|
module DBBinarySearch
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
|
-
|
8
|
-
def binary_search(column, value, lower_id=nil, upper_id=nil)
|
7
|
+
included do
|
8
|
+
def self.binary_search(column, value, lower_id=nil, upper_id=nil)
|
9
9
|
lower_id = self.first.id unless lower_id
|
10
10
|
upper_id = self.last.id unless upper_id
|
11
11
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: db_binary_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Crookston
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01
|
11
|
+
date: 2017-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -122,9 +122,10 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
-
description: "\n
|
126
|
-
\
|
127
|
-
|
125
|
+
description: "\n An Active Support concern extending Active Record with the ability
|
126
|
+
to binary\n search a table for use with non-indexed, sorted tables.\n\n The
|
127
|
+
gem allows you to avoid slow database scans if you have an\n auto-incrementing
|
128
|
+
primary key running in parallel with a column which\n you want to search.\n "
|
128
129
|
email:
|
129
130
|
- andrew@caoos.com
|
130
131
|
executables: []
|
@@ -168,5 +169,6 @@ rubygems_version: 2.4.3
|
|
168
169
|
signing_key:
|
169
170
|
specification_version: 4
|
170
171
|
summary: An Active Support concern extending Active Record with the ability to binary
|
171
|
-
search a table for use with non-indexed,
|
172
|
+
search a table for use with non-indexed, sorted tables.
|
172
173
|
test_files: []
|
174
|
+
has_rdoc:
|