Class: Spout::Commands::ProjectGenerator
- Inherits:
-
Object
- Object
- Spout::Commands::ProjectGenerator
- Includes:
- Helpers::Framework
- Defined in:
- lib/spout/commands/project_generator.rb
Overview
Generates folder and file structure for a new spout data dictionary.
Instance Method Summary collapse
- #generate_folder_structure!(argv) ⇒ Object
-
#initialize(argv) ⇒ ProjectGenerator
constructor
A new instance of ProjectGenerator.
Methods included from Helpers::Framework
#copy_file, #directory, #evaluate_file
Constructor Details
#initialize(argv) ⇒ ProjectGenerator
Returns a new instance of ProjectGenerator.
13 14 15 |
# File 'lib/spout/commands/project_generator.rb', line 13 def initialize(argv) generate_folder_structure!(argv) end |
Instance Method Details
#generate_folder_structure!(argv) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/spout/commands/project_generator.rb', line 17 def generate_folder_structure!(argv) skip_gemfile = !argv.delete("--skip-gemfile").nil? @project_name = argv[1].to_s.strip @full_path = File.join(@project_name) usage = <<-EOT Usage: spout new FOLDER The FOLDER must be empty or new. EOT if @full_path == "" || (Dir.exist?(@full_path) && (Dir.entries(@full_path) & [".gitignore", ".ruby-version", ".travis.yml", "Gemfile", "gems.rb", "domains", "variables", "test"]).size > 0) puts usage exit(0) end FileUtils.mkpath(@full_path) copy_file "gitignore", ".gitignore" copy_file "ruby-version", ".ruby-version" copy_file "travis.yml", ".travis.yml" evaluate_file "spout.yml.erb", ".spout.yml" evaluate_file "CHANGELOG.md.erb", "CHANGELOG.md" copy_file "gems.rb" evaluate_file "README.md.erb", "README.md" copy_file "VERSION" directory "domains" copy_file "keep", "domains/.keep" directory "variables" copy_file "keep", "variables/.keep" directory "forms" copy_file "keep", "forms/.keep" directory "test" copy_file "test/dictionary_test.rb" copy_file "test/test_helper.rb" return if skip_gemfile puts " run".green + " bundle install".cyan Dir.chdir(@full_path) system "bundle install" end |