Sha256: 94d2cb54667a0ed1e7153f88af37def85982a7ef27c72b022897eddae3d87da2

Contents?: true

Size: 1.72 KB

Versions: 8

Compression:

Stored size: 1.72 KB

Contents

module Hyla
  module Commands
    class Add < Command

      def self.process(args, options)
        destination = options[:destination] if check_mandatory_option?('-d / --destination', options[:destination])
        artefact_type = options[:artefact_type] if check_mandatory_option?('-a / --artefact_type', options[:artefact_type])
        type = options[:type] if check_mandatory_option?('-t / --type', options[:type])
        font_type = 'liberation'

        copy_fonts(font_type, destination)

        copy_artefact(type, artefact_type, destination)
      end

      #
      # Copy Artefact to Destination directory
      #
      def self.copy_artefact(type, artefact_type, destination)
        artefact_file_name = type + '_' + artefact_type + Configuration::ADOC_EXT
        source = [Configuration::samples, artefact_file_name] * '/'
        destination = File.expand_path(destination)

        FileUtils.cp(source, destination)

        Hyla::logger2.info ">>   Artefact #{artefact_file_name} added to project #{destination}"

        case artefact_type
          when 'image','audio','video','source'
           source_dir = [Configuration::samples, artefact_type] * '/'
           FileUtils.cp_r(source_dir,destination)
        end
      end

      #
      # Copy fonts
      #
      def self.copy_fonts(type, destination)
        source = [Configuration::fonts, type] * '/'
        destination = [destination, 'fonts'] * '/'
        destination = File.expand_path destination

        FileUtils.mkdir_p(destination) unless File.exists?(destination)
        FileUtils.cp_r source, destination

        Hyla::logger2.info ">>   Fonts #{type} added to project #{destination}"
      end

    end # class Create
  end # module Commands
end # module Hyla

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hyla-1.0.9 lib/hyla/commands/add.rb
hyla-1.0.9.pre.3 lib/hyla/commands/add.rb
hyla-1.0.9.pre.2 lib/hyla/commands/add.rb
hyla-1.0.9.pre.1 lib/hyla/commands/add.rb
hyla-1.0.8 lib/hyla/commands/add.rb
hyla-1.0.7 lib/hyla/commands/add.rb
hyla-1.0.7.pre.9 lib/hyla/commands/add.rb
hyla-1.0.7.pre.8 lib/hyla/commands/add.rb