Class: Travis::CLI::Env
- Inherits:
-
RepoCommand
- Object
- Command
- ApiCommand
- RepoCommand
- Travis::CLI::Env
- Defined in:
- lib/travis/cli/env.rb
Constant Summary
Constants inherited from RepoCommand
RepoCommand::GIT_REGEX, RepoCommand::TRAVIS
Constants inherited from Command
Command::DAY, Command::HOUR, Command::MINUTE, Command::WEEK
Constants included from Tools::Assets
Instance Attribute Summary
Attributes inherited from RepoCommand
Attributes inherited from ApiCommand
Attributes inherited from Command
#arguments, #config, #debug, #force_interactive, #formatter, #input, #output
Instance Method Summary collapse
- #copy(*names) ⇒ Object
- #env_vars ⇒ Object
- #list ⇒ Object
- #set(name, value) ⇒ Object
- #setup ⇒ Object
- #unset(*names) ⇒ Object
Methods inherited from RepoCommand
Methods inherited from ApiCommand
#authenticate, #detected_endpoint?, #endpoint_config, #enterprise?, #initialize, #org?, #pro?, #sync
Methods included from Travis::Client::Methods
#access_token, #access_token=, #account, #accounts, #api_endpoint, #api_endpoint=, #artifact, #broadcasts, #build, #cancel, #explicit_api_endpoint?, #github_auth, #hooks, #job, #lint, #listen, #repo, #repos, #restart, #user
Methods inherited from Command
abstract, abstract?, #check_completion, #check_ruby, #check_version, command_name, #command_name, #debug?, description, #execute, #help, #info, #initialize, #last_check, #on_signal, #parse, #say, skip, subcommands, #terminal, #time, #usage, #usage_for, #write_to
Methods included from Tools::Assets
Methods included from Parser
Constructor Details
This class inherits a constructor from Travis::CLI::ApiCommand
Instance Method Details
#copy(*names) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/travis/cli/env.rb', line 27 def copy(*names) names.each do |name| if ENV.include? name set(name, ENV[name]) else warn "missing in current environment: #{color "$#{name}", :bold}" end end end |
#env_vars ⇒ Object
50 51 52 |
# File 'lib/travis/cli/env.rb', line 50 def env_vars repository.env_vars end |
#list ⇒ Object
45 46 47 48 |
# File 'lib/travis/cli/env.rb', line 45 def list say color("# environment variables for #{color repository.slug, :bold}", :info) env_vars.each { |v| say "#{v.name}=" << color(v.value || "[secure]", :bold) } end |
#set(name, value) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/travis/cli/env.rb', line 20 def set(name, value) ||= { :public => public } if public != nil say color('[+] ', [:green, :bold]) + "setting environment variable #{color "$#{name}", :info}" value = Shellwords.escape(value) unless unescape? env_vars.upsert(name, value, || {}) end |
#setup ⇒ Object
14 15 16 17 18 |
# File 'lib/travis/cli/env.rb', line 14 def setup super authenticate error "not allowed to access environment variables for #{color(repository.slug, :bold)}" unless repository.admin? end |
#unset(*names) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/travis/cli/env.rb', line 37 def unset(*names) env_vars.each do |var| next unless names.include? var.name say color('[x] ', [:red, :bold]) + "removing environment variable #{color "$#{var.name}", :info}" var.delete end end |