<commit_before>require "pivo/version"

require 'yaml'
require 'tracker_api'
require 'thor'

module Pivo
  class Stories < Thor
    desc "stories all PROJECT_NAME", "listing all stories"
    def all(project_name)
      project = client.projects.select {|project| project.name == project_name}[0]
      project.stories.each do |story|
        say "[#{story.current_state}]\t#{story.name}\t#{story.url}"
      end
    end

    desc "stories me PROJECT_NAME", "listing my stories"
    def me(project_name)
      me = client.me
      project = client.projects.select {|project| project.name == project_name}[0]
      project.stories(filter: "mywork:\"#{me.name}\"").each do |story|
        say "[#{story.current_state}]\t#{story.name}\t#{story.url}"
      end
    end

    private

    def client
      TrackerApi::Client.new(token: token)
    end

    def token
      YAML.load(File.read("#{ENV['HOME']}/.pivo.yml"))['token']
    end
  end
  class CLI < Thor
    desc "projects", "listing project names"
    def projects
      say client.projects.map(&:name).join("\n")
    end

    desc "stories PROJECT_NAME", "listing project stories"
    def stories(project_name)
      project = client.projects.select {|project| project.name == project_name}[0]
      project.stories.each do |story|
        say "[#{story.current_state}]\t#{story.name}\t#{story.url}"
      end
    end

    desc "stories SUBCOMMAND ARGS", "listing stories"
    subcommand "stories", Stories

    private

    def client
      TrackerApi::Client.new(token: token)
    end

    def token
      YAML.load(File.read("#{ENV['HOME']}/.pivo.yml"))['token']
    end
  end
end<commit_msg>Extract client methods<commit_after>require "pivo/version"

require 'yaml'
require 'tracker_api'
require 'thor'

module Pivo
  module ApiClient
    private

    def client
      TrackerApi::Client.new(token: token)
    end

    def token
      YAML.load(File.read("#{ENV['HOME']}/.pivo.yml"))['token']
    end
  end

  class Stories < Thor
    include ApiClient
    
    desc "stories all PROJECT_NAME", "listing all stories"
    def all(project_name)
      project = client.projects.select {|project| project.name == project_name}[0]
      project.stories.each do |story|
        say "[#{story.current_state}]\t#{story.name}\t#{story.url}"
      end
    end

    desc "stories me PROJECT_NAME", "listing my stories"
    def me(project_name)
      me = client.me
      project = client.projects.select {|project| project.name == project_name}[0]
      project.stories(filter: "mywork:\"#{me.name}\"").each do |story|
        say "[#{story.current_state}]\t#{story.name}\t#{story.url}"
      end
    end
  end

  class CLI < Thor
    include ApiClient

    desc "projects", "listing project names"
    def projects
      say client.projects.map(&:name).join("\n")
    end

    desc "stories PROJECT_NAME", "listing project stories"
    def stories(project_name)
      project = client.projects.select {|project| project.name == project_name}[0]
      project.stories.each do |story|
        say "[#{story.current_state}]\t#{story.name}\t#{story.url}"
      end
    end

    desc "stories SUBCOMMAND ARGS", "listing stories"
    subcommand "stories", Stories
  end
end
{'fraction_non_alphanumeric': 0.13690105787181084, 'fraction_numerical': 0.001866832607342875, 'mean_word_length': 3.01875, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '3541395', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1040, 'n_words': 244}