Sha256: 991c075818eb3003e4158ea76836a2ed4c54b9fc1a9b2ff3941a86869e28a996

Contents?: true

Size: 1.09 KB

Versions: 25

Compression:

Stored size: 1.09 KB

Contents

module Eco
  module API
    class Session
      class Config
        class Files < BaseConfig

          def initialize(config:)
            super(config: config)
            @validations = {}
          end

          def working_directory=(path)
            self["dir"] = path
          end

          def working_directory
            if config.apis.active_api&.one_off?
              one_off_dir = File.join("one_off", config.apis.active_name.to_s)
              unless full_path = Eco::Data::Files::Directory.new(one_off_dir).create
                raise "Could not create the folder '#{full_path}'"
              end
              self["dir"] = one_off_dir
            end
            self["dir"]
          end

          attr_key :timestamp_pattern

          def add_validation(format)
            raise "Block must be given" unless block_given?
            @validations[format] = Proc.new
          end

          def validate(format, input)
            @validations[format].call(input) if  @validations.key?(format)
          end
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
eco-helpers-2.5.10 lib/eco/api/session/config/files.rb
eco-helpers-2.5.9 lib/eco/api/session/config/files.rb
eco-helpers-2.5.8 lib/eco/api/session/config/files.rb
eco-helpers-2.5.7 lib/eco/api/session/config/files.rb
eco-helpers-2.5.6 lib/eco/api/session/config/files.rb
eco-helpers-2.5.5 lib/eco/api/session/config/files.rb
eco-helpers-2.5.4 lib/eco/api/session/config/files.rb
eco-helpers-2.5.3 lib/eco/api/session/config/files.rb
eco-helpers-2.5.2 lib/eco/api/session/config/files.rb
eco-helpers-2.5.1 lib/eco/api/session/config/files.rb
eco-helpers-2.4.9 lib/eco/api/session/config/files.rb
eco-helpers-2.4.8 lib/eco/api/session/config/files.rb
eco-helpers-2.4.7 lib/eco/api/session/config/files.rb
eco-helpers-2.4.6 lib/eco/api/session/config/files.rb
eco-helpers-2.4.5 lib/eco/api/session/config/files.rb
eco-helpers-2.4.4 lib/eco/api/session/config/files.rb
eco-helpers-2.4.3 lib/eco/api/session/config/files.rb
eco-helpers-2.4.2 lib/eco/api/session/config/files.rb
eco-helpers-2.3.3 lib/eco/api/session/config/files.rb
eco-helpers-2.3.2 lib/eco/api/session/config/files.rb