Module: Cucumber::Relizy::CLI

Defined in:
lib/cucumber/relizy/cli.rb

Overview

Your code goes hereā€¦

Class Method Summary collapse

Class Method Details

.execute(filename) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cucumber/relizy/cli.rb', line 5

def self.execute(filename)
  doc = Nokogiri::HTML File.read(filename)

  a = doc.css("#cucumber-relizy")
  if a && a.size>0
    a.remove
  end

  script = File.expand_path('../assets/cucumber-relizy.css', __FILE__)
  script = File.read(script)
  a = doc.css("body").first
  a.add_child("<style type='text/css'>\n#{ script }\n</style>")

  script = File.expand_path('../assets/cucumber-relizy.js.coffee', __FILE__)
  script = CoffeeScript.compile File.read(script)
  a = doc.css("body").first
  a.add_child("<script type='text/javascript' id='cucumber-relizy'>\n#{ script }\n</script>")

  output = filename.gsub(/html$/, 'relizy.html')
  File.open(output,"w+") do |f|
    doc.write_to f
  end
end