manageiq-style 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87713f5170c0b2e2264839443cd86efd7e0a2e0cf7350520c40bf3cad60a569d
4
- data.tar.gz: 954625f619b519fe56af127ad53ba885e2c53b8accf191dcbd6bde88dbaca507
3
+ metadata.gz: 0c39d38f4271a8073edeef202ee92a1384823b678c273b5e21875d8b21af4dd7
4
+ data.tar.gz: 22c988be09d434be7fb20d06b96c6e1209711c073a2ddc6911537d35a29fe6ec
5
5
  SHA512:
6
- metadata.gz: a4609edf44018bd8c3b0f315fbde1b8a36dceb41b19002f518a77186adaad012c1bdfa115af1c9b4ea9159eb7482700309809d04d13eada0c443e85d67b56b1c
7
- data.tar.gz: 7a6712cd6fe92ec007c80990e96cecac67f39353b435c2e35514cf7c10dc2d6686a956c035d326a0455bb07f486b3bb9296a5e6362f479275df4f6a48378b480
6
+ metadata.gz: b8b8362e34ff3efb97007047af172b5a11f677fafe2ba0f1d465f30191b9b9cd4dcb7d03cf614e043d9af3573a00712d6d49466b373f766f50c373779ec701c6
7
+ data.tar.gz: b225d0b75481e663079b5dfc50d63845f6447f0c585d2d8703d870fba4580a9a3b649e3b5f34ecf00c12ee77fcc8d82d817b9c3c6e00126248c3e65b71316b00
@@ -0,0 +1,11 @@
1
+ prepare:
2
+ fetch:
3
+ - url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/.rubocop_base.yml
4
+ path: ".rubocop_base.yml"
5
+ - url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/.rubocop_cc_base.yml
6
+ path: ".rubocop_cc_base.yml"
7
+ plugins:
8
+ rubocop:
9
+ enabled: true
10
+ config: ".rubocop_cc.yml"
11
+ channel: rubocop-0-82
@@ -0,0 +1,4 @@
1
+ inherit_from:
2
+ - ".rubocop_base.yml"
3
+ - ".rubocop_cc_base.yml"
4
+ - ".rubocop_local.yml"
@@ -0,0 +1 @@
1
+
data/README.md CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ In the root of the repo that needs configuring, run `bundle exec manageiq-style -i` to install or update the rubocop and codeclimate configuration files.
26
26
 
27
27
  ## Development
28
28
 
@@ -32,7 +32,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
32
 
33
33
  ## Contributing
34
34
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/manageiq-style. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/manageiq-style/blob/master/CODE_OF_CONDUCT.md).
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ManageIQ/manageiq-style. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/ManageIQ/.github/blob/master/CODE_OF_CONDUCT.md).
36
36
 
37
37
 
