Module: Umami::Helper::FileTools

Included in:
Test::Integration, Test::Unit
Defined in:
lib/chef-umami/helpers/filetools.rb

Instance Method Summary collapse

Instance Method Details

#enforce_styling(path = 'spec/umami/') ⇒ Object

Call Rubocop to ensure proper indentation and thus legibility.



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/chef-umami/helpers/filetools.rb', line 30

def enforce_styling(path = 'spec/umami/')
  puts "Running Rubocop over '#{path}' to enforce styling..."
  r = RuboCop::CLI.new
  # Don't output to STDOUT.
  args = [
    '--only', 'Layout/IndentationWidth,Layout/IndentationConsistency',
    '--auto-correct',
    '--out', '/dev/null',
    path
  ]
  r.run(args)
end

#write_file(path = nil, content = '') ⇒ Object



21
22
23
24
25
26
27
# File 'lib/chef-umami/helpers/filetools.rb', line 21

def write_file(path = nil, content = '')
  parent_dir = File.dirname(path)
  FileUtils.mkdir_p(parent_dir) unless ::File.exist?(parent_dir)
  f = File.open(path, 'w') # Write with prejudice.
  f.write(content)
  f.close
end