Class: Billy::Commands::Eat
Instance Method Summary
collapse
Methods inherited from Command
instance, #name, register_self!
Instance Method Details
#eat_config(config_string) ⇒ Object
27
28
29
|
# File 'lib/billy/commands/eat.rb', line 27
def eat_config( config_string )
Billy::Config.instance.eat_string_config( config_string )
end
|
#file?(str) ⇒ Boolean
53
54
55
|
# File 'lib/billy/commands/eat.rb', line 53
def file?( str )
!uri?( str )
end
|
#load_remote_config(path) ⇒ Object
57
58
59
60
|
# File 'lib/billy/commands/eat.rb', line 57
def load_remote_config( path )
uri = URI( path )
Net::HTTP.get( uri )
end
|
#proceed!(arguments) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/billy/commands/eat.rb', line 9
def proceed!( arguments )
( path = arguments.shift ) unless arguments.nil?
begin
if path.nil? || path.empty?
raise "No config path given. \nYou have to provide some settings path, e.g. in your local filesystem or direct link to blob file in repository etc."
elsif uri?( path ) && ( result = load_remote_config( path ) ).nil?
raise "Remote config file could not be loaded"
elsif file?( path ) && ( !File.exists?( path ) || ( result = File.read( path ) ).nil? )
raise "Config File not found: #{path}"
end
rescue Exception => e
Billy::Util::UI.err e.message
exit 1
end
eat_config( result )
save_config
end
|
#uri?(str) ⇒ Boolean
44
45
46
47
48
49
50
51
|
# File 'lib/billy/commands/eat.rb', line 44
def uri?( str )
begin
uri = URI.parse( str )
%w( http https ).include?( uri.scheme )
rescue
false
end
end
|