Class: Teaspoon::Exporter

Inherits:
Object
  • Object
show all
Includes:
Utility
Defined in:
lib/teaspoon/exporter.rb

Instance Method Summary collapse

Methods included from Utility

#which

Constructor Details

#initialize(suite, url, output_path) ⇒ Exporter

Returns a new instance of Exporter.



5
6
7
8
9
# File 'lib/teaspoon/exporter.rb', line 5

def initialize(suite, url, output_path)
  @suite = suite
  @url = url
  @output_path = File.join(File.expand_path(output_path || "export"), @suite.to_s)
end

Instance Method Details

#exportObject



11
12
13
14
15
16
17
18
19
# File 'lib/teaspoon/exporter.rb', line 11

def export
  Dir.mktmpdir do |temp_path|
    Dir.chdir(temp_path) do
      %x{#{executable} --convert-links --adjust-extension --page-requisites --span-hosts #{@url.shellescape} 2>&1}
      raise Teaspoon::DependencyError.new("Unable to export #{@suite} suite.") unless $?.exitstatus == 0
      create_export(File.join(temp_path, @url.match(/^http:\/\/([^\/]+).*/)[1]))
    end
  end
end