lib/fastly.rb in fastly-0.95 vs lib/fastly.rb in fastly-0.96
- old
+ new
@@ -3,11 +3,11 @@
# License:: Distributes under the same terms as Ruby
# A client library for interacting with the Fastly web acceleration service
class Fastly
# The current version of the library
- VERSION = "0.95"
+ VERSION = "0.96"
require 'fastly/fetcher'
require 'fastly/client'
require 'fastly/base'
@@ -407,17 +407,18 @@
def self.load_config(file)
options = {}
return options unless File.exist?(file)
File.open(file, "r") do |infile|
- while (line = infile.gets.chomp) do
+ while (line = infile.gets) do
+ line.chomp!
next if line =~ /^#/;
next if line =~ /^\s*$/;
next unless line =~ /=/;
line.strip!
key, val = line.split(/\s*=\s*/, 2)
- options[key] = val;
+ options[key.to_sym] = val;
end
end
options;
end
@@ -428,19 +429,19 @@
# Then it overrides those options with command line options
# of the form
#
# --<key>=<value>
#
- def self.get_options(files)
+ def self.get_options(*files)
options = {}
files.each do |file|
next unless File.exist?(file)
- options = load_options(file)
+ options = load_config(file)
break
end
while (ARGV.size>0 && ARGV[0] =~ /^-+(\w+)\=(\w+)$/) do
- options[$1] = $2;
+ options[$1.to_sym] = $2;
@ARGV.shift;
end
raise"Couldn't find options from command line arguments or #{files.join(', ')}" unless options.size>0
options;
end