Class: ForgeCLI::CustomFileCopier
- Inherits:
-
Object
- Object
- ForgeCLI::CustomFileCopier
- Defined in:
- lib/forge-cli/custom_file_copier.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
Class Method Summary collapse
Instance Method Summary collapse
- #copy_files! ⇒ Object
- #files ⇒ Object
-
#initialize(app) ⇒ CustomFileCopier
constructor
A new instance of CustomFileCopier.
- #rejects ⇒ Object
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
#app ⇒ Object
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 |
#files ⇒ Object
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 |
#rejects ⇒ Object
24 25 26 |
# File 'lib/forge-cli/custom_file_copier.rb', line 24 def rejects %w{. .. .git} end |