Class: Homesteading::Update

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

Constant Summary

Constants inherited from Command

Command::COMMANDS

Instance Method Summary collapse

Methods inherited from Command

create, register

Instance Method Details

#clientObject



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
# File 'lib/homesteading/commands/update.rb', line 30

def client
  puts

  options = parse_options

  if options[:beta]
    puts "* Cloning Homesteading from GitHub into /tmp"
    FileUtils.cd "/tmp" do
      system "git clone [email protected]:homesteading/homesteading.git"
    end

    puts "* Building homesteading gem from .gemspec"
    FileUtils.cd "/tmp/homesteading" do
      system "gem build homesteading.gemspec"
    end

    dot_gem = Dir.glob("/tmp/homesteading/*.gem").last
    version = dot_gem.split("/").last.sub("homesteading-", "").sub(".gem", "")

    puts "* Installing homesteading version #{version}"
    system "gem install #{dot_gem}"

    puts "* Cleaning up"
    FileUtils.rm_rf "/tmp/homesteading"

    puts "* Homesteading CLI version #{version} successfully installed from GitHub"
  else
    system "gem install homesteading"
  end

  puts
end

#defaultObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/homesteading/commands/update.rb', line 7

def default
  puts

  options = parse_options
  hs_path = options[:hs_path] || Dir.pwd

  Dir.glob("#{hs_path}/*").each do |dir|
    unless Dir.glob("#{dir}/.git/config").empty?
      puts "* Updating #{dir.split("/").last}..."

      FileUtils.cd dir do
        system "git pull origin master"
      end

      puts "* ...done"
      puts
    end
  end

  puts "* All Homesteading apps are up to date"
  puts
end