Class: Travis::CLI::Encrypt
- Inherits:
-
RepoCommand
- Object
- Command
- ApiCommand
- RepoCommand
- Travis::CLI::Encrypt
- Defined in:
- lib/travis/cli/encrypt.rb
Constant Summary
Constants inherited from RepoCommand
Instance Attribute Summary collapse
-
#config_key ⇒ Object
Returns the value of attribute config_key.
Attributes inherited from RepoCommand
Attributes inherited from ApiCommand
Attributes inherited from Command
#arguments, #config, #force_interactive, #terminal
Instance Method Summary collapse
Methods inherited from RepoCommand
Methods inherited from ApiCommand
#authenticate, #detected_endpoint?, #endpoint_config, #initialize, #org?, #pro?, #setup
Methods included from Travis::Client::Methods
#access_token, #access_token=, #api_endpoint, #api_endpoint=, #explicit_api_endpoint?, #github_auth, #repo, #repos, #user
Methods inherited from Command
abstract, abstract?, command_name, #command_name, #execute, #help, #initialize, #input, #input=, #output, #output=, #parse, #say, #setup, skip, #usage, #write_to
Methods included from Parser
Constructor Details
This class inherits a constructor from Travis::CLI::ApiCommand
Instance Attribute Details
#config_key ⇒ Object
Returns the value of attribute config_key.
8 9 10 |
# File 'lib/travis/cli/encrypt.rb', line 8 def config_key @config_key end |
Instance Method Details
#run(*args) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/travis/cli/encrypt.rb', line 14 def run(*args) data = args.join(" ") if data.empty? say color("Reading from stdin, press Ctrl+D when done", :info) if $stdin.tty? data = $stdin.read end encrypted = repository.encrypt(data) if config_key travis_config = YAML.load_file(travis_yaml) keys = config_key.split('.') last_key = keys.pop nested_config = keys.inject(travis_config) { |c,k| c[k] ||= {}} nested_config[last_key] ||= [] << { 'secret' => encrypted } File.write(travis_yaml, travis_config.to_yaml) else say encrypted.inspect, template(__FILE__) end end |