Class: Sumodev::Commands::Box

Inherits:
Sumodev::Command show all
Defined in:
lib/sumodev/commands/box.rb

Instance Method Summary collapse

Methods inherited from Sumodev::Command

banner

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



94
95
96
# File 'lib/sumodev/commands/box.rb', line 94

def method_missing(*args)
  run_vagrant_command(args.join(" "))
end

Instance Method Details

#installObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/sumodev/commands/box.rb', line 65

def install
  # install vagrant plugins
  %x(vagrant plugin install vagrant-ohai)
  %x(vagrant plugin install vagrant-omnibus)

  # install .sumorc file
  File.open(File.expand_path("~/.sumorc"), 'w') do |f|
    f.write <<-SUMORC
      export SUMO_VAGRANT_PATH=""
SUMORC
  end unless File.exists?(File.expand_path("~/.sumorc"))

  # setup resolver
  File.open("/tmp/vagrant-resolver", 'w') do |f|
    f.write <<-RESOLVER
# Created by sumo command
nameserver 10.11.12.13
port 53
    RESOLVER
  end

  %x(sudo mv /tmp/vagrant-resolver /etc/resolver/vagrant)
end

#upObject



54
55
56
57
58
59
60
61
62
# File 'lib/sumodev/commands/box.rb', line 54

def up
  say("There is already a box running, you should manually start the box. Or halt the running instance", :red) && exit(1) if box_running?

  convert_sumofile_into_env_variables
  configure_port_mapping
  run_vagrant_command("up", "--provision")
rescue Sumodev::Sumofile::NoSuchFileError
  say("No Sumofile found! Please define one so the correct versions will be used!", :red) && exit(1)
end

#your_command(*args) ⇒ Object



90
91
92
# File 'lib/sumodev/commands/box.rb', line 90

def your_command(*args)
  say "Use sumo box <command> you bloody idiot, eg: sumo box ssh"
end