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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ee1df307755ee3675eefdc79578e639c6ea3bfc
4
- data.tar.gz: f79724e020c356c65315d5f20e2414df53108668
3
+ metadata.gz: ae1e00c5da9d6ad92606caf1ccdd797cd250143f
4
+ data.tar.gz: 27bdddd3c14c5c098ca9db575e86e43e5ecb0823
5
5
  SHA512:
6
- metadata.gz: a86bbb94484e724960c9cfefd418347d78cdb39c01e83f63259bdf1e07f38549cc01008916c866e3ca0ba5f285ce3ffa7aae3483ce29dd63964d5283b094d37e
7
- data.tar.gz: 652c224478445f4cb192ea1d0e7b841fdc7dfd09805e12072d9871b3d481d3f4fccecafaa6919b0c58fde0556396bf6db9fb70c1ab2a207dd8940c9414a7d941
6
+ metadata.gz: d27a39775793be1afb49d3a1d4cd342131c25b1052b8649085efd35c7db2ca55347b3698185df3e53a26d2630a046a1f1e52031bec9d3d53cfc4cbb7c52d59e0
7
+ data.tar.gz: e65e4e43db09fd02afa686f885f59aa57c65e77d2cc77cbeb43482f2719c03373d1b42716b830e1ce450618df344aac0c6a4edd9da7851d94c4ddc60db9589f9
@@ -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
- File.join(Govuk::Lint::CONFIG_PATH, "rubocop/all.yml")]
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
@@ -42,7 +42,6 @@ module Govuk
42
42
  def self.changed_files
43
43
  `git diff #{commit_options} --name-only`.
44
44
  split.
45
- select { |f| f =~ %r{.rb$} }.
46
45
  map { |f| File.expand_path(f.chomp, "./") }
47
46
  end
48
47
 
@@ -1,5 +1,5 @@
1
1
  module Govuk
2
2
  module Lint
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
data/lib/govuk/lint.rb CHANGED
@@ -2,6 +2,5 @@ require "govuk/lint/version"
2
2
 
3
3
  module Govuk
4
4
  module Lint
5
- CONFIG_PATH = File.expand_path("../../../configs", __FILE__)
6
5
  end
7
6
  end
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.3.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-08-03 00:00:00.000000000 Z
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