Sha256: de7663220b21ea04a3ea9bc0532fb87cdb57d6b767470d8784b92112f9e121ef

Contents?: true

Size: 1.25 KB

Versions: 64

Compression:

Stored size: 1.25 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

          def timestamp_pattern=(pattern)
            self["timestamp_pattern"] = pattern
          end

          def timestamp_pattern
            self["timestamp_pattern"]
          end

          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

64 entries across 64 versions & 1 rubygems

Version Path
eco-helpers-2.1.12 lib/eco/api/session/config/files.rb
eco-helpers-2.1.11 lib/eco/api/session/config/files.rb
eco-helpers-2.1.10 lib/eco/api/session/config/files.rb
eco-helpers-2.1.9 lib/eco/api/session/config/files.rb
eco-helpers-2.1.8 lib/eco/api/session/config/files.rb
eco-helpers-2.1.7 lib/eco/api/session/config/files.rb
eco-helpers-2.1.6 lib/eco/api/session/config/files.rb
eco-helpers-2.1.5 lib/eco/api/session/config/files.rb
eco-helpers-2.1.4 lib/eco/api/session/config/files.rb
eco-helpers-2.1.3 lib/eco/api/session/config/files.rb
eco-helpers-2.1.2 lib/eco/api/session/config/files.rb
eco-helpers-2.1.1 lib/eco/api/session/config/files.rb
eco-helpers-2.0.68 lib/eco/api/session/config/files.rb
eco-helpers-2.0.67 lib/eco/api/session/config/files.rb
eco-helpers-2.0.66 lib/eco/api/session/config/files.rb
eco-helpers-2.0.65 lib/eco/api/session/config/files.rb
eco-helpers-2.0.64 lib/eco/api/session/config/files.rb
eco-helpers-2.0.63 lib/eco/api/session/config/files.rb
eco-helpers-2.0.62 lib/eco/api/session/config/files.rb
eco-helpers-2.0.61 lib/eco/api/session/config/files.rb