diff options
author | elijah <elijah@riseup.net> | 2014-03-24 10:16:56 -0700 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2014-03-24 10:16:56 -0700 |
commit | 7272dfa3c6d4c3c8877eea2a66fe84c7904cafa5 (patch) | |
tree | dd0d9cd0566e96c6c01700c6e58349a38be5f257 /lib/leap_cli/config/macros.rb | |
parent | 347f4d0b301b19a791f463af4b21a66ec8596a4a (diff) |
fixed problems when default encoding is not utf8
Diffstat (limited to 'lib/leap_cli/config/macros.rb')
-rw-r--r-- | lib/leap_cli/config/macros.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/leap_cli/config/macros.rb b/lib/leap_cli/config/macros.rb index 69b3a22..c6938fe 100644 --- a/lib/leap_cli/config/macros.rb +++ b/lib/leap_cli/config/macros.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 # # MACROS # these are methods available when eval'ing a value in the .json configuration @@ -60,9 +61,9 @@ module LeapCli; module Config filepath = Path.find_file(filename) if filepath if filepath =~ /\.erb$/ - ERB.new(File.read(filepath), nil, '%<>').result(binding) + ERB.new(File.read(filepath, :encoding => 'UTF-8'), nil, '%<>').result(binding) else - File.read(filepath) + File.read(filepath, :encoding => 'UTF-8') end else raise FileMissing.new(Path.named_path(filename), options) @@ -343,14 +344,14 @@ module LeapCli; module Config hash = {} keys = Dir.glob(Path.named_path([:user_ssh, '*'])) keys.sort.each do |keyfile| - ssh_type, ssh_key = File.read(keyfile).strip.split(" ") + ssh_type, ssh_key = File.read(keyfile, :encoding => 'UTF-8').strip.split(" ") name = File.basename(File.dirname(keyfile)) hash[name] = { "type" => ssh_type, "key" => ssh_key } end - ssh_type, ssh_key = File.read(Path.named_path(:monitor_pub_key)).strip.split(" ") + ssh_type, ssh_key = File.read(Path.named_path(:monitor_pub_key), :encoding => 'UTF-8').strip.split(" ") hash[Leap::Platform.monitor_username] = { "type" => ssh_type, "key" => ssh_key |