deforest 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/deforest/version.rb +1 -1
- data/lib/generators/deforest/USAGE +9 -0
- data/lib/generators/deforest/deforest_generator.rb +39 -0
- data/lib/generators/deforest/templates/migration.rb +12 -0
- data/lib/generators/deforest/templates/zeitwerk_enabled_initializer.rb +10 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +1172 -0
- metadata +7 -4
- data/lib/tasks/deforest_tasks.rake +0 -7
- /data/lib/{tasks/deforest_initializer.rb → generators/deforest/templates/classic_enabled_initializer.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 696760761eb3f30b0c9005b4b415517b2425e818b5a314d23872821b3a596877
|
4
|
+
data.tar.gz: fc24e0c602020f5b8bafb8ec8bc409e7e08ae7a84832654ec4c2b6d8aaf21633
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3037cd3c5f07cf97a16199ffb3c710f6190be9575db5f96037b8d406eeecadc8fa3d2f5e7edf7a83c2a8eb490697d836403157b0d6b5efd14b3370fc5f375f39
|
7
|
+
data.tar.gz: bff04b8410c8c02c9ddb60d44190d1fc28eac31083e9c19842b3a10197120f4f9f7e1dfc73faafcbb5fe682ad7ebf6806ee091c4c3fd9fd75c9db1fafc2d7ab4
|
data/lib/deforest/version.rb
CHANGED
@@ -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
|
data/test/dummy/db/test.sqlite3
CHANGED
Binary file
|