Skip to content

Commit

Permalink
Simplify requires
Browse files Browse the repository at this point in the history
- Make module files require their nested contents
- Move library requires to the files that use them
- Remove require for timeout because it isn't used
- Remove require for thread because it is required by default

This patch also allows for easier transition to autoloading should we
choose to use it later.
  • Loading branch information
gmcgibbon authored and nateberkopec committed Apr 5, 2023
1 parent 7a26aae commit 5d07da7
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 25 deletions.
11 changes: 11 additions & 0 deletions lib/mini_profiler.rb
@@ -1,6 +1,17 @@
# frozen_string_literal: true

require 'cgi'
require 'json'
require 'erb'

require 'mini_profiler/timer_struct'
require 'mini_profiler/storage'
require 'mini_profiler/config'
require 'mini_profiler/profiling_methods'
require 'mini_profiler/context'
require 'mini_profiler/client_settings'
require 'mini_profiler/gc_profiler'
require 'mini_profiler/snapshots_transporter'

module Rack
class MiniProfiler
Expand Down
7 changes: 7 additions & 0 deletions lib/mini_profiler/storage.rb
@@ -0,0 +1,7 @@
# frozen_string_literal: true

require 'mini_profiler/storage/abstract_store'
require 'mini_profiler/storage/memcache_store'
require 'mini_profiler/storage/memory_store'
require 'mini_profiler/storage/redis_store'
require 'mini_profiler/storage/file_store'
2 changes: 2 additions & 0 deletions lib/mini_profiler/storage/file_store.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'securerandom'

module Rack
class MiniProfiler
class FileStore < AbstractStore
Expand Down
2 changes: 2 additions & 0 deletions lib/mini_profiler/storage/memory_store.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'securerandom'

module Rack
class MiniProfiler
class MemoryStore < AbstractStore
Expand Down
1 change: 1 addition & 0 deletions lib/mini_profiler/storage/redis_store.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'digest'
require 'securerandom'

module Rack
class MiniProfiler
Expand Down
8 changes: 8 additions & 0 deletions lib/mini_profiler/timer_struct.rb
@@ -0,0 +1,8 @@
# frozen_string_literal: true

require 'mini_profiler/timer_struct/base'
require 'mini_profiler/timer_struct/page'
require 'mini_profiler/timer_struct/sql'
require 'mini_profiler/timer_struct/custom'
require 'mini_profiler/timer_struct/client'
require 'mini_profiler/timer_struct/request'
2 changes: 2 additions & 0 deletions lib/mini_profiler/timer_struct/base.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'json'

module Rack
class MiniProfiler
module TimerStruct
Expand Down
2 changes: 2 additions & 0 deletions lib/mini_profiler/timer_struct/sql.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'erb'

module Rack
class MiniProfiler

Expand Down
26 changes: 1 addition & 25 deletions lib/rack-mini-profiler.rb
@@ -1,34 +1,10 @@
# frozen_string_literal: true

require 'erb'
require 'json'
require 'timeout'
require 'thread'
require 'securerandom'

require 'mini_profiler/version'
require 'mini_profiler/asset_version'

require 'mini_profiler/timer_struct/base'
require 'mini_profiler/timer_struct/page'
require 'mini_profiler/timer_struct/sql'
require 'mini_profiler/timer_struct/custom'
require 'mini_profiler/timer_struct/client'
require 'mini_profiler/timer_struct/request'

require 'mini_profiler/storage/abstract_store'
require 'mini_profiler/storage/memcache_store'
require 'mini_profiler/storage/memory_store'
require 'mini_profiler/storage/redis_store'
require 'mini_profiler/storage/file_store'

require 'mini_profiler/config'
require 'mini_profiler/profiling_methods'
require 'mini_profiler/context'
require 'mini_profiler/client_settings'
require 'mini_profiler/gc_profiler'
require 'mini_profiler/snapshots_transporter'
require 'mini_profiler'

require 'patches/sql_patches'
require 'patches/net_patches'

Expand Down
1 change: 1 addition & 0 deletions spec/integration/railtie_methods_spec.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require 'securerandom'
require 'rack/test'
require File.expand_path('../../../lib/mini_profiler_rails/railtie_methods', __FILE__)

Expand Down

0 comments on commit 5d07da7

Please sign in to comment.