Class: BootstrapEmail::Config
- Inherits:
-
Object
- Object
- BootstrapEmail::Config
- Defined in:
- lib/bootstrap-email/config.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Config
constructor
A new instance of Config.
- #sass_cache_location ⇒ Object
- #sass_load_paths ⇒ Object
- #sass_log_enabled? ⇒ Boolean
- #sass_string_for(type:) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Config
Returns a new instance of Config.
5 6 7 8 9 10 11 12 13 |
# File 'lib/bootstrap-email/config.rb', line 5 def initialize( = {}) @config_store = BootstrapEmail::ConfigStore.new() file = File.('bootstrap-email.config.rb', Dir.pwd) if [:config_path] require_relative [:config_path] elsif File.exist?(file) require_relative file end end |
Instance Method Details
#sass_cache_location ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/bootstrap-email/config.rb', line 37 def sass_cache_location option = config_for_option(:sass_cache_location) return option unless option.nil? if defined?(::Rails) && ::Rails.root ::Rails.root.join('tmp', 'cache', 'bootstrap-email', '.sass-cache') elsif File.writable?(Dir.pwd) File.join(Dir.pwd, '.sass-cache', 'bootstrap-email') else File.join(Dir.tmpdir, '.sass-cache', 'bootstrap-email') end end |
#sass_load_paths ⇒ Object
31 32 33 34 35 |
# File 'lib/bootstrap-email/config.rb', line 31 def sass_load_paths library_paths = [SassCache::SASS_DIR] user_paths = config_for_option(:sass_load_paths) || [] library_paths + user_paths end |
#sass_log_enabled? ⇒ Boolean
50 51 52 53 |
# File 'lib/bootstrap-email/config.rb', line 50 def sass_log_enabled? option = config_for_option(:sass_log_enabled) option.nil? ? true : option end |
#sass_string_for(type:) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bootstrap-email/config.rb', line 15 def sass_string_for(type:) # look for custom sass string sub_type = type.sub('bootstrap-', '') string = config_for_option("sass_#{sub_type}_string") return string unless string.nil? # look for custom sass path path = config_for_option("sass_#{sub_type}_location") return File.read(path) unless path.nil? # look up and return others if found in default locations lookup_locations = ["#{type}.scss", "app/assets/stylesheets/#{type}.scss"] locations = lookup_locations.map { |location| File.(location, Dir.pwd) }.select { |location| File.exist?(location) } File.read(locations.first) if locations.any? end |