Class: Guard::HotReload
- Inherits:
-
Plugin
- Object
- Plugin
- Guard::HotReload
- Defined in:
- lib/lanes/hot_reload_plugin.rb
Instance Method Summary collapse
- #asset_to_json(file) ⇒ Object
-
#initialize(options = {}) ⇒ HotReload
constructor
A new instance of HotReload.
- #run_all ⇒ Object
- #run_on_modifications(paths) ⇒ Object
Constructor Details
Instance Method Details
#asset_to_json(file) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/lanes/hot_reload_plugin.rb', line 17 def asset_to_json(file) file.gsub!(/client\//,'') if file.match(/\.(js|coffee|cjsx)$/) file.gsub!(/(.*)\.(js|coffee|cjsx)$/, '\1.js') comp = file.split('/')#[1..-1] comp[comp.length-1] = comp.last.gsub(/\.\w+$/,'') { "type" => "js", "path" => file, "components" => comp } else path = if file.match(%r{/screens/.*/\w+\.scss}) file.gsub(%r{/\w+.\w*css},'.css') else file end { "type" => "css", "path" => path, "trigger" => file } end end |
#run_all ⇒ Object
14 15 |
# File 'lib/lanes/hot_reload_plugin.rb', line 14 def run_all end |
#run_on_modifications(paths) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/lanes/hot_reload_plugin.rb', line 35 def run_on_modifications(paths) post = Net::HTTP::Post.new(@uri.request_uri) body = paths.map do | file | asset_to_json(file) end post.body = Oj.dump(body) http = Net::HTTP.new(@uri.host, @uri.port) http.request(post) end |