yaccl 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,8 @@
1
1
  module YACCL
2
- def self.init(url)
3
- YACCL.const_set('SERVICE_URL', url)
2
+ def self.init(service_url, basic_auth_username=nil, basic_auth_password=nil)
3
+ YACCL.const_set('SERVICE_URL', service_url)
4
+ YACCL.const_set('BASIC_AUTH_USERNAME', basic_auth_username)
5
+ YACCL.const_set('BASIC_AUTH_PASSWORD', basic_auth_password)
4
6
  end
5
7
  end
6
8
 
@@ -13,7 +13,7 @@ module YACCL
13
13
  module Services
14
14
  class << self
15
15
  def perform_request(*params)
16
- service = Internal::BrowserBindingService.new(YACCL::SERVICE_URL)
16
+ service = Internal::BrowserBindingService.new(YACCL::SERVICE_URL, YACCL::BASIC_AUTH_USERNAME, YACCL::BASIC_AUTH_PASSWORD)
17
17
  service.perform_request(*params)
18
18
  end
19
19
 
@@ -9,8 +9,11 @@ module YACCL
9
9
 
10
10
  module Internal
11
11
  class BrowserBindingService
12
- def initialize(service_url)
12
+ def initialize(service_url, basic_auth_username=nil, basic_auth_password=nil)
13
13
  @service_url = service_url
14
+ @basic_auth_username = basic_auth_username
15
+ @basic_auth_password = basic_auth_password
16
+
14
17
  @repository_urls = LRUCache.new(ttl: 3600)
15
18
  @root_folder_urls = LRUCache.new(ttl: 3600)
16
19
  end
@@ -99,11 +102,14 @@ module YACCL
99
102
 
100
103
  class Basement
101
104
  include HTTParty
105
+ basic_auth @basic_auth_username, @basic_auth_password unless @basic_auth_username.nil?
102
106
 
103
107
  def self.multipart_post(url, options)
104
108
  url = URI.parse(url)
109
+ req = Net::HTTP::Post::Multipart.new(url.path, options)
110
+ req.basic_auth @basic_auth_username, @basic_auth_password unless @basic_auth_username.nil?
105
111
  Net::HTTP.start(url.host, url.port) do |http|
106
- http.request(Net::HTTP::Post::Multipart.new(url.path, options))
112
+ http.request(req)
107
113
  end
108
114
  end
109
115
  end
@@ -1,3 +1,3 @@
1
1
  module YACCL
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaccl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-03-04 00:00:00.000000000 Z
13
+ date: 2013-03-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty