Sha256: ad00776a2b38df88cfdee42170c34af341782916b44735bb02d337f1b19785e1

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

module GitHubRecordsArchiver
  class Organization
    attr_reader :name

    include DataHelper

    def initialize(name)
      @name = name
    end

    def data
      @data ||= GitHubRecordsArchiver.client.organization name
    end

    def repositories
      @repositories ||= begin
        repos = GitHubRecordsArchiver.client.organization_repositories(name)
        repos.map { |hash| Repository.new(hash) }
      end
    end
    alias repos repositories

    def teams
      @teams ||= begin
        teams = GitHubRecordsArchiver.client.organization_teams(name)
        teams.map { |h| Team.from_hash(self, h) }
      rescue Octokit::Forbidden
        []
      end
    end

    def archive_dir
      @archive_dir ||= begin
        dir = File.expand_path name, GitHubRecordsArchiver.dest_dir
        FileUtils.mkdir_p(dir) unless Dir.exist?(dir)
        dir
      end
    end

    def teams_dir
      @teams_dir ||= begin
        dir = File.expand_path 'teams', archive_dir
        FileUtils.mkdir_p(dir) unless Dir.exist?(dir)
        dir
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
github_records_archiver-0.3.1 lib/github_records_archiver/organization.rb
github_records_archiver-0.2.0 lib/github_records_archiver/organization.rb
github_records_archiver-0.1.0 lib/github_records_archiver/organization.rb