Sha256: 648eb269ceb8f96833992f8c81b6a26d46fd66ea93ca35cf8163ee8b06ec5a14

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

require_relative './core_helper'
module CapistranoMulticonfigParallel
  # class that holds the options that are configurable for this gem
  module ApplicationHelper
    extend ActiveSupport::Concern
    included do
      def app_configuration
        CapistranoMulticonfigParallel.configuration
      end

      def change_config_type(type)
        ['boolean'].include?(type) ? type.delete(':').to_sym : type.constantize
      end

      def strip_characters_from_string(value)
        return unless value.present?
        value = value.delete("\r\n").delete("\n")
        value = value.gsub(/\s+/, ' ').strip if value.present?
        value
      end

      def parse_task_string(string) # :nodoc:
        /^([^\[]+)(?:\[(.*)\])$/ =~ string.to_s

        name           = Regexp.last_match(1)
        remaining_args = Regexp.last_match(2)

        return string, [] unless name
        return name,   [] if     remaining_args.empty?

        args = []

        loop do
          /((?:[^\\,]|\\.)*?)\s*(?:,\s*(.*))?$/ =~ remaining_args

          remaining_args = Regexp.last_match(2)
          args << Regexp.last_match(1).gsub(/\\(.)/, '\1')
          break if remaining_args.blank?
        end

        [name, args]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capistrano_multiconfig_parallel-0.17.0 lib/capistrano_multiconfig_parallel/helpers/application_helper.rb