Class: LiveReload::Config
Overview
note that host and port options do not make sense in per-project config files
Instance Attribute Summary collapse
-
#apply_css_live ⇒ Object
Returns the value of attribute apply_css_live.
-
#apply_images_live ⇒ Object
Returns the value of attribute apply_images_live.
-
#apply_js_live ⇒ Object
Returns the value of attribute apply_js_live.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#exclusions ⇒ Object
Returns the value of attribute exclusions.
-
#exts ⇒ Object
Returns the value of attribute exts.
-
#exts_overwrite ⇒ Object
Returns the value of attribute exts_overwrite.
-
#grace_period ⇒ Object
Returns the value of attribute grace_period.
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(&block) ⇒ Config
constructor
A new instance of Config.
- #merge!(other) ⇒ Object
- #update! {|_self| ... } ⇒ Object
Constructor Details
#initialize(&block) ⇒ Config
Returns a new instance of Config.
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/livereload.rb', line 55 def initialize &block @host = nil @port = nil @debug = nil @exts = [] @exclusions = [] @apply_js_live = nil @apply_css_live = nil @apply_images_live = nil @grace_period = nil update!(&block) if block end |
Instance Attribute Details
#apply_css_live ⇒ Object
Returns the value of attribute apply_css_live.
53 54 55 |
# File 'lib/livereload.rb', line 53 def apply_css_live @apply_css_live end |
#apply_images_live ⇒ Object
Returns the value of attribute apply_images_live.
53 54 55 |
# File 'lib/livereload.rb', line 53 def apply_images_live @apply_images_live end |
#apply_js_live ⇒ Object
Returns the value of attribute apply_js_live.
53 54 55 |
# File 'lib/livereload.rb', line 53 def apply_js_live @apply_js_live end |
#debug ⇒ Object
Returns the value of attribute debug.
53 54 55 |
# File 'lib/livereload.rb', line 53 def debug @debug end |
#exclusions ⇒ Object
Returns the value of attribute exclusions.
53 54 55 |
# File 'lib/livereload.rb', line 53 def exclusions @exclusions end |
#exts ⇒ Object
Returns the value of attribute exts.
53 54 55 |
# File 'lib/livereload.rb', line 53 def exts @exts end |
#exts_overwrite ⇒ Object
Returns the value of attribute exts_overwrite.
53 54 55 |
# File 'lib/livereload.rb', line 53 def exts_overwrite @exts_overwrite end |
#grace_period ⇒ Object
Returns the value of attribute grace_period.
53 54 55 |
# File 'lib/livereload.rb', line 53 def grace_period @grace_period end |
#host ⇒ Object
Returns the value of attribute host.
53 54 55 |
# File 'lib/livereload.rb', line 53 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
53 54 55 |
# File 'lib/livereload.rb', line 53 def port @port end |
Class Method Details
.load_from(file) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/livereload.rb', line 100 def load_from file Config.new do |config| if File.file? file Object.send(:instance_variable_set, '@livereload_config', config) Object.send(:alias_method, :method_missing_without_livereload, :method_missing) Object.send(:alias_method, :method_missing, :method_missing_with_livereload) load file, true Object.send(:alias_method, :method_missing, :method_missing_without_livereload) Object.send(:instance_variable_set, '@livereload_config', nil) end end end |
Instance Method Details
#merge!(other) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/livereload.rb', line 81 def merge! other @host = other.host if other.host @port = other.port if other.port if other.exts_overwrite @exts = other.exts else @exts += other.exts.compact end @exclusions = other.exclusions + @exclusions @debug = other.debug if other.debug != nil @apply_js_live = other.apply_js_live if other.apply_js_live != nil @apply_css_live = other.apply_css_live if other.apply_css_live != nil @apply_images_live = other.apply_images_live if other.apply_images_live != nil @grace_period = other.grace_period if other.grace_period != nil self end |
#update! {|_self| ... } ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/livereload.rb', line 69 def update! @exts = [nil] + @exts # nil is used as a marker to detect if the array has been overwritten yield self @exts_overwrite = @exts.empty? || ! @exts.first.nil? @exts = @exts.compact # remove leading dots @exts = @exts.collect { |e| e.sub(/^\./, '') } end |