Sha256: a8d9dc2cf12fb56be3fa0feab0268ea39f9a331fd539efaf0c794a5ca8d491ba

Contents?: true

Size: 1.37 KB

Versions: 9

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true
module Licensed
  module Commands
    class Environment < Command
      class AppEnvironment
        include Licensed::Sources::ContentVersioning

        attr_reader :config
        def initialize(config)
          @config = config
        end

        def enabled_source_types
          config.sources.select { |s| s.enabled? }.map { |s| s.class.type }
        end

        def to_h
          {
            "name" => config["name"],
            "source_path" => config.source_path,
            "cache_path" => config.cache_path,
            "sources" => enabled_source_types,
            "allowed" => config["allowed"],
            "ignored" => config["ignored"],
            "reviewed" => config["reviewed"],
            "version_strategy" => self.version_strategy,
            "root" => config.root
          }
        end
      end

      def run(**options)
        super do |report|
          report["git_repo"] = Licensed::Git.git_repo?
        end
      end

      def create_reporter(options)
        case options[:format]
        when "json"
          Licensed::Reporters::JsonReporter.new
        else
          Licensed::Reporters::YamlReporter.new
        end
      end

      protected

      def run_app(app)
        reporter.report_app(app) do |report|
          report.merge! AppEnvironment.new(app).to_h
          true
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
licensed-2.12.2 lib/licensed/commands/environment.rb
licensed-2.12.1 lib/licensed/commands/environment.rb
licensed-2.12.0 lib/licensed/commands/environment.rb
licensed-2.11.1 lib/licensed/commands/environment.rb
licensed-2.11.0 lib/licensed/commands/environment.rb
licensed-2.10.0 lib/licensed/commands/environment.rb
licensed-2.9.2 lib/licensed/commands/environment.rb
licensed-2.9.1 lib/licensed/commands/environment.rb
licensed-2.9.0 lib/licensed/commands/environment.rb