active-record-forcible-index 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +1 -0
- data/.travis.yml +2 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +63 -0
- data/LICENSE +20 -0
- data/README.md +44 -0
- data/Rakefile +6 -0
- data/active-record-forcible-index.gemspec +30 -0
- data/lib/active_record_forcible_index.rb +27 -0
- data/spec/active_record_forcible_index_spec.rb +39 -0
- data/spec/spec_helper.rb +2 -0
- metadata +134 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f85f6913f9f90a1861129eca443d923e4b7415ff
|
4
|
+
data.tar.gz: 6a7bb3bb166a18642ed4c9324082893ffee50b4d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b4cbf8fb091696a75e0161280fa49d95c6b5694e1e8fc99a3ebbe382fd19baa95f30897eb68902362ace4fbdb2163ba81fed1cddd2adeb4b4d0faed5a67b2ef3
|
7
|
+
data.tar.gz: 7dd8f577701500e20871aaa444272157eebaa84f3ae857e632f32d688887447e046766e36fd7a7ab367de2e7750c0adc2e4050cbd2784b6a1192de53f2ef7b9c
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
active-record-forcible-index (0.0.1)
|
5
|
+
activerecord (~> 4.0)
|
6
|
+
bundler (~> 1.3)
|
7
|
+
rake
|
8
|
+
rspec (~> 2.0)
|
9
|
+
rspec-given
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://rubygems.org/
|
13
|
+
specs:
|
14
|
+
ZenTest (4.10.0)
|
15
|
+
activemodel (4.1.0)
|
16
|
+
activesupport (= 4.1.0)
|
17
|
+
builder (~> 3.1)
|
18
|
+
activerecord (4.1.0)
|
19
|
+
activemodel (= 4.1.0)
|
20
|
+
activesupport (= 4.1.0)
|
21
|
+
arel (~> 5.0.0)
|
22
|
+
activesupport (4.1.0)
|
23
|
+
i18n (~> 0.6, >= 0.6.9)
|
24
|
+
json (~> 1.7, >= 1.7.7)
|
25
|
+
minitest (~> 5.1)
|
26
|
+
thread_safe (~> 0.1)
|
27
|
+
tzinfo (~> 1.1)
|
28
|
+
arel (5.0.1.20140414130214)
|
29
|
+
autotest (4.4.6)
|
30
|
+
ZenTest (>= 4.4.1)
|
31
|
+
builder (3.2.2)
|
32
|
+
diff-lcs (1.2.5)
|
33
|
+
given_core (3.5.4)
|
34
|
+
sorcerer (>= 0.3.7)
|
35
|
+
i18n (0.6.9)
|
36
|
+
json (1.8.1)
|
37
|
+
minitest (5.3.3)
|
38
|
+
rake (10.3.1)
|
39
|
+
rspec (2.14.1)
|
40
|
+
rspec-core (~> 2.14.0)
|
41
|
+
rspec-expectations (~> 2.14.0)
|
42
|
+
rspec-mocks (~> 2.14.0)
|
43
|
+
rspec-core (2.14.8)
|
44
|
+
rspec-expectations (2.14.5)
|
45
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
46
|
+
rspec-given (3.5.4)
|
47
|
+
given_core (= 3.5.4)
|
48
|
+
rspec (>= 2.12)
|
49
|
+
rspec-mocks (2.14.6)
|
50
|
+
sorcerer (1.0.2)
|
51
|
+
thread_safe (0.3.3)
|
52
|
+
tzinfo (1.1.0)
|
53
|
+
thread_safe (~> 0.1)
|
54
|
+
|
55
|
+
PLATFORMS
|
56
|
+
ruby
|
57
|
+
|
58
|
+
DEPENDENCIES
|
59
|
+
ZenTest
|
60
|
+
active-record-forcible-index!
|
61
|
+
autotest
|
62
|
+
rake
|
63
|
+
rspec
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 SC 2Parale Afiliere S.R.L.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# ActiveRecord::ForcibleIndex
|
2
|
+
|
3
|
+
ActiveRecord extension that implements USE INDEX and FORCE INDEX.
|
4
|
+
|
5
|
+
## How to use
|
6
|
+
|
7
|
+
Add it to your ```Gemfile```.
|
8
|
+
|
9
|
+
```
|
10
|
+
# ...
|
11
|
+
gem 'active-record-forcible-index'
|
12
|
+
# ...
|
13
|
+
```
|
14
|
+
|
15
|
+
Having the model bellow:
|
16
|
+
|
17
|
+
```
|
18
|
+
class DummyModel < ActiveRecord::Base
|
19
|
+
include ActiveRecordForcibleIndex
|
20
|
+
end
|
21
|
+
```
|
22
|
+
|
23
|
+
You can use ```#use_index``` or ```#force_index``` by invoking:
|
24
|
+
|
25
|
+
```
|
26
|
+
# code here
|
27
|
+
DummyModel.all.use_index('dummy_index')
|
28
|
+
# code here
|
29
|
+
```
|
30
|
+
|
31
|
+
Note: Get *dummy_index* value from your SQL database.
|
32
|
+
|
33
|
+
## Authors
|
34
|
+
[Catalin Ilinca](https://github.com/ducknorris) and [Alexandru Emil Lupu](https://github.com/alecslupu)
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
Thanks to our [contributors](https://github.com/2Parale/active-record-forcible-index/graphs/contributors).
|
39
|
+
|
40
|
+
1. Fork it
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'active_record_forcible_index'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "active-record-forcible-index"
|
8
|
+
spec.version = "0.0.1"
|
9
|
+
spec.authors = ["Catalin Ilinca", "Alexandru Emil Lupu"]
|
10
|
+
spec.email = ["c@talin.ro", "contact@alecslupu.ro"]
|
11
|
+
spec.description = %q{ActiveRecord extension that gives USE and FORCE index to any ActiveRecord Model.}
|
12
|
+
spec.summary = %q{Use the desired index}
|
13
|
+
spec.homepage = "https://github.com/2Parale/active-record-forcible-index"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.extra_rdoc_files = [
|
16
|
+
"README.md",
|
17
|
+
"CHANGELOG.md"
|
18
|
+
]
|
19
|
+
|
20
|
+
spec.files = `git ls-files`.split($/)
|
21
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_dependency 'activerecord', '~> 4.0'
|
26
|
+
spec.add_dependency 'rspec', '~> 2.0'
|
27
|
+
spec.add_dependency "rspec-given"
|
28
|
+
spec.add_dependency "bundler", "~> 1.3"
|
29
|
+
spec.add_dependency "rake"
|
30
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
|
3
|
+
module ActiveRecordForcibleIndex
|
4
|
+
class << self
|
5
|
+
def included(klass)
|
6
|
+
klass.class_eval do
|
7
|
+
extend ClassMethods
|
8
|
+
include InstanceMethods
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module InstanceMethods
|
14
|
+
end
|
15
|
+
|
16
|
+
module ClassMethods
|
17
|
+
def use_index(index)
|
18
|
+
from("#{self.table_name} USE INDEX(#{index})")
|
19
|
+
end
|
20
|
+
|
21
|
+
def force_index(index)
|
22
|
+
from("#{self.table_name} FORCE INDEX(#{index})")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
ActiveRecord::Base.send(:include, ActiveRecordForcibleIndex)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class DummyModel < ActiveRecord::Base
|
4
|
+
include ActiveRecordForcibleIndex
|
5
|
+
end
|
6
|
+
|
7
|
+
describe ActiveRecordForcibleIndex do
|
8
|
+
|
9
|
+
describe "#use_index" do
|
10
|
+
describe "responsiveness" do
|
11
|
+
Given { }
|
12
|
+
|
13
|
+
Then { expect(DummyModel).to respond_to(:use_index) }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "sql output" do
|
17
|
+
Given(:active_record_relation) { DummyModel.use_index('dummy_index') }
|
18
|
+
Given { active_record_relation.stub to_sql: 'SELECT `dummy_models`.* FROM dummy_models USE INDEX(dummy_index) ' }
|
19
|
+
|
20
|
+
Then { expect(active_record_relation.to_sql).to eq('SELECT `dummy_models`.* FROM dummy_models USE INDEX(dummy_index) ') }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#force_index" do
|
25
|
+
describe "responsiveness" do
|
26
|
+
Given { }
|
27
|
+
|
28
|
+
Then { expect(DummyModel).to respond_to(:force_index) }
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "sql output" do
|
32
|
+
Given(:active_record_relation) { DummyModel.force_index('dummy_index') }
|
33
|
+
Given { active_record_relation.stub to_sql: 'SELECT `dummy_models`.* FROM dummy_models FORCE INDEX(dummy_index) ' }
|
34
|
+
|
35
|
+
Then { expect(active_record_relation.to_sql).to eq('SELECT `dummy_models`.* FROM dummy_models FORCE INDEX(dummy_index) ') }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active-record-forcible-index
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Catalin Ilinca
|
8
|
+
- Alexandru Emil Lupu
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-05-06 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activerecord
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '4.0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '4.0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rspec
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '2.0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '2.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rspec-given
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: bundler
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '1.3'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.3'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rake
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
description: ActiveRecord extension that gives USE and FORCE index to any ActiveRecord
|
85
|
+
Model.
|
86
|
+
email:
|
87
|
+
- c@talin.ro
|
88
|
+
- contact@alecslupu.ro
|
89
|
+
executables: []
|
90
|
+
extensions: []
|
91
|
+
extra_rdoc_files:
|
92
|
+
- README.md
|
93
|
+
- CHANGELOG.md
|
94
|
+
files:
|
95
|
+
- .gitignore
|
96
|
+
- .rspec
|
97
|
+
- .travis.yml
|
98
|
+
- CHANGELOG.md
|
99
|
+
- Gemfile
|
100
|
+
- Gemfile.lock
|
101
|
+
- LICENSE
|
102
|
+
- README.md
|
103
|
+
- Rakefile
|
104
|
+
- active-record-forcible-index.gemspec
|
105
|
+
- lib/active_record_forcible_index.rb
|
106
|
+
- spec/active_record_forcible_index_spec.rb
|
107
|
+
- spec/spec_helper.rb
|
108
|
+
homepage: https://github.com/2Parale/active-record-forcible-index
|
109
|
+
licenses:
|
110
|
+
- MIT
|
111
|
+
metadata: {}
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.2.2
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: Use the desired index
|
132
|
+
test_files:
|
133
|
+
- spec/active_record_forcible_index_spec.rb
|
134
|
+
- spec/spec_helper.rb
|