deforest 1.0.1 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e0f8ee18838f3fa7aad4e5c40bddee3793dd76b58710d1475e1d23d312adfd5e
4
- data.tar.gz: 60cdc0c189618498661e99f987d58566ea54e4175d508124385ce52cf932a265
3
+ metadata.gz: 696760761eb3f30b0c9005b4b415517b2425e818b5a314d23872821b3a596877
4
+ data.tar.gz: fc24e0c602020f5b8bafb8ec8bc409e7e08ae7a84832654ec4c2b6d8aaf21633
5
5
  SHA512:
6
- metadata.gz: ac3635d10c11fc7697408fceb9ddf8796b559253390bdf515ca185b3f000dca9cea60eab8ce508cd5f52b5eed2fe49061f9c6483f46fab3240d6599136807aa8
7
- data.tar.gz: b0ac948cc52507577a105b6d33382dede26a7da1a7c45d01a874f0daf078a8e2d3af5b535ee78b5f48b2a7ab7b6adb55ff576a1281e596bbb2eef4aa8ee7c02f
6
+ metadata.gz: 3037cd3c5f07cf97a16199ffb3c710f6190be9575db5f96037b8d406eeecadc8fa3d2f5e7edf7a83c2a8eb490697d836403157b0d6b5efd14b3370fc5f375f39
7
+ data.tar.gz: bff04b8410c8c02c9ddb60d44190d1fc28eac31083e9c19842b3a10197120f4f9f7e1dfc73faafcbb5fe682ad7ebf6806ee091c4c3fd9fd75c9db1fafc2d7ab4
@@ -1,3 +1,3 @@
1
1
  module Deforest
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -0,0 +1,9 @@
1
+ Description:
2
+ Generate initializer file and migration file for logs.
3
+
4
+ Example:
5
+ rails g deforest
6
+
7
+ This will create:
8
+ db/migrate/[TIMESTAMP]create_deforest_logs.rb
9
+ config/initializers/deforest.rb
@@ -0,0 +1,39 @@
1
+ require 'rails/generators/base'
2
+ require 'rails/generators/migration'
3
+
4
+ class DeforestGenerator < Rails::Generators::Base
5
+ include Rails::Generators::Migration
6
+
7
+ source_root File.expand_path('../templates', __FILE__)
8
+
9
+ def copy_migration_file
10
+ migration_template "migration.rb", "db/migrate/create_deforest_logs.rb", migration_version: migration_version
11
+ end
12
+
13
+ def copy_initializer_file
14
+ if rails5_and_up? && Rails.autoloaders.zeitwerk_enabled?
15
+ copy_file "zeitwerk_enabled_initializer.rb", "config/initializers/deforest.rb"
16
+ else
17
+ copy_file "classic_enabled_initializer.rb", "config/initializers/deforest.rb"
18
+ end
19
+ end
20
+
21
+ def rails5_and_up?
22
+ Rails::VERSION::MAJOR >= 5
23
+ end
24
+
25
+ def migration_version
26
+ if rails5_and_up?
27
+ "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
28
+ end
29
+ end
30
+
31
+ def self.next_migration_number(dirname)
32
+ if ActiveRecord::Base.timestamped_migrations
33
+ current_time = Time.now.utc
34
+ current_time.strftime("%Y%m%d%H%M%S")
35
+ else
36
+ "%.3d" % (current_numeric_version(dirname) + 1)
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,12 @@
1
+ class CreateDeforestLogs < ActiveRecord::Migration<%= migration_version %>
2
+ def change
3
+ create_table :deforest_logs do |t|
4
+ t.string :file_name
5
+ t.integer :line_no
6
+ t.string :method_name
7
+ t.integer :count
8
+
9
+ t.timestamps null: false
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ Rails.application.config.to_prepare do
2
+ Deforest.initialize! do |config|
3
+ config.write_logs_to_db_every = 1.minute
4
+ config.current_admin_method_name = :current_admin
5
+ config.most_used_percentile_threshold = 80
6
+ config.least_used_percentile_threshold = 20
7
+ config.track_dirs = ["/app/models", "/app/controllers", "/app/helpers"]
8
+ config.render_source_on_browser = true
9
+ end
10
+ end
Binary file