Module: DeepCover::Load
- Included in:
- DeepCover
- Defined in:
- lib/deep_cover/load.rb
Constant Summary collapse
- AUTOLOAD =
%i[analyser autoload_tracker auto_run config coverage covered_code custom_requirer flag_comment_associator global_variables memoize module_override node persistence problem_with_diagnostic reporter ]
Instance Method Summary collapse
- #bootstrap ⇒ Object
- #load_absolute_basics ⇒ Object
- #load_all ⇒ Object
- #load_parser ⇒ Object
- #load_pry ⇒ Object
Instance Method Details
#bootstrap ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/deep_cover/load.rb', line 43 def bootstrap @bootstrapped ||= false # Avoid warning return if @bootstrapped require_relative 'backports' require_relative 'tools' @bootstrapped = true end |
#load_absolute_basics ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/deep_cover/load.rb', line 11 def load_absolute_basics require_relative 'base' require_relative 'basics' require_relative 'config_setter' require_relative 'tools/camelize' AUTOLOAD.each do |module_name| DeepCover.autoload(Tools::Camelize.camelize(module_name), "#{__dir__}/#{module_name}") end DeepCover.autoload :VERSION, "#{__dir__}/version" Object.autoload :Forwardable, 'forwardable' Object.autoload :YAML, 'yaml' # In ruby 2.2 and less, autoload doesn't work for gems which are not already on the `$LOAD_PATH`. # The fix is to just require right away for those rubies # # Low-level: autoload not working for gems not on the `$LOAD_PATH` is because those rubies don't # call the regular `#require` when triggering an autoload, and the gem system monkey-patches `#require` # so that when a file is not found in the `$LOAD_PATH`, but can be found in an existing gem, that gem's # path is added to the `$LOAD_PATH` {JSON: 'json', Term: 'term/ansicolor', Terminal: 'terminal-table', }.each do |const, require_path| if RUBY_VERSION < '2.3' require require_path else Object.autoload const, require_path end end end |
#load_all ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/deep_cover/load.rb', line 68 def load_all @all_loaded ||= false return if @all_loaded bootstrap load_parser AUTOLOAD.each do |module_name| DeepCover.const_get(Tools::Camelize.camelize(module_name)) end DeepCover.const_get(:VERSION) @all_loaded = true end |
#load_parser ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/deep_cover/load.rb', line 51 def load_parser @parser_loaded ||= false # Avoid warning return if @parser_loaded Tools.silence_warnings do require 'parser' require 'parser/current' end require_relative_dir 'parser_ext' @parser_loaded = true end |
#load_pry ⇒ Object
62 63 64 65 66 |
# File 'lib/deep_cover/load.rb', line 62 def load_pry Tools.silence_warnings do # Avoid "WARN: Unresolved specs during Gem::Specification.reset" require 'pry' # after `pry` calls `Gem.refresh` end end |