googleauth 0.16.0 → 0.16.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,64 +0,0 @@
1
- require "open3"
2
-
3
- class LinkChecker
4
- def initialize
5
- @failed = false
6
- end
7
-
8
- def run
9
- job_info
10
- git_commit = ENV.fetch "KOKORO_GITHUB_COMMIT", "master"
11
-
12
- markdown_files = Dir.glob "**/*.md"
13
- broken_markdown_links = check_links markdown_files,
14
- "https://github.com/googleapis/google-auth-library-ruby/tree/#{git_commit}",
15
- " --skip '^(?!(\\Wruby.*google|.*google.*\\Wruby|.*cloud\\.google\\.com))'"
16
-
17
- broken_devsite_links = check_links ["googleauth"],
18
- "https://googleapis.dev/ruby",
19
- "/latest/ --recurse --skip https:.*github.*"
20
-
21
- puts_broken_links broken_markdown_links
22
- puts_broken_links broken_devsite_links
23
- end
24
-
25
- def check_links location_list, base, tail
26
- broken_links = Hash.new { |h, k| h[k] = [] }
27
- location_list.each do |location|
28
- out, err, st = Open3.capture3 "npx linkinator #{base}/#{location}#{tail}"
29
- puts out
30
- unless st.to_i.zero?
31
- @failed = true
32
- puts err
33
- end
34
- checked_links = out.split "\n"
35
- checked_links.select! { |link| link =~ /\[\d+\]/ && !link.include?("[200]") }
36
- unless checked_links.empty?
37
- @failed = true
38
- broken_links[location] += checked_links
39
- end
40
- end
41
- broken_links
42
- end
43
-
44
- def puts_broken_links link_hash
45
- link_hash.each do |location, links|
46
- puts "#{location} contains the following broken links:"
47
- links.each { |link| puts " #{link}" }
48
- puts ""
49
- end
50
- end
51
-
52
- def job_info
53
- line_length = "Using Ruby - #{RUBY_VERSION}".length + 8
54
- puts ""
55
- puts "#" * line_length
56
- puts "### Using Ruby - #{RUBY_VERSION} ###"
57
- puts "#" * line_length
58
- puts ""
59
- end
60
-
61
- def exit_status
62
- @failed ? 1 : 0
63
- end
64
- end
@@ -1,59 +0,0 @@
1
- require "json"
2
-
3
- class RepoMetadata
4
- attr_reader :data
5
-
6
- def initialize data
7
- @data = data
8
- normalize_data!
9
- end
10
-
11
- def allowed_fields
12
- [
13
- "name", "version", "language", "distribution-name",
14
- "product-page", "github-repository", "issue-tracker"
15
- ]
16
- end
17
-
18
- def build output_directory
19
- fields = @data.to_a.map { |kv| "--#{kv[0]} #{kv[1]}" }
20
- Dir.chdir output_directory do
21
- cmd "python3 -m docuploader create-metadata #{fields.join ' '}"
22
- end
23
- end
24
-
25
- def normalize_data!
26
- require_relative "../lib/googleauth/version.rb"
27
-
28
- @data.delete_if { |k, _| !allowed_fields.include?(k) }
29
- @data["version"] = "v#{Google::Auth::VERSION}"
30
- end
31
-
32
- def [] key
33
- data[key]
34
- end
35
-
36
- def []= key, value
37
- @data[key] = value
38
- end
39
-
40
- def cmd line
41
- puts line
42
- output = `#{line}`
43
- puts output
44
- output
45
- end
46
-
47
- def self.from_source source
48
- if source.is_a? RepoMetadata
49
- data = source.data
50
- elsif source.is_a? Hash
51
- data = source
52
- elsif File.file? source
53
- data = JSON.parse File.read(source)
54
- else
55
- raise "Source must be a path, hash, or RepoMetadata instance"
56
- end
57
- RepoMetadata.new data
58
- end
59
- end