rubocop-schema-gen 0.1.4 → 0.1.5
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99db5861b36cfdf148861814554c532213934e810770b8ed61f570b81a51ea1c
|
4
|
+
data.tar.gz: f7a310fbab5d4889cf24d8e138ca3acacf1fe66ab823699561d60b6db4320b02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b646939f86c4db226daf43887e9039fb487143d8ceea498124d9b84f0297a0815558494982531edab03a2754e2a26c8f6c6f06e04f6d3a406f63f3ac7d526e9
|
7
|
+
data.tar.gz: 42c0d2d6769be3de1ec6aec0dbb8efa8a609bfd59f82615587757a8bcbe5b79cad6e7ccbda6186cbe0f6ae59b4dc4fb84c106182b58ea05dcecabf8b059dc660
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
|
3
1
|
require 'rubocop/schema/ascii_doc/stringifier'
|
4
2
|
require 'rubocop/schema/helpers'
|
5
3
|
|
@@ -26,8 +24,7 @@ module RuboCop
|
|
26
24
|
|
27
25
|
def link_text(str)
|
28
26
|
# The Asciidoctor API doesn't provide access to the raw title, or parts of it.
|
29
|
-
|
30
|
-
Nokogiri::HTML(str).at_css('a')&.text
|
27
|
+
str[%r{<a\s.+?>(.+?)</a>}, 1]&.then &method(:strip_html)
|
31
28
|
end
|
32
29
|
|
33
30
|
# @param [Asciidoctor::Table] table
|
@@ -19,13 +19,15 @@ module RuboCop
|
|
19
19
|
# @param [Hash] defaults
|
20
20
|
def initialize(defaults)
|
21
21
|
@cops = defaults.map do |cop_name, attributes|
|
22
|
+
next unless attributes.is_a? Hash
|
23
|
+
|
22
24
|
CopInfo.new(
|
23
25
|
name: cop_name,
|
24
26
|
description: attributes['Description'],
|
25
27
|
enabled_by_default: attributes['Enabled'] == true,
|
26
28
|
attributes: transform_attributes(attributes)
|
27
29
|
)
|
28
|
-
end
|
30
|
+
end.compact
|
29
31
|
end
|
30
32
|
|
31
33
|
private
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require 'nokogiri'
|
2
1
|
require 'uri'
|
3
2
|
require 'yaml'
|
4
3
|
require 'net/http'
|
4
|
+
require 'cgi'
|
5
5
|
|
6
6
|
module RuboCop
|
7
7
|
module Schema
|
@@ -47,9 +47,8 @@ module RuboCop
|
|
47
47
|
|
48
48
|
# Used for stripping HTML from Asciidoctor output, where raw output is not available, or not
|
49
49
|
# appropriate to use.
|
50
|
-
# TODO: look into the Asciidoctor for a way to do a non-HTML conversion
|
51
50
|
def strip_html(str)
|
52
|
-
|
51
|
+
CGI.unescapeHTML str.gsub(/<.*?>/, '').gsub(/\s+/, ' ')
|
53
52
|
end
|
54
53
|
|
55
54
|
def http_get(url)
|
data/lib/rubocop/schema/repo.rb
CHANGED
@@ -10,7 +10,10 @@ module RuboCop
|
|
10
10
|
class Repo
|
11
11
|
include Helpers
|
12
12
|
|
13
|
-
|
13
|
+
# GitHub public APIs have a rate limit of 60/hour when making unauthenticated requests. 100 items
|
14
|
+
# per page is the maximum allowed, which we'll use to keep the number of requests to a minimum.
|
15
|
+
TAGS_PER_PAGE = 100
|
16
|
+
TAGS_URL_TEMPLATE = -"https://api.github.com/repos/rubocop/%s/tags?page=%d&per_page=#{TAGS_PER_PAGE}"
|
14
17
|
|
15
18
|
def initialize(dir, loader, &event_handler)
|
16
19
|
@dir = Pathname(dir)
|
@@ -71,10 +74,17 @@ module RuboCop
|
|
71
74
|
end
|
72
75
|
|
73
76
|
def versions_of(name)
|
74
|
-
|
75
|
-
|
77
|
+
tags = []
|
78
|
+
loop do
|
79
|
+
json = http_get(format(TAGS_URL_TEMPLATE, name, (tags.length / TAGS_PER_PAGE) + 1))
|
80
|
+
raise "No tags available for #{name}" if json == ''
|
76
81
|
|
77
|
-
|
82
|
+
parsed = JSON.parse(json)
|
83
|
+
tags += parsed
|
84
|
+
break unless parsed.length == TAGS_PER_PAGE
|
85
|
+
end
|
86
|
+
|
87
|
+
tags.reverse.map { |obj| obj['name'].to_s[/(?<=\Av)\d.+/] }.compact
|
78
88
|
end
|
79
89
|
end
|
80
90
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-schema-gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Neil E. Pearson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -24,34 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.0.14
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.17'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.17'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: nokogiri
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '1'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '1'
|
55
27
|
description: Generate JSON schemas for IDE integration with RuboCop
|
56
28
|
email:
|
57
29
|
- neil@helium.net.au
|
@@ -106,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
78
|
- !ruby/object:Gem::Version
|
107
79
|
version: '0'
|
108
80
|
requirements: []
|
109
|
-
rubygems_version: 3.
|
81
|
+
rubygems_version: 3.2.3
|
110
82
|
signing_key:
|
111
83
|
specification_version: 4
|
112
84
|
summary: Generate JSON schemas for IDE integration with RuboCop
|