lib/travis/cli/encrypt.rb in travis-1.2.8 vs lib/travis/cli/encrypt.rb in travis-1.3.0

- old
+ new

@@ -1,8 +1,7 @@ # encoding: utf-8 require 'travis/cli' -require 'yaml' module Travis module CLI class Encrypt < RepoCommand attr_accessor :config_key @@ -31,26 +30,19 @@ data = split? ? data.split("\n") : [data] encrypted = data.map { |data| repository.encrypt(data) } if config_key set_config encrypted.map { |e| { 'secure' => e } } - File.write(travis_yaml, travis_config.to_yaml) + save_travis_config else list = encrypted.map { |data| format(data.inspect, " secure: %s") } say(list.join("\n"), template(__FILE__), :none) end end private - def travis_config - @travis_config ||= begin - payload = YAML.load_file(travis_yaml) - payload.respond_to?(:to_hash) ? payload.to_hash : {} - end - end - def set_config(result) parent_config[last_key] = merge_config(result) end def merge_config(result) @@ -84,20 +76,9 @@ when Hash then value else { 'matrix' => Array(value) } end traverse_config(hash[key], *rest) - end - - def travis_yaml(dir = Dir.pwd) - path = File.expand_path('.travis.yml', dir) - if File.exist? path - path - else - parent = File.expand_path('..', dir) - error "no .travis.yml found" if parent == dir - travis_yaml(parent) - end end end end end