activerecord-indexhint 0.0.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 +7 -0
- data/.gitignore +19 -0
- data/.hound.yml +2 -0
- data/.rspec +3 -0
- data/.rubocop.yml +62 -0
- data/.ruby-version +1 -0
- data/.travis.yml +10 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +45 -0
- data/Rakefile +1 -0
- data/activerecord-indexhint.gemspec +37 -0
- data/lib/active_record/index_hint/errors.rb +9 -0
- data/lib/active_record/index_hint/model.rb +38 -0
- data/lib/active_record/index_hint/version.rb +5 -0
- data/lib/activerecord-indexhint.rb +11 -0
- data/spec/active_record/index_hint/model_spec.rb +85 -0
- data/spec/active_record/index_hint/version_spec.rb +5 -0
- data/spec/models.rb +10 -0
- data/spec/schema.rb +9 -0
- data/spec/spec_helper.rb +55 -0
- metadata +251 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 36f572d0c8ee57d4b63c1d2f0757bbdefe36b7e8
         | 
| 4 | 
            +
              data.tar.gz: d028e8e1853337c51b585d5a4ea58c7f9c2663d8
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 6a69da9a0d84c18c11e9d9f17107df08584b982aea428e4010107a8f8b7060752836c73a10fe5f8c1f81fbc25013d8430f3974360cc5dbd72b34ef8293ff89b0
         | 
| 7 | 
            +
              data.tar.gz: cebd12473a6ea794f360203e401169a4a77e526db99ac19d492065d8ce8f50baf89645d02535262b9e287d918f22c6ed86e98822bf92381b71939a9913412e67
         | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.hound.yml
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/.rubocop.yml
    ADDED
    
    | @@ -0,0 +1,62 @@ | |
| 1 | 
            +
            AllCops:
         | 
| 2 | 
            +
              Exclude:
         | 
| 3 | 
            +
                - "vendor/**/*"
         | 
| 4 | 
            +
              DisplayCopNames: true
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Style/AsciiComments:
         | 
| 7 | 
            +
              Enabled: false
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            Style/BracesAroundHashParameters:
         | 
| 10 | 
            +
              Enabled: false
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            Style/Documentation:
         | 
| 13 | 
            +
              Enabled: false
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            Style/ExtraSpacing:
         | 
| 16 | 
            +
              Enabled: false
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            Style/GuardClause:
         | 
| 19 | 
            +
              MinBodyLength: 5
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            Style/MethodDefParentheses:
         | 
| 22 | 
            +
              EnforcedStyle: require_parentheses
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            Style/ModuleFunction:
         | 
| 25 | 
            +
              Enabled: false
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            Style/StringLiterals:
         | 
| 28 | 
            +
              EnforcedStyle: double_quotes
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            Style/IndentationConsistency:
         | 
| 31 | 
            +
              EnforcedStyle: rails
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            Style/SignalException:
         | 
| 34 | 
            +
              EnforcedStyle: only_raise
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            Style/HashSyntax:
         | 
| 37 | 
            +
              EnforcedStyle: ruby19_no_mixed_keys
         | 
| 38 | 
            +
              Exclude:
         | 
| 39 | 
            +
                - "**/*.rake"
         | 
| 40 | 
            +
                - "Rakefile"
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            Metrics/LineLength:
         | 
| 43 | 
            +
              Max: 160
         | 
| 44 | 
            +
              Exclude:
         | 
| 45 | 
            +
                - "db/migrate/*.rb"
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            NumericLiterals:
         | 
| 48 | 
            +
              MinDigits: 7
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            Lint/AssignmentInCondition:
         | 
| 51 | 
            +
              Enabled: false
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            Lint/BlockAlignment:
         | 
| 54 | 
            +
              Enabled: false
         | 
| 55 | 
            +
             | 
| 56 | 
            +
            Metrics/MethodLength:
         | 
| 57 | 
            +
              Max: 12
         | 
| 58 | 
            +
             | 
| 59 | 
            +
            FileName:
         | 
| 60 | 
            +
              Exclude:
         | 
