class Startling::Command

Constants

RUN

Public Class Methods

run(attrs={}) click to toggle source
Calls superclass method
# File lib/startling/command.rb, line 14
def self.run(attrs={})
  options = Startling::CliOptions.parse
  options.merge!(attrs)
  options.merge({argv: ARGV, args: ARGV})

  super(options)
end

Public Instance Methods

execute() click to toggle source
# File lib/startling/command.rb, line 22
def execute
  load_configuration
  load_commands
  load_handlers

  command_args = cli_options.merge(git: git)

  check_for_local_mods

  run_hook_commands(hook: :before_story_start, command_args: command_args)
  start_story(command_args)
  run_hook_commands(hook: :after_story_start, command_args: command_args)

  run_hook_commands(hook: :before_pull_request, command_args: command_args)
  create_pull_request(command_args)
  run_hook_commands(hook: :after_pull_request, command_args: command_args)
end
git() click to toggle source
# File lib/startling/command.rb, line 40
def git
  @git ||= GitLocal.new
end

Private Instance Methods

check_for_local_mods() click to toggle source
# File lib/startling/command.rb, line 46
def check_for_local_mods
  Commands::CheckForLocalMods.run(git: git)
end
create_pull_request(command_args) click to toggle source
# File lib/startling/command.rb, line 62
def create_pull_request(command_args)
  pull_request = command_class(:create_pull_request)
    .send(RUN, command_args)
  command_args.merge!(pull_request: pull_request)
end
run_hook_commands(hook:, command_args:) click to toggle source
# File lib/startling/command.rb, line 50
def run_hook_commands(hook:, command_args:)
  Startling.hook_commands.send(hook).map do |command|
    command_class(command).send(RUN, command_args)
  end
end
start_story(command_args) click to toggle source
# File lib/startling/command.rb, line 56
def start_story(command_args)
  story = command_class(Startling.story_handler)
    .send(RUN, command_args) if Startling.story_handler
  command_args.merge!(story: story)
end