Class: Shakapacker::Doctor

Inherits:
Object
  • Object
show all
Defined in:
lib/shakapacker/doctor.rb

Defined Under Namespace

Classes: Reporter

Constant Summary collapse

CATEGORY_ACTION_REQUIRED =

Warning categories for better organization

:action_required
:recommended
CATEGORY_INFO =
:info

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = nil, root_path = nil, options = {}) ⇒ Doctor

Returns a new instance of Doctor.



15
16
17
18
19
20
21
22
# File 'lib/shakapacker/doctor.rb', line 15

def initialize(config = nil, root_path = nil, options = {})
  @config = config || Shakapacker.config
  @root_path = root_path || (defined?(Rails) ? Rails.root : Pathname.new(Dir.pwd))
  @issues = []
  @warnings = []  # Now stores hashes: { category: :symbol, message: "..." }
  @info = []
  @options = options
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/shakapacker/doctor.rb', line 8

def config
  @config
end

#infoObject (readonly)

Returns the value of attribute info.



8
9
10
# File 'lib/shakapacker/doctor.rb', line 8

def info
  @info
end

#issuesObject (readonly)

Returns the value of attribute issues.



8
9
10
# File 'lib/shakapacker/doctor.rb', line 8

def issues
  @issues
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/shakapacker/doctor.rb', line 8

def options
  @options
end

#root_pathObject (readonly)

Returns the value of attribute root_path.



8
9
10
# File 'lib/shakapacker/doctor.rb', line 8

def root_path
  @root_path
end

#warningsObject (readonly)

Returns the value of attribute warnings.



8
9
10
# File 'lib/shakapacker/doctor.rb', line 8

def warnings
  @warnings
end

Instance Method Details

#runObject



24
25
26
27
28
29
30
31
32
# File 'lib/shakapacker/doctor.rb', line 24

def run
  if options[:help]
    print_help
    return
  end

  perform_checks
  report_results
end

#success?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/shakapacker/doctor.rb', line 34

def success?
  @issues.empty?
end