google-api-client 0.34.0 → 0.34.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.kokoro/continuous/linux.cfg +2 -2
- data/.kokoro/continuous/post.cfg +30 -0
- data/.kokoro/presubmit/linux.cfg +1 -1
- data/.kokoro/release.cfg +94 -0
- data/.repo-metadata.json +5 -0
- data/.rubocop.yml +5 -0
- data/CHANGELOG.md +18 -0
- data/Gemfile +1 -0
- data/Rakefile +71 -2
- data/generated/google/apis/bigquery_v2.rb +1 -1
- data/generated/google/apis/bigquery_v2/classes.rb +33 -0
- data/generated/google/apis/bigquery_v2/representations.rb +18 -0
- data/generated/google/apis/cloudshell_v1.rb +1 -1
- data/generated/google/apis/cloudshell_v1/classes.rb +2 -1
- data/generated/google/apis/cloudshell_v1alpha1.rb +1 -1
- data/generated/google/apis/cloudshell_v1alpha1/classes.rb +2 -1
- data/generated/google/apis/dlp_v2.rb +1 -1
- data/generated/google/apis/dlp_v2/classes.rb +25 -0
- data/generated/google/apis/dlp_v2/representations.rb +14 -0
- data/generated/google/apis/dlp_v2/service.rb +55 -43
- data/generated/google/apis/docs_v1.rb +1 -1
- data/generated/google/apis/docs_v1/classes.rb +8 -4
- data/generated/google/apis/genomics_v2alpha1.rb +1 -1
- data/generated/google/apis/recommender_v1beta1.rb +1 -1
- data/generated/google/apis/redis_v1.rb +1 -1
- data/generated/google/apis/redis_v1/classes.rb +11 -11
- data/generated/google/apis/redis_v1/service.rb +5 -5
- data/generated/google/apis/redis_v1beta1.rb +1 -1
- data/generated/google/apis/redis_v1beta1/classes.rb +11 -11
- data/generated/google/apis/redis_v1beta1/service.rb +5 -5
- data/generated/google/apis/securitycenter_v1.rb +1 -1
- data/generated/google/apis/securitycenter_v1/classes.rb +22 -18
- data/generated/google/apis/securitycenter_v1/service.rb +14 -12
- data/generated/google/apis/securitycenter_v1beta1.rb +1 -1
- data/generated/google/apis/securitycenter_v1beta1/classes.rb +8 -7
- data/generated/google/apis/securitycenter_v1beta1/service.rb +14 -12
- data/generated/google/apis/sheets_v4.rb +1 -1
- data/generated/google/apis/sheets_v4/classes.rb +768 -18
- data/generated/google/apis/sheets_v4/representations.rb +101 -0
- data/generated/google/apis/vision_v1.rb +1 -1
- data/generated/google/apis/vision_v1/classes.rb +66 -0
- data/generated/google/apis/vision_v1/representations.rb +32 -0
- data/generated/google/apis/vision_v1p1beta1.rb +1 -1
- data/generated/google/apis/vision_v1p1beta1/classes.rb +66 -0
- data/generated/google/apis/vision_v1p1beta1/representations.rb +32 -0
- data/generated/google/apis/vision_v1p2beta1.rb +1 -1
- data/generated/google/apis/vision_v1p2beta1/classes.rb +66 -0
- data/generated/google/apis/vision_v1p2beta1/representations.rb +32 -0
- data/lib/google/apis/core/upload.rb +4 -0
- data/lib/google/apis/version.rb +1 -1
- data/rakelib/devsite/devsite_builder.rb +126 -0
- data/rakelib/devsite/link_checker.rb +64 -0
- data/rakelib/devsite/repo_metadata.rb +56 -0
- metadata +9 -3
@@ -1144,6 +1144,12 @@ module Google
|
|
1144
1144
|
include Google::Apis::Core::JsonObjectSupport
|
1145
1145
|
end
|
1146
1146
|
|
1147
|
+
class GoogleCloudVisionV1p4beta1Celebrity
|
1148
|
+
class Representation < Google::Apis::Core::JsonRepresentation; end
|
1149
|
+
|
1150
|
+
include Google::Apis::Core::JsonObjectSupport
|
1151
|
+
end
|
1152
|
+
|
1147
1153
|
class GoogleCloudVisionV1p4beta1ColorInfo
|
1148
1154
|
class Representation < Google::Apis::Core::JsonRepresentation; end
|
1149
1155
|
|
@@ -1186,6 +1192,12 @@ module Google
|
|
1186
1192
|
include Google::Apis::Core::JsonObjectSupport
|
1187
1193
|
end
|
1188
1194
|
|
1195
|
+
class GoogleCloudVisionV1p4beta1FaceRecognitionResult
|
1196
|
+
class Representation < Google::Apis::Core::JsonRepresentation; end
|
1197
|
+
|
1198
|
+
include Google::Apis::Core::JsonObjectSupport
|
1199
|
+
end
|
1200
|
+
|
1189
1201
|
class GoogleCloudVisionV1p4beta1GcsDestination
|
1190
1202
|
class Representation < Google::Apis::Core::JsonRepresentation; end
|
1191
1203
|
|
@@ -3652,6 +3664,15 @@ module Google
|
|
3652
3664
|
end
|
3653
3665
|
end
|
3654
3666
|
|
3667
|
+
class GoogleCloudVisionV1p4beta1Celebrity
|
3668
|
+
# @private
|
3669
|
+
class Representation < Google::Apis::Core::JsonRepresentation
|
3670
|
+
property :description, as: 'description'
|
3671
|
+
property :display_name, as: 'displayName'
|
3672
|
+
property :name, as: 'name'
|
3673
|
+
end
|
3674
|
+
end
|
3675
|
+
|
3655
3676
|
class GoogleCloudVisionV1p4beta1ColorInfo
|
3656
3677
|
# @private
|
3657
3678
|
class Representation < Google::Apis::Core::JsonRepresentation
|
@@ -3722,6 +3743,8 @@ module Google
|
|
3722
3743
|
collection :landmarks, as: 'landmarks', class: Google::Apis::VisionV1p1beta1::GoogleCloudVisionV1p4beta1FaceAnnotationLandmark, decorator: Google::Apis::VisionV1p1beta1::GoogleCloudVisionV1p4beta1FaceAnnotationLandmark::Representation
|
3723
3744
|
|
3724
3745
|
property :pan_angle, as: 'panAngle'
|
3746
|
+
collection :recognition_result, as: 'recognitionResult', class: Google::Apis::VisionV1p1beta1::GoogleCloudVisionV1p4beta1FaceRecognitionResult, decorator: Google::Apis::VisionV1p1beta1::GoogleCloudVisionV1p4beta1FaceRecognitionResult::Representation
|
3747
|
+
|
3725
3748
|
property :roll_angle, as: 'rollAngle'
|
3726
3749
|
property :sorrow_likelihood, as: 'sorrowLikelihood'
|
3727
3750
|
property :surprise_likelihood, as: 'surpriseLikelihood'
|
@@ -3739,6 +3762,15 @@ module Google
|
|
3739
3762
|
end
|
3740
3763
|
end
|
3741
3764
|
|
3765
|
+
class GoogleCloudVisionV1p4beta1FaceRecognitionResult
|
3766
|
+
# @private
|
3767
|
+
class Representation < Google::Apis::Core::JsonRepresentation
|
3768
|
+
property :celebrity, as: 'celebrity', class: Google::Apis::VisionV1p1beta1::GoogleCloudVisionV1p4beta1Celebrity, decorator: Google::Apis::VisionV1p1beta1::GoogleCloudVisionV1p4beta1Celebrity::Representation
|
3769
|
+
|
3770
|
+
property :confidence, as: 'confidence'
|
3771
|
+
end
|
3772
|
+
end
|
3773
|
+
|
3742
3774
|
class GoogleCloudVisionV1p4beta1GcsDestination
|
3743
3775
|
# @private
|
3744
3776
|
class Representation < Google::Apis::Core::JsonRepresentation
|
@@ -27,7 +27,7 @@ module Google
|
|
27
27
|
# @see https://cloud.google.com/vision/
|
28
28
|
module VisionV1p2beta1
|
29
29
|
VERSION = 'V1p2beta1'
|
30
|
-
REVISION = '
|
30
|
+
REVISION = '20191105'
|
31
31
|
|
32
32
|
# View and manage your data across Google Cloud Platform services
|
33
33
|
AUTH_CLOUD_PLATFORM = 'https://www.googleapis.com/auth/cloud-platform'
|
@@ -7442,6 +7442,38 @@ module Google
|
|
7442
7442
|
end
|
7443
7443
|
end
|
7444
7444
|
|
7445
|
+
# A Celebrity is a group of Faces with an identity.
|
7446
|
+
class GoogleCloudVisionV1p4beta1Celebrity
|
7447
|
+
include Google::Apis::Core::Hashable
|
7448
|
+
|
7449
|
+
# The Celebrity's description.
|
7450
|
+
# Corresponds to the JSON property `description`
|
7451
|
+
# @return [String]
|
7452
|
+
attr_accessor :description
|
7453
|
+
|
7454
|
+
# The Celebrity's display name.
|
7455
|
+
# Corresponds to the JSON property `displayName`
|
7456
|
+
# @return [String]
|
7457
|
+
attr_accessor :display_name
|
7458
|
+
|
7459
|
+
# The resource name of the preloaded Celebrity. Has the format
|
7460
|
+
# `builtin/`mid``.
|
7461
|
+
# Corresponds to the JSON property `name`
|
7462
|
+
# @return [String]
|
7463
|
+
attr_accessor :name
|
7464
|
+
|
7465
|
+
def initialize(**args)
|
7466
|
+
update!(**args)
|
7467
|
+
end
|
7468
|
+
|
7469
|
+
# Update properties of this object
|
7470
|
+
def update!(**args)
|
7471
|
+
@description = args[:description] if args.key?(:description)
|
7472
|
+
@display_name = args[:display_name] if args.key?(:display_name)
|
7473
|
+
@name = args[:name] if args.key?(:name)
|
7474
|
+
end
|
7475
|
+
end
|
7476
|
+
|
7445
7477
|
# Color information consists of RGB channels, score, and the fraction of
|
7446
7478
|
# the image that the color occupies in the image.
|
7447
7479
|
class GoogleCloudVisionV1p4beta1ColorInfo
|
@@ -7786,6 +7818,14 @@ module Google
|
|
7786
7818
|
# @return [Float]
|
7787
7819
|
attr_accessor :pan_angle
|
7788
7820
|
|
7821
|
+
# Additional recognition information. Only computed if
|
7822
|
+
# image_context.face_recognition_params is provided, **and** a match is found
|
7823
|
+
# to a Celebrity in the input CelebritySet. This field is
|
7824
|
+
# sorted in order of decreasing confidence values.
|
7825
|
+
# Corresponds to the JSON property `recognitionResult`
|
7826
|
+
# @return [Array<Google::Apis::VisionV1p2beta1::GoogleCloudVisionV1p4beta1FaceRecognitionResult>]
|
7827
|
+
attr_accessor :recognition_result
|
7828
|
+
|
7789
7829
|
# Roll angle, which indicates the amount of clockwise/anti-clockwise rotation
|
7790
7830
|
# of the face relative to the image vertical about the axis perpendicular to
|
7791
7831
|
# the face. Range [-180,180].
|
@@ -7830,6 +7870,7 @@ module Google
|
|
7830
7870
|
@landmarking_confidence = args[:landmarking_confidence] if args.key?(:landmarking_confidence)
|
7831
7871
|
@landmarks = args[:landmarks] if args.key?(:landmarks)
|
7832
7872
|
@pan_angle = args[:pan_angle] if args.key?(:pan_angle)
|
7873
|
+
@recognition_result = args[:recognition_result] if args.key?(:recognition_result)
|
7833
7874
|
@roll_angle = args[:roll_angle] if args.key?(:roll_angle)
|
7834
7875
|
@sorrow_likelihood = args[:sorrow_likelihood] if args.key?(:sorrow_likelihood)
|
7835
7876
|
@surprise_likelihood = args[:surprise_likelihood] if args.key?(:surprise_likelihood)
|
@@ -7865,6 +7906,31 @@ module Google
|
|
7865
7906
|
end
|
7866
7907
|
end
|
7867
7908
|
|
7909
|
+
# Information about a face's identity.
|
7910
|
+
class GoogleCloudVisionV1p4beta1FaceRecognitionResult
|
7911
|
+
include Google::Apis::Core::Hashable
|
7912
|
+
|
7913
|
+
# A Celebrity is a group of Faces with an identity.
|
7914
|
+
# Corresponds to the JSON property `celebrity`
|
7915
|
+
# @return [Google::Apis::VisionV1p2beta1::GoogleCloudVisionV1p4beta1Celebrity]
|
7916
|
+
attr_accessor :celebrity
|
7917
|
+
|
7918
|
+
# Recognition confidence. Range [0, 1].
|
7919
|
+
# Corresponds to the JSON property `confidence`
|
7920
|
+
# @return [Float]
|
7921
|
+
attr_accessor :confidence
|
7922
|
+
|
7923
|
+
def initialize(**args)
|
7924
|
+
update!(**args)
|
7925
|
+
end
|
7926
|
+
|
7927
|
+
# Update properties of this object
|
7928
|
+
def update!(**args)
|
7929
|
+
@celebrity = args[:celebrity] if args.key?(:celebrity)
|
7930
|
+
@confidence = args[:confidence] if args.key?(:confidence)
|
7931
|
+
end
|
7932
|
+
end
|
7933
|
+
|
7868
7934
|
# The Google Cloud Storage location where the output will be written to.
|
7869
7935
|
class GoogleCloudVisionV1p4beta1GcsDestination
|
7870
7936
|
include Google::Apis::Core::Hashable
|
@@ -1144,6 +1144,12 @@ module Google
|
|
1144
1144
|
include Google::Apis::Core::JsonObjectSupport
|
1145
1145
|
end
|
1146
1146
|
|
1147
|
+
class GoogleCloudVisionV1p4beta1Celebrity
|
1148
|
+
class Representation < Google::Apis::Core::JsonRepresentation; end
|
1149
|
+
|
1150
|
+
include Google::Apis::Core::JsonObjectSupport
|
1151
|
+
end
|
1152
|
+
|
1147
1153
|
class GoogleCloudVisionV1p4beta1ColorInfo
|
1148
1154
|
class Representation < Google::Apis::Core::JsonRepresentation; end
|
1149
1155
|
|
@@ -1186,6 +1192,12 @@ module Google
|
|
1186
1192
|
include Google::Apis::Core::JsonObjectSupport
|
1187
1193
|
end
|
1188
1194
|
|
1195
|
+
class GoogleCloudVisionV1p4beta1FaceRecognitionResult
|
1196
|
+
class Representation < Google::Apis::Core::JsonRepresentation; end
|
1197
|
+
|
1198
|
+
include Google::Apis::Core::JsonObjectSupport
|
1199
|
+
end
|
1200
|
+
|
1189
1201
|
class GoogleCloudVisionV1p4beta1GcsDestination
|
1190
1202
|
class Representation < Google::Apis::Core::JsonRepresentation; end
|
1191
1203
|
|
@@ -3652,6 +3664,15 @@ module Google
|
|
3652
3664
|
end
|
3653
3665
|
end
|
3654
3666
|
|
3667
|
+
class GoogleCloudVisionV1p4beta1Celebrity
|
3668
|
+
# @private
|
3669
|
+
class Representation < Google::Apis::Core::JsonRepresentation
|
3670
|
+
property :description, as: 'description'
|
3671
|
+
property :display_name, as: 'displayName'
|
3672
|
+
property :name, as: 'name'
|
3673
|
+
end
|
3674
|
+
end
|
3675
|
+
|
3655
3676
|
class GoogleCloudVisionV1p4beta1ColorInfo
|
3656
3677
|
# @private
|
3657
3678
|
class Representation < Google::Apis::Core::JsonRepresentation
|
@@ -3722,6 +3743,8 @@ module Google
|
|
3722
3743
|
collection :landmarks, as: 'landmarks', class: Google::Apis::VisionV1p2beta1::GoogleCloudVisionV1p4beta1FaceAnnotationLandmark, decorator: Google::Apis::VisionV1p2beta1::GoogleCloudVisionV1p4beta1FaceAnnotationLandmark::Representation
|
3723
3744
|
|
3724
3745
|
property :pan_angle, as: 'panAngle'
|
3746
|
+
collection :recognition_result, as: 'recognitionResult', class: Google::Apis::VisionV1p2beta1::GoogleCloudVisionV1p4beta1FaceRecognitionResult, decorator: Google::Apis::VisionV1p2beta1::GoogleCloudVisionV1p4beta1FaceRecognitionResult::Representation
|
3747
|
+
|
3725
3748
|
property :roll_angle, as: 'rollAngle'
|
3726
3749
|
property :sorrow_likelihood, as: 'sorrowLikelihood'
|
3727
3750
|
property :surprise_likelihood, as: 'surpriseLikelihood'
|
@@ -3739,6 +3762,15 @@ module Google
|
|
3739
3762
|
end
|
3740
3763
|
end
|
3741
3764
|
|
3765
|
+
class GoogleCloudVisionV1p4beta1FaceRecognitionResult
|
3766
|
+
# @private
|
3767
|
+
class Representation < Google::Apis::Core::JsonRepresentation
|
3768
|
+
property :celebrity, as: 'celebrity', class: Google::Apis::VisionV1p2beta1::GoogleCloudVisionV1p4beta1Celebrity, decorator: Google::Apis::VisionV1p2beta1::GoogleCloudVisionV1p4beta1Celebrity::Representation
|
3769
|
+
|
3770
|
+
property :confidence, as: 'confidence'
|
3771
|
+
end
|
3772
|
+
end
|
3773
|
+
|
3742
3774
|
class GoogleCloudVisionV1p4beta1GcsDestination
|
3743
3775
|
# @private
|
3744
3776
|
class Representation < Google::Apis::Core::JsonRepresentation
|
@@ -138,6 +138,10 @@ module Google
|
|
138
138
|
@state = :start
|
139
139
|
@upload_url = nil
|
140
140
|
@offset = 0
|
141
|
+
# Prevent the command from populating the body with form encoding, by
|
142
|
+
# asserting that it already has a body. Form encoding is never used
|
143
|
+
# by upload requests.
|
144
|
+
self.body = '' unless self.body
|
141
145
|
super
|
142
146
|
end
|
143
147
|
|
data/lib/google/apis/version.rb
CHANGED
@@ -0,0 +1,126 @@
|
|
1
|
+
require "pathname"
|
2
|
+
require "tmpdir"
|
3
|
+
|
4
|
+
require_relative "repo_metadata.rb"
|
5
|
+
|
6
|
+
class DevsiteBuilder
|
7
|
+
def initialize build_tag = nil
|
8
|
+
@build_tag = build_tag || latest_tag
|
9
|
+
@output_dir = "doc"
|
10
|
+
end
|
11
|
+
|
12
|
+
def build tag
|
13
|
+
checkout_tag tag
|
14
|
+
doc_path = tmp_dir + @output_dir
|
15
|
+
FileUtils.remove_dir doc_path if Dir.exist? doc_path
|
16
|
+
markup = "--markup markdown --markup-provider redcarpet"
|
17
|
+
|
18
|
+
Dir.chdir tmp_dir do
|
19
|
+
cmds = ["-o #{@output_dir}", markup]
|
20
|
+
cmd "yard --verbose #{cmds.join ' '}"
|
21
|
+
end
|
22
|
+
metadata.build doc_path
|
23
|
+
end
|
24
|
+
|
25
|
+
def upload
|
26
|
+
Dir.chdir tmp_dir + @output_dir do
|
27
|
+
opts = [
|
28
|
+
"--credentials=#{ENV['KOKORO_KEYSTORE_DIR']}/73713_docuploader_service_account",
|
29
|
+
"--staging-bucket=#{ENV.fetch 'STAGING_BUCKET', 'docs-staging'}",
|
30
|
+
"--metadata-file=./docs.metadata"
|
31
|
+
]
|
32
|
+
cmd "python3 -m docuploader upload . #{opts.join ' '}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def publish tag = nil
|
37
|
+
build(tag || @build_tag)
|
38
|
+
upload
|
39
|
+
end
|
40
|
+
|
41
|
+
def publish_if_missing tag = nil
|
42
|
+
tag ||= @build_tag
|
43
|
+
puts tag
|
44
|
+
puts missing? tag
|
45
|
+
publish tag if missing? tag
|
46
|
+
end
|
47
|
+
|
48
|
+
def missing? tag
|
49
|
+
require "httparty"
|
50
|
+
|
51
|
+
url = "https://googleapis.dev/ruby/google-api-client/v#{version tag}/index.html"
|
52
|
+
response = HTTParty.get url
|
53
|
+
response.code != 200
|
54
|
+
rescue StandardError
|
55
|
+
true
|
56
|
+
end
|
57
|
+
|
58
|
+
def cmd line
|
59
|
+
puts line
|
60
|
+
output = `#{line}`
|
61
|
+
puts output
|
62
|
+
output
|
63
|
+
end
|
64
|
+
|
65
|
+
def metadata
|
66
|
+
return @metadata if @metadata
|
67
|
+
|
68
|
+
metadata_json = "#{tmp_dir}/.repo-metadata.json"
|
69
|
+
@metadata = RepoMetadata.from_source metadata_json if File.file? metadata_json
|
70
|
+
@metadata ||= RepoMetadata.from_source "name" => "google-api-client",
|
71
|
+
"distribution-name" => "google-api-client",
|
72
|
+
"language" => "ruby"
|
73
|
+
@metadata["version"] = version @build_tag
|
74
|
+
@metadata
|
75
|
+
end
|
76
|
+
|
77
|
+
def checkout_tag git_tag
|
78
|
+
Dir.chdir tmp_dir do
|
79
|
+
`git checkout tags/#{git_tag} -b v#{version git_tag}`
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def version git_tag
|
84
|
+
m = git_tag.match(/(\d+\.\d+\.\d+)/)
|
85
|
+
return m if m.nil?
|
86
|
+
m[0]
|
87
|
+
end
|
88
|
+
|
89
|
+
def versions
|
90
|
+
Dir.chdir tmp_dir do
|
91
|
+
tags.map { |t| version t }.reject(&:nil?).sort_by { |v| Gem::Version.new v }.reverse
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def tags
|
96
|
+
Dir.chdir tmp_dir do
|
97
|
+
`git tag`.split "\n"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def latest_version
|
102
|
+
@latest_version ||= versions.first
|
103
|
+
end
|
104
|
+
|
105
|
+
def latest_tag
|
106
|
+
@latest_tag ||= tags.select { |t| t.include? latest_version }.min_by(&:size)
|
107
|
+
end
|
108
|
+
|
109
|
+
def tmp_dir
|
110
|
+
return @tmp_dir if @tmp_dir
|
111
|
+
|
112
|
+
tmp = Dir.tmpdir
|
113
|
+
dir_name = "google-api-ruby-client"
|
114
|
+
@tmp_dir = Pathname.new(tmp) + dir_name
|
115
|
+
FileUtils.remove_dir @tmp_dir if Dir.exist? @tmp_dir
|
116
|
+
|
117
|
+
Dir.chdir tmp do
|
118
|
+
`git clone https://github.com/googleapis/google-api-ruby-client.git`
|
119
|
+
end
|
120
|
+
Dir.chdir @tmp_dir do
|
121
|
+
`git fetch`
|
122
|
+
end
|
123
|
+
|
124
|
+
@tmp_dir
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,64 @@
|
|
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-api-ruby-client/tree/#{git_commit}",
|
15
|
+
" --skip '^(?!(\\Wruby.*google|.*google.*\\Wruby|.*cloud\\.google\\.com))'")
|
16
|
+
|
17
|
+
broken_devsite_links = check_links(["google-api-client"],
|
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
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "json"
|
2
|
+
|
3
|
+
class RepoMetadata
|
4
|
+
attr_accessor :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
|
+
@data.delete_if { |k, _| !allowed_fields.include?(k) }
|
27
|
+
end
|
28
|
+
|
29
|
+
def [] key
|
30
|
+
data[key]
|
31
|
+
end
|
32
|
+
|
33
|
+
def []= key, value
|
34
|
+
@data[key] = value
|
35
|
+
end
|
36
|
+
|
37
|
+
def cmd line
|
38
|
+
puts line
|
39
|
+
output = `#{line}`
|
40
|
+
puts output
|
41
|
+
output
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.from_source source
|
45
|
+
if source.is_a? RepoMetadata
|
46
|
+
data = source.data
|
47
|
+
elsif source.is_a? Hash
|
48
|
+
data = source
|
49
|
+
elsif File.file? source
|
50
|
+
data = JSON.parse File.read(source)
|
51
|
+
else
|
52
|
+
raise "Source must be a path, hash, or RepoMetadata instance"
|
53
|
+
end
|
54
|
+
RepoMetadata.new data
|
55
|
+
end
|
56
|
+
end
|