Sha256: e886e07d689b17605b83b1aeb573240987b047f5bfd7ab531c3fb20d3478740e

Contents?: true

Size: 1.8 KB

Versions: 5

Compression:

Stored size: 1.8 KB

Contents

require File.join(File.dirname(__FILE__), "..", 'lib', 'dmeta')

module Decoct
    
    class Dscript
      
      include Decoct::Dmeta

      attr_accessor :app_name
      
      create_dir [:lib, :spec, :views, :public, :icons]

      def initialize(app_name)
        fail "app name cannot be nil or empty!!!" if app_name.eql?(nil) || app_name.empty?
        @app_name = app_name      
      end

      def run
        create_app_dir
        create_lib
        create_spec
        create_views
        create_public
        create_icons
        copy_autotest_file
        copy_rspec_files
        copy_app_file
        copy_icons
      end
      
      def create_app_dir
        Dir.mkdir("#{app_name}") if !test(?d, "#{app_name}")
      end

      def copy_autotest_file
        copy_file(".autotest", "#{app_name}#{File::SEPARATOR}.autotest") 
      end

      def copy_rspec_files
	from = ["spec#{File::SEPARATOR}spec.opts", "spec#{File::SEPARATOR}rcov.opts", "spec#{File::SEPARATOR}spec_helper.rb", "spec#{File::SEPARATOR}app_spec.rb"]
	to = ["#{app_name}#{File::SEPARATOR}spec#{File::SEPARATOR}spec.opts", "#{app_name}#{File::SEPARATOR}spec#{File::SEPARATOR}rcov.opts", "#{app_name}#{File::SEPARATOR}spec#{File::SEPARATOR}spec_helper.rb", "#{app_name}#{File::SEPARATOR}spec#{File::SEPARATOR}#{app_name}_spec.rb"]
	copy_file(from, to)
      end

      def copy_app_file
        copy_file("generic_app.rb", "#{app_name}#{File::SEPARATOR}#{app_name}.rb")
      end
      
      def copy_icons
        from = ["icons#{File::SEPARATOR}fail.png", "icons#{File::SEPARATOR}ok.png"]
        to = [ "#{app_name}#{File::SEPARATOR}icons#{File::SEPARATOR}fail.png",  "#{app_name}#{File::SEPARATOR}icons#{File::SEPARATOR}ok.png"]
        copy_file(from, to)
      end
      
    end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
andhapp-decoct-1.5.4 lib/dscript.rb
andhapp-decoct-1.6.4 lib/dscript.rb
andhapp-decoct-1.7.4 lib/dscript.rb
andhapp-decoct-1.8.4 lib/dscript.rb
andhapp-decoct-1.9.5 lib/dscript.rb