Class: Munge::Core::Write

Inherits:
Object
  • Object
show all
Defined in:
lib/munge/core/write.rb

Instance Method Summary collapse

Constructor Details

#initialize(output:) ⇒ Write



4
5
6
# File 'lib/munge/core/write.rb', line 4

def initialize(output:)
  @output = output
end

Instance Method Details

#write(relpath, content) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/munge/core/write.rb', line 8

def write(relpath, content)
  abspath = File.join(@output, relpath)

  FileUtils.mkdir_p(File.dirname(abspath))

  if File.exist?(abspath) && File.read(abspath) == content
    return false
  else
    File.write(abspath, content)
    true
  end
end