<commit_before># encoding: utf-8
require "octokit"

module OpenSesame
  class Member

    def self.organization_name
      OpenSesame.organization_name
    end

    def self.find(member_id)
      return nil unless member_id.present?
      attributes = organization_members.detect { |member| member.id.to_s == member_id.to_s }
      return nil unless attributes.present?
      new(attributes)
    end

    def self.organization_members
      github_api.organization_members(organization_name)
    end

    def self.github_api
      @github_api ||= begin
        if OpenSesame.github_account
          Octokit::Client.new(
            login: OpenSesame.github_account[:login],
            oauth_token: OpenSesame.github_account[:oauth_token])
        else
          Octokit.new
        end
      end
    end

    def self.lazy_attr_reader(*attrs)
      attrs.each do |attribute|
        class_eval do
          define_method(attribute) do
            @attributes[attribute.to_s] || @attributes[attribute] # allow string or symbol access
          end
        end
      end
    end

    def self.serialize_into_session(member)
      [member.id]
    end

    def self.serialize_from_session(*args)
      id = args.shift
      find(id)
    end

    attr_accessor :attributes
    lazy_attr_reader :id, :login, :avatar_url, :gravatar_id, :url

    def initialize(attributes = {})
      @attributes = attributes
    end

    def id
      @attributes["id"]
    end

    def organization_name
      self.class.organization_name
    end

    def ==(other)
      super || (other.class == self.class && other.id == self.id)
    end

  end
end
<commit_msg>ruby 1.8.7 compatability change<commit_after># encoding: utf-8
require "octokit"

module OpenSesame
  class Member

    def self.organization_name
      OpenSesame.organization_name
    end

    def self.find(member_id)
      return nil unless member_id.present?
      attributes = organization_members.detect { |member| member.id.to_s == member_id.to_s }
      return nil unless attributes.present?
      new(attributes)
    end

    def self.organization_members
      github_api.organization_members(organization_name)
    end

    def self.github_api
      @github_api ||= begin
        if OpenSesame.github_account
          Octokit::Client.new(
            :login => OpenSesame.github_account[:login],
            :oauth_token => OpenSesame.github_account[:oauth_token])
        else
          Octokit.new
        end
      end
    end

    def self.lazy_attr_reader(*attrs)
      attrs.each do |attribute|
        class_eval do
          define_method(attribute) do
            @attributes[attribute.to_s] || @attributes[attribute] # allow string or symbol access
          end
        end
      end
    end

    def self.serialize_into_session(member)
      [member.id]
    end

    def self.serialize_from_session(*args)
      id = args.shift
      find(id)
    end

    attr_accessor :attributes
    lazy_attr_reader :id, :login, :avatar_url, :gravatar_id, :url

    def initialize(attributes = {})
      @attributes = attributes
    end

    def id
      @attributes["id"]
    end

    def organization_name
      self.class.organization_name
    end

    def ==(other)
      super || (other.class == self.class && other.id == self.id)
    end

  end
end

{'fraction_non_alphanumeric': 0.08162031438935913, 'fraction_numerical': 0.0015114873035066505, 'mean_word_length': 2.3559837728194726, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '631010', 'n_tokens_mistral': 1025, 'n_tokens_neox': 986, 'n_words': 225}