Class: Homesteading::New
- Defined in:
- lib/homesteading/commands/new.rb
Constant Summary collapse
- PUBLISHER_APPS =
PUBLISHER_APPS = [“article”, “bookmark”, “event”, “note”, “photo”, “sound”, “video”, “walk”, “weight”]
["publisher-note"]
- NONPUBLISHER_APPS =
TODO “hub”, “syndicator”
["router-rack"]
Constants inherited from Command
Instance Method Summary collapse
Methods inherited from Command
Instance Method Details
#default ⇒ Object
12 13 14 15 16 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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/homesteading/commands/new.rb', line 12 def default puts = # Install location constellation_dir = ARGV.shift constellation_path = "#{Dir.pwd}/#{constellation_dir}" if File.exist?(constellation_path) unless [:quiet] puts "* #{constellation_path} already exists" puts "* Using #{constellation_path}" end else unless [:quiet] puts "* Creating homesteading directory: #{constellation_dir}" end unless [:pretend] FileUtils.mkpath constellation_dir end end # Apps to install apps = [NONPUBLISHER_APPS, PUBLISHER_APPS].flatten if [:only] apps = [:only].split(",").map { |a| a.downcase } end if [:except] only_list = [:except].split(",").map { |a| a.downcase } apps = apps.delete_if { |a| only_list.include?(a) } end apps.each do |app| unless [:pretend] puts end app_dir = "#{constellation_path}/homesteading-#{app}" if File.exist?(app_dir) if [:skip] unless [:quiet] puts "* #{app_dir} already exists" puts "* Skipping homesteading-#{app}" end elsif [:force] unless [:quiet] puts "* #{app_dir} already exists" puts "* Removing homesteading-#{app}" end unless [:pretend] FileUtils.rm_rf app_dir end unless [:quiet] puts "* Cloning homesteading app from GitHub: #{app}" end unless [:pretend] FileUtils.cd constellation_dir do system "git clone [email protected]:homesteading/homesteading-#{app}.git" end end else unless [:quiet] puts "* #{app_dir} already exists" puts "* TODO gets user input on what to do about the conflict" end end else unless [:quiet] puts "* Cloning homesteading app from GitHub: #{app}" end unless [:pretend] FileUtils.cd constellation_dir do system "git clone [email protected]:homesteading/homesteading-#{app}.git" end end end end puts Homesteading::Command.create("init").default(constellation_dir) unless [:quiet] puts "* Next up, do this:" puts " cd #{constellation_dir}" puts " homesteading server" end puts end |