Sha256: fe8677932b2be835019fad6ad79876d52e225ce21dba70a063923e018736c55d

Contents?: true

Size: 1.71 KB

Versions: 6

Compression:

Stored size: 1.71 KB

Contents

require 'build-tool/application'
require 'build-tool/commands'

module BuildTool; module Commands;

    #
    # BuildCommand
    #
    class Files < Standard

        name        "files"
        description "Get the content of some helper files."

        def applicable?
            BuildTool::Application.instance.name != "build-tool"
        end

        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

        def print_file_list
            recipe = Application::instance.recipe
            files_dir = recipe.files_path
            if !files_dir.exist?
                say "No files supplied with this recipe"
                return 0
            end
            Dir.new(files_dir).each do |entry|
                next if entry == "."
                next if entry == ".."
                say entry
            end
            return 0
        end

        def print_file( filename )
            recipe = Application::instance.recipe
            files_dir = recipe.files_path
            if !files_dir.exist?
                say "No files supplied with this recipe"
                return 0
            end
            file = files_dir.join( filename )
            if !files_dir.exist?
                say "That file does not exist"
                return -1
            end

            erb = ERB.new( file.read, nil, "%<>" )
            b = binding
            settings = recipe.settings
            puts erb.result(b)
            return 0
        end

    end # class Build

end; end # module BuildTool::Commands



Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
build-tool-0.2 lib/build-tool/commands/files.rb
build-tool-0.1.4 lib/build-tool/commands/files.rb
build-tool-0.1.3 lib/build-tool/commands/files.rb
build-tool-0.1.2 lib/build-tool/commands/files.rb
build-tool-0.1.0 lib/build-tool/commands/files.rb
build-tool-0.1.1 lib/build-tool/commands/files.rb