Class: Gloss::Writer

Inherits:
Object
  • Object
show all
Defined in:
lib/gloss/writer.rb

Instance Method Summary collapse

Constructor Details

#initialize(content, src_path, output_path = Pathname.new(Utils.src_path_to_output_path(src_path))) ⇒ Writer

Returns a new instance of Writer.



10
11
12
13
14
# File 'lib/gloss/writer.rb', line 10

def initialize(content, src_path, output_path = Pathname.new(Utils.src_path_to_output_path(src_path)))
  @content = content
  @src_path = src_path
  @output_path = output_path
end

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gloss/writer.rb', line 15

def run()
  unless       @output_path.parent
.exist?
    FileUtils.mkdir_p(@output_path.parent)
  end
  File.open(@output_path, "wb") { |file|
    sb = shebang
    (if sb
      file.puts(sb)
    end)
    file.puts(@content)
  }
  (if Config.prettify_output_executable_path
    system(Config.prettify_output_executable_path, @output_path.to_s)
  end)
end