Class: TF::CommentTestInput
- Inherits:
-
Object
- Object
- TF::CommentTestInput
- Defined in:
- lib/plugins/tf/comment_test_input.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ CommentTestInput
constructor
A new instance of CommentTestInput.
- #load(file_name) ⇒ Object
Constructor Details
#initialize ⇒ CommentTestInput
Returns a new instance of CommentTestInput.
2 3 |
# File 'lib/plugins/tf/comment_test_input.rb', line 2 def initialize end |
Class Method Details
.argument_matches?(argument) ⇒ Boolean
5 6 7 8 9 10 11 |
# File 'lib/plugins/tf/comment_test_input.rb', line 5 def self.argument_matches? argument if argument =~ /_comment_test\.sh$/ && File.exist?(argument) [:load, :input] else nil end end |
Instance Method Details
#load(file_name) ⇒ Object
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 42 |
# File 'lib/plugins/tf/comment_test_input.rb', line 13 def load file_name lines = [] file_lines = File.readlines(file_name) shell = "bash" shell = file_lines.shift.sub(/^#!/,'') if file_lines[0] =~ /^#!/ file_lines.each{|line| # Fix jruby-1.6.6-d19 bug with empty strings from files line = "#{line}" # remove human comments line.sub!(/##.*$/,'') # reject empty lines line.strip! next if line =~ /^$/ # extract command and tests cmd, tests = line.split("#") cmd.strip! tests = if tests.blank? [] else tests.split(";").map(&:strip) end if cmd.blank? lines.last[:tests] += tests unless lines.last.nil? else lines << { :cmd => cmd, :tests => tests } end } name = file_name.gsub(/^.*\//,'').sub(/_comment_test\.sh$/,'') { :name => name, :commands => lines, :shell => shell } end |