Sha256: cef005c2c162f7b0e9aacdc0e9b563edd892078c3d8ad71de84d30baba931c67

Contents?: true

Size: 1.28 KB

Versions: 7

Compression:

Stored size: 1.28 KB

Contents

module Deano
  class NewProjectGenerator < Deano::NameCommand

    def self.command
      "new"
    end

    def self.help
      "name"
    end

    def initialize(*args)
      super
      @app_dir = File.expand_path(File.join(FileUtils.pwd, self.underscored))
    end

    def classified
      "#{self.name.classify}App"
    end

    def call
      FileUtils.mkdir self.underscored, verbose: true
      Dir[template_path("**", "*")].each do |f|
        if File.directory?(f)
          FileUtils.mkdir_p clean_string(f), verbose: true
        else
          FileUtils.mkdir_p clean_string(File.dirname(f)), verbose: true
          File.open(clean_string(f), 'w') do |file|
            file.puts clean_string(File.read(f))
          end
        end
      end
      File.open(app_path(".gitignore"), "w") do |f|
        f.puts File.read(template_path(".gitignore"))
      end
      rm app_path("Gemfile.lock")
      Dir[app_path("**", "*")].each do |file|
        if File.directory?(file)
          if Dir[File.join(file, "**", "*")].empty?
            File.open(File.join(file, ".git-keep"), 'w') {|f| f.puts ""}
          end
        end
      end
      FileUtils.cd app_path
      system "bundle"
      system "git init"
      system "git add ."
      system "git commit -a -m 'Initial Commit'"
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
deano-1.2.1 lib/deano/commands/new_project_generator_command.rb
deano-1.2.0 lib/deano/commands/new_project_generator_command.rb
deano-1.1.3 lib/deano/commands/new_project_generator_command.rb
deano-1.1.2 lib/deano/commands/new_project_generator_command.rb
deano-1.1.1 lib/deano/commands/new_project_generator_command.rb
deano-1.1.0 lib/deano/commands/new_project_generator_command.rb
deano-1.0.0 lib/deano/commands/new_project_generator_command.rb