Sha256: d789c9f62a9c7e2efc84bd73a4198b49f9b1c6fb9bb9fc6fbe0fb0ed2f61ea38

Contents?: true

Size: 1.56 KB

Versions: 2

Compression:

Stored size: 1.56 KB

Contents

require "cbaoth/version"

module Cbaoth
  
  class Generator

    def generate app_name
      vars = init_variables app_name
      create_app_name_dir app_name
      create_dir_structure vars[:working_directory]
      generate_base_files vars[:working_directory], vars[:gem_directory]
      alert_user app_name
    end

    def init_variables app_name
      wd = Dir.pwd + "/#{app_name}"
      gem_dir = File.dirname(__FILE__)

      { working_directory: wd, gem_directory: gem_dir }
    end

    def create_app_name_dir app_name
      puts "creating app '#{app_name}' folder"
      puts
      system "mkdir #{app_name}"
    end

    def create_dir_structure wd
      puts "creating base app dir structure"
      puts
      system "mkdir -p #{wd}/lib #{wd}/bin #{wd}/config #{wd}/db/migrate"
    end

    def generate_base_files wd, gem_dir
      puts "generating base files"
      puts
      base_files = gem_dir + "/base_files"
      system "cp #{base_files}/base_gemfile #{wd}/Gemfile"
      system "cp #{base_files}/base_rakefile #{wd}/Rakefile"
      system "cp #{base_files}/base_readme #{wd}/README.md"
      system "cp #{base_files}/base_database.yml #{wd}/config/database.yml"
    end

    def alert_user app_name
      puts
      puts "*" * 90
      puts "App created if you want to set up rspec and guard follow the instructions below:"
      puts "-" * 90
      puts "\t$ cd #{app_name}"
      puts "\t$ rspec --init"
      puts "\t$ guard init rspec"
      puts
      puts "That's it. Thanks for using cbaoth."
      puts "Happy rubying =) - #{ENV["LOGNAME"]}"
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cbaoth-0.0.3 lib/cbaoth.rb
cbaoth-0.0.2 lib/cbaoth.rb