class Psychic::Runner::CodeSample
Public Instance Methods
command(runner)
click to toggle source
# File lib/psychic/runner/code_sample.rb, line 17 def command(runner) command = runner.task_for(:run_sample) # FIXME: Shouldn't this be relative to runner's cwd? # command ||= Psychic::Util.relativize(source_file, runner.cwd) command ||= "./#{source_file}" command_params = { sample: name, sample_file: source_file } command_params.merge!(@parameters) unless @parameters.nil? Psychic::Util.replace_tokens(command, command_params) end
to_path()
click to toggle source
# File lib/psychic/runner/code_sample.rb, line 37 def to_path # So coercion to Pathname is possible source_file.to_s end
to_s(verbose = false)
click to toggle source
# File lib/psychic/runner/code_sample.rb, line 28 def to_s(verbose = false) build_string do status('Sample Name', name) display_tokens status('Source File', formatted_file_name) display_source if verbose end end
token_handler()
click to toggle source
property :name property :basedir property :source_file
# File lib/psychic/runner/code_sample.rb, line 12 def token_handler # Default token pattern/replacement (used by php-opencloud) should be configurable @token_handler ||= RegexpTokenHandler.new(source, /'\{(\w+)\}'/, "'\\1'") end
Private Instance Methods
display_source()
click to toggle source
# File lib/psychic/runner/code_sample.rb, line 44 def display_source return unless source? status 'Source Code' say highlighted_code end
display_tokens()
click to toggle source
# File lib/psychic/runner/code_sample.rb, line 50 def display_tokens return status 'Tokens', '(None)' if token_handler.tokens.empty? status 'Tokens' indent do token_handler.tokens.each do | token | say "- #{token}" end end end
formatted_file_name()
click to toggle source
# File lib/psychic/runner/code_sample.rb, line 61 def formatted_file_name if source? Psychic::Util.relativize(absolute_source_file, Dir.pwd) else colorize('<No code sample>', :red) end end