Class: LiveReload::Config

Inherits:
Object show all
Defined in:
lib/livereload.rb

Overview

note that host and port options do not make sense in per-project config files

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Config

Returns a new instance of Config.



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/livereload.rb', line 49

def initialize &block
  @host           = nil
  @port           = nil
  @debug          = nil
  @exts           = []
  @exclusions     = []
  @apply_js_live  = nil
  @apply_css_live = nil

  update!(&block) if block
end

Instance Attribute Details

#apply_css_liveObject

Returns the value of attribute apply_css_live.



47
48
49
# File 'lib/livereload.rb', line 47

def apply_css_live
  @apply_css_live
end

#apply_js_liveObject

Returns the value of attribute apply_js_live.



47
48
49
# File 'lib/livereload.rb', line 47

def apply_js_live
  @apply_js_live
end

#debugObject

Returns the value of attribute debug.



47
48
49
# File 'lib/livereload.rb', line 47

def debug
  @debug
end

#exclusionsObject

Returns the value of attribute exclusions.



47
48
49
# File 'lib/livereload.rb', line 47

def exclusions
  @exclusions
end

#extsObject

Returns the value of attribute exts.



47
48
49
# File 'lib/livereload.rb', line 47

def exts
  @exts
end

#hostObject

Returns the value of attribute host.



47
48
49
# File 'lib/livereload.rb', line 47

def host
  @host
end

#portObject

Returns the value of attribute port.



47
48
49
# File 'lib/livereload.rb', line 47

def port
  @port
end

Class Method Details

.load_from(file) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/livereload.rb', line 81

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

.merge(*configs) ⇒ Object



94
95
96
# File 'lib/livereload.rb', line 94

def merge *configs
  configs.reduce(Config.new) { |merged, config| config && merged.merge!(config) || merged }
end

Instance Method Details

#merge!(other) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/livereload.rb', line 68

def merge! other
  @host           = other.host             if other.host
  @port           = other.port             if other.port
  @exts          += other.exts
  @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

  self
end

#update! {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



61
62
63
64
65
66
# File 'lib/livereload.rb', line 61

def update!
  yield self

  # remove leading dots
  @exts = @exts.collect { |e| e.sub(/^\./, '') }
end