sql_query 0.4.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8996df6ea13c7ce6e1b4ffb04d2137d537852326
4
- data.tar.gz: 776b12b91ab006e9ec2170268cfe2cb258f56603
3
+ metadata.gz: af40c82f9dec121a1f1c9eafe7fe38dcefc6ef83
4
+ data.tar.gz: 246c7a3a2a21c02e4385d098f90d2e80383f50cd
5
5
  SHA512:
6
- metadata.gz: 0d535b70950bfd98f169873ff9471453296e7eb4fb045dc0cf525d9563153022fa8e743aed56a00533ae67d62fc4ceeda4089d4483638b988a7922077c9dfd29
7
- data.tar.gz: 8615b61a80e9d78e6492404437bf0c6195ab241ec44be1e50f4544b2994c224c9c16982860886157e7659d3e25142a27b15bb3e9a361ea198f51f7b2200d22a3
6
+ metadata.gz: 748600bc36576a006cccc698dfda7f7796d12ba96ff005098fd130b1264f0435b924c6d1263b84c535c2c9407d5b6c1d130397ac953418ca06a6ce0e7f7debdf
7
+ data.tar.gz: 15857961b369f7acc40cd3bab7d155907b41973a3508fcae1d9c021db4ef24eb0a2d49d76376ecaa5aa2f8809918722d2e18cbe21b2086c5914ae91f79fe8605
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ sql_query
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.3
data/.travis.yml CHANGED
@@ -1,24 +1,28 @@
1
1
  language: ruby
2
+ cache: bundler
3
+ before_install:
4
+ - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
5
+ - gem install bundler -v '< 2'
6
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
7
+ - chmod +x ./cc-test-reporter
2
8
 
3
9
  gemfile:
4
10
  - gemfiles/3.2.gemfile
5
11
  - gemfiles/4.0.gemfile
6
12
  - gemfiles/4.1.gemfile
7
13
  - gemfiles/4.2.gemfile
14
+ - gemfiles/5.0.gemfile
8
15
 
9
16
  rvm:
10
- - '1.9.3'
11
- - '2.0.0'
12
- - '2.1.5'
13
- - '2.2.3'
17
+ - '2.3.3'
14
18
 
15
19
  addons:
16
- postgresql: '9.3'
17
- code_climate:
18
- repo_token: 743bf63d7a422064551b35931628682c6cad81a30743edee7ff9ea8af061397d
20
+ postgresql: '9.4'
19
21
 
20
22
  env:
21
23
  - BUILDER=travis
22
-
23
24
  before_script:
24
25
  - psql -c 'create database travis_ci_test;' -U postgres
26
+ - ./cc-test-reporter before-build
27
+ after_script:
28
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT -r 743bf63d7a422064551b35931628682c6cad81a30743edee7ff9ea8af061397d
data/Appraisals CHANGED
@@ -1,15 +1,21 @@
1
- appraise "3.2" do
2
- gem "activerecord", "~> 3.2.21"
1
+ # frozen_string_literal: true
2
+
3
+ appraise '3.2' do
4
+ gem 'activerecord', '~> 3.2.21'
5
+ end
6
+
7
+ appraise '4.0' do
8
+ gem 'activerecord', '~> 4.0.0'
3
9
  end
4
10
 
5
- appraise "4.0" do
6
- gem "activerecord", "~> 4.0.0"
11
+ appraise '4.1' do
12
+ gem 'activerecord', '~> 4.1.0'
7
13
  end
8
14
 
9
- appraise "4.1" do
10
- gem "activerecord", "~> 4.1.0"
15
+ appraise '4.2' do
16
+ gem 'activerecord', '~> 4.2.0'
11
17
  end
12
18
 
13
- appraise "4.2" do
14
- gem "activerecord", "~> 4.2.0"
19
+ appraise '5.0' do
20
+ gem 'activerecord', '~> 5.0.0'
15
21
  end
data/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SqlQuery change log
2
2
 
3
- ## 0.4.1 / Unreleased
3
+ ## 0.7.2 / Unreleased
4
4
 
