class Cucumber::PySupport::PyLanguage
Public Class Methods
new(runtime)
click to toggle source
# File lib/cucumber/py_support/py_language.rb, line 8 def initialize(runtime) @step_def_files = [] # # @python_path = ENV['PYTHONPATH'] ? ENV['PYTHONPATH'].split(':') : [] # add_to_python_path(File.dirname(__FILE__)) # # RubyPython.start # at_exit{RubyPython.stop} # # import(File.dirname(__FILE__) + '/py_language.py') end
Public Instance Methods
alias_adverbs(adverbs)
click to toggle source
# File lib/cucumber/py_support/py_language.rb, line 24 def alias_adverbs(adverbs) end
begin_scenario(scenario)
click to toggle source
# File lib/cucumber/py_support/py_language.rb, line 31 def begin_scenario(scenario) @python_path = [] add_to_python_path(File.dirname(__FILE__)) @step_def_files.each { |f| add_to_python_path(File.dirname(f)) } RubyPython.start @delegate = import(File.dirname(__FILE__) + '/py_language.py') @step_def_files.each { |f| import(f) } end
end_scenario()
click to toggle source
# File lib/cucumber/py_support/py_language.rb, line 42 def end_scenario end
load_code_file(py_file)
click to toggle source
# File lib/cucumber/py_support/py_language.rb, line 20 def load_code_file(py_file) @step_def_files << py_file end
snippet_text(code_keyword, step_name, multiline_arg_class, snippet_type)
click to toggle source
# File lib/cucumber/py_support/py_language.rb, line 27 def snippet_text(code_keyword, step_name, multiline_arg_class, snippet_type) "python snippet: #{code_keyword}, #{step_name}" end
step_matches(step_name, name_to_report)
click to toggle source
# File lib/cucumber/py_support/py_language.rb, line 45 def step_matches(step_name, name_to_report) @delegate.step_matches(step_name, name_to_report) end
Private Instance Methods
add_to_python_path(dir)
click to toggle source
# File lib/cucumber/py_support/py_language.rb, line 61 def add_to_python_path(dir) dir = File.expand_path(dir) @python_path.unshift(dir) @python_path.uniq! ENV['PYTHONPATH'] = @python_path.join(':') end
import(path)
click to toggle source
# File lib/cucumber/py_support/py_language.rb, line 51 def import(path) modname = File.basename(path)[0...-File.extname(path).length] begin mod = RubyPython.import(modname) rescue RubyPython::PythonError => e # e.message << "Couldn't load #{path}\nConsider adding #{File.expand_path(File.dirname(path))} to your PYTHONPATH" raise e end end