Révision b0b39b01
Ruby plugins: apply style changes as suggested by "rubocop --fix-layout"
| plugins/icecast/icecast2_simple | ||
|---|---|---|
| 18 | 18 |
|
| 19 | 19 |
def get_conf |
| 20 | 20 |
# Default values |
| 21 |
conf = {:host => '127.0.0.1', :port => 8000,
|
|
| 22 |
:username => 'admin', :password => 'hackme' } |
|
| 21 |
conf = { :host => '127.0.0.1', :port => 8000,
|
|
| 22 |
:username => 'admin', :password => 'hackme' }
|
|
| 23 | 23 |
conf.keys.each do |key| |
| 24 | 24 |
env_key = sprintf('icecast_%s', key)
|
| 25 | 25 |
conf[key] = ENV[env_key] if ENV.has_key?(env_key) |
| ... | ... | |
| 31 | 31 |
begin |
| 32 | 32 |
data = Hpricot(open(sprintf('http://%s:%s/admin/stats',
|
| 33 | 33 |
conf[:host], conf[:port]), |
| 34 |
:http_basic_authentication=>[conf[:username],
|
|
| 35 |
conf[:password]])) |
|
| 34 |
:http_basic_authentication => [conf[:username],
|
|
| 35 |
conf[:password]]))
|
|
| 36 | 36 |
rescue OpenURI::HTTPError |
| 37 | 37 |
puts "Cannot connect: HTTP connection error" |
| 38 | 38 |
exit 1 |
| ... | ... | |
| 43 | 43 |
def get_values(data) |
| 44 | 44 |
vals = {}
|
| 45 | 45 |
[:sources, :clients].each do |key| |
| 46 |
elem = data/key
|
|
| 46 |
elem = data / key
|
|
| 47 | 47 |
if elem.nil? |
| 48 | 48 |
vals[key] = 0 |
| 49 | 49 |
else |
Formats disponibles : Unified diff