lib/travis/cli/command.rb in travis-1.7.2.travis.635.5 vs lib/travis/cli/command.rb in travis-1.7.2.travis.636.5
- old
+ new
@@ -357,14 +357,17 @@
return unless path = config_path(name) and File.exist? path
debug "Deleting %p" % path
File.delete(path)
end
- def save_file(name, content)
+ def save_file(name, content, read_only = false)
path = config_path(name)
debug "Storing %p" % path
- File.write(path, content.to_s)
+ File.open(path, 'w') do |file|
+ file.write(content.to_s)
+ file.chmod(0600) if read_only
+ end
end
YAML_ERROR = defined?(Psych::SyntaxError) ? Psych::SyntaxError : ArgumentError
def load_config
@config = YAML.load load_file('config.yml', '{}')
@@ -376,10 +379,10 @@
exit 1 unless interactive? and agree("Remove config file? ") { |q| q.default = "no" }
@original_config, @config = {}, {}
end
def store_config
- save_file('config.yml', @config.to_yaml)
+ save_file('config.yml', @config.to_yaml, true)
end
def check_arity(method, *args)
return unless method.respond_to? :parameters
method.parameters.each do |type, name|