Class: ForgeCLI::CustomFileCopier

Inherits:
Object
  • Object
show all
Defined in:
lib/forge-cli/custom_file_copier.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ CustomFileCopier

Returns a new instance of CustomFileCopier.



7
8
9
# File 'lib/forge-cli/custom_file_copier.rb', line 7

def initialize(app)
  @app = app
end

Instance Attribute Details

#appObject

Returns the value of attribute app.



2
3
4
# File 'lib/forge-cli/custom_file_copier.rb', line 2

def app
  @app
end

Class Method Details

.copy_files!(app) ⇒ Object



3
4
5
# File 'lib/forge-cli/custom_file_copier.rb', line 3

def self.copy_files!(app)
  new(app).copy_files!
end

Instance Method Details

#copy_files!Object



11
12
13
14
15
16
17
# File 'lib/forge-cli/custom_file_copier.rb', line 11

def copy_files!
  files.each do |file|
    rel_path = file.gsub(File.join(ENV["HOME"], '.forge') + "/", '')
    ForgeCLI::Output.write('create', rel_path)
    FileUtils.cp_r(file, @app)
  end
end

#filesObject



19
20
21
22
# File 'lib/forge-cli/custom_file_copier.rb', line 19

def files
  @files ||= Dir.glob(File.join(ENV["HOME"], '.forge', '{*,.*}')).
                 reject { |f| rejects.include?(File.basename(f)) }
end

#rejectsObject



24
25
26
# File 'lib/forge-cli/custom_file_copier.rb', line 24

def rejects
  %w{. .. .git}
end