plugin.rb 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. class String
  2. # reformat a multiline string to have given number of whitespace columns;
  3. # helpful for formatting heredocs
  4. def left_margin(margin=0)
  5. non_whitespace_column = 0
  6. new_lines = []
  7. # find first line with non-whitespace and count left columns of whitespace
  8. self.each_line do |line|
  9. if (line =~ /^\s*\S/)
  10. non_whitespace_column = $&.length - 1
  11. break
  12. end
  13. end
  14. # iterate through each line, chopping off leftmost whitespace columns and add back the desired whitespace margin
  15. self.each_line do |line|
  16. columns = []
  17. margin.times{columns << ' '}
  18. # handle special case of line being narrower than width to be lopped off
  19. if (non_whitespace_column < line.length)
  20. new_lines << "#{columns.join}#{line[non_whitespace_column..-1]}"
  21. else
  22. new_lines << "\n"
  23. end
  24. end
  25. return new_lines.join
  26. end
  27. end
  28. class Plugin
  29. attr_reader :name, :environment
  30. attr_accessor :plugin_objects
  31. def initialize(system_objects, name)
  32. @environment = []
  33. @ceedling = system_objects
  34. @name = name
  35. self.setup
  36. end
  37. def setup; end
  38. # mock generation
  39. def pre_mock_generate(arg_hash); end
  40. def post_mock_generate(arg_hash); end
  41. # test runner generation
  42. def pre_runner_generate(arg_hash); end
  43. def post_runner_generate(arg_hash); end
  44. # compilation (test or source)
  45. def pre_compile_execute(arg_hash); end
  46. def post_compile_execute(arg_hash); end
  47. # linking (test or source)
  48. def pre_link_execute(arg_hash); end
  49. def post_link_execute(arg_hash); end
  50. # test fixture execution
  51. def pre_test_fixture_execute(arg_hash); end
  52. def post_test_fixture_execute(arg_hash); end
  53. # test task
  54. def pre_test; end
  55. def post_test; end
  56. # release task
  57. def pre_release; end
  58. def post_release; end
  59. # whole shebang (any use of Ceedling)
  60. def pre_build; end
  61. def post_build; end
  62. def summary; end
  63. end