Sha256: 39ced07b3f05ad8479d61d7f46e7d2c2da45c70f9929adadf67a2a6e8e0e739c

Contents?: true

Size: 1.13 KB

Versions: 7

Compression:

Stored size: 1.13 KB

Contents

module Utils
  module LitaPuppet
    # Utility methods for manipulating text
    module Text
      def agent_command
        command = 'puppet agent'
        command << ' --onetime --verbose --no-daemonize'
        command << ' --no-usecacheonfailure'
        command << ' --no-splay --show_diff 2>&1'
      end

      # Format some text as code
      #  Note that this is HipChat specific for the moment
      # TODO: Make this *not* HipChat specific
      def as_code(text)
        '/code ' + sanitze_for_chat(text)
      end

      # camel case puppet classes
      def class_camel(text)
        text.split('::').map(&:capitalize).join('::')
      end

      def r10k_command(environment, mod)
        command = 'r10k deploy'
        if environment && mod
          command << " module -e #{environment} #{mod} -v"
        else
          command << ' environment'
          command << " #{environment}" if environment
          command << ' -pv'
        end
      end

      # Strip off bad characters
      def sanitze_for_chat(text)
        # Remove bash colorings
        text.gsub(/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]/, '')
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lita-puppet-2.1.3 lib/utils/lita_puppet/text.rb
lita-puppet-2.1.1 lib/utils/lita_puppet/text.rb
lita-puppet-2.1.0 lib/utils/lita_puppet/text.rb
lita-puppet-2.0.0 lib/utils/lita_puppet/text.rb
lita-puppet-1.0.0 lib/utils/lita_puppet/text.rb
lita-puppet-0.7.2 lib/utils/lita_puppet/text.rb
lita-puppet-0.7.1 lib/utils/lita_puppet/text.rb