Class: GoFigure::GoConfigEndpoint
- Inherits:
-
Object
- Object
- GoFigure::GoConfigEndpoint
- Defined in:
- lib/go_figure/go_config_endpoint.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :host => 'localhost', :port => 8153 }
- @@http_fetcher =
nil
Class Method Summary collapse
Instance Method Summary collapse
- #get_config ⇒ Object
- #http_fetcher ⇒ Object
-
#initialize(options = {}) ⇒ GoConfigEndpoint
constructor
A new instance of GoConfigEndpoint.
- #update_config(go_config) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ GoConfigEndpoint
Returns a new instance of GoConfigEndpoint.
23 24 25 26 27 |
# File 'lib/go_figure/go_config_endpoint.rb', line 23 def initialize(={}) DEFAULT_OPTIONS.each do |k, v| self.send("#{k}=", [k] || v) end end |
Class Method Details
.http_fetcher ⇒ Object
18 19 20 |
# File 'lib/go_figure/go_config_endpoint.rb', line 18 def http_fetcher @@http_fetcher ||= GoFigure::HttpFetcher.new end |
.http_fetcher=(fetcher) ⇒ Object
14 15 16 |
# File 'lib/go_figure/go_config_endpoint.rb', line 14 def http_fetcher=(fetcher) @@http_fetcher = fetcher end |
Instance Method Details
#get_config ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/go_figure/go_config_endpoint.rb', line 29 def get_config response = http_fetcher.get(config_xml_url) if response.code == '200' return GoConfig.new(:md5 => response['X-CRUISE-CONFIG-MD5'], :xml => response.body) else raise "Could not fetch the go config file" end end |
#http_fetcher ⇒ Object
42 43 44 |
# File 'lib/go_figure/go_config_endpoint.rb', line 42 def http_fetcher self.class.http_fetcher end |
#update_config(go_config) ⇒ Object
38 39 40 |
# File 'lib/go_figure/go_config_endpoint.rb', line 38 def update_config(go_config) http_fetcher.post(config_xml_url, :xmlFile => go_config.xml_content, :md5 => go_config.original_md5) end |