Class: Downspout::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/downspout/config.rb

Constant Summary collapse

@@tmp_dir =

Default Values

"/tmp/downloads/"
@@network_enabled =
true
@@credentials =
[]
@@curb_allowed =
true
@@curb_enabled =
true
@@prefix =
'downspout'
@@max_redirects =
2
@@ssl_verification =
true

Class Method Summary collapse

Class Method Details

.add_credential(options = nil) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/downspout/config.rb', line 85

def self.add_credential( options = nil )
  return nil unless options

  if (options.class == Downspout::Credential) then
    c = options
  else
    return nil unless options.respond_to?(:keys)

    options = {:scheme => 'ftp'}.merge!( options ) # defaults to FTP

    c = Credential.new( options )
  end
  
  $logger.debug("downspout | config | add_credential | #{c.host}, #{c.user_name}, #{c.scheme} ")

  @@credentials << c

  return c
end

.credentialsObject



30
31
32
# File 'lib/downspout/config.rb', line 30

def self.credentials
  return @@credentials
end

.curb_available?Boolean

Returns:

  • (Boolean)


59
60
61
62
63
64
65
66
# File 'lib/downspout/config.rb', line 59

def self.curb_available?
  begin
    require 'curb'
    return true
  rescue LoadError
    return false
  end
end

.default_prefixObject



22
23
24
# File 'lib/downspout/config.rb', line 22

def self.default_prefix
  @@prefix
end

.default_prefix=(name) ⇒ Object



26
27
28
# File 'lib/downspout/config.rb', line 26

def self.default_prefix=( name )
  @@prefix = name
end

.disable_curb!Object



80
81
82
83
# File 'lib/downspout/config.rb', line 80

def self.disable_curb!
  $logger.debug("downspout | config | disable_curb! | will fall back to Net/HTTP.")
  @@curb_enabled = false
end

.disable_networking!Object



46
47
48
49
# File 'lib/downspout/config.rb', line 46

def self.disable_networking!
  @@network_enabled = false
  return !(@@network_enabled)
end

.enable_curb!Object



72
73
74
75
76
77
78
# File 'lib/downspout/config.rb', line 72

def self.enable_curb!
  if self.curb_available? then
    @@curb_enabled = true
  else
    @@curb_enabled = false
  end
end

.enable_networking!Object



51
52
53
# File 'lib/downspout/config.rb', line 51

def self.enable_networking!
  @@network_enabled = true
end

.max_redirectsObject



34
35
36
# File 'lib/downspout/config.rb', line 34

def self.max_redirects
  @@max_redirects
end

.max_redirects=(num) ⇒ Object



38
39
40
# File 'lib/downspout/config.rb', line 38

def self.max_redirects=( num )
  @@max_redirects = num
end

.network_enabled?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/downspout/config.rb', line 42

def self.network_enabled?
  return @@network_enabled
end

.ssl_verification?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/downspout/config.rb', line 55

def self.ssl_verification?
  @@ssl_verification
end

.tmp_dirObject



14
15
16
# File 'lib/downspout/config.rb', line 14

def self.tmp_dir
  return @@tmp_dir
end

.tmp_dir=(some_path) ⇒ Object



18
19
20
# File 'lib/downspout/config.rb', line 18

def self.tmp_dir=( some_path )
  @@tmp_dir = some_path
end

.use_curb?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/downspout/config.rb', line 68

def self.use_curb?
  @@curb_enabled unless !(self.curb_available?)
end