Sha256: 668f8657f7c6f07be70f44b6ea51d07c0317d97c1aa7b06a342cd8eab4123733

Contents?: true

Size: 928 Bytes

Versions: 3

Compression:

Stored size: 928 Bytes

Contents

module Snowglobe
  class Configuration
    attr_accessor :root_directory
    attr_accessor :temporary_directory
    attr_writer :project_name

    def initialize
      self.temporary_directory = Pathname.new("/tmp/snowglobe")
      @project_name = nil
      @database_name = nil
    end

    def project_name
      if @project_name
        "#{@project_name}-test-app"
      else
        raise NotConfiguredError.new(<<~EXAMPLE)
          Snowglobe.configure do |config|
            config.project_name = "your_project_name"
          end
        EXAMPLE
      end
    end

    def database_name
      @database_name || project_name
    end

    def update!
      yield self
    end

    class NotConfiguredError < StandardError
      def initialize(example)
        super(<<~MESSAGE)
          You need to configure Snowglobe before you can use it! For example:

          #{example}
        MESSAGE
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
snowglobe-0.3.0 lib/snowglobe/configuration.rb
snowglobe-0.2.0 lib/snowglobe/configuration.rb
snowglobe-0.1.0 lib/snowglobe/configuration.rb