Class: Hiptest::Publisher
- Inherits:
-
Object
- Object
- Hiptest::Publisher
- Defined in:
- lib/hiptest-publisher.rb
Instance Method Summary collapse
- #export ⇒ Object
- #export_actionwords ⇒ Object
- #export_scenarios ⇒ Object
- #export_tests ⇒ Object
- #fetch_xml_file ⇒ Object
- #get_project(xml) ⇒ Object
-
#initialize(args) ⇒ Publisher
constructor
A new instance of Publisher.
- #write_node_to_file(path, node, context, message) ⇒ Object
Constructor Details
#initialize(args) ⇒ Publisher
Returns a new instance of Publisher.
13 14 15 16 17 18 19 20 |
# File 'lib/hiptest-publisher.rb', line 13 def initialize(args) @options = OptionsParser.parse(args) xml = fetch_xml_file return if xml.nil? @project = get_project(xml) end |
Instance Method Details
#export ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/hiptest-publisher.rb', line 108 def export @language_config = LanguageConfigParser.new(@options) Hiptest::Nodes::ParentAdder.add(@project) Hiptest::Nodes::ParameterTypeAdder.add(@project) Hiptest::DefaultArgumentAdder.add(@project) unless @options.actionwords_only @options.leafless_export ? export_tests : export_scenarios end export_actionwords unless @options.tests_only end |
#export_actionwords ⇒ Object
99 100 101 102 103 104 105 106 |
# File 'lib/hiptest-publisher.rb', line 99 def export_actionwords write_node_to_file( @language_config.aw_output_dir, @project.children[:actionwords], @language_config.actionword_render_context, "Exporting actionwords" ) end |
#export_scenarios ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/hiptest-publisher.rb', line 78 def export_scenarios if @options.split_scenarios @project.children[:scenarios].children[:scenarios].each do |scenario| context = @language_config.tests_render_context context[:test_file_name] = @language_config.scenario_output_file(scenario.children[:name]) write_node_to_file( @language_config.scenario_output_dir(scenario.children[:name]), scenario, context, "Exporting scenario \"#{scenario.children[:name]}\"") end else write_node_to_file( @language_config.tests_output_dir, @project.children[:scenarios], @language_config.tests_render_context, "Exporting scenarios") end end |
#export_tests ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/hiptest-publisher.rb', line 57 def export_tests if @options.split_scenarios @project.children[:tests].children[:tests].each do |test| context = @language_config.tests_render_context context[:test_file_name] = @language_config.scenario_output_file(test.children[:name]) write_node_to_file( @language_config.scenario_output_dir(test.children[:name]), test, context, "Exporting test \"#{test.children[:name]}\"") end else write_node_to_file( @language_config.tests_output_dir, @project.children[:tests], @language_config.tests_render_context, "Exporting tests") end end |
#fetch_xml_file ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/hiptest-publisher.rb', line 22 def fetch_xml_file "Fetching data from Hiptest" xml = fetch_project_export(@options) "Fetching data from Hiptest", :success return xml rescue Exception => err "Fetching data from Hiptest", :failure puts "Unable to open the file, please check that the token is correct".red trace_exception(err) if @options.verbose end |
#get_project(xml) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/hiptest-publisher.rb', line 34 def get_project(xml) "Extracting data" parser = Hiptest::XMLParser.new(xml, @options) "Extracting data", :success return parser.build_project end |
#write_node_to_file(path, node, context, message) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/hiptest-publisher.rb', line 42 def write_node_to_file(path, node, context, ) = "#{}: #{path}" begin File.open(path, 'w') do |file| file.write(Hiptest::Renderer.render(node, @options.language, context)) end , :success rescue Exception => err , :failure trace_exception(err) if @options.verbose end end |