Module: Fetcher

Defined in:
lib/gl-repos/main.rb

Instance Method Summary collapse

Instance Method Details

#fetchObject



18
19
20
21
22
23
24
25
26
# File 'lib/gl-repos/main.rb', line 18

def fetch()
  cache = ""
  Gitlab.endpoint = ENV["GITLAB_ENDPOINT"] 
  Gitlab.private_token = ENV["GITLAB_TOKEN"] 
  Gitlab.projects.auto_paginate do |project|
    cache="#{cache}\n#{project.name_with_namespace}:#{project.web_url}"
  end
  File.write(ENV["GITLAB_REPO_CACHE"], cache)
end


5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/gl-repos/main.rb', line 5

def print()
  if not File.exist? ENV["GITLAB_REPO_CACHE"]
    fetch()
  end
  File.open(ENV["GITLAB_REPO_CACHE"], "r:UTF-8") do |file_handle|
    file_handle.each_line do |repo|
      if repo.length > 0
        STDOUT.write "#{repo.split(":")[0]}\n"
      end
    end
  end
end