assets-watchify 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +3 -10
- data/Rakefile +1 -1
- data/assets-watchify.gemspec +32 -32
- data/lib/assets/watchify.rb +26 -4
- data/lib/assets/watchify/main.rb +9 -19
- data/lib/assets/watchify/sprockets.rb +5 -5
- data/lib/assets/watchify/version.rb +1 -1
- data/rakelib/apps.rake +1 -1
- metadata +3 -4
- data/lib/assets/watchify/boot.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fc574bdc0daf1342d47c720bd1b962c9f2a6745
|
4
|
+
data.tar.gz: c7520b80c34aa9c47f868595ca6845b9aa159d07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a56590dd75819e9e506a70428dfcb1fef54ad7f10db853bc845995b2f1a00261eac1c29166605fd9c42601a070bd53f39a5968a826f2cf80a91bcfb9db1fc73a
|
7
|
+
data.tar.gz: f568d30307814c2dd959aa65ea1aeb58ac6c6d88d4ec022d277dcc34ed67ab8e06fe6243837270adf887323a428c6e52f4e249456d3b0cb0c75fbadf7ed7648a
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in assets-watchify.gemspec
|
4
|
-
gemspec
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in assets-watchify.gemspec
|
4
|
+
gemspec
|
data/LICENSE.txt
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
Copyright (c) 2015 Stas Ukolov
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2015 Stas Ukolov
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -66,21 +66,14 @@ server {
|
|
66
66
|
## Precompilation
|
67
67
|
|
68
68
|
It's useful sometimes to compile large JavaScript on Rails server start.
|
69
|
-
Request
|
69
|
+
Request this with `preload` method:
|
70
70
|
|
71
71
|
```ruby
|
72
72
|
# config/initializers/watchify.rb
|
73
|
-
Assets::Watchify
|
74
|
-
Assets::Watchify::Bundles['other.js']=nil
|
75
|
-
```
|
76
|
-
Precompiling `application.js` should be frequent, there exists
|
77
|
-
`defaults!` method for it:
|
78
|
-
|
79
|
-
```ruby
|
80
|
-
# config/initializers/watchify.rb
|
81
|
-
Assets::Watchify.defaults! rescue nil
|
73
|
+
Assets::Watchify.preload 'application.js', 'my/other.js' rescue nil
|
82
74
|
```
|
83
75
|
|
76
|
+
`preload` without arguments is `preload 'application.js'`.
|
84
77
|
|
85
78
|
## See also
|
86
79
|
|
data/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
1
|
+
require "bundler/gem_tasks"
|
data/assets-watchify.gemspec
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'assets/watchify/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "assets-watchify"
|
8
|
-
spec.version = Assets::Watchify::VERSION
|
9
|
-
spec.authors = ["Stas Ukolov"]
|
10
|
-
spec.email = ["ukoloff@gmail.com"]
|
11
|
-
spec.summary = 'Fast serving Rails assets in development'
|
12
|
-
spec.description = ''
|
13
|
-
spec.homepage = "https://github.com/ukoloff/assets-watchify"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_dependency "railties"
|
22
|
-
spec.add_dependency 'source_map'
|
23
|
-
spec.add_dependency 'listen'
|
24
|
-
if Gem.win_platform?
|
25
|
-
spec.add_dependency 'wdm'
|
26
|
-
spec.add_dependency 'execjs-xtrn'
|
27
|
-
spec.add_dependency 'openssl-win-root'
|
28
|
-
end
|
29
|
-
|
30
|
-
spec.add_development_dependency "bundler", "~> 1.3"
|
31
|
-
spec.add_development_dependency "rake"
|
32
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'assets/watchify/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "assets-watchify"
|
8
|
+
spec.version = Assets::Watchify::VERSION
|
9
|
+
spec.authors = ["Stas Ukolov"]
|
10
|
+
spec.email = ["ukoloff@gmail.com"]
|
11
|
+
spec.summary = 'Fast serving Rails assets in development'
|
12
|
+
spec.description = ''
|
13
|
+
spec.homepage = "https://github.com/ukoloff/assets-watchify"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "railties"
|
22
|
+
spec.add_dependency 'source_map'
|
23
|
+
spec.add_dependency 'listen'
|
24
|
+
if Gem.win_platform?
|
25
|
+
spec.add_dependency 'wdm'
|
26
|
+
spec.add_dependency 'execjs-xtrn'
|
27
|
+
spec.add_dependency 'openssl-win-root'
|
28
|
+
end
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
31
|
+
spec.add_development_dependency "rake"
|
32
|
+
end
|
data/lib/assets/watchify.rb
CHANGED
@@ -7,14 +7,36 @@ end
|
|
7
7
|
|
8
8
|
class Rails::Application
|
9
9
|
initializer :assets_watchify do
|
10
|
-
|
10
|
+
Assets::Watchify.boot!
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
module Assets::Watchify
|
15
|
-
|
15
|
+
Folder='w6y'
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
@bundles={}
|
18
|
+
|
19
|
+
def self.preload *args
|
20
|
+
args=['application.js'] if args.empty?
|
21
|
+
args.flatten.compact.each{|js| @bundles[js]=nil}
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.use?
|
25
|
+
defined?(Rails::Server) &&
|
26
|
+
'development'==Rails.env &&
|
27
|
+
@root.directory?
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.boot!
|
31
|
+
@prefix=Rails.application.config.assets.prefix
|
32
|
+
@path=@prefix+'/'+Folder
|
33
|
+
@root=Rails.root.join "public"+@path
|
34
|
+
return unless use?
|
35
|
+
require_relative "watchify/main"
|
36
|
+
start!
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.mkdir
|
40
|
+
FileUtils.mkpath @root
|
19
41
|
end
|
20
42
|
end
|
data/lib/assets/watchify/main.rb
CHANGED
@@ -8,17 +8,13 @@ module Assets::Watchify
|
|
8
8
|
require_relative 'sprockets'
|
9
9
|
|
10
10
|
def self.clean
|
11
|
-
Dir.glob
|
11
|
+
Dir.glob @root.join '**', '*' do |f|
|
12
12
|
File.delete f rescue nil
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
def self.mkdir
|
17
|
-
FileUtils.mkpath Root
|
18
|
-
end
|
19
|
-
|
20
16
|
def self.rmdir
|
21
|
-
FileUtils.remove_entry
|
17
|
+
FileUtils.remove_entry @root
|
22
18
|
end
|
23
19
|
|
24
20
|
def self.ms seconds
|
@@ -37,12 +33,12 @@ module Assets::Watchify
|
|
37
33
|
|
38
34
|
t2 = Time.now
|
39
35
|
|
40
|
-
unless File.exist? js =
|
41
|
-
File.delete
|
42
|
-
|
36
|
+
unless File.exist? js = @root.join(z.digest_path)
|
37
|
+
File.delete @bundles[name], "#{@bundles[name]}.map" rescue nil if @bundles[name]
|
38
|
+
@bundles[name] = js
|
43
39
|
FileUtils.mkpath js.dirname
|
44
40
|
jsf = File.open js, 'w+'
|
45
|
-
map = SourceMap.new file: js.basename, source_root:
|
41
|
+
map = SourceMap.new file: js.basename, source_root: @prefix, generated_output: jsf
|
46
42
|
z.to_a.each {|d| map.add_generated d.source, source: d.logical_path+'?body=1'}
|
47
43
|
map.save "#{js}.map"
|
48
44
|
jsf.puts
|
@@ -51,11 +47,11 @@ module Assets::Watchify
|
|
51
47
|
t3 = Time.now
|
52
48
|
puts "#{self} built '#{name}' (#{ms t2-t1}+#{ms t3-t2}=#{ms t3-t1})..."
|
53
49
|
end
|
54
|
-
"<script src='
|
50
|
+
"<script src='#{@path}/#{z.digest_path}'></script><!-- #{z.length}/#{z.to_a.length} -->"
|
55
51
|
end
|
56
52
|
|
57
53
|
def self.ping
|
58
|
-
|
54
|
+
@bundles.keys.each{|name| jstag name}
|
59
55
|
end
|
60
56
|
|
61
57
|
def self.path? f
|
@@ -66,15 +62,11 @@ module Assets::Watchify
|
|
66
62
|
true
|
67
63
|
end
|
68
64
|
|
69
|
-
def self.pathz
|
70
|
-
@paths||=Rails.application.config.assets.paths#.select{|f| path? f}
|
71
|
-
end
|
72
|
-
|
73
65
|
def self.start!
|
74
66
|
clean
|
75
67
|
Rails.application.config.assets.debug = false # Let CSS to glue either
|
76
68
|
|
77
|
-
paths=
|
69
|
+
paths=Rails.application.config.assets.paths.select{|f| path? f}
|
78
70
|
|
79
71
|
Thread.new do
|
80
72
|
listener = Listen.to paths do |m,a,r|
|
@@ -94,6 +86,4 @@ module Assets::Watchify
|
|
94
86
|
ping
|
95
87
|
end
|
96
88
|
end
|
97
|
-
|
98
|
-
start!
|
99
89
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
module Assets::Watchify::Helper
|
2
|
-
def javascript_include_tag(*sources)
|
3
|
-
sources.map {|s| Assets::Watchify.jstag s }.join("\n").html_safe
|
4
|
-
end
|
5
|
-
end
|
1
|
+
module Assets::Watchify::Helper
|
2
|
+
def javascript_include_tag(*sources)
|
3
|
+
sources.map {|s| Assets::Watchify.jstag s }.join("\n").html_safe
|
4
|
+
end
|
5
|
+
end
|
data/rakelib/apps.rake
CHANGED
@@ -28,7 +28,7 @@ namespace :apps do
|
|
28
28
|
FileUtils.mkdir_p "#{app}/public/assets/w6y"
|
29
29
|
File.open "#{app}/config/initializers/w6y.rb", 'w' do |f|
|
30
30
|
f.puts <<-EOF.each_line.map(&:strip)
|
31
|
-
Assets::Watchify.
|
31
|
+
Assets::Watchify.preload rescue nil
|
32
32
|
EOF
|
33
33
|
end
|
34
34
|
File.open "#{app}/config/routes.rb", 'w' do |f|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assets-watchify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stas Ukolov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -137,7 +137,6 @@ files:
|
|
137
137
|
- Rakefile
|
138
138
|
- assets-watchify.gemspec
|
139
139
|
- lib/assets/watchify.rb
|
140
|
-
- lib/assets/watchify/boot.rb
|
141
140
|
- lib/assets/watchify/main.rb
|
142
141
|
- lib/assets/watchify/sprockets.rb
|
143
142
|
- lib/assets/watchify/version.rb
|
@@ -162,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
161
|
version: '0'
|
163
162
|
requirements: []
|
164
163
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.
|
164
|
+
rubygems_version: 2.4.6
|
166
165
|
signing_key:
|
167
166
|
specification_version: 4
|
168
167
|
summary: Fast serving Rails assets in development
|
data/lib/assets/watchify/boot.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require_relative "version"
|
2
|
-
|
3
|
-
module Assets::Watchify
|
4
|
-
Folder='w6y'
|
5
|
-
|
6
|
-
Root=Rails.root.join "public/assets", Folder
|
7
|
-
|
8
|
-
def self.use?
|
9
|
-
defined?(Rails::Server) &&
|
10
|
-
'development'==Rails.env &&
|
11
|
-
Dir.exist?(Root)
|
12
|
-
end
|
13
|
-
|
14
|
-
require_relative "main" if use?
|
15
|
-
end
|