Sha256: 2a9e9d350830d8c25974803af3e1b2bf19ced1224b1797b3178a75309a85340d

Contents?: true

Size: 936 Bytes

Versions: 18

Compression:

Stored size: 936 Bytes

Contents

module Pantograph
  class ConfigurationHelper
    def self.parse(action, params)
      first_element = (action.available_options || []).first

      if first_element && first_element.kind_of?(PantographCore::ConfigItem)
        # default use case
        return PantographCore::Configuration.create(action.available_options, params)
      elsif first_element
        UI.error("Old configuration format for action '#{action}'") if Helper.test?
        return params
      else

        # No parameters... we still need the configuration object array
        PantographCore::Configuration.create(action.available_options, {})

      end
    rescue => ex
      if action.respond_to?(:action_name)
        UI.error("You passed invalid parameters to '#{action.action_name}'.")
        UI.error("Check out the error below and available options by running `pantograph action #{action.action_name}`")
      end
      raise ex
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
pantograph-0.1.22 pantograph/lib/pantograph/configuration_helper.rb
pantograph-0.1.21 pantograph/lib/pantograph/configuration_helper.rb
pantograph-0.1.20 pantograph/lib/pantograph/configuration_helper.rb
pantograph-0.1.19 pantograph/lib/pantograph/configuration_helper.rb
pantograph-0.1.17 pantograph/lib/pantograph/configuration_helper.rb
pantograph-0.1.16 pantograph/lib/pantograph/configuration_helper.rb
pantograph-0.1.15 pantograph/lib/pantograph/configuration_helper.rb
pantograph-0.1.14 pantograph/lib/pantograph/configuration_helper.rb
pantograph-0.1.13 pantograph/lib/pantograph/configuration_helper.rb
pantograph-0.1.12 pantograph/lib/pantograph/configuration_helper.rb
pantograph-0.1.10 pantograph/lib/pantograph/configuration_helper.rb
pantograph-0.1.8 pantograph/lib/pantograph/configuration_helper.rb
pantograph-0.1.7 pantograph/lib/pantograph/configuration_helper.rb
pantograph-0.1.6 pantograph/lib/pantograph/configuration_helper.rb
pantograph-0.1.4 pantograph/lib/pantograph/configuration_helper.rb
pantograph-0.1.3 pantograph/lib/pantograph/configuration_helper.rb
pantograph-0.1.1 pantograph/lib/pantograph/configuration_helper.rb
pantograph-0.1.0 pantograph/lib/pantograph/configuration_helper.rb