Sha256: 137944491ecb80be3d355d1020205f085c66032f9041b9d3cd99350da549a6fc
Contents?: true
Size: 1.37 KB
Versions: 2
Compression:
Stored size: 1.37 KB
Contents
# TODO: try to see if you can implement Environment variables module K2Config @config = YAML.load_file(File.join(File.dirname(__FILE__), 'k2_config.yml')).with_indifferent_access class << self # Set the Host Url def set_base_url(base_url) raise ArgumentError, 'Invalid URL Format.' unless base_url =~ /\A#{URI.regexp(%w[http https])}\z/ @config[:base_url] = base_url File.open("lib/k2-connect-ruby/k2_utilities/config/k2_config.yml", 'w') { |f| YAML.dump(@config, f) } end # TODO: Versioning def set_version(version_number) raise ArgumentError, 'Invalid Format: Version Number input should be Numeric' unless version_number.is_a?(Numeric) @config[:version] = "v#{version_number}" File.open("lib/k2-connect-ruby/k2_utilities/config/k2_config.yml", 'w') { |f| YAML.dump(@config, f) } end def version @config[:version] end def path_endpoint(key) unless key.eql?('oauth_token') return "api/#{version}/#{@config[:endpoints][:"#{key}"]}" end @config[:endpoints][:"#{key}"] end def path_endpoints @config[:endpoints] end def path_url(key) # TODO: Custom error/exception message base_url + path_endpoint(key) end def network_operators @config[:network_operators] end private def base_url @config[:base_url] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
k2-connect-ruby-0.0.2 | lib/k2-connect-ruby/k2_utilities/config/k2_config.rb |
k2-connect-ruby-0.0.1 | lib/k2-connect-ruby/k2_utilities/config/k2_config.rb |