Sha256: b9e3526e31a69ca1c9cde5cec22e8f6ccacfdb5e7a1d615b441e8d1feef01844

Contents?: true

Size: 1.1 KB

Versions: 7

Compression:

Stored size: 1.1 KB

Contents

class Onceover
  module CodeQuality
    module Environment

      ENVIRONMENT_CONF = "environment.conf"

      # Latest best practice is to change the name of `site` to be
      # `site-modules`. This means we need to start processing `environment.conf`
      # to extract this...
      def self.get_site_dirs()
        if File.exist?(ENVIRONMENT_CONF)
          #modulepath = site-modules:modules:$basemodulepath
          modulepath = open(ENVIRONMENT_CONF) { |f| f.each_line.find { |line| line.include?("modulepath") } }

          begin
            environments = modulepath.split("=")[1].split(":").reject { |e|
              # reject any elements containing interpolation or referencing modules
              # loaded by r10k
              e =~ /\$/ || e == "modules" || e =~ /[\\.\/]/
            }.map {
              |e| e.strip
            }
          rescue NoMethodError => e
            raise "Malformed environment configuration: #{ENVIRONMENT_CONF}"
          end
        else
          raise "Missing environment configuration: #{ENVIRONMENT_CONF}"
        end

        environments
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
onceover-codequality-0.12.0 lib/onceover/codequality/environment.rb
onceover-codequality-0.11.0 lib/onceover/codequality/environment.rb
onceover-codequality-0.10.0 lib/onceover/codequality/environment.rb
onceover-codequality-0.9.0 lib/onceover/codequality/environment.rb
onceover-codequality-0.8.0 lib/onceover/codequality/environment.rb
onceover-codequality-0.7.2 lib/onceover/codequality/environment.rb
onceover-codequality-0.7.1 lib/onceover/codequality/environment.rb