| 61 | 
            +
                - 'lib/activerecord-indexhint.rb'
         | 
| 62 | 
            +
                - 'spec/tasks/activerecord-indexhint_spec.rb'
         | 
    
        data/.ruby-version
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            2.2.3
         | 
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            Copyright (c) 2015 hirocaster
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            MIT License
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 6 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 7 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 8 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 9 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 10 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 11 | 
            +
            the following conditions:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 14 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 17 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 18 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 19 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 20 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 21 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 22 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,45 @@ | |
| 1 | 
            +
            # Activerecord::Indexhint
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            [](https://travis-ci.org/hirocaster/activerecord-indexhint) [](https://coveralls.io/github/hirocaster/activerecord-slave?branch=master) [](https://codeclimate.com/github/hirocaster/activerecord-indexhint) [](https://gemnasium.com/hirocaster/activerecord-indexhint)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Add method, index hint(use/ignore/force index) for ActiveRecord(MySQL).
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            ## Installation
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            Add this line to your application's Gemfile:
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                gem 'activerecord-indexhint'
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            And then execute:
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                $ bundle
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            Or install it yourself as:
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                $ gem install activerecord-indexhint
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            ## Usage
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            ```ruby
         | 
| 24 | 
            +
            class User < ActiveRecord::Base
         | 
| 25 | 
            +
            end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            index_name = "index_users_on_name"
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            User.use_index(index_name).where(name: "foo")
         | 
| 30 | 
            +
            # => "SELECT `users`.* FROM `users` USE INDEX (index_users_on_name) WHERE `users`.`name` = 'foo'"
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            User.ignore_index(index_name).where(name: "foo")
         | 
| 33 | 
            +
            # => "SELECT `users`.* FROM `users` IGNORE INDEX (index_users_on_name) WHERE `users`.`name` = 'foo'"
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            User.force_index(index_name).where(name: "foo")
         | 
| 36 | 
            +
            # => "SELECT `users`.* FROM `users` FORCE INDEX (index_users_on_name) WHERE `users`.`name` = 'foo'"
         | 
| 37 | 
            +
            ```
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            ## Contributing
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            1. Fork it ( http://github.com/hirocaster/activerecord-indexhint/fork )
         | 
| 42 | 
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         | 
| 43 | 
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         | 
| 44 | 
            +
            4. Push to the branch (`git push origin my-new-feature`)
         | 
| 45 | 
            +
            5. Create new Pull Request
         | 
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            require "bundler/gem_tasks"
         | 
| @@ -0,0 +1,37 @@ | |
| 1 | 
            +
            # coding: utf-8
         | 
| 2 | 
            +
            lib = File.expand_path("../lib", __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
            require "active_record/index_hint/version"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |spec|
         | 
| 7 | 
            +
              spec.name          = "activerecord-indexhint"
         | 
| 8 | 
            +
              spec.version       = ActiveRecord::IndexHint::VERSION
         | 
| 9 | 
            +
              spec.authors       = ["hirocaster"]
         | 
| 10 | 
            +
              spec.email         = ["hohtsuka@gmail.com"]
         | 
| 11 | 
            +
              spec.summary       = "Add index hints method(use/ignore/force index) to ActiveRecord"
         | 
| 12 | 
            +
              spec.description   = "Add index hints method(use/ignore/force index) to ActiveRecord"
         | 
| 13 | 
            +
              spec.homepage      = ""
         | 
| 14 | 
            +
              spec.license       = "MIT"
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              spec.files         = `git ls-files -z`.split("\x0")
         | 
| 17 | 
            +
              spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         | 
| 18 | 
            +
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         | 
| 19 | 
            +
              spec.require_paths = ["lib"]
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              spec.required_ruby_version = ">= 2.0"
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              spec.add_dependency "activerecord", ">= 4.1.0"
         | 
| 24 | 
            +
              spec.add_dependency "activesupport"
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              spec.add_development_dependency "bundler", "~> 1.5"
         | 
| 27 | 
            +
              spec.add_development_dependency "rake"
         | 
| 28 | 
            +
              spec.add_development_dependency "rspec"
         | 
| 29 | 
            +
              spec.add_development_dependency "pry"
         | 
| 30 | 
            +
              spec.add_development_dependency "pry-byebug"
         | 
| 31 | 
            +
              spec.add_development_dependency "awesome_print"
         | 
| 32 | 
            +
              spec.add_development_dependency "mysql2"
         | 
| 33 | 
            +
              spec.add_development_dependency "database_rewinder"
         | 
| 34 | 
            +
              spec.add_development_dependency "coveralls"
         | 
| 35 | 
            +
              spec.add_development_dependency "simplecov"
         | 
| 36 | 
            +
              spec.add_development_dependency "codeclimate-test-reporter"
         | 
| 37 | 
            +
            end
         | 
| @@ -0,0 +1,38 @@ | |
| 1 | 
            +
            require "active_support/concern"
         | 
| 2 | 
            +
            require "active_support/core_ext"
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module ActiveRecord
         | 
| 5 | 
            +
              module IndexHint
         | 
| 6 | 
            +
                module Model
         | 
| 7 | 
            +
                  extend ActiveSupport::Concern
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  module ClassMethods
         | 
| 10 | 
            +
                    def use_index(*index_names)
         | 
| 11 | 
            +
                      from_index :use, *index_names
         | 
| 12 | 
            +
                    end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                    def ignore_index(*index_names)
         | 
| 15 | 
            +
                      ignore_indexes = validate_index_lists(*index_names)
         | 
| 16 | 
            +
                      from_index :ignore, *ignore_indexes
         | 
| 17 | 
            +
                    end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    def force_index(*index_names)
         | 
| 20 | 
            +
                      force_indexes = validate_index_lists(*index_names)
         | 
| 21 | 
            +
                      from_index :force, *force_indexes
         | 
| 22 | 
            +
                    end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                    private
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                      def validate_index_lists(*index_names)
         | 
| 27 | 
            +
                        index_lists = index_names.compact
         | 
| 28 | 
            +
                        raise ActiveRecord::IndexHint::StatementInvalid, "You have an error in your SQL syntax; Please, set index_names" if index_lists.blank?
         | 
| 29 | 
            +
                        index_lists
         | 
| 30 | 
            +
                      end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                      def from_index(index_hint, *index_lists)
         | 
| 33 | 
            +
                        from "#{quoted_table_name} #{index_hint.upcase} INDEX (#{index_lists.join ', '})"
         | 
| 34 | 
            +
                      end
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
            end
         | 
| @@ -0,0 +1,11 @@ | |
| 1 | 
            +
            require "active_support/lazy_load_hooks"
         | 
| 2 | 
            +
            require "active_record"
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            require "active_record/index_hint/version"
         | 
| 5 | 
            +
            require "active_record/index_hint/errors"
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            ActiveSupport.on_load(:active_record) do
         | 
| 8 | 
            +
              require "active_record/index_hint/model"
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              ActiveRecord::Base.send(:include, ActiveRecord::IndexHint::Model)
         | 
| 11 | 
            +
            end
         | 
| @@ -0,0 +1,85 @@ | |
| 1 | 
            +
            describe "ActiveRecord::IndexHint::Model" do
         | 
| 2 | 
            +
              describe ".create" do
         | 
| 3 | 
            +
                it "return Model object" do
         | 
| 4 | 
            +
                  expect(User.create name: "foobar").to be_a User
         | 
| 5 | 
            +
                end
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              describe ".use_index" do
         | 
| 9 | 
            +
                it "has use_index method" do
         | 
| 10 | 
            +
                  expect(User.respond_to? :use_index).to be true
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                context "Give non hint, not use index" do
         | 
| 14 | 
            +
                  it "`USE INDEX` in SQL Query" do
         | 
| 15 | 
            +
                    expect(User.use_index(nil).to_sql).to be_include "FROM `users` USE INDEX ()"
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                context "Give one hint" do
         | 
| 20 | 
            +
                  it "`USE INDEX` in SQL Query" do
         | 
| 21 | 
            +
                    expect(User.use_index("PRIMARY").to_sql).to be_include "FROM `users` USE INDEX (PRIMARY)"
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                context "Give two hint" do
         | 
| 26 | 
            +
                  it "`USE INDEX` in SQL Query" do
         | 
| 27 | 
            +
                    expect(User.use_index("index_users_on_name", "PRIMARY").to_sql).to be_include "FROM `users` USE INDEX (index_users_on_name, PRIMARY)"
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              describe ".ignore_index" do
         | 
| 33 | 
            +
                it "has ignore_index method" do
         | 
| 34 | 
            +
                  expect(User.respond_to? :ignore_index).to be true
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                context "Give non hint" do
         | 
| 38 | 
            +
                  it "raise SQL Syntax Error" do
         | 
| 39 | 
            +
                    expect { User.ignore_index nil }.to raise_error ActiveRecord::IndexHint::StatementInvalid
         | 
| 40 | 
            +
                  end
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                context "Give two hint" do
         | 
| 44 | 
            +
                  it "`IGNORE INDEX` in SQL Query" do
         | 
| 45 | 
            +
                    expect(User.ignore_index("index_users_on_name", "PRIMARY").to_sql).to be_include "FROM `users` IGNORE INDEX (index_users_on_name, PRIMARY)"
         | 
| 46 | 
            +
                  end
         | 
| 47 | 
            +
                end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                context "nil in hints" do
         | 
| 50 | 
            +
                  it "Deleted nil, `IGNORE INDEX` in SQL Query" do
         | 
| 51 | 
            +
                    expect(User.ignore_index("index_users_on_name", nil, "PRIMARY").to_sql).to be_include "FROM `users` IGNORE INDEX (index_users_on_name, PRIMARY)"
         | 
| 52 | 
            +
                  end
         | 
| 53 | 
            +
                end
         | 
| 54 | 
            +
              end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
              describe ".force_index" do
         | 
| 57 | 
            +
                it "has force_index method" do
         | 
| 58 | 
            +
                  expect(User.respond_to? :force_index).to be true
         | 
| 59 | 
            +
                end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                context "Give non hint" do
         | 
| 62 | 
            +
                  it "raise SQL Syntax Error" do
         | 
| 63 | 
            +
                    expect { User.force_index nil }.to raise_error ActiveRecord::IndexHint::StatementInvalid
         | 
| 64 | 
            +
                  end
         | 
| 65 | 
            +
                end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                context "Give one hint" do
         | 
| 68 | 
            +
                  it "`FORCE INDEX` in SQL Query" do
         | 
| 69 | 
            +
                    expect(User.force_index("PRIMARY").to_sql).to be_include "FROM `users` FORCE INDEX (PRIMARY)"
         | 
| 70 | 
            +
                  end
         | 
| 71 | 
            +
                end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                context "Give two hint" do
         | 
| 74 | 
            +
                  it "`FORCE INDEX` in SQL Query" do
         | 
| 75 | 
            +
                    expect(User.force_index("index_users_on_name", "PRIMARY").to_sql).to be_include "FROM `users` FORCE INDEX (index_users_on_name, PRIMARY)"
         | 
| 76 | 
            +
                  end
         | 
| 77 | 
            +
                end
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                context "nil in hints" do
         | 
| 80 | 
            +
                  it "Deleted nil, `FORCE INDEX` in SQL Query" do
         | 
| 81 | 
            +
                    expect(User.force_index("index_users_on_name", nil, "PRIMARY").to_sql).to be_include "FROM `users` FORCE INDEX (index_users_on_name, PRIMARY)"
         | 
| 82 | 
            +
                  end
         | 
| 83 | 
            +
                end
         | 
| 84 | 
            +
              end
         | 
| 85 | 
            +
            end
         | 
    
        data/spec/models.rb
    ADDED
    
    | @@ -0,0 +1,10 @@ | |
| 1 | 
            +
            base = { "adapter" => "mysql2", "encoding" => "utf8", "pool" => 5, "username" => "root", "password" => "", "host" => "127.0.0.1" }
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            ActiveRecord::Base.configurations = {
         | 
| 4 | 
            +
              "test" => base.merge("database" => "test")
         | 
| 5 | 
            +
            }
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            ActiveRecord::Base.establish_connection(:test)
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            class User < ActiveRecord::Base
         | 
| 10 | 
            +
            end
         | 
    
        data/spec/schema.rb
    ADDED
    
    
    
        data/spec/spec_helper.rb
    ADDED
    
    | @@ -0,0 +1,55 @@ | |
| 1 | 
            +
            require "simplecov"
         | 
| 2 | 
            +
            require "coveralls"
         | 
| 3 | 
            +
            require "codeclimate-test-reporter"
         | 
| 4 | 
            +
            Coveralls.wear!
         | 
| 5 | 
            +
            SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
         | 
| 6 | 
            +
              SimpleCov::Formatter::HTMLFormatter,
         | 
| 7 | 
            +
              Coveralls::SimpleCov::Formatter,
         | 
| 8 | 
            +
              CodeClimate::TestReporter::Formatter
         | 
| 9 | 
            +
            ]
         | 
| 10 | 
            +
            SimpleCov.start do
         | 
| 11 | 
            +
              add_filter "/spec"
         | 
| 12 | 
            +
              add_filter "/vendor"
         | 
| 13 | 
            +
            end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
         | 
| 16 | 
            +
            require "activerecord-indexhint"
         | 
| 17 | 
            +
            require "pry"
         | 
| 18 | 
            +
            require "pry-byebug"
         | 
| 19 | 
            +
            require "awesome_print"
         | 
| 20 | 
            +
            require "database_rewinder"
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            require_relative "models"
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            log_directry = File.expand_path("../../log/", __FILE__)
         | 
| 25 | 
            +
            Dir.mkdir log_directry unless Dir.exist? log_directry
         | 
| 26 | 
            +
            ActiveRecord::Base.logger = Logger.new("#{log_directry}/test.log")
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            RSpec.configure do |config|
         | 
| 29 | 
            +
              config.profile_examples = 10
         | 
| 30 | 
            +
              config.order = :random
         | 
| 31 | 
            +
              Kernel.srand config.seed
         | 
| 32 | 
            +
             | 
| 33 | 
            +
              config.before(:suite) do
         | 
| 34 | 
            +
                ActiveRecord::Tasks::DatabaseTasks.db_dir = File.expand_path "..", __FILE__
         | 
| 35 | 
            +
                ActiveRecord::Tasks::DatabaseTasks.root   = File.expand_path "../..", __FILE__
         | 
| 36 | 
            +
                ActiveRecord::Tasks::DatabaseTasks.env    = "test"
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                configuration = ActiveRecord::Base.configurations["test"]
         | 
| 39 | 
            +
                ActiveRecord::Tasks::DatabaseTasks.drop(configuration)
         | 
| 40 | 
            +
                ActiveRecord::Tasks::DatabaseTasks.create(configuration)
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                ActiveRecord::Tasks::DatabaseTasks.load_schema_for configuration, :ruby
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                DatabaseRewinder["test"]
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
              config.after(:each) do
         | 
| 48 | 
            +
                DatabaseRewinder.clean
         | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
              config.after(:suite) do
         | 
| 52 | 
            +
                configuration = ActiveRecord::Base.configurations["test"]
         | 
| 53 | 
            +
                ActiveRecord::Tasks::DatabaseTasks.drop(configuration)
         | 
| 54 | 
            +
              end
         | 
| 55 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,251 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: activerecord-indexhint
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.1
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - hirocaster
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2015-09-08 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: activerecord
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - ">="
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: 4.1.0
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - ">="
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: 4.1.0
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: activesupport
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - ">="
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0'
         | 
| 34 | 
            +
              type: :runtime
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - ">="
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '0'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: bundler
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - "~>"
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '1.5'
         | 
| 48 | 
            +
              type: :development
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - "~>"
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '1.5'
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: rake
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ">="
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '0'
         | 
| 62 | 
            +
              type: :development
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - ">="
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: '0'
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: rspec
         | 
| 71 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
                requirements:
         | 
| 73 | 
            +
                - - ">="
         | 
| 74 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            +
                    version: '0'
         | 
| 76 | 
            +
              type: :development
         | 
| 77 | 
            +
              prerelease: false
         | 
| 78 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 | 
            +
                requirements:
         | 
| 80 | 
            +
                - - ">="
         | 
| 81 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            +
                    version: '0'
         | 
| 83 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 84 | 
            +
              name: pry
         | 
| 85 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 | 
            +
                requirements:
         | 
| 87 | 
            +
                - - ">="
         | 
| 88 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 89 | 
            +
                    version: '0'
         | 
| 90 | 
            +
              type: :development
         | 
| 91 | 
            +
              prerelease: false
         | 
| 92 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 | 
            +
                requirements:
         | 
| 94 | 
            +
                - - ">="
         | 
| 95 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 96 | 
            +
                    version: '0'
         | 
| 97 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 98 | 
            +
              name: pry-byebug
         | 
| 99 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 100 | 
            +
                requirements:
         | 
| 101 | 
            +
                - - ">="
         | 
| 102 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 103 | 
            +
                    version: '0'
         | 
| 104 | 
            +
              type: :development
         | 
| 105 | 
            +
              prerelease: false
         | 
| 106 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 107 | 
            +
                requirements:
         | 
| 108 | 
            +
                - - ">="
         | 
| 109 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            +
                    version: '0'
         | 
| 111 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 112 | 
            +
              name: awesome_print
         | 
| 113 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 114 | 
            +
                requirements:
         | 
| 115 | 
            +
                - - ">="
         | 
| 116 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                    version: '0'
         | 
| 118 | 
            +
              type: :development
         | 
| 119 | 
            +
              prerelease: false
         | 
| 120 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 | 
            +
                requirements:
         | 
| 122 | 
            +
                - - ">="
         | 
| 123 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 124 | 
            +
                    version: '0'
         | 
| 125 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 126 | 
            +
              name: mysql2
         | 
| 127 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 128 | 
            +
                requirements:
         | 
| 129 | 
            +
                - - ">="
         | 
| 130 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 131 | 
            +
                    version: '0'
         | 
| 132 | 
            +
              type: :development
         | 
| 133 | 
            +
              prerelease: false
         | 
| 134 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 135 | 
            +
                requirements:
         | 
| 136 | 
            +
                - - ">="
         | 
| 137 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 138 | 
            +
                    version: '0'
         | 
| 139 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 140 | 
            +
              name: database_rewinder
         | 
| 141 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 142 | 
            +
                requirements:
         | 
| 143 | 
            +
                - - ">="
         | 
| 144 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 145 | 
            +
                    version: '0'
         | 
| 146 | 
            +
              type: :development
         | 
| 147 | 
            +
              prerelease: false
         | 
| 148 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 149 | 
            +
                requirements:
         | 
| 150 | 
            +
                - - ">="
         | 
| 151 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 152 | 
            +
                    version: '0'
         | 
| 153 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 154 | 
            +
              name: coveralls
         | 
| 155 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 156 | 
            +
                requirements:
         | 
| 157 | 
            +
                - - ">="
         | 
| 158 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 159 | 
            +
                    version: '0'
         | 
| 160 | 
            +
              type: :development
         | 
| 161 | 
            +
              prerelease: false
         | 
| 162 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 163 | 
            +
                requirements:
         | 
| 164 | 
            +
                - - ">="
         | 
| 165 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 166 | 
            +
                    version: '0'
         | 
| 167 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 168 | 
            +
              name: simplecov
         | 
| 169 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 170 | 
            +
                requirements:
         | 
| 171 | 
            +
                - - ">="
         | 
| 172 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 173 | 
            +
                    version: '0'
         | 
| 174 | 
            +
              type: :development
         | 
| 175 | 
            +
              prerelease: false
         | 
| 176 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 177 | 
            +
                requirements:
         | 
| 178 | 
            +
                - - ">="
         | 
| 179 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 180 | 
            +
                    version: '0'
         | 
| 181 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 182 | 
            +
              name: codeclimate-test-reporter
         | 
| 183 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 184 | 
            +
                requirements:
         | 
| 185 | 
            +
                - - ">="
         | 
| 186 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 187 | 
            +
                    version: '0'
         | 
| 188 | 
            +
              type: :development
         | 
| 189 | 
            +
              prerelease: false
         | 
| 190 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 191 | 
            +
                requirements:
         | 
| 192 | 
            +
                - - ">="
         | 
| 193 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 194 | 
            +
                    version: '0'
         | 
| 195 | 
            +
            description: Add index hints method(use/ignore/force index) to ActiveRecord
         | 
| 196 | 
            +
            email:
         | 
| 197 | 
            +
            - hohtsuka@gmail.com
         | 
| 198 | 
            +
            executables: []
         | 
| 199 | 
            +
            extensions: []
         | 
| 200 | 
            +
            extra_rdoc_files: []
         | 
| 201 | 
            +
            files:
         | 
| 202 | 
            +
            - ".gitignore"
         | 
| 203 | 
            +
            - ".hound.yml"
         | 
| 204 | 
            +
            - ".rspec"
         | 
| 205 | 
            +
            - ".rubocop.yml"
         | 
| 206 | 
            +
            - ".ruby-version"
         | 
| 207 | 
            +
            - ".travis.yml"
         | 
| 208 | 
            +
            - Gemfile
         | 
| 209 | 
            +
            - LICENSE.txt
         | 
| 210 | 
            +
            - README.md
         | 
| 211 | 
            +
            - Rakefile
         | 
| 212 | 
            +
            - activerecord-indexhint.gemspec
         | 
| 213 | 
            +
            - lib/active_record/index_hint/errors.rb
         | 
| 214 | 
            +
            - lib/active_record/index_hint/model.rb
         | 
| 215 | 
            +
            - lib/active_record/index_hint/version.rb
         | 
| 216 | 
            +
            - lib/activerecord-indexhint.rb
         | 
| 217 | 
            +
            - spec/active_record/index_hint/model_spec.rb
         | 
| 218 | 
            +
            - spec/active_record/index_hint/version_spec.rb
         | 
| 219 | 
            +
            - spec/models.rb
         | 
| 220 | 
            +
            - spec/schema.rb
         | 
| 221 | 
            +
            - spec/spec_helper.rb
         | 
| 222 | 
            +
            homepage: ''
         | 
| 223 | 
            +
            licenses:
         | 
| 224 | 
            +
            - MIT
         | 
| 225 | 
            +
            metadata: {}
         | 
| 226 | 
            +
            post_install_message: 
         | 
| 227 | 
            +
            rdoc_options: []
         | 
| 228 | 
            +
            require_paths:
         | 
| 229 | 
            +
            - lib
         | 
| 230 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 231 | 
            +
              requirements:
         | 
| 232 | 
            +
              - - ">="
         | 
| 233 | 
            +
                - !ruby/object:Gem::Version
         | 
| 234 | 
            +
                  version: '2.0'
         | 
| 235 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 236 | 
            +
              requirements:
         | 
| 237 | 
            +
              - - ">="
         | 
| 238 | 
            +
                - !ruby/object:Gem::Version
         | 
| 239 | 
            +
                  version: '0'
         | 
| 240 | 
            +
            requirements: []
         | 
| 241 | 
            +
            rubyforge_project: 
         | 
| 242 | 
            +
            rubygems_version: 2.4.5.1
         | 
| 243 | 
            +
            signing_key: 
         | 
| 244 | 
            +
            specification_version: 4
         | 
| 245 | 
            +
            summary: Add index hints method(use/ignore/force index) to ActiveRecord
         | 
| 246 | 
            +
            test_files:
         | 
| 247 | 
            +
            - spec/active_record/index_hint/model_spec.rb
         | 
| 248 | 
            +
            - spec/active_record/index_hint/version_spec.rb
         | 
| 249 | 
            +
            - spec/models.rb
         | 
| 250 | 
            +
            - spec/schema.rb
         | 
| 251 | 
            +
            - spec/spec_helper.rb
         |