Class: FlexmlsApi::Configuration::YamlConfig
- Inherits:
-
Object
- Object
- FlexmlsApi::Configuration::YamlConfig
- Defined in:
- lib/flexmls_api/configuration/yaml.rb
Constant Summary collapse
- KEY_CONFIGURATIONS =
VALID_OPTION_KEYS + [:oauth2] + OAUTH2_KEYS
- DEFAULT_OAUTH2_PROVIDER =
"FlexmlsApi::Authentication::OAuth2Impl::PasswordProvider"
Instance Attribute Summary collapse
-
#client_keys ⇒ Object
readonly
Returns the value of attribute client_keys.
-
#oauth2_keys ⇒ Object
readonly
Returns the value of attribute oauth2_keys.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
Class Method Summary collapse
- .build(name) ⇒ Object
- .config_keys ⇒ Object
-
.config_path ⇒ Object
Used to specify the root of where to look for flexmlsApi config files.
- .exists?(name) ⇒ Boolean
Instance Method Summary collapse
- #api_env ⇒ Object
-
#initialize(filename = nil) ⇒ YamlConfig
constructor
A new instance of YamlConfig.
- #load_file(file) ⇒ Object
- #name ⇒ Object
- #oauth2? ⇒ Boolean
Constructor Details
#initialize(filename = nil) ⇒ YamlConfig
Returns a new instance of YamlConfig.
11 12 13 14 |
# File 'lib/flexmls_api/configuration/yaml.rb', line 11 def initialize(filename=nil) @oauth2 = false load_file(filename) unless filename.nil?() end |
Instance Attribute Details
#client_keys ⇒ Object (readonly)
Returns the value of attribute client_keys.
9 10 11 |
# File 'lib/flexmls_api/configuration/yaml.rb', line 9 def client_keys @client_keys end |
#oauth2_keys ⇒ Object (readonly)
Returns the value of attribute oauth2_keys.
9 10 11 |
# File 'lib/flexmls_api/configuration/yaml.rb', line 9 def oauth2_keys @oauth2_keys end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
9 10 11 |
# File 'lib/flexmls_api/configuration/yaml.rb', line 9 def provider @provider end |
Class Method Details
.build(name) ⇒ Object
56 57 58 |
# File 'lib/flexmls_api/configuration/yaml.rb', line 56 def self.build(name) yaml = YamlConfig.new("#{config_path}/#{name}.yml") end |
.config_keys ⇒ Object
47 48 49 50 |
# File 'lib/flexmls_api/configuration/yaml.rb', line 47 def self.config_keys() files = Dir["#{config_path}/*.yml"] files.map {|f| File.basename(f,".yml") } end |
.config_path ⇒ Object
Used to specify the root of where to look for flexmlsApi config files
43 44 45 |
# File 'lib/flexmls_api/configuration/yaml.rb', line 43 def self.config_path path_prefix + "config/flexmls_api" end |
.exists?(name) ⇒ Boolean
52 53 54 |
# File 'lib/flexmls_api/configuration/yaml.rb', line 52 def self.exists?(name) File.exists? "#{config_path}/#{name}.yml" end |
Instance Method Details
#api_env ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/flexmls_api/configuration/yaml.rb', line 32 def api_env current_env = "development" if env.include?("FLEXMLS_API_ENV") current_env = env["FLEXMLS_API_ENV"] elsif env.include?("RAILS_ENV") current_env = env["RAILS_ENV"] end return current_env end |
#load_file(file) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/flexmls_api/configuration/yaml.rb', line 15 def load_file(file) @file = file @name = File.basename(file, ".yml") config = YAML.load(ERB.new(File.read(file)).result)[api_env] config["oauth2"] == true ? load_oauth2(config) : load_api_auth(config) rescue => e FlexmlsApi.logger().error("Unable to load config file #{file}[#{api_env}]") raise e end |
#name ⇒ Object
29 30 31 |
# File 'lib/flexmls_api/configuration/yaml.rb', line 29 def name @name end |
#oauth2? ⇒ Boolean
25 26 27 |
# File 'lib/flexmls_api/configuration/yaml.rb', line 25 def oauth2? return oauth2 == true end |