a_r_q_logger 0.0.6 → 0.0.7

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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +53 -102
  3. data/README.md +75 -0
  4. data/a_r_q_logger.gemspec +3 -3
  5. data/lib/a_r_q_logger.rb +14 -5
  6. data/lib/a_r_q_logger/initializer.rb +4 -0
  7. data/lib/a_r_q_logger/version.rb +1 -1
  8. data/spec/{dummy/app/models → models}/test_child_model.rb +0 -0
  9. data/spec/{dummy/app/models → models}/test_model.rb +0 -0
  10. data/spec/supports/schema.rb +56 -0
  11. data/spec/test_model_spec.rb +73 -0
  12. metadata +26 -68
  13. data/spec/dummy/README.rdoc +0 -28
  14. data/spec/dummy/Rakefile +0 -6
  15. data/spec/dummy/app/assets/images/.keep +0 -0
  16. data/spec/dummy/app/assets/javascripts/application.js +0 -13
  17. data/spec/dummy/app/assets/stylesheets/application.css +0 -13
  18. data/spec/dummy/app/controllers/application_controller.rb +0 -5
  19. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  20. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  21. data/spec/dummy/app/mailers/.keep +0 -0
  22. data/spec/dummy/app/models/.keep +0 -0
  23. data/spec/dummy/app/models/concerns/.keep +0 -0
  24. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  25. data/spec/dummy/bin/bundle +0 -3
  26. data/spec/dummy/bin/rails +0 -4
  27. data/spec/dummy/bin/rake +0 -4
  28. data/spec/dummy/config.ru +0 -4
  29. data/spec/dummy/config/application.rb +0 -35
  30. data/spec/dummy/config/boot.rb +0 -5
  31. data/spec/dummy/config/database.def.yml +0 -25
  32. data/spec/dummy/config/environment.rb +0 -5
  33. data/spec/dummy/config/environments/development.rb +0 -29
  34. data/spec/dummy/config/environments/production.rb +0 -80
  35. data/spec/dummy/config/environments/test.rb +0 -36
  36. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  37. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  38. data/spec/dummy/config/initializers/inflections.rb +0 -16
  39. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  40. data/spec/dummy/config/initializers/secret_token.rb +0 -12
  41. data/spec/dummy/config/initializers/session_store.rb +0 -3
  42. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  43. data/spec/dummy/config/locales/en.yml +0 -23
  44. data/spec/dummy/config/routes.rb +0 -56
  45. data/spec/dummy/db/migrate/20161016035357_create_test_models.rb +0 -9
  46. data/spec/dummy/db/migrate/20161016035434_create_test_child_models.rb +0 -10
  47. data/spec/dummy/db/schema.rb +0 -28
  48. data/spec/dummy/lib/assets/.keep +0 -0
  49. data/spec/dummy/log/.keep +0 -0
  50. data/spec/dummy/public/404.html +0 -58
  51. data/spec/dummy/public/422.html +0 -58
  52. data/spec/dummy/public/500.html +0 -57
  53. data/spec/dummy/public/favicon.ico +0 -0
  54. data/spec/dummy/spec/models/test_model_spec.rb +0 -45
  55. data/spec/rails_helper.rb +0 -67
  56. data/spec/spec_helper.rb +0 -101
@@ -0,0 +1,73 @@
1
+ require 'active_record'
2
+ require 'supports/schema'
3
+ require 'models/test_child_model'
4
+ require 'models/test_model'
5
+ require 'tempfile'
6
+
7
+ ActiveRecord::Base.logger = Logger.new(Tempfile.new(''))
8
+
9
+
10
+ require 'a_r_q_logger'
11
+
12
+
13
+ RSpec.describe TestModel, type: :model do
14
+ it do
15
+ TestModel.create!
16
+ end
17
+
18
+ it do
19
+ expect(ARQLogger.log {
20
+ TestModel.create!
21
+ }.count).to eq(1)
22
+ end
23
+
24
+ it do
25
+ expect(ARQLogger.log {
26
+ TestModel.create!
27
+ TestModel.create!
28
+ }.count).to eq(2)
29
+ end
30
+
31
+ context 'with associations' do
32
+ before :all do
33
+ TestModel.delete_all
34
+ TestChildModel.delete_all
35
+
36
+ 10.times {
37
+ TestChildModel.create!(test_model: TestModel.create!, name: SecureRandom.hex(4))
38
+ }
39
+ end
40
+
41
+ after :all do
42
+ TestModel.destroy_all
43
+ end
44
+
45
+ describe 'queries' do
46
+ it do
47
+ expect(ARQLogger.log {
48
+ TestModel.includes(:test_child_models).all.each { |m| m.test_child_models.map(&:name) }
49
+ }.count).to eq(2)
50
+ end
51
+
52
+ it do
53
+ expect(ARQLogger.log {
54
+ TestModel.all.each { |m| m.test_child_models.map(&:name) }
55
+ }.count).to eq(11)
56
+ end
57
+ end
58
+
59
+ describe 'instantiating' do
60
+ it do
61
+ expect(ARQLogger.log {
62
+ TestModel.includes(:test_child_models).load
63
+ }.instances).to eq(20)
64
+ end
65
+
66
+ it do
67
+ expect(ARQLogger.log {
68
+ TestModel.joins(:test_child_models).select('test_child_models.id as as_id').load
69
+ }.instances).to eq(10)
70
+ end
71
+ end
72
+ end
73
+ end
metadata CHANGED
@@ -1,73 +1,73 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: a_r_q_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - mmmpa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-16 00:00:00.000000000 Z
11
+ date: 2017-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '4.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.0'
26
+ version: '4.2'
27
27
  - !ruby/object:Gem::Dependency