38
38
  ## Code of Conduct
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH << File.expand_path("../lib", __dir__)
4
+
5
+ require 'bundler/setup'
6
+ require 'manageiq/style/cli'
7
+
8
+ Manageiq::Style::CLI.run
@@ -0,0 +1,137 @@
1
+ require "manageiq/style"
2
+
3
+ module Manageiq
4
+ module Style
5
+ class CLI
6
+ def self.run
7
+ new.run
8
+ end
9
+
10
+ def initialize(options = parse_cli_options)
11
+ @opts = options
12
+ end
13
+
14
+ def parse_cli_options
15
+ require 'optimist'
16
+
17
+ Optimist.options do
18
+ usage "manageiq-version [OPTIONS]"
19
+ synopsis "The ManageIQ communities style configuration utility"
20
+ version "v#{Manageiq::Style::VERSION}\n"
21
+
22
+ opt :install, "Install or update the style configurations", :default => false
23
+ end
24
+ end
25
+
26
+ def run
27
+ version if @opts[:version]
28
+ install if @opts[:install]
29
+ end
30
+
31
+ def install
32
+ require 'yaml'
33
+ require 'more_core_extensions/all'
34
+
35
+ check_for_codeclimate_channel
36
+ update_rubocop_yml
37
+ write_rubocop_cc_yml
38
+ ensure_rubocop_local_yml_exists
39
+ update_codeclimate_yml
40
+ update_generator
41
+ end
42
+
43
+ private
44
+
45
+ def check_for_codeclimate_channel
46
+ begin
47
+ require 'open-uri'
48
+ URI::HTTPS.build(
49
+ :host => "raw.githubusercontent.com",
50
+ :path => File.join("/codeclimate", "codeclimate-rubocop", "channel", cc_rubocop_channel, "Gemfile")
51
+ ).open
52
+ rescue OpenURI::HTTPError
53
+ puts "RuboCop version #{rubocop_version.version} is not supported by CodeClimate."
54
+ exit 1
55
+ end
56
+ end
57
+
58
+ def update_rubocop_yml(file = ".rubocop.yml")
59
+ data = begin
60
+ YAML.load_file(file)
61
+ rescue Errno::ENOENT
62
+ {}
63
+ end
64
+
65
+ data.store_path("inherit_gem", "manageiq-style", ".rubocop_base.yml")
66
+ data["inherit_from"] = [".rubocop_local.yml"]
67
+
68
+ File.write(".rubocop.yml", data.to_yaml.sub("---\n", ""))
69
+ end
70
+
71
+ def write_rubocop_cc_yml(file = ".rubocop_cc.yml")
72
+ data = {
73
+ "inherit_from" => [
74
+ ".rubocop_base.yml",
75
+ ".rubocop_cc_base.yml",
76
+ ".rubocop_local.yml"
77
+ ]
78
+ }
79
+
80
+ File.write(file, data.to_yaml.sub("---\n", ""))
81
+ end
82
+
83
+ def ensure_rubocop_local_yml_exists(file = ".rubocop_local.yml")
84
+ require 'fileutils'
85
+ FileUtils.touch(file)
86
+ end
87
+
88
+ def update_codeclimate_yml(file = ".codeclimate.yml")
89
+ data = begin
90
+ YAML.load_file(file)
91
+ rescue Errno::ENOENT
92
+ {}
93
+ end
94
+
95
+ data["prepare"] = {
96
+ "fetch" => [
97
+ {"url" => "https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/.rubocop_base.yml", "path" => ".rubocop_base.yml"},
98
+ {"url" => "https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/.rubocop_cc_base.yml", "path" => ".rubocop_cc_base.yml"}
99
+ ]
100
+ }
101
+
102
+ data.delete_path("engines", "rubocop")
103
+
104
+ data["plugins"] ||= {}
105
+ data["plugins"]["rubocop"] = {
106
+ "enabled" => true,
107
+ "config" => ".rubocop_cc.yml",
108
+ "channel" => cc_rubocop_channel,
109
+ }
110
+
111
+ File.write(".codeclimate.yml", data.to_yaml.sub("---\n", ""))
112
+ end
113
+
114
+ def update_generator
115
+ plugin_dir = "lib/generators/manageiq/plugin/templates"
116
+
117
+ return unless File.directory?(plugin_dir)
118
+
119
+ update_rubocop_yml(File.join(plugin_dir, ".rubocop.yml"))
120
+ write_rubocop_cc_yml(File.join(plugin_dir, ".rubocop_cc.yml"))
121
+ ensure_rubocop_local_yml_exists(File.join(plugin_dir, ".rubocop_local.yml"))
122
+ update_codeclimate_yml(File.join(plugin_dir, ".codeclimate.yml"))
123
+ end
124
+
125
+ def cc_rubocop_channel
126
+ @cc_rubocop_channel ||= "rubocop-#{rubocop_version.segments[0]}-#{rubocop_version.segments[1]}"
127
+ end
128
+
129
+ def rubocop_version
130
+ @rubocop_version ||= begin
131
+ require 'rubocop'
132
+ Gem::Version.new(RuboCop::Version.version)
133
+ end
134
+ end
135
+ end
136
+ end
137
+ end
@@ -1,5 +1,5 @@
1
1
  module Manageiq
2
2
  module Style
3
- VERSION = "1.0.1"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -24,6 +24,8 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ["lib"]
26
26
 
27
+ spec.add_runtime_dependency "more_core_extensions"
28
+ spec.add_runtime_dependency "optimist"
27
29
  spec.add_runtime_dependency "rubocop", "~> 0.82.0"
28
30
  spec.add_runtime_dependency "rubocop-performance"
29
31
  spec.add_runtime_dependency "rubocop-rails"
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manageiq-style
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Dunne
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-19 00:00:00.000000000 Z
11
+ date: 2020-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: more_core_extensions
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: optimist
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: rubocop
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -55,16 +83,20 @@ dependencies:
55
83
  description: Style and linting configuration for ManageIQ projects.
56
84
  email:
57
85
  - brandondunne@hotmail.com
58
- executables: []
86
+ executables:
87
+ - manageiq-style
59
88
  extensions: []
60
89
  extra_rdoc_files: []
61
90
  files:
91
+ - ".codeclimate.yml"
62
92
  - ".gitignore"
63
93
  - ".haml-lint.yml"
64
94
  - ".rspec"
65
95
  - ".rubocop.yml"
66
96
  - ".rubocop_base.yml"
97
+ - ".rubocop_cc.yml"
67
98
  - ".rubocop_cc_base.yml"
99
+ - ".rubocop_local.yml"
68
100
  - ".travis.yml"
69
101
  - Gemfile
70
102
  - LICENSE.txt
@@ -72,7 +104,9 @@ files:
72
104
  - Rakefile
73
105
  - bin/console
74
106
  - bin/setup
107
+ - exe/manageiq-style
75
108
  - lib/manageiq/style.rb
109
+ - lib/manageiq/style/cli.rb
76
110
  - lib/manageiq/style/version.rb
77
111
  - manageiq-style.gemspec
78
112
  homepage: https://github.com/ManageIQ/manageiq-style