class Tacoma::Command
Constants
- TOOLS
Public Class Methods
source_root()
click to toggle source
# File lib/tacoma/command.rb, line 161 def self.source_root File.dirname(__FILE__) end
Public Instance Methods
build_template_path(template_name)
click to toggle source
# File lib/tacoma/command.rb, line 167 def build_template_path(template_name) Pathname.new( "#{self.class.source_root}/../template/#{template_name}" ).realpath.to_s end
cd(environment)
click to toggle source
# File lib/tacoma/command.rb, line 133 def cd(environment) return unless switch(environment) Dir.chdir `echo #{@repo}`.strip puts 'Welcome to the tacoma shell' shell = ENV['SHELL'].split('/').last options = case shell when 'zsh' '' else '--login' end system("#{shell} #{options}") Process.kill(:SIGQUIT, Process.getpgid(Process.ppid)) end
current()
click to toggle source
# File lib/tacoma/command.rb, line 91 def current puts Tool.current_environment true end
install()
click to toggle source
# File lib/tacoma/command.rb, line 151 def install if File.exist?(File.join(Dir.home, '.tacoma.yml')) puts "File ~/.tacoma.yml already present, won't overwrite" else template_path = build_template_path('tacoma.yml') new_path = File.join(Dir.home, '.tacoma.yml') template template_path, new_path end end
list()
click to toggle source
# File lib/tacoma/command.rb, line 69 def list Tool.config.each_key do |key| puts key end end
switch(environment)
click to toggle source
# File lib/tacoma/command.rb, line 99 def switch(environment) if Tool.load_vars(environment) @aws_identity_file = Tool.aws_identity_file @aws_secret_access_key = Tool.aws_secret_access_key @aws_access_key_id = Tool.aws_access_key_id @region = Tool.region @repo = Tool.repo @s3cfg = Tool.s3cfg # set configurations for tools TOOLS.each do |tool, config_path| template_path = build_template_path(tool) file_path = File.join(Dir.home, config_path) template template_path, file_path, force: true end system("ssh-add #{@aws_identity_file}") if options[:'with-exports'] puts "export AWS_SECRET_ACCESS_KEY=#{@aws_secret_access_key}" puts "export AWS_SECRET_KEY=#{@aws_secret_access_key}" puts "export AWS_ACCESS_KEY=#{@aws_access_key_id}" puts "export AWS_ACCESS_KEY_ID=#{@aws_access_key_id}" puts "export AWS_DEFAULT_REGION=#{@region}" end update_environment_to_cache(environment) true else false end end
version()
click to toggle source
# File lib/tacoma/command.rb, line 82 def version puts "tacoma, version #{Tacoma::VERSION}" puts 'Configuration templates available for:' TOOLS.each do |tool, config_path| puts " #{tool} => '~/#{config_path}'" end end