Class: MrGithub::MrConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/mr_github.rb

Instance Method Summary collapse

Constructor Details

#initialize(github_user, github_password) ⇒ MrConfig

Returns a new instance of MrConfig.



14
15
16
# File 'lib/mr_github.rb', line 14

def initialize(github_user, github_password)
  @gh = Ghee.basic_auth(github_user, github_password)
end

Instance Method Details

#configObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/mr_github.rb', line 18

def config
  @config ||= begin
                @config = StringIO.new

                user = @gh.user

                @config.puts "# That #{user.} has access to directly"
                @gh.user.repos.all.each do |repo|
                  @config.puts "[src/#{repo.owner..to_s}/#{repo.name.to_s}]"
                  @config.puts "checkout = git clone #{repo.ssh_url.to_s}"
                  @config.puts ""
                end

                @gh.orgs.each do |org|
                  @config.puts "# That #{user.} has access to via #{org.}"
                  @gh.orgs(org.).repos.all.each do |repo|
                    next if repo == ["message", "Not Found"]
                    next if repo.name == 'rails' # don't need people's forks of rails
                    @config.puts "[src/#{repo.owner..to_s}/#{repo.name.to_s}]"
                    @config.puts "checkout = git clone #{repo.ssh_url.to_s}"
                    @config.puts ""
                  end

                end

                @config.string
              end
end

#to_sObject



47
48
49
# File 'lib/mr_github.rb', line 47

def to_s
  config.to_s
end