<commit_before>##
# Definitions for issue objects
module Taskit
  ISSUE_LABEL = Struct.new(:name, :color)

  ##
  # An issue object, used to normalize the GitHub API response
  class Issue
    attr_reader :repo, :repo_url, :owner,
                :url, :id, :number, :title, :body, :reporter,
                :labels, :state

    def initialize(raw)
      load_repo_info raw
      load_issue_info raw
      load_state_info raw
    end

    def load_repo_info(raw)
      repo_info = raw[:repository]
      @repo = repo_info[:name]
      @repo_url = repo_info[:html_url]
      @owner = repo_info[:owner][:login]
    end

    def load_issue_info(raw)
      @url, @id, @number, @title, @body = raw.values_at(
        :html_url, :id, :number, :title, :body
      )
      @reporter = raw[:user][:login]
    end

    def load_state_info(raw)
      @state = raw[:state]
      @labels = raw[:labels].map { |x| ISSUE_LABEL.new(x[:name], x[:color]) }
    end
  end
end<commit_msg>fix Issue because sawyer isn't quite a hash<commit_after>##
# Definitions for issue objects
module Taskit
  ISSUE_LABEL = Struct.new(:name, :color)

  ##
  # An issue object, used to normalize the GitHub API response
  class Issue
    attr_reader :repo, :repo_url, :owner,
                :url, :id, :number, :title, :body, :reporter,
                :labels, :state

    def initialize(raw)
      load_repo_info raw
      load_issue_info raw
      load_state_info raw
    end

    def load_repo_info(raw)
      repo_info = raw[:repository]
      @repo = repo_info[:name]
      @repo_url = repo_info[:html_url]
      @owner = repo_info[:owner][:login]
    end

    def load_issue_info(raw)
      @url, @id, @number, @title, @body = raw.to_h.values_at(
        :html_url, :id, :number, :title, :body
      )
      @reporter = raw[:user][:login]
    end

    def load_state_info(raw)
      @state = raw[:state]
      @labels = raw[:labels].map { |x| ISSUE_LABEL.new(x[:name], x[:color]) }
    end
  end
end
{'fraction_non_alphanumeric': 0.12569690826153065, 'fraction_numerical': 0.0, 'mean_word_length': 2.689719626168224, 'pattern_counts': {'":': 0, '<': 3, '<?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': '207962', 'n_tokens_mistral': 693, 'n_tokens_neox': 673, 'n_words': 170}