lib/nutrella/task_board_name.rb in nutrella-1.1.0 vs lib/nutrella/task_board_name.rb in nutrella-1.2.0

- old
+ new

@@ -2,29 +2,19 @@ module Nutrella # # Knows the name of the task board associated with the current git branch. # - module TaskBoardName - def self.from_git_branch + # Note: will also accept the name of a branch as an argument. + # + class TaskBoardName + def self.board_name(args) git_branch_name, status = Open3.capture2("git rev-parse --abbrev-ref HEAD") + return git_branch_name.chomp if status.success? - abort "Sorry. Can't find an associated git branch here." unless status.success? - - normalize(git_branch_name) - end - - def self.from_command_line(args) git_branch_name = args[0] + return git_branch_name if git_branch_name.present? - abort "Sorry. Can't create a board without a branch name." unless git_branch_name.present? - - normalize(git_branch_name) - end - - private - - def self.normalize(git_branch_name) - git_branch_name.chomp.titleize + abort "Sorry. Can't figure out a name for the board." end end end