govuk-lint 0.3.0 → 0.4.0
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/lib/govuk/lint/cli.rb +2 -1
- data/lib/govuk/lint/config_file.rb +49 -0
- data/lib/govuk/lint/diff.rb +0 -1
- data/lib/govuk/lint/version.rb +1 -1
- data/lib/govuk/lint.rb +0 -1
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae1e00c5da9d6ad92606caf1ccdd797cd250143f
|
4
|
+
data.tar.gz: 27bdddd3c14c5c098ca9db575e86e43e5ecb0823
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d27a39775793be1afb49d3a1d4cd342131c25b1052b8649085efd35c7db2ca55347b3698185df3e53a26d2630a046a1f1e52031bec9d3d53cfc4cbb7c52d59e0
|
7
|
+
data.tar.gz: e65e4e43db09fd02afa686f885f59aa57c65e77d2cc77cbeb43482f2719c03373d1b42716b830e1ce450618df344aac0c6a4edd9da7851d94c4ddc60db9589f9
|
data/lib/govuk/lint/cli.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "govuk/lint"
|
2
2
|
require "govuk/lint/diff"
|
3
|
+
require "govuk/lint/config_file"
|
3
4
|
|
4
5
|
require "rubocop"
|
5
6
|
|
@@ -8,7 +9,7 @@ module Govuk
|
|
8
9
|
class CLI < RuboCop::CLI
|
9
10
|
def run(args = ARGV)
|
10
11
|
args += ["--config",
|
11
|
-
|
12
|
+
ConfigFile.new.config_file_path]
|
12
13
|
|
13
14
|
Diff.enable!(args) if args.include? "--diff"
|
14
15
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module Govuk
|
5
|
+
module Lint
|
6
|
+
class ConfigFile
|
7
|
+
CONFIG_PATH = File.expand_path("../../../../configs", __FILE__)
|
8
|
+
BASE_CONFIG_FILE = File.join(CONFIG_PATH, "rubocop/all.yml")
|
9
|
+
|
10
|
+
def config_file_path
|
11
|
+
return BASE_CONFIG_FILE unless File.exist?(local_config_file_path)
|
12
|
+
|
13
|
+
config = merged_global_and_local_configs
|
14
|
+
file = create_tempfile_for_configs(config)
|
15
|
+
file.path
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def merged_global_and_local_configs
|
21
|
+
config = load_global_config
|
22
|
+
config['inherit_from'] = absolutize_paths(config)
|
23
|
+
config['inherit_from'] << local_config_file_path
|
24
|
+
config
|
25
|
+
end
|
26
|
+
|
27
|
+
def load_global_config
|
28
|
+
YAML.load_file(BASE_CONFIG_FILE)
|
29
|
+
end
|
30
|
+
|
31
|
+
def absolutize_paths(config)
|
32
|
+
config['inherit_from'].map do |filename|
|
33
|
+
File.join(CONFIG_PATH, "rubocop/#{filename}")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def local_config_file_path
|
38
|
+
@local_config_file_path ||= File.join(Dir.pwd, ".rubocop.yml")
|
39
|
+
end
|
40
|
+
|
41
|
+
def create_tempfile_for_configs(config)
|
42
|
+
file = Tempfile.new('tmp-rubocop-all.yml')
|
43
|
+
file.write(config.to_yaml)
|
44
|
+
file.close
|
45
|
+
file
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/govuk/lint/diff.rb
CHANGED
data/lib/govuk/lint/version.rb
CHANGED
data/lib/govuk/lint.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk-lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Government Digital Service
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.5.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.3'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rubocop
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,6 +98,7 @@ files:
|
|
84
98
|
- configs/rubocop/other-style.yml
|
85
99
|
- lib/govuk/lint.rb
|
86
100
|
- lib/govuk/lint/cli.rb
|
101
|
+
- lib/govuk/lint/config_file.rb
|
87
102
|
- lib/govuk/lint/diff.rb
|
88
103
|
- lib/govuk/lint/version.rb
|
89
104
|
homepage: https://github.com/alphagov/govuk-lint
|
@@ -105,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
120
|
version: '0'
|
106
121
|
requirements: []
|
107
122
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.4.5
|
123
|
+
rubygems_version: 2.4.5.1
|
109
124
|
signing_key:
|
110
125
|
specification_version: 4
|
111
126
|
summary: A wrapper around rubocop, configured with the GDS style guides
|