diff --git a/.travis.yml b/.travis.yml index d5aa731..7003de1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ language: ruby cache: bundler -before_install: gem update bundler +before_install: + - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true + - gem install bundler -v '< 2' gemfile: - gemfiles/3.2.gemfile diff --git a/gemfiles/3.2.gemfile b/gemfiles/3.2.gemfile index 16aa781..b497013 100644 --- a/gemfiles/3.2.gemfile +++ b/gemfiles/3.2.gemfile @@ -1,7 +1,9 @@ +# frozen_string_literal: true + # This file was generated by Appraisal -source "https://rubygems.org" +source 'https://rubygems.org' -gem "activerecord", "~> 3.2.21" +gem 'activerecord', '~> 3.2.21' -gemspec :path => "../" +gemspec path: '../' diff --git a/gemfiles/4.0.gemfile b/gemfiles/4.0.gemfile index 8041b59..50d72ed 100644 --- a/gemfiles/4.0.gemfile +++ b/gemfiles/4.0.gemfile @@ -1,7 +1,9 @@ +# frozen_string_literal: true + # This file was generated by Appraisal -source "https://rubygems.org" +source 'https://rubygems.org' -gem "activerecord", "~> 4.0.0" +gem 'activerecord', '~> 4.0.0' -gemspec :path => "../" +gemspec path: '../' diff --git a/gemfiles/4.1.gemfile b/gemfiles/4.1.gemfile index 5a00994..6fbbfc6 100644 --- a/gemfiles/4.1.gemfile +++ b/gemfiles/4.1.gemfile @@ -1,7 +1,9 @@ +# frozen_string_literal: true + # This file was generated by Appraisal -source "https://rubygems.org" +source 'https://rubygems.org' -gem "activerecord", "~> 4.1.0" +gem 'activerecord', '~> 4.1.0' -gemspec :path => "../" +gemspec path: '../' diff --git a/gemfiles/4.2.gemfile b/gemfiles/4.2.gemfile index 88e5a3c..9c45f5b 100644 --- a/gemfiles/4.2.gemfile +++ b/gemfiles/4.2.gemfile @@ -1,7 +1,9 @@ +# frozen_string_literal: true + # This file was generated by Appraisal -source "https://rubygems.org" +source 'https://rubygems.org' -gem "activerecord", "~> 4.2.0" +gem 'activerecord', '~> 4.2.0' -gemspec :path => "../" +gemspec path: '../' diff --git a/gemfiles/5.0.gemfile b/gemfiles/5.0.gemfile index b9c1ad0..53a444a 100644 --- a/gemfiles/5.0.gemfile +++ b/gemfiles/5.0.gemfile @@ -1,7 +1,9 @@ +# frozen_string_literal: true + # This file was generated by Appraisal -source "https://rubygems.org" +source 'https://rubygems.org' -gem "activerecord", "~> 5.0.0" +gem 'activerecord', '~> 5.0.0' -gemspec :path => "../" +gemspec path: '../' diff --git a/lib/sql_query.rb b/lib/sql_query.rb index 3c07c7a..30a5365 100644 --- a/lib/sql_query.rb +++ b/lib/sql_query.rb @@ -9,6 +9,7 @@ def initialize(file_name, options = {}) unless file_name.is_a?(String) || file_name.is_a?(Symbol) raise ArgumentError, 'SQL file name should be String or Symbol' end + @sql_filename = file_name @options = options @connection = options.try(:delete, :db_connection) || @@ -35,7 +36,7 @@ def pretty_sql pretty(sql.dup) end - def quote(value) # rubocop:disable Rails/Delegate + def quote(value) connection.quote(value) end @@ -90,6 +91,7 @@ def value.inspect def prepare_variables return if @options.blank? + @options.each do |k, v| instance_variable_set("@#{k}", v) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 814b801..0d718cc 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,7 +12,7 @@ require 'active_record' require 'sql_query' -require 'pry' +#require 'pry' SqlQuery.configure do |config| config.path = '/spec/sql_queries' diff --git a/sql_query.gemspec b/sql_query.gemspec index 18fca9e..1edf2db 100644 --- a/sql_query.gemspec +++ b/sql_query.gemspec @@ -1,7 +1,6 @@ -# coding: utf-8 # frozen_string_literal: true -lib = File.expand_path('../lib', __FILE__) +lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) Gem::Specification.new do |spec| @@ -24,14 +23,13 @@ Gem::Specification.new do |spec| spec.required_ruby_version = '>= 1.9.3' - spec.add_dependency 'activerecord', '>= 3.2' + spec.add_dependency 'activerecord', '>= 3.2', '< 6.0' spec.add_development_dependency 'bundler', '~> 1.13' + spec.add_development_dependency 'pg', '~> 0.18' spec.add_development_dependency 'rake', '~> 11.3' spec.add_development_dependency 'rspec', '~> 3.4' - spec.add_development_dependency 'pg', '~> 0.18' - spec.add_development_dependency 'pry', '~> 0.10' spec.add_development_dependency 'with_model', '~> 1.2' - spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.4' spec.add_development_dependency 'appraisal' - spec.add_development_dependency 'rubocop' + spec.add_development_dependency 'rubocop', '<= 0.81' + spec.add_development_dependency 'simplecov' end