rubocop-schema-gen 0.1.2 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubocop/schema/ascii_doc/base.rb +3 -2
- data/lib/rubocop/schema/cached_http_client.rb +0 -1
- data/lib/rubocop/schema/defaults_ripper.rb +3 -1
- data/lib/rubocop/schema/document_loader.rb +2 -1
- data/lib/rubocop/schema/helpers.rb +4 -3
- data/lib/rubocop/schema/repo.rb +16 -4
- data/lib/rubocop/schema/version.rb +1 -1
- data/lib/rubocop/schema.rb +0 -1
- metadata +3 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d98e35c60ef286f1d5c9df9233a47697e6902709cf821e35bab4e1fbbdc3bc3c
|
4
|
+
data.tar.gz: e510ba95ef1cebccef9309ac5645c5beb2b4cf62c37a7263545eedacc9420e03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 366bb50398f6bb733cd8ee2cd83294b0db503bf8c1580533c9498131d00a4b680f016211d8927ef320fc3228baad0ef7aa5f8508e716ef05a7bcac8cccb68cce
|
7
|
+
data.tar.gz: b68e8aa28af5a18e9f2efadce1cc32e8feb67274434b0ceaac1e9192945e0376dd91594c3279b7db61d950d7fff386bcf24630a29f74034fa28abb00ffa7ef92
|
@@ -24,8 +24,9 @@ module RuboCop
|
|
24
24
|
|
25
25
|
def link_text(str)
|
26
26
|
# The Asciidoctor API doesn't provide access to the raw title, or parts of it.
|
27
|
-
|
28
|
-
|
27
|
+
return unless (text = str[%r{<a\s.+?>(.+?)</a>}, 1])
|
28
|
+
|
29
|
+
strip_html text
|
29
30
|
end
|
30
31
|
|
31
32
|
# @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,4 +1,5 @@
|
|
1
1
|
require 'asciidoctor'
|
2
|
+
require 'yaml'
|
2
3
|
|
3
4
|
module RuboCop
|
4
5
|
module Schema
|
@@ -25,7 +26,7 @@ module RuboCop
|
|
25
26
|
# @param [Spec] spec
|
26
27
|
def defaults(spec)
|
27
28
|
@defaults[spec] ||=
|
28
|
-
YAML.safe_load @http_client.get(url_for_defaults(spec)), [Regexp, Symbol]
|
29
|
+
YAML.safe_load @http_client.get(url_for_defaults(spec)), [Regexp, Symbol], [], true
|
29
30
|
end
|
30
31
|
|
31
32
|
# @param [Spec] spec
|
@@ -1,5 +1,7 @@
|
|
1
|
-
require 'nokogiri'
|
2
1
|
require 'uri'
|
2
|
+
require 'yaml'
|
3
|
+
require 'net/http'
|
4
|
+
require 'cgi'
|
3
5
|
|
4
6
|
module RuboCop
|
5
7
|
module Schema
|
@@ -45,9 +47,8 @@ module RuboCop
|
|
45
47
|
|
46
48
|
# Used for stripping HTML from Asciidoctor output, where raw output is not available, or not
|
47
49
|
# appropriate to use.
|
48
|
-
# TODO: look into the Asciidoctor for a way to do a non-HTML conversion
|
49
50
|
def strip_html(str)
|
50
|
-
|
51
|
+
CGI.unescapeHTML str.gsub(/<.*?>/, '').gsub(/\s+/, ' ')
|
51
52
|
end
|
52
53
|
|
53
54
|
def http_get(url)
|
data/lib/rubocop/schema/repo.rb
CHANGED
@@ -2,13 +2,18 @@ require 'json'
|
|
2
2
|
|
3
3
|
require 'rubocop/schema/helpers'
|
4
4
|
require 'rubocop/schema/diff'
|
5
|
+
require 'rubocop/schema/extension_spec'
|
6
|
+
require 'rubocop/schema/value_objects'
|
5
7
|
|
6
8
|
module RuboCop
|
7
9
|
module Schema
|
8
10
|
class Repo
|
9
11
|
include Helpers
|
10
12
|
|
11
|
-
|
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}"
|
12
17
|
|
13
18
|
def initialize(dir, loader, &event_handler)
|
14
19
|
@dir = Pathname(dir)
|
@@ -69,10 +74,17 @@ module RuboCop
|
|
69
74
|
end
|
70
75
|
|
71
76
|
def versions_of(name)
|
72
|
-
|
73
|
-
|
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 == ''
|
74
81
|
|
75
|
-
|
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
|
76
88
|
end
|
77
89
|
end
|
78
90
|
end
|
data/lib/rubocop/schema.rb
CHANGED
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.6
|
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-
|
11
|
+
date: 2021-11-29 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.0.
|
81
|
+
rubygems_version: 3.0.9
|
110
82
|
signing_key:
|
111
83
|
specification_version: 4
|
112
84
|
summary: Generate JSON schemas for IDE integration with RuboCop
|