5
5
  * [Added]
6
6
 
@@ -10,6 +10,24 @@
10
10
 
11
11
  * [Fixed]
12
12
 
13
+ ## 0.7.1 / 2021-12-14
14
+
15
+ * [Added] rails 6.1 as supported version https://github.com/sufleR/sql_query/pull/10
16
+
17
+
18
+ ## 0.7.0 / 2020-08-04
19
+
20
+ * [Added] support for exec_query from ActiveRecord https://github.com/sufleR/sql_query/pull/7
21
+
22
+
23
+ ## 0.6.0 / 2017-03-30
24
+
25
+ * [Added] possibility to override path where gem will look for sql file.
26
+
27
+ ## 0.5.0 / 2016-04-26
28
+
29
+ * [Added] possibility to overwrite default connection class and connection directly using db_connection option.
30
+
13
31
  ## 0.4.0 / 2016-01-20
14
32
 
15
33
  * [Added] execute will accept boolean attribute.
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in sql_query.gemspec
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/sql_query.svg)](http://badge.fury.io/rb/sql_query)
2
- [![Dependency Status](https://gemnasium.com/sufleR/sql_query.svg)](https://gemnasium.com/sufleR/sql_query)
3
2
  [![Code Climate](https://codeclimate.com/github/sufleR/sql_query/badges/gpa.svg)](https://codeclimate.com/github/sufleR/sql_query)
4
3
  [![Test Coverage](https://codeclimate.com/github/sufleR/sql_query/badges/coverage.svg)](https://codeclimate.com/github/sufleR/sql_query)
5
4
  [![Build Status](https://travis-ci.org/sufleR/sql_query.svg?branch=master)](https://travis-ci.org/sufleR/sql_query)
@@ -79,9 +78,15 @@ Example:
79
78
  SqlQuery.new('player/get_by_email', email: 'e@mail.dev')
80
79
  ```
81
80
 
81
+ #### Special options
82
+
83
+ * db_connection - If you want to change default connection to database you may do it for every query execution using this option.
84
+ * sql_file_path - it will override default path where gem will look for sql file.
85
+
82
86
  ### Methods
83
87
 
84
- - **execute** - executes query and returns result data. It accepts boolean argument. When argument is false it will raw sql query instead of prepared_for_logs.
88
+ - **execute** - executes query and returns result data. It accepts boolean argument. When argument is false it will run raw sql query instead of prepared_for_logs.
89
+ - **exec_query** - similar to `#execute` but with data returned via `ActiveRecord::Result`.
85
90
  - **explain** - runs explain for SQL from template
86
91
  - **sql** - returns SQL string
87
92
  - **pretty_sql** - returns SQL string prettier to read in console
@@ -89,14 +94,19 @@ SqlQuery.new('player/get_by_email', email: 'e@mail.dev')
89
94
 
90
95
  ### Configuration
91
96
 
92
- If you don't like default path to your queries you can configure it in initializer.
93
-
94
97
  ```ruby
95
98
  # config/initializers/sql_query.rb
96
99
  SqlQuery.configure do |config|
97
100
  config.path = '/app/sql_templates'
101
+ config.adapter = ActiveRecord::Base
98
102
  end
99
103
  ```
104
+
105
+ #### Configuration options
106
+ * path - If you don't like default path to your queries you can change it here.
107
+
108
+ * adapter - class which implements connection method.
109
+
100
110
  ### Partials
101
111
 
102
112
  You can prepare part of sql query in partial file and reuse it in multiple queries.
@@ -131,3 +141,10 @@ If you have some examples to share please make pull request.
131
141
  3. Commit your changes (`git commit -am 'Add some feature'`)
132
142
  4. Push to the branch (`git push origin my-new-feature`)
133
143
  5. Create a new Pull Request
144
+
145
+ To run specs, setup Postgres with the following:
146
+
147
+ ```sql
148
+ CREATE DATABASE sqlquery;
149
+ CREATE ROLE sqlquery WITH LOGIN;
150
+ ```
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
 
4
- task :default => :spec
6
+ task default: :spec
5
7
 
6
8
  RSpec::Core::RakeTask.new
data/gemfiles/3.2.gemfile CHANGED
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file was generated by Appraisal
2
4
 
3
- source "https://rubygems.org"
5
+ source 'https://rubygems.org'
4
6
 
5
- gem "activerecord", "~> 3.2.21"
7
+ gem 'activerecord', '~> 3.2.21'
6
8
 
7
- gemspec :path => "../"
9
+ gemspec path: '../'
data/gemfiles/4.0.gemfile CHANGED
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file was generated by Appraisal
2
4
 
3
- source "https://rubygems.org"
5
+ source 'https://rubygems.org'
4
6
 
5
- gem "activerecord", "~> 4.0.0"
7
+ gem 'activerecord', '~> 4.0.0'
6
8
 
7
- gemspec :path => "../"
9
+ gemspec path: '../'
data/gemfiles/4.1.gemfile CHANGED
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file was generated by Appraisal
2
4
 
3
- source "https://rubygems.org"
5
+ source 'https://rubygems.org'
4
6
 
5
- gem "activerecord", "~> 4.1.0"
7
+ gem 'activerecord', '~> 4.1.0'
6
8
 
7
- gemspec :path => "../"
9
+ gemspec path: '../'
data/gemfiles/4.2.gemfile CHANGED
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file was generated by Appraisal
2
4
 
3
- source "https://rubygems.org"
5
+ source 'https://rubygems.org'
4
6
 
5
- gem "activerecord", "~> 4.2.0"
7
+ gem 'activerecord', '~> 4.2.0'
6
8
 
7
- gemspec :path => "../"
9
+ gemspec path: '../'
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by Appraisal
4
+
5
+ source 'https://rubygems.org'
6
+
7
+ gem 'activerecord', '~> 5.0.0'
8
+
9
+ gemspec path: '../'
data/lib/sql_query.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'erb'
2
4
 
3
5
  class SqlQuery
@@ -5,16 +7,18 @@ class SqlQuery
5
7
 
6
8
  def initialize(file_name, options = {})
7
9
  unless file_name.is_a?(String) || file_name.is_a?(Symbol)
8
- fail ArgumentError, 'SQL file name should be String or Symbol'
10
+ raise ArgumentError, 'SQL file name should be String or Symbol'
9
11
  end
12
+
10
13
  @sql_filename = file_name
11
14
  @options = options
15
+ @connection = options.try(:delete, :db_connection) ||
16
+ self.class.config.adapter.connection
12
17
  prepare_variables
13
- @connection = ActiveRecord::Base.connection
14
18
  end
15
19
 
16
20
  def explain
17
- msg = "EXPLAIN for: \n#{ sql }\n"
21
+ msg = "EXPLAIN for: \n#{sql}\n"
18
22
  msg += connection.explain(sql)
19
23
  pretty(msg)
20
24
  end
@@ -24,6 +28,11 @@ class SqlQuery
24
28
  connection.execute(to_execute).entries
25
29
  end
26
30
 
31
+ def exec_query(prepare = true)
32
+ to_execute = prepare ? prepared_for_logs : sql
33
+ connection.exec_query(to_execute).to_a
34
+ end
35
+
27
36
  def sql
28
37
  @sql ||= ERB.new(File.read(file_path)).result(binding)
29
38
  end
@@ -37,20 +46,16 @@ class SqlQuery
37
46
  end
38
47
 
39
48
  def prepared_for_logs
40
- sql.gsub(/(\n|\s)+/,' ')
49
+ sql.gsub(/(\n|\s)+/, ' ')
41
50
  end
42
51
 
43
52
  def partial(partial_name, partial_options = {})
44
53
  path, file_name = split_to_path_and_name(partial_name)
45
54
  self.class.new("#{path}/_#{file_name}",
46
- @options.merge(partial_options),
47
- ).sql
48
- end
49
-
50
- def self.config=(value)
51
- @config = value
55
+ @options.merge(partial_options)).sql
52
56
  end
53
57
 
58
+ attr_writer :config
54
59
  def self.config
55
60
  @config ||= Config.new
56
61
  end
@@ -60,10 +65,11 @@ class SqlQuery
60
65
  end
61
66
 
62
67
  class Config
63
- attr_accessor :path
68
+ attr_accessor :path, :adapter
64
69
 
65
70
  def initialize
66
71
  @path = '/app/sql_queries'
72
+ @adapter = ActiveRecord::Base
67
73
  end
68
74
  end
69
75
 
@@ -82,11 +88,15 @@ class SqlQuery
82
88
  # override inspect to be more human readable from console
83
89
  # code copy from ActiveRecord
84
90
  # https://github.com/rails/rails/blob/master/activerecord/lib/active_record/explain.rb#L30
85
- def value.inspect; self; end
91
+ def value.inspect
92
+ self
93
+ end
86
94
  value
87
95
  end
88
96
 
89
97
  def prepare_variables
98
+ return if @options.blank?
99
+
90
100
  @options.each do |k, v|
91
101
  instance_variable_set("@#{k}", v)
92
102
  end
@@ -94,18 +104,22 @@ class SqlQuery
94
104
 
95
105
  def file_path
96
106
  files = Dir.glob(path)
97
- if files.size == 0
107
+ if files.empty?
98
108
  raise "File not found: #{@sql_filename}"
99
109
  elsif files.size > 1
100
- raise "More than one file found: #{ files.join(', ')}"
110
+ raise "More than one file found: #{files.join(', ')}"
101
111
  else
102
112
  files.first
103
113
  end
104
114
  end
105
115
 
106
116
  def path
107
- root = defined?(Rails) ? Rails.root.to_s : Dir.pwd
108
- tmp_path = "#{root}#{self.class.config.path}"
117
+ if @sql_file_path.present?
118
+ tmp_path = @sql_file_path
119
+ else
120
+ root = defined?(Rails) ? Rails.root.to_s : Dir.pwd
121
+ tmp_path = "#{root}#{self.class.config.path}"
122
+ end
109
123
  tmp_path += "/#{@sql_filename}.{sql.erb,erb.sql}"
110
124
  tmp_path
111
125
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe SqlQuery::Config do
6
+ describe 'initialize' do
7
+ it 'sets path to default' do
8
+ expect(described_class.new.path).to eq('/app/sql_queries')
9
+ end
10
+
11
+ it 'sets adapter to ActiveRecord::Base' do
12
+ expect(described_class.new.adapter).to eq(ActiveRecord::Base)
13
+ end
14
+ end
15
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,16 +1,13 @@
1
- if ENV['BUILDER'] == 'travis'
2
- require "codeclimate-test-reporter"
3
- CodeClimate::TestReporter.start
4
- else
5
- require 'simplecov'
6
- SimpleCov.start do
7
- add_filter '/spec/'
8
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'simplecov'
4
+ SimpleCov.start do
5
+ add_filter '/spec/'
9
6
  end
10
7
 
11
8
  require 'active_record'
12
9
  require 'sql_query'
13
- require 'pry'
10
+ #require 'pry'
14
11
 
15
12
  SqlQuery.configure do |config|
16
13
  config.path = '/spec/sql_queries'
@@ -26,15 +23,15 @@ RSpec.configure do |config|
26
23
  end
27
24
 
28
25
  connection = if ENV['BUILDER'] == 'travis'
29
- "postgres://postgres@localhost/travis_ci_test"
26
+ 'postgres://postgres@localhost/travis_ci_test'
30
27
  else
31
- "postgres://sqlquery:sqlquery@localhost/sqlquery"
28
+ 'postgres://sqlquery:sqlquery@localhost/sqlquery'
32
29
  end
33
30
 
34
31
  ActiveRecord::Base.establish_connection(connection)
35
32
 
36
33
  ActiveRecord::Base.connection.execute(
37
- "CREATE TABLE IF NOT EXISTS players (email text);"
34
+ 'CREATE TABLE IF NOT EXISTS players (email text);'
38
35
  )
39
36
 
40
37
  config.order = :random
@@ -1,13 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe SqlQuery do
4
-
5
6
  let(:options) { { email: 'e@mail.dev' } }
6
7
  let(:file_name) { :get_player_by_email }
7
8
  let(:query) { described_class.new(file_name, options) }
8
9
 
9
- describe '#initialize' do
10
+ class Model < ActiveRecord::Base
11
+ self.abstract_class = true
12
+ end
10
13
 
14
+ describe '#initialize' do
11
15
  it 'sets instance variables for all options' do
12
16
  expect(query.instance_variable_get(:@email)).to eq 'e@mail.dev'
13
17
  end
@@ -20,11 +24,21 @@ describe SqlQuery do
20
24
  end
21
25
  end
22
26
 
23
- context 'file_name argument is not Symbol or String' do
27
+ context 'when file_name argument is not Symbol or String' do
24
28
  let(:file_name) { { do: 'something' } }
25
29
 
26
30
  it 'raises ArgumentError' do
27
- expect{ query }.to raise_error(ArgumentError, 'SQL file name should be String or Symbol')
31
+ expect { query }
32
+ .to raise_error(ArgumentError,
33
+ 'SQL file name should be String or Symbol')
34
+ end
35
+ end
36
+
37
+ context 'with db_connection option' do
38
+ let(:options) { { db_connection: Model.connection } }
39
+
40
+ it 'sets connection to requested' do
41
+ expect(query.connection).to eq(Model.connection)
28
42
  end
29
43
  end
30
44
  end
@@ -39,7 +53,8 @@ describe SqlQuery do
39
53
  let(:file_name) { :not_exists }
40
54
 
41
55
  it 'raises error' do
42
- expect{ query.send(:file_path) }.to raise_error('File not found: not_exists')
56
+ expect { query.send(:file_path) }
57
+ .to raise_error('File not found: not_exists')
43
58
  end
44
59
  end
45
60
 
@@ -47,14 +62,27 @@ describe SqlQuery do
47
62
  let(:file_name) { :duplicated }
48
63
 
49
64
  it 'raises error' do
50
- expect{ query.send(:file_path) }.to raise_error.with_message(/More than one file found:/)
65
+ expect { query.send(:file_path) }
66
+ .to raise_error.with_message(/More than one file found:/)
67
+ end
68
+ end
69
+ end
70
+
71
+ describe '#path' do
72
+ context 'when there is sql_file_path option' do
73
+ let(:options) { { sql_file_path: '/path_to_file' } }
74
+ let(:file_name) { 'fname' }
75
+
76
+ it 'sets it as dir for file' do
77
+ expect(query.send(:path)).to eq('/path_to_file/fname.{sql.erb,erb.sql}')
51
78
  end
52
79
  end
53
80
  end
54
81
 
55
82
  describe '#sql' do
56
83
  it 'returns query string' do
57
- expect(query.sql).to eq "SELECT *\nFROM players\nWHERE email = 'e@mail.dev'\n"
84
+ expect(query.sql)
85
+ .to eq("SELECT *\nFROM players\nWHERE email = 'e@mail.dev'\n")
58
86
  end
59
87
 
60
88
  context 'when file is .erb.sql' do
@@ -69,7 +97,8 @@ describe SqlQuery do
69
97
 
70
98
  describe '#pretty_sql' do
71
99
  it 'returns query string' do
72
- expect(query.pretty_sql).to eq "SELECT *\nFROM players\nWHERE email = 'e@mail.dev'\n"
100
+ expect(query.pretty_sql)
101
+ .to eq("SELECT *\nFROM players\nWHERE email = 'e@mail.dev'\n")
73
102
  end
74
103
  end
75
104
 
@@ -77,7 +106,7 @@ describe SqlQuery do
77
106
  let(:explain) { query.explain }
78
107
  it 'returns explain string' do
79
108
  expect(explain).to include 'EXPLAIN for:'
80
- expect(explain).to include "FROM players"
109
+ expect(explain).to include 'FROM players'
81
110
  expect(explain).to include "WHERE email = 'e@mail.dev'"
82
111
  expect(explain).to include 'QUERY PLAN'
83
112
  expect(explain).to include 'Seq Scan on players'
@@ -93,12 +122,12 @@ describe SqlQuery do
93
122
 
94
123
  after do
95
124
  ActiveRecord::Base.connection.execute(
96
- "DELETE FROM players"
125
+ 'DELETE FROM players'
97
126
  )
98
127
  end
99
128
 
100
129
  it 'returns data from database' do
101
- expect(query.execute).to eq [{ 'email' => 'e@mail.dev'}]
130
+ expect(query.execute).to eq [{ 'email' => 'e@mail.dev' }]
102
131
  end
103
132
 
104
133
  context 'when prepare argument is true' do
@@ -116,10 +145,54 @@ describe SqlQuery do
116
145
  end
117
146
  end
118
147
 
148
+ describe '#exec_query' do
149
+ before do
150
+ ActiveRecord::Base.connection.execute(
151
+ "INSERT INTO players (email) VALUES ('e@mail.dev')"
152
+ )
153
+ end
154
+
155
+ after do
156
+ ActiveRecord::Base.connection.execute(
157
+ 'DELETE FROM players'
158
+ )
159
+ end
160
+
161
+ it 'returns data from database' do
162
+ expect(query.exec_query).to eq [{ 'email' => 'e@mail.dev' }]
163
+ end
164
+
165
+ context 'when prepare argument is true' do
166
+ it 'executes prepared query for logs' do
167
+ expect(query).to receive(:prepared_for_logs) { '' }
168
+ query.exec_query
169
+ end
170
+ end
171
+
172
+ context 'when prepare argument is false' do
173
+ it 'executes unchanged sql query' do
174
+ expect(query).not_to receive(:prepared_for_logs)
175
+ query.exec_query(false)
176
+ end
177
+ end
178
+ end
179
+
119
180
  describe '#partial' do
120
181
  let(:file_name) { :get_player_by_email_with_template }
121
182
  it 'resolves partials as parts of sql queries' do
122
- expect(query.sql).to eq("SELECT *\nFROM players\nWHERE players.email = 'e@mail.dev'\n\n")
183
+ expect(query.sql)
184
+ .to eq("SELECT *\nFROM players\nWHERE players.email = 'e@mail.dev'\n\n")
185
+ end
186
+
187
+ context 'when partial name is string with file path' do
188
+ let(:file_name) { :get_player_by_email }
189
+
190
+ it 'should find file by whole path and _name' do
191
+ query
192
+ expect(described_class)
193
+ .to receive(:new).with('some/path/to/_file.sql', options) { query }
194
+ query.partial('some/path/to/file.sql', {})
195
+ end
123
196
  end
124
197
  end
125
198
 
@@ -129,4 +202,10 @@ describe SqlQuery do
129
202
  .to eq("SELECT * FROM players WHERE email = 'e@mail.dev' ")
130
203
  end
131
204
  end
205
+
206
+ describe '.config' do
207
+ it 'returns configuration instance' do
208
+ expect(described_class.config).to be_kind_of(SqlQuery::Config)
209
+ end
210
+ end
132
211
  end
data/sql_query.gemspec CHANGED
@@ -1,34 +1,35 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
 
5
6
  Gem::Specification.new do |spec|
6
- spec.name = "sql_query"
7
- spec.version = "0.4.0"
8
- spec.authors = ["sufleR"]
9
- spec.email = ["szymon.fracczak@gmail.com"]
10
- spec.summary = %q{Ruby gem to load and execute SQL queries from `.sql.erb` templates}
11
- spec.description = %q{
7
+ spec.name = 'sql_query'
8
+ spec.version = '0.7.1'
9
+ spec.authors = ['sufleR']
10
+ spec.email = ['szymon.fracczak@gmail.com']
11
+ spec.summary = 'Ruby gem to load and execute SQL queries from `.sql.erb` templates'
12
+ spec.description = "
12
13
  It makes working with pure SQL easier with syntax highlighting.
13
14
  Let's you clean your Ruby code from SQL strings.
14
- }
15
- spec.homepage = "https://github.com/sufleR/sql_query"
16
- spec.license = "MIT"
15
+ "
16
+ spec.homepage = 'https://github.com/sufleR/sql_query'
17
+ spec.license = 'MIT'
17
18
 
18
19
  spec.files = `git ls-files -z`.split("\x0")
19
20
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
21
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
- spec.require_paths = ["lib"]
22
+ spec.require_paths = ['lib']
22
23
 
23
- spec.required_ruby_version = ">= 1.9.3"
24
+ spec.required_ruby_version = '>= 1.9.3'
24
25
 
25
- spec.add_dependency "activerecord", ">= 3.2"
26
- spec.add_development_dependency "bundler", "~> 1.7"
27
- spec.add_development_dependency "rake", "~> 10"
28
- spec.add_development_dependency "rspec", "~> 3.2"
29
- spec.add_development_dependency "pg", "~> 0.18"
30
- spec.add_development_dependency "pry", "~> 0.10"
31
- spec.add_development_dependency "with_model", "~> 1.2"
32
- spec.add_development_dependency "codeclimate-test-reporter", "~> 0.4"
33
- spec.add_development_dependency "appraisal"
26
+ spec.add_dependency 'activerecord', '>= 3.2', '< 6.2'
27
+ spec.add_development_dependency 'appraisal'
28
+ spec.add_development_dependency 'bundler'
29
+ spec.add_development_dependency 'pg', '~> 0.18'
30
+ spec.add_development_dependency 'rake', '~> 13.0'
31
+ spec.add_development_dependency 'rspec', '~> 3.4'
32
+ spec.add_development_dependency 'rubocop', '<= 0.81'
33
+ spec.add_development_dependency 'simplecov'
34
+ spec.add_development_dependency 'with_model', '~> 1.2'
34
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sql_query
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - sufleR
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-20 00:00:00.000000000 Z
11
+ date: 2021-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.2'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '6.2'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,118 +27,121 @@ dependencies:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '3.2'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '6.2'
27
33
  - !ruby/object:Gem::Dependency
28
- name: bundler
34
+ name: appraisal
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - "~>"
37
+ - - ">="
32
38
  - !ruby/object:Gem::Version
33
- version: '1.7'
39
+ version: '0'
34
40
  type: :development
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
- - - "~>"
44
+ - - ">="
39
45
  - !ruby/object:Gem::Version
40
- version: '1.7'
46
+ version: '0'
41
47
  - !ruby/object:Gem::Dependency
42
- name: rake
48
+ name: bundler
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - "~>"
51
+ - - ">="
46
52
  - !ruby/object:Gem::Version
47
- version: '10'
53
+ version: '0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - "~>"
58
+ - - ">="
53
59
  - !ruby/object:Gem::Version
54
- version: '10'
60
+ version: '0'
55
61
  - !ruby/object:Gem::Dependency
56
- name: rspec
62
+ name: pg
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
65
  - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '3.2'
67
+ version: '0.18'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
72
  - - "~>"
67
73
  - !ruby/object:Gem::Version
68
- version: '3.2'
74
+ version: '0.18'
69
75
  - !ruby/object:Gem::Dependency
70
- name: pg
76
+ name: rake
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
79
  - - "~>"
74
80
  - !ruby/object:Gem::Version
75
- version: '0.18'
81
+ version: '13.0'
76
82
  type: :development
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
86
  - - "~>"
81
87
  - !ruby/object:Gem::Version
82
- version: '0.18'
88
+ version: '13.0'
83
89
  - !ruby/object:Gem::Dependency
84
- name: pry
90
+ name: rspec
85
91
  requirement: !ruby/object:Gem::Requirement
86
92
  requirements:
87
93
  - - "~>"
88
94
  - !ruby/object:Gem::Version
89
- version: '0.10'
95
+ version: '3.4'
90
96
  type: :development
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
100
  - - "~>"
95
101
  - !ruby/object:Gem::Version
96
- version: '0.10'
102
+ version: '3.4'
97
103
  - !ruby/object:Gem::Dependency
98
- name: with_model
104
+ name: rubocop
99
105
  requirement: !ruby/object:Gem::Requirement
100
106
  requirements:
101
- - - "~>"
107
+ - - "<="
102
108
  - !ruby/object:Gem::Version
103
- version: '1.2'
109
+ version: '0.81'
104
110
  type: :development
105
111
  prerelease: false
106
112
  version_requirements: !ruby/object:Gem::Requirement
107
113
  requirements:
108
- - - "~>"
114
+ - - "<="
109
115
  - !ruby/object:Gem::Version
110
- version: '1.2'
116
+ version: '0.81'
111
117
  - !ruby/object:Gem::Dependency
112
- name: codeclimate-test-reporter
118
+ name: simplecov
113
119
  requirement: !ruby/object:Gem::Requirement
114
120
  requirements:
115
- - - "~>"
121
+ - - ">="
116
122
  - !ruby/object:Gem::Version
117
- version: '0.4'
123
+ version: '0'
118
124
  type: :development
119
125
  prerelease: false
120
126
  version_requirements: !ruby/object:Gem::Requirement
121
127
  requirements:
122
- - - "~>"
128
+ - - ">="
123
129
  - !ruby/object:Gem::Version
124
- version: '0.4'
130
+ version: '0'
125
131
  - !ruby/object:Gem::Dependency
126
- name: appraisal
132
+ name: with_model
127
133
  requirement: !ruby/object:Gem::Requirement
128
134
  requirements:
129
- - - ">="
135
+ - - "~>"
130
136
  - !ruby/object:Gem::Version
131
- version: '0'
137
+ version: '1.2'
132
138
  type: :development
133
139
  prerelease: false
134
140
  version_requirements: !ruby/object:Gem::Requirement
135
141
  requirements:
136
- - - ">="
142
+ - - "~>"
137
143
  - !ruby/object:Gem::Version
138
- version: '0'
144
+ version: '1.2'
139
145
  description: "\n It makes working with pure SQL easier with syntax highlighting.\n
140
146
  \ Let's you clean your Ruby code from SQL strings.\n "
141
147
  email:
@@ -145,6 +151,8 @@ extensions: []
145
151
  extra_rdoc_files: []
146
152
  files:
147
153
  - ".gitignore"
154
+ - ".ruby-gemset"
155
+ - ".ruby-version"
148
156
  - ".travis.yml"
149
157
  - Appraisals
150
158
  - CHANGELOG.md
@@ -158,7 +166,9 @@ files:
158
166
  - gemfiles/4.0.gemfile
159
167
  - gemfiles/4.1.gemfile
160
168
  - gemfiles/4.2.gemfile
169
+ - gemfiles/5.0.gemfile
161
170
  - lib/sql_query.rb
171
+ - spec/config_spec.rb
162
172
  - spec/spec_helper.rb
163
173
  - spec/sql_queries/_email_partial.sql.erb
164
174
  - spec/sql_queries/duplicated.erb.sql
@@ -188,11 +198,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
198
  version: '0'
189
199
  requirements: []
190
200
  rubyforge_project:
191
- rubygems_version: 2.5.1
201
+ rubygems_version: 2.6.12
192
202
  signing_key:
193
203
  specification_version: 4
194
204
  summary: Ruby gem to load and execute SQL queries from `.sql.erb` templates
195
205
  test_files:
206
+ - spec/config_spec.rb
196
207
  - spec/spec_helper.rb
197
208
  - spec/sql_queries/_email_partial.sql.erb
198
209
  - spec/sql_queries/duplicated.erb.sql