Sha256: 2a9b1f43a792d7e8bc56f8354ee0be3a9942b6b28a09118e9ad13d2aa7a32025

Contents?: true

Size: 1.26 KB

Versions: 14

Compression:

Stored size: 1.26 KB

Contents

module SimplerTiles
  class << self
    def config
      @config ||= Configuration.new
    end
  end

  class Configuration
    attr_reader :settings
    attr_writer :bg_color,
                :fill,
                :stroke,
                :weight,
                :line_cap,
                :line_join,
                :radius

    def initialize
      @settings ||= File.exist?(config_file) ? YAML.load_file(config_file) : {}
    end

    def config_file
      File.join(Rails.root, 'config/simpler_tiles.yml')
    end

    def to_h
      {
        'stroke' => stroke,
        'line-cap' => line_cap,
        'line-join' => line_join,
        'weight' => weight,
        'fill' => fill,
        'radius' => radius
      }
    end

    def bg_color
      @bg_color ||= settings.fetch('bg_color', '#ffffff00')
    end

    def fill
      @fill ||= settings.fetch('fill', '#e4e3ea')
    end

    def stroke
      @stroke ||= settings.fetch('stroke', '#483d8b')
    end

    def weight
      @weight ||= settings.fetch('weight', '0.3')
    end

    def line_cap
      @line_cap ||= settings.fetch('line_cap', 'square')
    end

    def line_join
      @line_join ||= settings.fetch('line_join', 'miter')
    end

    def radius
      @radius ||= settings.fetch('radius', '2')
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
geo_works-0.2.0 config/initializers/simpler_tiles.rb
geo_works-0.1.4 config/initializers/simpler_tiles.rb
geo_works-0.1.3 config/initializers/simpler_tiles.rb
geo_works-0.1.2 config/initializers/simpler_tiles.rb
geo_works-0.1.1 config/initializers/simpler_tiles.rb
geo_works-0.1.0 config/initializers/simpler_tiles.rb
geo_concerns-0.3.4 lib/generators/geo_concerns/templates/config/initializers/simpler_tiles.rb
geo_concerns-0.3.3 lib/generators/geo_concerns/templates/config/initializers/simpler_tiles.rb
geo_concerns-0.3.2 lib/generators/geo_concerns/templates/config/initializers/simpler_tiles.rb
geo_concerns-0.3.1 lib/generators/geo_concerns/templates/config/initializers/simpler_tiles.rb
geo_concerns-0.3.0 lib/generators/geo_concerns/templates/config/initializers/simpler_tiles.rb
geo_concerns-0.2.0 lib/generators/geo_concerns/templates/config/initializers/simpler_tiles.rb
geo_concerns-0.1.1 lib/generators/geo_concerns/templates/config/initializers/simpler_tiles.rb
geo_concerns-0.1.0 lib/generators/geo_concerns/templates/config/initializers/simpler_tiles.rb