Class: Transpec::DynamicAnalyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/transpec/dynamic_analyzer.rb,
lib/transpec/dynamic_analyzer/rewriter.rb,
lib/transpec/dynamic_analyzer/constants.rb,
lib/transpec/dynamic_analyzer/node_util.rb,
lib/transpec/dynamic_analyzer/runtime_data.rb

Defined Under Namespace

Modules: NodeUtil Classes: AnalysisError, Rewriter, RuntimeData

Constant Summary collapse

ANALYSIS_MODULE =
'Transpec'
ANALYSIS_METHOD =
'analyze'
RUNTIME_DATA_ERROR_MESSAGE_KEY =
:error_message
HELPER_TEMPLATE_FILE =
'transpec_analysis_helper.rb.erb'
RESULT_FILE =
'transpec_analysis_result.json'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ DynamicAnalyzer

Returns a new instance of DynamicAnalyzer.



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/transpec/dynamic_analyzer.rb', line 19

def initialize(options = {})
  @project = options[:project] || Project.new
  @rspec_command = options[:rspec_command] || default_rspec_command
  @silent = options[:silent] || false

  if block_given?
    in_copied_project do
      yield self
    end
  end
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



16
17
18
# File 'lib/transpec/dynamic_analyzer.rb', line 16

def project
  @project
end

#rspec_commandObject (readonly)

Returns the value of attribute rspec_command.



16
17
18
# File 'lib/transpec/dynamic_analyzer.rb', line 16

def rspec_command
  @rspec_command
end

#silentObject (readonly) Also known as: silent?

Returns the value of attribute silent.



16
17
18
# File 'lib/transpec/dynamic_analyzer.rb', line 16

def silent
  @silent
end

Instance Method Details

#analyze(paths = []) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/transpec/dynamic_analyzer.rb', line 39

def analyze(paths = [])
  in_copied_project do
    rewrite_specs(paths)
    put_analysis_helper
    modify_dot_rspec
    run_rspec(paths)
    load_analysis_result
  end
end

#default_rspec_commandObject



31
32
33
34
35
36
37
# File 'lib/transpec/dynamic_analyzer.rb', line 31

def default_rspec_command
  if project.using_bundler?
    'bundle exec rspec'
  else
    'rspec'
  end
end