Sha256: 978aebc1f6c1ce0661d26be6618013e0a359b69cd64c5a7cfba4096903c07fab

Contents?: true

Size: 1.27 KB

Versions: 8

Compression:

Stored size: 1.27 KB

Contents

module FastlaneCore
  # Responsible for loading configuration files
  class ConfigurationFile
    # A reference to the actual configuration
    attr_accessor :config

    # @param config [FastlaneCore::Configuration] is stored to save the resulting values
    # @param path [String] The path to the configuration file to use
    def initialize(config, path, block_for_missing)
      self.config = config
      @block_for_missing = block_for_missing

      eval(File.read(path))
    end

    def method_missing(method_sym, *arguments, &block)
      # First, check if the key is actually available
      if self.config.all_keys.include?method_sym
        value = arguments.first || (block.call if block_given?) # this is either a block or a value
        if value
          self.config[method_sym] = value
        end
      else
        # We can't set this value, maybe the tool using this configuration system has its own
        # way of handling this block, as this might be a special block (e.g. ipa block) that's only
        # executed on demand
        if @block_for_missing
          @block_for_missing.call(method_sym, arguments, block)
        else
          self.config[method_sym] = '' # important, since this will raise a good exception for free
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fastlane_core-0.15.1 lib/fastlane_core/configuration/configuration_file.rb
fastlane_core-0.15.0 lib/fastlane_core/configuration/configuration_file.rb
fastlane_core-0.14.0 lib/fastlane_core/configuration/configuration_file.rb
fastlane_core-0.13.1 lib/fastlane_core/configuration/configuration_file.rb
fastlane_core-0.13.0 lib/fastlane_core/configuration/configuration_file.rb
fastlane_core-0.12.0 lib/fastlane_core/configuration/configuration_file.rb
fastlane_core-0.11.1 lib/fastlane_core/configuration/configuration_file.rb
fastlane_core-0.11.0 lib/fastlane_core/configuration/configuration_file.rb