Class: SimpleDav::Base
- Inherits:
-
Object
- Object
- SimpleDav::Base
- Defined in:
- lib/simple_dav/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#gen_uid ⇒ Object
generate unique id to create resources.
-
#initialize(params = {}) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(params = {}) ⇒ Base
Returns a new instance of Base.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/simple_dav/base.rb', line 21 def initialize(params = {}) begin url = params[:ssl] ? "https://#{params[:server]}/" : "http://#{params[:server]}/" url += case (@type = params[:type]) when "sogo" then "SOGo/dav/#{params[:user]}/" else "" end @uri = URI.parse(url) @uid = nil @headers = {} #open(uri) if uri proxy = ENV['HTTP_PROXY'] || ENV['http_proxy'] || nil @client = HTTPClient.new(proxy) @client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE unless params[:verify] if (@user = params[:user]) && params[:pass] @client.set_basic_auth(@uri, @user, params[:pass]) end rescue raise RuntimeError.exception("Init Failed!! (#{$!.to_s})") end end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
14 15 16 |
# File 'lib/simple_dav/base.rb', line 14 def client @client end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
14 15 16 |
# File 'lib/simple_dav/base.rb', line 14 def headers @headers end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
14 15 16 |
# File 'lib/simple_dav/base.rb', line 14 def uri @uri end |
Instance Method Details
#gen_uid ⇒ Object
generate unique id to create resources
17 18 19 |
# File 'lib/simple_dav/base.rb', line 17 def gen_uid "#{rand(100000)}-#{Time.now.to_i}-#{rand(100000)}" end |