module Taperole::Helpers::Files
Public Instance Methods
copy_example(file, cp_file)
click to toggle source
# File lib/taperole/helpers/files.rb, line 46 def copy_example(file, cp_file) file_text = "#{::Pathname.new(cp_file).basename}: " begin if File.exist?(cp_file.to_s) exists(file_text) else FileUtils.cp("#{tape_dir}/#{file}", cp_file.to_s) success(file_text) end rescue StandardError => e error(file_text) raise e end end
fe_app?()
click to toggle source
# File lib/taperole/helpers/files.rb, line 4 def fe_app? !Dir["#{local_dir}/package.json"].empty? end
local_dir()
click to toggle source
# File lib/taperole/helpers/files.rb, line 16 def local_dir Dir.pwd end
mkdir(name)
click to toggle source
# File lib/taperole/helpers/files.rb, line 33 def mkdir(name) file_text = "#{::Pathname.new(name).basename}: " begin FileUtils.mkdir name success(file_text) rescue Errno::EEXIST exists(file_text) rescue StandardError => e error(file_text) raise e end end
rails_app?()
click to toggle source
# File lib/taperole/helpers/files.rb, line 8 def rails_app? !Dir["#{local_dir}/config.ru"].empty? end
rm(file)
click to toggle source
# File lib/taperole/helpers/files.rb, line 28 def rm(file) logger.info 'Deleting '.red + file FileUtils.rm_r file end
tape_dir()
click to toggle source
# File lib/taperole/helpers/files.rb, line 12 def tape_dir File.realpath(File.join(__dir__, '../../../')) end
tapecfg_dir()
click to toggle source
# File lib/taperole/helpers/files.rb, line 24 def tapecfg_dir local_dir + '/.tape' end
tapefiles_dir()
click to toggle source
# File lib/taperole/helpers/files.rb, line 20 def tapefiles_dir local_dir + '/taperole' end
Private Instance Methods
error(file_text)
click to toggle source
# File lib/taperole/helpers/files.rb, line 67 def error(file_text) logger.info file_text + '✘'.red end
exists(file_text)
click to toggle source
# File lib/taperole/helpers/files.rb, line 71 def exists(file_text) logger.info file_text + '✘ (Exists)'.yellow end
success(file_text)
click to toggle source
# File lib/taperole/helpers/files.rb, line 63 def success(file_text) logger.info file_text + '✔'.green end