Module: GenRelease::FileUtils

Extended by:
FileUtils
Included in:
FileUtils
Defined in:
lib/genRelease/commands/help_modules/FileUtils.rb

Instance Method Summary collapse

Instance Method Details

#format(content) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/genRelease/commands/help_modules/FileUtils.rb', line 17

def format(content)
  json_arr = []
  content.each do |k,v|
    json_arr << {:file => k.to_s,:md5 => v[:md5].to_s,:sha1 => v[:sha1]}
  end
  json_arr.to_json.to_s
end

#touch(file) ⇒ Object



13
14
15
# File 'lib/genRelease/commands/help_modules/FileUtils.rb', line 13

def touch file
  File.open(file,'w')
end

#write(file, content) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/genRelease/commands/help_modules/FileUtils.rb', line 5

def write(file,content)
  tmpfile = touch file
  tmpfile.flock File::LOCK_EX
  tmpfile.print content
  tmpfile.flock File::LOCK_UN
  tmpfile.close
end