Sha256: f60a3a1826dc11198b28886ef8757668298129a61d58e3dcea28b7f230cfb28d

Contents?: true

Size: 1.43 KB

Versions: 34

Compression:

Stored size: 1.43 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

      # Returns the default reporter to use during the command run
      #
      # options - The options the command was run with
      #
      # Returns a Licensed::Reporters::StatusReporter
      def default_reporter(options)
        Licensed::Reporters::YamlReporter.new
      end

      protected

      def run_command(report)
        report["git_repo"] = Licensed::Git.git_repo?
        super
      end

      def run_app(app, report)
        report.merge! AppEnvironment.new(app).to_h
        super
      end

      def run_source(app, source, report)
        true
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
licensed-3.7.0 lib/licensed/commands/environment.rb
licensed-3.6.0 lib/licensed/commands/environment.rb
licensed-3.5.0 lib/licensed/commands/environment.rb
licensed-3.4.4 lib/licensed/commands/environment.rb
licensed-3.4.3 lib/licensed/commands/environment.rb
licensed-3.4.2 lib/licensed/commands/environment.rb
licensed-3.4.1 lib/licensed/commands/environment.rb
licensed-3.4.0 lib/licensed/commands/environment.rb
licensed-3.3.1 lib/licensed/commands/environment.rb
licensed-3.3.0 lib/licensed/commands/environment.rb
licensed-3.2.3 lib/licensed/commands/environment.rb
licensed-3.2.2 lib/licensed/commands/environment.rb
licensed-3.2.1 lib/licensed/commands/environment.rb
licensed-3.2.0 lib/licensed/commands/environment.rb