module StartingBlocks::Cli
Public Class Methods
run(arguments)
click to toggle source
# File lib/starting_blocks/cli.rb, line 5 def self.run arguments load_the_arguments_to_be_considered arguments setup_the_system run_the_appropriate_command end
Private Class Methods
arguments_from_the_config_file()
click to toggle source
# File lib/starting_blocks/cli.rb, line 24 def arguments_from_the_config_file config_file = File.expand_path('~/.sb') return [] unless File.exists?(config_file) File.read(config_file).split(' ') end
build_all_arguments_with(arguments)
click to toggle source
# File lib/starting_blocks/cli.rb, line 19 def build_all_arguments_with arguments args = [arguments, arguments_from_the_config_file].flatten args.map { |x| x.gsub('--', '').to_sym } end
load_the_arguments_to_be_considered(arguments)
click to toggle source
# File lib/starting_blocks/cli.rb, line 15 def load_the_arguments_to_be_considered arguments StartingBlocks.arguments = build_all_arguments_with arguments end
name_of_action_to_take()
click to toggle source
# File lib/starting_blocks/cli.rb, line 52 def name_of_action_to_take action = StartingBlocks.actions.keys.select { |x| StartingBlocks.arguments.include? x }.first action || :run_all_tests end
run_the_appropriate_command()
click to toggle source
# File lib/starting_blocks/cli.rb, line 48 def run_the_appropriate_command StartingBlocks.actions[name_of_action_to_take].call end
setup_the_system()
click to toggle source
# File lib/starting_blocks/cli.rb, line 30 def setup_the_system StartingBlocks.arguments.each do |argument| if operation = StartingBlocks.conditional_operations[argument] operation.call else try_to_load_a_blinky_extension argument end end StartingBlocks.operations_to_always_run.each { |_, o| o.call } end
try_to_load_a_blinky_extension(argument)
click to toggle source
# File lib/starting_blocks/cli.rb, line 41 def try_to_load_a_blinky_extension argument begin require "starting_blocks-#{argument}" rescue LoadError => error end end