diff options
author | Rick Bradley <rick@rickbradley.com> | 2008-04-02 21:27:14 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-04-11 13:11:29 -0500 |
commit | 04aba5253d774fae013919605363022781f16d55 (patch) | |
tree | 14959000e8058bf3ebfb000139383ddf7ab488c1 /lib | |
parent | a0804ae29a4d2be7b3f15015f87f5b274e95c7bd (diff) | |
download | puppet-04aba5253d774fae013919605363022781f16d55.tar.gz puppet-04aba5253d774fae013919605363022781f16d55.tar.xz puppet-04aba5253d774fae013919605363022781f16d55.zip |
fill out specs for network_* methods; refactor lowest-level network hooks
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/indirector/rest.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/puppet/indirector/rest.rb b/lib/puppet/indirector/rest.rb index e6a7bd6cf..34596cad4 100644 --- a/lib/puppet/indirector/rest.rb +++ b/lib/puppet/indirector/rest.rb @@ -5,19 +5,19 @@ require 'uri' class Puppet::Indirector::REST < Puppet::Indirector::Terminus def rest_connection_details - { :host => '127.0.0.1', :port => 34343 } + { :host => '127.0.0.1', :port => 34343 } end def network_fetch(path) - Net::HTTP.start("127.0.0.1", 34343) {|x| x.get("/#{path}").body } + network {|conn| conn.get("/#{path}").body } end def network_delete(path) - Net::HTTP.start("127.0.0.1", 34343) {|x| x.delete("/#{path}").body } + network {|conn| conn.delete("/#{path}").body } end def network_put(path, data) - Net::HTTP.start("127.0.0.1", 34343) {|x| x.put("/#{path}", data).body } + network {|conn| conn.put("/#{path}", data).body } end def find(name, options = {}) @@ -46,6 +46,10 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus private + def network(&block) + Net::HTTP.start(rest_connection_details[:host], rest_connection_details[:port]) {|conn| yield(conn) } + end + def exception?(yaml_string) yaml_string =~ %r{--- !ruby/exception} end |