Module: ProScribe::Helpers
- Included in:
- CLI
- Defined in:
- lib/proscribe/helpers.rb
Instance Method Summary collapse
- #copy_files(from, to, options = {}) ⇒ Object
- #find_config_file ⇒ Object
- #no_project ⇒ Object
- #project ⇒ Object
- #status(msg) ⇒ Object
Instance Method Details
#copy_files(from, to, options = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/proscribe/helpers.rb', line 28 def copy_files(from, to, ={}) exceptions = [:except] || [] Dir["#{from}/**/*"].each do |f| next unless File.file?(f) next if exceptions.include?(File.basename(f)) target = File.join(to, f.gsub(from, '')) FileUtils.mkdir_p File.dirname(target) FileUtils.cp f, target end end |
#find_config_file ⇒ Object
20 21 22 |
# File 'lib/proscribe/helpers.rb', line 20 def find_config_file %w(Scribefile).inject(nil) { |a, fname| a ||= find_in_project(fname) } end |
#no_project ⇒ Object
16 17 18 |
# File 'lib/proscribe/helpers.rb', line 16 def no_project "Error: no Scribefile file found." end |
#project ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/proscribe/helpers.rb', line 6 def project @project ||= begin config = find_config_file Dir.chdir(File.dirname(config)) if config Project.new(config) if config end @project || pass(no_project) end |
#status(msg) ⇒ Object
24 25 26 |
# File 'lib/proscribe/helpers.rb', line 24 def status(msg) puts " * #{msg}" end |