class Awestruct::CLI::Manifest::AddRequires

Adds a requires for each library in libs to the top of the file specified by path

Public Class Methods

new(path, libs) click to toggle source
# File lib/awestruct/cli/manifest.rb, line 165
def initialize(path, libs)
  @path = path
  @libs = libs
end

Public Instance Methods

perform(dir) click to toggle source
# File lib/awestruct/cli/manifest.rb, line 170
def perform(dir)
  file = File.join(dir, @path)
  old_lines = File.read file
  FileUtils.rm(file)

  File.open(file, 'w') do |new|
    @libs.each do |lib|
      new.write "require '#{lib}'\n"
    end
    new.write old_lines
  end
end
unperform(dir) click to toggle source
# File lib/awestruct/cli/manifest.rb, line 183
def unperform(dir)
  #nothing
end