Sha256: 18f25db44b3e14fbb6700421a728d142b5b632119348410cba3a17b0820fd724

Contents?: true

Size: 1.24 KB

Versions: 7

Compression:

Stored size: 1.24 KB

Contents

module Pantograph
  module Actions
    class EnsureEnvVarsAction < Action
      def self.run(params)
        null_keys = params[:vars].reject do |var|
          ENV.key?(var)
        end

        if null_keys.any?
          UI.user_error!("Unable to find ENV Variable(s):\n#{null_keys.join("\n")}")
        end

        UI.success("ENV variable(s) '#{params[:vars].join('\', \'')}' set!")
      end

      def self.description
        'Raises an exception if the specified env vars are not set'
      end

      def self.details
      end

      def self.available_options
        [
          PantographCore::ConfigItem.new(
            key: :vars,
            description: 'The ENV variables keys to verify',
            type: Array,
            verify_block: proc do |value|
              UI.user_error!('Specify at least one environment variable key') if value.empty?
            end
          )
        ]
      end

      def self.authors
        ['johnknapprs']
      end

      def self.example_code
        [
          'ensure_env_vars(
            vars: [\'GITHUB_USER_NAME\', \'GITHUB_API_TOKEN\']
          )'
        ]
      end

      def self.category
        :misc
      end

      def self.is_supported?(platform)
        true
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pantograph-0.1.22 pantograph/lib/pantograph/actions/ensure_env_vars.rb
pantograph-0.1.21 pantograph/lib/pantograph/actions/ensure_env_vars.rb
pantograph-0.1.20 pantograph/lib/pantograph/actions/ensure_env_vars.rb
pantograph-0.1.19 pantograph/lib/pantograph/actions/ensure_env_vars.rb
pantograph-0.1.17 pantograph/lib/pantograph/actions/ensure_env_vars.rb
pantograph-0.1.16 pantograph/lib/pantograph/actions/ensure_env_vars.rb
pantograph-0.1.15 pantograph/lib/pantograph/actions/ensure_env_vars.rb