class Billy::Commands::Eat
Public Instance Methods
eat_config( config_string )
click to toggle source
# File lib/billy/commands/eat.rb, line 27 def eat_config( config_string ) Billy::Config.instance.eat_string_config( config_string ) end
file?( str )
click to toggle source
# File lib/billy/commands/eat.rb, line 53 def file?( str ) !uri?( str ) end
load_remote_config( path )
click to toggle source
# File lib/billy/commands/eat.rb, line 57 def load_remote_config( path ) uri = URI( path ) Net::HTTP.get( uri ) end
proceed!( arguments )
click to toggle source
# 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
save_config()
click to toggle source
# File lib/billy/commands/eat.rb, line 31 def save_config Billy::Util::UI.inform "Parsed config data:" Billy::Config.settings.each_pair do |k, v| Billy::Util::UI.inform "#{k}: #{v}" end if !Billy::Util::UI.confirm? "Save this settings?(y/n): " Billy::Util::UI.inform "Billy didn't save config file. Skipping." exit 1 end Billy::Config.save Billy::Util::UI.succ "Billy saved config file to #{Billy::Config::BILLYRC}" end
uri?( str )
click to toggle source
# 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