Class: Homesteading::New

Inherits:
Object
  • Object
show all
Defined in:
lib/homesteading/commands/new.rb

Constant Summary collapse

PUBLISHER_APPS =
["article", "bookmark", "event", "note", "photo", "sound", "video", "walk", "weight"]
NONPUBLISHER_APPS =

TODO “syndicator”

["hub", "router-rack"]

Class Method Summary collapse

Class Method Details

.default(options = nil) ⇒ Object



7
8
9
10
11
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
# File 'lib/homesteading/commands/new.rb', line 7

def default(options=nil)
  puts

  # Parse command line options
  options = {}
  optparse = OptionParser.new do |opts|
    opts.on("-p", "--pretend", "Run but do not make any changes") do |pretend|
      options[:pretend] = pretend
    end

    opts.on("-q", "--quiet", "Suppress status output") do |quiet|
      options[:quiet] = quiet
    end
  end
  optparse.parse!


  # Install location
  constellation_dir = ARGV.shift

  unless options[:quiet]
    puts "* Creating homesteading directory:      #{constellation_dir}"
  end

  unless options[:pretend]
    puts
    system("mkdir -p #{constellation_dir}")
  end

  [NONPUBLISHER_APPS, PUBLISHER_APPS].flatten.each do |app|
    unless options[:quiet]
      puts "* Cloning homesteading app from GitHub: #{app}"
    end

    unless options[:pretend]
      puts
      system("cd #{constellation_dir} && git clone [email protected]:homesteading/homesteading-#{app}.git")
      puts
    end
  end

  unless options[:pretend]
    system("cd #{constellation_dir}")
  end

  puts
end