Class: Monet::Config
Constant Summary collapse
- MissingBaseURL =
Class.new(Exception)
- DEFAULT_OPTIONS =
{ driver: :poltergeist, dimensions: [1024], base_url: nil, map: nil, compare_type: "ColorBlend", capture_dir: "./captures", baseline_dir: "./baselines", thumbnail_dir: "./thumbnails", thumbnail: false }
Class Method Summary collapse
Instance Method Summary collapse
- #base_url ⇒ Object
- #base_url=(url) ⇒ Object
- #baseline_dir=(path) ⇒ Object
- #capture_dir=(path) ⇒ Object
-
#initialize(opts = {}) ⇒ Config
constructor
A new instance of Config.
- #map(type = :explicit, &block) ⇒ Object
- #map=(paths) ⇒ Object
- #thumbnail? ⇒ Boolean
- #thumbnail_dir=(path) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Config
Returns a new instance of Config.
24 25 26 27 28 |
# File 'lib/monet/config.rb', line 24 def initialize(opts={}) DEFAULT_OPTIONS.each do |opt, default| send "#{opt}=", opts[opt] || default end end |
Class Method Details
.build_config(opts) ⇒ Object
41 42 43 |
# File 'lib/monet/config.rb', line 41 def self.build_config(opts) (opts.is_a? Monet::Config) ? opts : new(opts) end |
.config(&block) ⇒ Object
30 31 32 33 34 |
# File 'lib/monet/config.rb', line 30 def self.config(&block) cfg = new block.call cfg cfg end |
.load(path = "./config.yaml") ⇒ Object
36 37 38 39 |
# File 'lib/monet/config.rb', line 36 def self.load(path="./config.yaml") config = YAML::load(File.open(path)) new(config) end |
Instance Method Details
#base_url ⇒ Object
49 50 51 52 |
# File 'lib/monet/config.rb', line 49 def base_url raise MissingBaseURL, "Please set the base_url in the config" unless @base_url @base_url end |
#base_url=(url) ⇒ Object
45 46 47 |
# File 'lib/monet/config.rb', line 45 def base_url=(url) @base_url ||= parse_uri(url) unless url.nil? end |
#baseline_dir=(path) ⇒ Object
62 63 64 |
# File 'lib/monet/config.rb', line 62 def baseline_dir=(path) @baseline_dir = (path) end |
#capture_dir=(path) ⇒ Object
58 59 60 |
# File 'lib/monet/config.rb', line 58 def capture_dir=(path) @capture_dir = (path) end |
#map(type = :explicit, &block) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/monet/config.rb', line 74 def map(type=:explicit, &block) @map ||= CaptureMap.new(base_url, type) block.call(@map) if block_given? && type == :explicit @map end |
#map=(paths) ⇒ Object
70 71 72 |
# File 'lib/monet/config.rb', line 70 def map=(paths) map.paths = paths unless paths.nil? end |
#thumbnail? ⇒ Boolean
54 55 56 |
# File 'lib/monet/config.rb', line 54 def thumbnail? !!thumbnail end |
#thumbnail_dir=(path) ⇒ Object
66 67 68 |
# File 'lib/monet/config.rb', line 66 def thumbnail_dir=(path) @thumbnail_dir = (path) end |