onceover-codequality 0.6.0 → 0.7.1

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: ee41694d81a21ab44a8d2c7b6630740ac8caa219d64e2bbcf14fadf1f9d919af
4
- data.tar.gz: a3a16cc00241852ee07f0cf162cdd2fb10187c9218912ef814f3f13dcd6ce44d
3
+ metadata.gz: 74c3c08709d8f2e00c4a2df14806c6a8c87d510543aa23aaa95351df5c27fdaf
4
+ data.tar.gz: b2b2c9023c49a39365be2266c7c74d43e53d35fc13a492153d8720cda54132ed
5
5
  SHA512:
6
- metadata.gz: 6f63484487dc3d9211652a827648879b1d8c9dc76e7720b959dff30e17357061bd249cc5eb1fc5a22ac3fe714809e36bdd2cff65f72e4ddf2ac6dedcb6b1ea78
7
- data.tar.gz: 75e20bdd744457c8783c903f290cc4238d83f3d44479db02146f00f666daacab8041cb7d0abead69df1b468ed0e441b488cb0863a48f89d5b2e3e021b8757f65
6
+ metadata.gz: f03f53e1f1a475f1e7f93fdb17cf06b979661c684a092ea805d75fa07e32ce31794293c5a6a866c352175f729c0e4ebebf218a198107c36d24ff9f26423c4416
7
+ data.tar.gz: dbf6f562d7de09b0134d41330a5db2a0d6a306c0c9b6b92e1d8ffe262e85a44259379111787a35ef58087982bcc1e8ab0d6b492e15ea53aeea9b953a28b94001
data/.gitignore CHANGED
@@ -1,7 +1,7 @@
1
1
  /.bundle/
2
2
  **/.yardoc
3
3
  **/REFERENCE.md
4
- /spec/fixtures/**/doc
4
+ /spec/testcase/**/doc
5
5
  /_yardoc/
6
6
  /coverage/
7
7
  /doc/
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- onceover-codequality (0.6.0)
4
+ onceover-codequality (0.7.0)
5
5
  onceover (~> 3)
6
6
  puppet-lint (~> 2)
7
7
  puppet-strings (~> 2)
@@ -2,6 +2,7 @@ require "onceover/codequality/lint"
2
2
  require "onceover/codequality/syntax"
3
3
  require "onceover/codequality/docs"
4
4
  require "onceover/codequality/puppetfile"
5
+ require "onceover/codequality/environment"
5
6
  require "onceover/codequality/executor"
6
7
  require "onceover/codequality/formatter"
7
8
  class Onceover
@@ -1,24 +1,26 @@
1
1
  # Support for generating documentation using Puppet Strings for each module
2
- # listed in the site directory
2
+ # listed in the environment.conf modulepath
3
3
  class Onceover
4
4
  module CodeQuality
5
5
  module Docs
6
- LOCAL_MOD_DIR = "site"
7
6
 
8
7
  def self.puppet_strings(html_docs)
9
8
  status = true
10
9
  format = html_docs ? "--markup html" : "--format markdown"
11
- if Dir.exist?(LOCAL_MOD_DIR)
12
- Dir.glob("#{LOCAL_MOD_DIR}/*/") { |dir|
13
- Dir.chdir(dir) {
14
- CodeQuality::Formatter.start_test("Generate documentation in #{dir}")
15
- # puppet strings prints useful metrics so don't swallow its output
16
- output, ok = CodeQuality::Executor.run("puppet strings generate #{format}")
17
- status &= ok
18
- CodeQuality::Formatter.end_test(output, ok, true)
10
+
11
+ CodeQuality::Environment.get_site_dirs.each { |local_mod_dir|
12
+ if Dir.exist?(local_mod_dir)
13
+ Dir.glob("#{local_mod_dir}/*/") { |dir|
14
+ Dir.chdir(dir) {
15
+ CodeQuality::Formatter.start_test("Generate documentation in #{dir}")
16
+ # puppet strings prints useful metrics so don't swallow its output
17
+ output, ok = CodeQuality::Executor.run("puppet strings generate #{format}")
18
+ status &= ok
19
+ CodeQuality::Formatter.end_test(output, ok, true)
20
+ }
19
21
  }
20
- }
21
- end
22
+ end
23
+ }
22
24
 
23
25
  status
24
26
  end
@@ -0,0 +1,34 @@
1
+ class Onceover
2
+ module CodeQuality
3
+ module Environment
4
+
5
+ ENVIRONMENT_CONF = "environment.conf"
6
+
7
+ # Latest best practice is to change the name of `site` to be
8
+ # `site-modules`. This means we need to start processing `environment.conf`
9
+ # to extract this...
10
+ def self.get_site_dirs()
11
+ if File.exist?(ENVIRONMENT_CONF)
12
+ #modulepath = site-modules:modules:$basemodulepath
13
+ modulepath = open(ENVIRONMENT_CONF) { |f| f.each_line.find { |line| line.include?("modulepath") } }
14
+
15
+ begin
16
+ environments = modulepath.split("=")[1].split(":").reject { |e|
17
+ # reject any elements containing interpolation or referencing modules
18
+ # loaded by r10k
19
+ e =~ /\$/ || e == "modules" || e =~ /[\\.\/]/
20
+ }.map {
21
+ |e| e.strip
22
+ }
23
+ rescue NoMethodError => e
24
+ raise "Malformed environment configuration: #{ENVIRONMENT_CONF}"
25
+ end
26
+ else
27
+ raise "Missing environment configuration: #{ENVIRONMENT_CONF}"
28
+ end
29
+
30
+ environments
31
+ end
32
+ end
33
+ end
34
+ end
@@ -26,11 +26,12 @@ class Onceover
26
26
 
27
27
  # wait until runtime to scan directories for unit tests
28
28
  lint_paths = LINT_PATHS.concat(
29
- Dir.glob('site/*')
30
- .select { |f| File.directory? f}
29
+ CodeQuality::Environment.get_site_dirs.each { |site_dir|
30
+ Dir.glob("#{site_dir}/*").select { |f| File.directory? f}
31
+ }
31
32
  )
32
33
  lint_paths.each { |p|
33
- if Dir.exists?(p)
34
+ if Dir.exist?(p)
34
35
  CodeQuality::Formatter.start_test("lint in #{p}")
35
36
  output, ok = CodeQuality::Executor.run("puppet-lint #{LINT_OPTIONS.join ' '} #{p}")
36
37
  status &= ok
@@ -1,5 +1,5 @@
1
1
  class Onceover
2
2
  module CodeQuality
3
- VERSION = "0.6.0"
3
+ VERSION = "0.7.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onceover-codequality
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Declarative Systems
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-18 00:00:00.000000000 Z
11
+ date: 2019-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -128,6 +128,7 @@ files:
128
128
  - lib/onceover/codequality.rb
129
129
  - lib/onceover/codequality/cli.rb
130
130
  - lib/onceover/codequality/docs.rb
131
+ - lib/onceover/codequality/environment.rb
131
132
  - lib/onceover/codequality/executor.rb
132
133
  - lib/onceover/codequality/formatter.rb
133
134
  - lib/onceover/codequality/lint.rb