<commit_before>require 'commands/base'

module Commands
  class Pick < Base
  
    def run!
      super
    
      put "Retrieving latest stories from Pivotal Tracker..."
      api = Pivotal::Api.new(:api_token => options[:api_token])

      project = api.projects.find(:id => options[:project_id])
      story = project.stories.find(:conditions => { :story_type => :feature, :current_state => :unstarted }, :limit => 1).first
    
      unless story
        put "No stories available!"
        return 0
      end
    
      put "Story: #{story.name}"
      put "URL:   #{story.url}"

      suffix = "feature"
      unless options[:quiet]
        put "Enter branch name (will be prepended by #{story.id}) [feature]: ", false
        suffix = input.gets.chomp
      
        suffix = "feature" if suffix == ""
      end

      branch = "#{story.id}-#{suffix}"<commit_msg>Reworking Commands::Pick to be subclassed to handle multiple story types<commit_after>require 'commands/base'

module Commands
  class Pick < Base
  
    def type
      raise Error "must define in subclass"
    end
    
    def plural_type
      raise Error "must define in subclass"
    end
  
    def branch_suffix
      raise Error "must define in subclass"
    end
    
    def run!
      super
    
      put "Retrieving latest #{plural_type} from Pivotal Tracker..."
      api = Pivotal::Api.new(:api_token => options[:api_token])

      project = api.projects.find(:id => options[:project_id])
      story = project.stories.find(:conditions => { :story_type => type, :current_state => :unstarted }, :limit => 1).first
    
      unless story
        put "No stories available!"
        return 0
      end
    
      put "Story: #{story.name}"
      put "URL:   #{story.url}"

      suffix = branch_suffix
      unless options[:quiet]
        put "Enter branch name (will be prepended by #{story.id}) [#{suffix}]: ", false
        suffix = input.gets.chomp
      
        suffix = "feature" if suffix == ""
      end

      branch = "#{story.id}-#{suffix}"
{'fraction_non_alphanumeric': 0.11958661417322834, 'fraction_numerical': 0.001968503937007874, 'mean_word_length': 2.3218954248366015, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1736749', 'n_tokens_mistral': 616, 'n_tokens_neox': 590, 'n_words': 175}