Class: BaseChip::InstallMenu
- Includes:
- Cli
- Defined in:
- lib/base_chip/install_menu.rb
Instance Method Summary collapse
-
#after ⇒ Object
@table = [] case pattern when /^/(.*)/$/ ; @pattern = /#$1/ else ; @pattern = pattern end # exit unless BaseChip.project.blocks.
- #before(name) ⇒ Object
- #plugin(name) ⇒ Object
- #recipe(name) ⇒ Object
- #tool(name, version = nil) ⇒ Object
Methods included from Cli
Methods inherited from Menu
Methods included from Reporting
Instance Method Details
#after ⇒ Object
@table = [] case pattern when /^/(.*)/$/ ; @pattern = /#$1/ else ; @pattern = pattern end # exit unless BaseChip.project.blocks
31 32 33 34 35 |
# File 'lib/base_chip/install_menu.rb', line 31 def after if @table.size > 0 print_table(@table,'=>') end end |
#before(name) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/base_chip/install_menu.rb', line 22 def before(name) BaseChip.load_environment # \@table = [] # case pattern # when /^\/(.*)\/$/ ; @pattern = /#\{$1}/ # else ; @pattern = pattern # end # # exit unless BaseChip.project.blocks end |
#plugin(name) ⇒ Object
57 58 59 |
# File 'lib/base_chip/install_menu.rb', line 57 def plugin(name) fault "This feature is soon forthcoming" end |
#recipe(name) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/base_chip/install_menu.rb', line 38 def recipe(name) name_a = name.split /:/ fault "Recipe names should be of the format 'author_name:recipe_name'" unless name_a.size == 2 begin infile = open("http://basechip.com/recipe_code/#{name_a.first}/#{name_a.last}") rescue OpenURI::HTTPError fault "Recipe '#{name}' could not be found" end file = "#{BaseChip.root}/base_chip/recipes/#{name_a.last}.rb" out = File.open(file,"w") out.puts infile.read out.close infile.close puts "Recipe '#{name}' installed as #{file}" end |
#tool(name, version = nil) ⇒ Object
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 |
# File 'lib/base_chip/install_menu.rb', line 62 def tool(name, version=nil) before(name) tools = [] n = name.to_sym BaseChip.tools.each do |tool| next unless tool.name.to_s == n.to_s tools << tool end unless tools[0] puts "Available tools are:" ListMenu.new.run_cli(%w{tools --show select_version}) fault "No tool found named '#{name}'. Consider installing a recipe to teach basechip how to install '#{name}'" end versions = [] tools.each do |tool| tool.configure if version if v = tool.versions[version] versions << v end else versions << tool.selected_version end end unless versions[0] puts "Available versions for tool '#{name}' are:" ListMenu.new.run_cli(['tools', name, '--show', 'available_versions']) fault "No version found named '#{version}' for tool '#{name}'." end puts "Installing version(s) #{versions.map{|v|v.name}.uniq} for tool '#{name}'" installed = [] versions.each do |version| next if installed.include? version.name installed << version.name version.configure fault "shared_directory must be specified in project for install locations" unless version.project.shared_directory puts "cd #{version.project.shared_directory}\n#{version.install}" system "cd #{version.project.shared_directory}\n#{version.install}" end end |