Class: BuildTool::Commands::Files
- Defined in:
- lib/build-tool/commands/files.rb
Overview
BuildCommand
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #applicable? ⇒ Boolean
- #do_execute(args) ⇒ Object
- #initialize_options ⇒ Object
- #print_file(filename) ⇒ Object
- #print_file_list ⇒ Object
Methods inherited from Standard
#complete_module, #complete_modules, #initialize, #log_directory, #while_logging_to
Methods inherited from Base
#<=>, #cleanup_after_vcs_access, #complete, #complete_arguments, #complete_readline_1_8, #complete_readline_1_9, #configuration, #do_complete_1_8, #do_complete_1_9, #each_option, #execute, #fullname, #initialize, #log?, #say, #setup_command, #show_help, #skip_command, #summarize, #teardown_command, #usage
Methods included from HelpText
#cmdalias, #description, included, #long_description, #name
Constructor Details
This class inherits a constructor from BuildTool::Commands::Standard
Instance Method Details
#applicable? ⇒ Boolean
16 17 18 |
# File 'lib/build-tool/commands/files.rb', line 16 def applicable? BuildTool::Application.instance.has_recipe? end |
#do_execute(args) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/build-tool/commands/files.rb', line 20 def do_execute( args ) case args.length when 0 return print_file_list when 1 return print_file( args[0] ) else return usage("Too many arguments.") end end |
#initialize_options ⇒ Object
35 36 37 38 |
# File 'lib/build-tool/commands/files.rb', line 35 def @options. = "Usage: #{Pathname.new($0).basename} #{self.fullname} [FILENAME]" super end |
#print_file(filename) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/build-tool/commands/files.rb', line 55 def print_file( filename ) recipe = Application::instance.recipe files_dir = recipe.files_path if !files_dir.exist? logger.error "No files supplied with this recipe" return 0 end file = files_dir.join( filename ) if !file.exist? logger.error "File '#{filename}' not found! Found those:" print_file_list return -1 end erb = ERB.new( file.read, nil, "%<>" ) b = binding settings = recipe.settings puts erb.result(b) return 0 end |
#print_file_list ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/build-tool/commands/files.rb', line 40 def print_file_list recipe = Application::instance.recipe files_dir = recipe.files_path if !files_dir.exist? logger.error "No files supplied with this recipe" return 0 end Dir.new(files_dir).sort.each do |entry| next if entry == "." next if entry == ".." say entry end return 0 end |