Sha256: 6ce4783643dde839d7ccb1e2de8385492d6d5eec338ee271d30be52ed7a8fc56

Contents?: true

Size: 1.74 KB

Versions: 11

Compression:

Stored size: 1.74 KB

Contents

module Pantograph
  module Actions
    class PutsAction < Action
      def self.run(params)
        # display text from the message param
        # if called like `puts 'hi'` then params won't be a configuration item, so we have to check
        if params.kind_of?(PantographCore::Configuration) && params[:message]
          UI.message(params[:message])
          return
        end

        # no parameter included in the call means treat this like a normal pantograph ruby call
        UI.message(params.join(' '))
      end

      #####################################################
      # @!group Documentation
      #####################################################

      def self.description
        "Prints out the given text"
      end

      def self.available_options
        [
          PantographCore::ConfigItem.new(key: :message,
                                       env_name: 'PUTS_MESSAGE',
                                       description: 'Message to be printed out',
                                       optional: true,
                                       type: String)
        ]
      end

      def self.authors
        ['KrauseFx']
      end

      def self.is_supported?(platform)
        true
      end

      def self.alias_used(action_alias, params)
        if !params.kind_of?(PantographCore::Configuration) || params[:message].nil?
          UI.important("#{action_alias} called, please use 'puts' instead!")
        end
      end

      def self.aliases
        ["println", "echo"]
      end

      # We don't want to show this as step
      def self.step_text
        nil
      end

      def self.example_code
        [
          'puts "Hi there"'
        ]
      end

      def self.category
        :misc
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
pantograph-0.1.22 pantograph/lib/pantograph/actions/puts.rb
pantograph-0.1.21 pantograph/lib/pantograph/actions/puts.rb
pantograph-0.1.20 pantograph/lib/pantograph/actions/puts.rb
pantograph-0.1.19 pantograph/lib/pantograph/actions/puts.rb
pantograph-0.1.17 pantograph/lib/pantograph/actions/puts.rb
pantograph-0.1.16 pantograph/lib/pantograph/actions/puts.rb
pantograph-0.1.15 pantograph/lib/pantograph/actions/puts.rb
pantograph-0.1.14 pantograph/lib/pantograph/actions/puts.rb
pantograph-0.1.13 pantograph/lib/pantograph/actions/puts.rb
pantograph-0.1.12 pantograph/lib/pantograph/actions/puts.rb
pantograph-0.1.10 pantograph/lib/pantograph/actions/puts.rb