lib/nv/config.rb in nv-1.0.1 vs lib/nv/config.rb in nv-1.2.1
- old
+ new
@@ -1,9 +1,8 @@
require 'ostruct'
require 'yaml'
require 'fileutils'
-require 'active_support/core_ext'
class String
def undent
gsub(/^.{#{slice(/^ +/).length}}/, '')
end
@@ -23,11 +22,11 @@
super(@config)
end
def save
File.open(@config_path, 'w') do |f|
- f.print YAML.dump(self.to_h.stringify_keys)
+ f.print YAML.dump(transform_keys(self.to_h){|k| k.to_s})
end
end
def verify_for_authentication
self.email && self.password
@@ -40,8 +39,18 @@
$ nv config email <email>
$ nv config password <password>
EOD
exit
end
+ end
+
+ private
+
+ def transform_keys(hs)
+ result = {}
+ hs.each_key do |key|
+ result[yield(key)] = hs[key]
+ end
+ result
end
end
end