livereload 1.5 → 1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/livereload.rb +11 -5
  2. metadata +3 -3
@@ -21,8 +21,8 @@ class Object
21
21
  end
22
22
 
23
23
  module LiveReload
24
- GEM_VERSION = "1.5"
25
- API_VERSION = "1.5"
24
+ GEM_VERSION = "1.6"
25
+ API_VERSION = "1.6"
26
26
 
27
27
  PROJECT_CONFIG_FILE_TEMPLATE = <<-END.strip.split("\n").collect { |line| line.strip + "\n" }.join("")
28
28
  # Lines starting with pound sign (#) are ignored.
@@ -41,6 +41,8 @@ module LiveReload
41
41
  #config.apply_js_live = false
42
42
  # reload the whole page when .css changes
43
43
  #config.apply_css_live = false
44
+ # reload the whole page when images (png, jpg, gif) change
45
+ #config.apply_images_live = false
44
46
 
45
47
  # wait 100ms for more changes before reloading a page
46
48
  #config.grace_period = 0.1
@@ -48,7 +50,7 @@ module LiveReload
48
50
 
49
51
  # note that host and port options do not make sense in per-project config files
50
52
  class Config
51
- attr_accessor :host, :port, :exts, :exts_overwrite, :exclusions, :debug, :apply_js_live, :apply_css_live, :grace_period
53
+ attr_accessor :host, :port, :exts, :exts_overwrite, :exclusions, :debug, :apply_js_live, :apply_css_live, :apply_images_live, :grace_period
52
54
 
53
55
  def initialize &block
54
56
  @host = nil
@@ -58,6 +60,7 @@ module LiveReload
58
60
  @exclusions = []
59
61
  @apply_js_live = nil
60
62
  @apply_css_live = nil
63
+ @apply_images_live = nil
61
64
  @grace_period = nil
62
65
 
63
66
  update!(&block) if block
@@ -87,6 +90,7 @@ module LiveReload
87
90
  @debug = other.debug if other.debug != nil
88
91
  @apply_js_live = other.apply_js_live if other.apply_js_live != nil
89
92
  @apply_css_live = other.apply_css_live if other.apply_css_live != nil
93
+ @apply_images_live = other.apply_images_live if other.apply_images_live != nil
90
94
  @grace_period = other.grace_period if other.grace_period != nil
91
95
 
92
96
  self
@@ -120,6 +124,7 @@ module LiveReload
120
124
  config.exclusions = %w!*/.git/* */.svn/* */.hg/*!
121
125
  config.apply_js_live = false
122
126
  config.apply_css_live = true
127
+ config.apply_images_live = true
123
128
  config.grace_period = 0.05
124
129
  end
125
130
 
@@ -181,7 +186,7 @@ module LiveReload
181
186
  if File.basename(path) == '.livereload'
182
187
  @when_changes_detected.call [:config_changed, path]
183
188
  else
184
- @when_changes_detected.call [:modified, path]
189
+ @when_changes_detected.call [:modified, File.join(@directory, path)]
185
190
  end
186
191
  end
187
192
  rescue
@@ -231,7 +236,8 @@ module LiveReload
231
236
  puts "Modified: #{File.basename(modified_file)}"
232
237
  data = ['refresh', { :path => modified_file,
233
238
  :apply_js_live => project.config.apply_js_live,
234
- :apply_css_live => project.config.apply_css_live }].to_json
239
+ :apply_css_live => project.config.apply_css_live,
240
+ :apply_images_live => project.config.apply_images_live }].to_json
235
241
  puts data if global_config.debug
236
242
  web_sockets.each do |ws|
237
243
  ws.send data
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: livereload
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 5
9
- version: "1.5"
8
+ - 6
9
+ version: "1.6"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Andrey Tarantsov