Class: Lono::Configset::New
- Includes:
- Blueprint::Helper
- Defined in:
- lib/lono/configset/new.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_license ⇒ Object
- #create_project ⇒ Object
-
#set_cwd ⇒ Object
for specs.
-
#set_destination_root ⇒ Object
After this commands are executed with the newly created project.
- #set_variables ⇒ Object
- #tree ⇒ Object
- #welcome_message ⇒ Object
Methods included from Blueprint::Helper
Class Method Details
.cli_options ⇒ Object
12 13 14 15 16 17 |
# File 'lib/lono/configset/new.rb', line 12 def self. [ [:demo, type: :boolean, default: true, desc: "Include demo template"], [:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files."], ] end |
.source_root ⇒ Object
7 8 9 10 |
# File 'lib/lono/configset/new.rb', line 7 def self.source_root templates = File.("../../templates", File.dirname(__FILE__)) "#{templates}/configset" end |
Instance Method Details
#create_license ⇒ Object
45 46 47 48 |
# File 'lib/lono/configset/new.rb', line 45 def create_license return unless ENV['LONO_LICENSE_FILE'] copy_file ENV['LONO_LICENSE_FILE'], "#{@cwd}/#{configset_name}/LICENSE.txt" end |
#create_project ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/lono/configset/new.rb', line 33 def create_project puts "=> Creating new configset called #{configset_name}." if @demo = {} else create_file "#{@cwd}/#{configset_name}/lib/configset.yml" = {exclude_pattern: %r{configset\.yml}} end directory ".", "#{@cwd}/#{configset_name}", end |
#set_cwd ⇒ Object
for specs
24 25 26 |
# File 'lib/lono/configset/new.rb', line 24 def set_cwd @cwd = ENV['LONO_TEST'] ? File.dirname(Lono.root) : "#{Dir.pwd}/app/configsets" end |
#set_destination_root ⇒ Object
After this commands are executed with the newly created project
51 52 53 54 55 56 |
# File 'lib/lono/configset/new.rb', line 51 def set_destination_root destination_root = "#{@cwd}/#{configset_name}" self.destination_root = destination_root @old_dir = Dir.pwd # for reset_current_dir FileUtils.cd(self.destination_root) end |
#set_variables ⇒ Object
28 29 30 31 |
# File 'lib/lono/configset/new.rb', line 28 def set_variables @demo = @options[:demo] @demo = false if ENV["LONO_ORG"] # overrides --demo CLI option end |
#tree ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/lono/configset/new.rb', line 72 def tree tree_installed = system("type tree > /dev/null") return unless tree_installed structure = `tree .` puts <<~EOL Here is the structure of your configset: #{structure} EOL end |
#welcome_message ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/lono/configset/new.rb', line 58 def puts <<~EOL #{"="*64} Congrats 🎉 You have successfully created a lono configset. Cd into your configset and check things out. cd #{configset_name} More info: https://lono.cloud/docs/core/configsets EOL end |