28
- name: bundler
28
+ name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: '1.10'
33
+ version: '4.2'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: '1.10'
40
+ version: '4.2'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '1.10'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '1.10'
55
55
  - !ruby/object:Gem::Dependency
56
- name: sqlite3
56
+ name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '10.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '10.0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rspec
70
+ name: mysql
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rspec-rails
84
+ name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -164,57 +164,16 @@ files:
164
164
  - Gemfile
165
165
  - Gemfile.lock
166
166
  - MIT-LICENSE
167
+ - README.md
167
168
  - Rakefile
168
169
  - a_r_q_logger.gemspec
169
170
  - lib/a_r_q_logger.rb
170
171
  - lib/a_r_q_logger/initializer.rb
171
172
  - lib/a_r_q_logger/version.rb
172
- - spec/dummy/README.rdoc
173
- - spec/dummy/Rakefile
174
- - spec/dummy/app/assets/images/.keep
175
- - spec/dummy/app/assets/javascripts/application.js
176
- - spec/dummy/app/assets/stylesheets/application.css
177
- - spec/dummy/app/controllers/application_controller.rb
178
- - spec/dummy/app/controllers/concerns/.keep
179
- - spec/dummy/app/helpers/application_helper.rb
180
- - spec/dummy/app/mailers/.keep
181
- - spec/dummy/app/models/.keep
182
- - spec/dummy/app/models/concerns/.keep
183
- - spec/dummy/app/models/test_child_model.rb
184
- - spec/dummy/app/models/test_model.rb
185
- - spec/dummy/app/views/layouts/application.html.erb
186
- - spec/dummy/bin/bundle
187
- - spec/dummy/bin/rails
188
- - spec/dummy/bin/rake
189
- - spec/dummy/config.ru
190
- - spec/dummy/config/application.rb
191
- - spec/dummy/config/boot.rb
192
- - spec/dummy/config/database.def.yml
193
- - spec/dummy/config/environment.rb
194
- - spec/dummy/config/environments/development.rb
195
- - spec/dummy/config/environments/production.rb
196
- - spec/dummy/config/environments/test.rb
197
- - spec/dummy/config/initializers/backtrace_silencers.rb
198
- - spec/dummy/config/initializers/filter_parameter_logging.rb
199
- - spec/dummy/config/initializers/inflections.rb
200
- - spec/dummy/config/initializers/mime_types.rb
201
- - spec/dummy/config/initializers/secret_token.rb
202
- - spec/dummy/config/initializers/session_store.rb
203
- - spec/dummy/config/initializers/wrap_parameters.rb
204
- - spec/dummy/config/locales/en.yml
205
- - spec/dummy/config/routes.rb
206
- - spec/dummy/db/migrate/20161016035357_create_test_models.rb
207
- - spec/dummy/db/migrate/20161016035434_create_test_child_models.rb
208
- - spec/dummy/db/schema.rb
209
- - spec/dummy/lib/assets/.keep
210
- - spec/dummy/log/.keep
211
- - spec/dummy/public/404.html
212
- - spec/dummy/public/422.html
213
- - spec/dummy/public/500.html
214
- - spec/dummy/public/favicon.ico
215
- - spec/dummy/spec/models/test_model_spec.rb
216
- - spec/rails_helper.rb
217
- - spec/spec_helper.rb
173
+ - spec/models/test_child_model.rb
174
+ - spec/models/test_model.rb
175
+ - spec/supports/schema.rb
176
+ - spec/test_model_spec.rb
218
177
  homepage: http://mmmpa.net
