Class: Typhoeus::EasyFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/osdn/cli/overrides.rb

Instance Method Summary collapse

Instance Method Details

#get(*args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/osdn/cli/overrides.rb', line 6

def get(*args)
  easy = get_orig(*args)

  if ENV['CURL_CA_BUNDLE']
    Ethon::Curl.set_option(:cainfo, ENV['CURL_CA_BUNDLE'], easy.handle)
  else
    ["#{ENV['HOME']}/.config/osdn/ca-certificates.crt"] + %w(
       /usr/local/share/curl/curl-ca-bundle.crt
       /usr/share/curl/ca-bundle.crt
       /etc/ssl/certs/ca-certificates.crt
       /etc/ssl/certs/ca-certificates.pem
       /etc/pki/tls/certs/ca-bundle.crt
       /etc/pki/tls/certs/ca-bundle.pem
       /etc/ssl/ca-bundle.pem
    ).each do |ca|
      next unless File.exists? ca
      Ethon::Curl.set_option(:cainfo, ca, easy.handle)
    end
  end

  if OSDN::CLI._show_progress
    Ethon::Curl.set_option(:noprogress, false, easy.handle)
  else
    Ethon::Curl.set_option(:noprogress, true, easy.handle)
  end

  if OSDN::CLI._rate_limit
    Ethon::Curl.set_option(:max_send_speed_large, OSDN::CLI._rate_limit, easy.handle)
    Ethon::Curl.set_option(:max_recv_speed_large, OSDN::CLI._rate_limit, easy.handle)
  end

  easy
end

#get_origObject



5
# File 'lib/osdn/cli/overrides.rb', line 5

alias_method :get_orig, :get