Sha256: d4c0867d0590b213884256ce6730a9a3b15430d745af819e2749227a9e72a931

Contents?: true

Size: 1.1 KB

Versions: 45

Compression:

Stored size: 1.1 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, &block)
            raise "Block must be given" unless block_given?
            @validations[format] = block
          end

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

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
eco-helpers-3.0.1 lib/eco/api/session/config/files.rb
eco-helpers-3.0.0 lib/eco/api/session/config/files.rb
eco-helpers-2.7.25 lib/eco/api/session/config/files.rb
eco-helpers-2.7.24 lib/eco/api/session/config/files.rb
eco-helpers-2.7.23 lib/eco/api/session/config/files.rb
eco-helpers-2.7.22 lib/eco/api/session/config/files.rb
eco-helpers-2.7.21 lib/eco/api/session/config/files.rb
eco-helpers-2.7.20 lib/eco/api/session/config/files.rb
eco-helpers-2.7.19 lib/eco/api/session/config/files.rb
eco-helpers-2.7.18 lib/eco/api/session/config/files.rb
eco-helpers-2.7.17 lib/eco/api/session/config/files.rb
eco-helpers-2.7.16 lib/eco/api/session/config/files.rb
eco-helpers-2.7.15 lib/eco/api/session/config/files.rb
eco-helpers-2.7.14 lib/eco/api/session/config/files.rb
eco-helpers-2.7.13 lib/eco/api/session/config/files.rb
eco-helpers-2.7.12 lib/eco/api/session/config/files.rb
eco-helpers-2.7.4 lib/eco/api/session/config/files.rb
eco-helpers-2.7.2 lib/eco/api/session/config/files.rb
eco-helpers-2.7.1 lib/eco/api/session/config/files.rb
eco-helpers-2.7.0 lib/eco/api/session/config/files.rb