Sha256: c5e2eb605eea591be87a83938ea48d301648c94a3e493ab626d0c4089f0a9889
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 KB
Contents
require 'guard/compat/plugin' module ::Guard class HotReload < Plugin def initialize(options = {}) super @uri = URI.parse( "http://localhost:#{options[:port]}/file-change.json" ) end def run_all end 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 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lanes-0.5.6 | lib/lanes/hot_reload_plugin.rb |
lanes-0.5.5 | lib/lanes/hot_reload_plugin.rb |