219
178
  licenses: []
220
179
  metadata: {}
@@ -234,9 +193,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
193
  version: '0'
235
194
  requirements: []
236
195
  rubyforge_project:
237
- rubygems_version: 2.5.1
196
+ rubygems_version: 2.5.2
238
197
  signing_key:
239
198
  specification_version: 4
240
199
  summary: count of querying
241
200
  test_files: []
242
- has_rdoc:
@@ -1,28 +0,0 @@
1
- == README
2
-
3
- This README would normally document whatever steps are necessary to get the
4
- application up and running.
5
-
6
- Things you may want to cover:
7
-
8
- * Ruby version
9
-
10
- * System dependencies
11
-
12
- * Configuration
13
-
14
- * Database creation
15
-
16
- * Database initialization
17
-
18
- * How to run the test suite
19
-
20
- * Services (job queues, cache servers, search engines, etc.)
21
-
22
- * Deployment instructions
23
-
24
- * ...
25
-
26
-
27
- Please feel free to use a different markup language if you do not plan to run
28
- <tt>rake doc:app</tt>.
data/spec/dummy/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require File.expand_path('../config/application', __FILE__)
5
-
6
- Dummy::Application.load_tasks
File without changes
@@ -1,13 +0,0 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file.
9
- //
10
- // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
- // about supported directives.
12
- //
13
- //= require_tree .
@@ -1,13 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the top of the
9
- * compiled file, but it's generally better to create a new file per style scope.
10
- *
11
- *= require_self
12
- *= require_tree .
13
- */
@@ -1,5 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- # Prevent CSRF attacks by raising an exception.
3
- # For APIs, you may want to use :null_session instead.
4
- protect_from_forgery with: :exception
5
- end
File without changes
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
File without changes
File without changes
File without changes
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
6
- <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
- load Gem.bin_path('bundler', 'bundle')
data/spec/dummy/bin/rails DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_PATH = File.expand_path('../../config/application', __FILE__)
3
- require_relative '../config/boot'
4
- require 'rails/commands'
data/spec/dummy/bin/rake DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require_relative '../config/boot'
3
- require 'rake'
4
- Rake.application.run
data/spec/dummy/config.ru DELETED
@@ -1,4 +0,0 @@
1
- # This file is used by Rack-based servers to start the application.
2
-
3
- require ::File.expand_path('../config/environment', __FILE__)
4
- run Rails.application
@@ -1,35 +0,0 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- # Pick the frameworks you want:
4
- require "active_record/railtie"
5
- require "action_controller/railtie"
6
- require "action_mailer/railtie"
7
- require "sprockets/railtie"
8
- # require "rails/test_unit/railtie"
9
-
10
- module Dummy
11
- class Application < Rails::Application
12
- config.generators do |g|
13
- g.assets false
14
- g.helper false
15
- g.view false
16
-
17
- g.test_framework :rspec, fixtures: true, view_specs: false, helper_specs: false, routing_specs:
18
- false, controller_specs: true, request_specs: true
19
- g.fixture_replacement :factory_girl, dir: 'spec/factories'
20
- end
21
-
22
- # Settings in config/environments/* take precedence over those specified here.
23
- # Application configuration should go into files in config/initializers
24
- # -- all .rb files in that directory are automatically loaded.
25
-
26
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
27
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
28
- # config.time_zone = 'Central Time (US & Canada)'
29
-
30
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
31
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
32
- # config.i18n.default_locale = :de
33
- end
34
- end
35
-
@@ -1,5 +0,0 @@
1
- # Set up gems listed in the Gemfile.
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
-
4
- require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
5
- $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -1,25 +0,0 @@
1
- # SQLite version 3.x
2
- # gem install sqlite3
3
- #
4
- # Ensure the SQLite 3 gem is defined in your Gemfile
5
- # gem 'sqlite3'
6
- development:
7
- adapter: sqlite3
8
- database: db/development.sqlite3
9
- pool: 5
10
- timeout: 5000
11
-
12
- # Warning: The database defined as "test" will be erased and
13
- # re-generated from your development database when you run "rake".
14
- # Do not set this db to the same as development or production.
15
- test:
16
- adapter: sqlite3
17
- database: db/test.sqlite3
18
- pool: 5
19
- timeout: 5000
20
-
21
- production:
22
- adapter: sqlite3
23
- database: db/production.sqlite3
24
- pool: 5
25
- timeout: 5000