24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/pluto/tasks.rb', line 24
def self.fetch_config_for( key )
puts "trying to fetch pluto.index.ini shortcut planet registry..."
worker = ::Fetcher::Worker.new
res = worker.get_response( 'https://raw.githubusercontent.com/feedreader/planets/master/pluto.index.ini' )
if res.code != '200'
puts "sorry; failed to fetch pluto.index - HTTP #{res.code} - #{res.message}"
exit 1
end
index_txt = res.body.dup.to_s
index_txt = index_txt.force_encoding( Encoding::UTF_8 )
shortcuts = INI.load( index_txt )
pp shortcuts
shortcut = shortcuts[key]
if shortcut.nil?
puts "sorry; no planet shortcut found for key >#{key}<"
exit 1
end
res = worker.get_response( shortcut['source'] )
if res.code != '200'
puts "sorry; failed to fetch planet config for >#{key}< - HTTP #{res.code} - #{res.message}"
exit 1
end
config_txt = res.body.dup.to_s
config_txt = config_txt.force_encoding( Encoding::UTF_8 )
config = INI.load( config_txt )
config
end
|