lib/jiralicious/configuration.rb in jiralicious-0.1.0 vs lib/jiralicious/configuration.rb in jiralicious-0.2.0
- old
+ new
@@ -1,13 +1,13 @@
# encoding: utf-8
-
+require 'ostruct'
module Jiralicious
module Configuration
VALID_OPTIONS = [:username, :password, :uri, :api_version, :auth_type]
DEFAULT_USERNAME = nil
- DEFAULT_AUTH_TYPE = :basic
DEFAULT_PASSWORD = nil
+ DEFAULT_AUTH_TYPE = :basic
DEFAULT_URI = nil
DEFAULT_API_VERSION = "latest"
def configure
yield self
@@ -30,8 +30,19 @@
self.username = DEFAULT_USERNAME
self.password = DEFAULT_PASSWORD
self.uri = DEFAULT_URI
self.api_version = DEFAULT_API_VERSION
self.auth_type = DEFAULT_AUTH_TYPE
+ end
+
+ def load_yml(yml_file)
+ if File.exist?(yml_file)
+ yml_cfg = OpenStruct.new(YAML.load_file(yml_file))
+ yml_cfg.jira.each do |k, v|
+ instance_variable_set("@#{k}", v)
+ end
+ else
+ reset
+ end
end
end
end