assets-watchify 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/FarMenu.ini +4 -0
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +97 -75
- data/Rakefile +1 -1
- data/assets-watchify.gemspec +32 -32
- data/lib/assets/watchify.rb +20 -16
- data/lib/assets/watchify/boot.rb +15 -15
- data/lib/assets/watchify/main.rb +99 -87
- data/lib/assets/watchify/sprockets.rb +5 -5
- data/lib/assets/watchify/version.rb +5 -5
- data/rakelib/apps.rake +9 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2c12f4b19795435aaa980226d2a8f89346c3123
|
4
|
+
data.tar.gz: 9f4a56fd987a94497f6bafc65c07ad5c88ed343b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f77f519bdc6895873c0563b3d23c6f7f7a700eab19e2d91dd031680748510470c2abcd1f5cc85286aaa423a3e3671862bc3857e15796ed5d92cce1b959419231
|
7
|
+
data.tar.gz: af97267c82f9acccf7b8b758313b63b6bb43e8039ff9ff83c43770992b7df648a24deab6236196b3414bcb822411f77119b75068f89ad0e7d1555608cfcd92cd
|
data/FarMenu.ini
CHANGED
@@ -8,6 +8,8 @@ L: Install gem locally
|
|
8
8
|
U: Uninstall gem
|
9
9
|
gem uninstall -a assets-watchify
|
10
10
|
--:
|
11
|
+
+: Install Rails apps
|
12
|
+
bundle exec rake apps:init -new_console:c
|
11
13
|
R: Run Rails
|
12
14
|
cd test/v3
|
13
15
|
rails s -p 3003 -new_console:cb
|
@@ -16,3 +18,5 @@ R: Run Rails
|
|
16
18
|
rails s -p 3004 -new_console:cb
|
17
19
|
cd ../..
|
18
20
|
start test/index.html
|
21
|
+
-: Remove Rails apps
|
22
|
+
bundle exec rake apps:clear -new_console:c
|
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
@@ -1,75 +1,97 @@
|
|
1
|
-
# Assets::Watchify
|
2
|
-
|
3
|
-
[](http://badge.fury.io/rb/assets-watchify)
|
4
|
-
|
5
|
-
Fast serving Rails assets in development.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
```
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
```
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
*
|
40
|
-
*
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
1
|
+
# Assets::Watchify
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/assets-watchify)
|
4
|
+
|
5
|
+
Fast serving Rails assets in development.
|
6
|
+
|
7
|
+
Useful for Rails applications with hundreds of JavaScript files
|
8
|
+
(eg Backbone Marionette at client side).
|
9
|
+
|
10
|
+
This Gem doesn't use Watchify, Browserify or Node.js.
|
11
|
+
Rails Assets Pipeline is smart enough to do all the job.
|
12
|
+
We just set a couple of hooks.
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'assets-watchify', group: :development
|
20
|
+
```
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
```sh
|
24
|
+
$ bundle
|
25
|
+
```
|
26
|
+
Or install it yourself as:
|
27
|
+
|
28
|
+
```sh
|
29
|
+
$ gem install assets-watchify
|
30
|
+
```
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
Create folder `public/assets/w6y` and start rails server.
|
34
|
+
|
35
|
+
## Operation
|
36
|
+
|
37
|
+
The Gem:
|
38
|
+
|
39
|
+
* Instructs Rails to concatenate CSS files together
|
40
|
+
* Installs hook on generating JavaScript tag
|
41
|
+
* Combines all JavaScript assets into single file
|
42
|
+
* Generates SourceMap for concatenated JavaScript
|
43
|
+
* Listens to changes in asset folders and rebuilds JavaScript files
|
44
|
+
|
45
|
+
For Rails v3 it's enough.
|
46
|
+
|
47
|
+
Rails v4 is slooow serving large files (and combined JavaScript is large!).
|
48
|
+
Use nginx as reverse proxy:
|
49
|
+
|
50
|
+
```
|
51
|
+
server {
|
52
|
+
listen 80;
|
53
|
+
|
54
|
+
root /my/Rails/app/public;
|
55
|
+
|
56
|
+
location @Rails {
|
57
|
+
proxy_pass http://127.0.0.1:3000;
|
58
|
+
}
|
59
|
+
|
60
|
+
location / {
|
61
|
+
try_files $uri @Rails;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
```
|
66
|
+
## Precompilation
|
67
|
+
|
68
|
+
It's useful sometimes to compile large JavaScript on Rails server start.
|
69
|
+
Request it via Bundles constant , eg:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
# config/initializers/watchify.rb
|
73
|
+
Assets::Watchify::Bundles['application.js']=nil
|
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
|
82
|
+
```
|
83
|
+
|
84
|
+
|
85
|
+
## See also
|
86
|
+
|
87
|
+
* [OpenSSL::Win::Root](https://github.com/ukoloff/openssl-win-root)
|
88
|
+
* [ExecJS::Xtrn](https://github.com/ukoloff/execjs-xtrn)
|
89
|
+
|
90
|
+
## Credits
|
91
|
+
|
92
|
+
* [Ruby](https://www.ruby-lang.org/)
|
93
|
+
* [Ruby on Rails](http://rubyonrails.org/)
|
94
|
+
* [nginx](http://nginx.org/)
|
95
|
+
* Gem [source_map](https://github.com/ConradIrwin/ruby-source_map)
|
96
|
+
* [Listen](https://github.com/guard/listen)
|
97
|
+
* [Backbone Marionette](http://marionettejs.com/)
|
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
@@ -1,16 +1,20 @@
|
|
1
|
-
require_relative "watchify/version"
|
2
|
-
|
3
|
-
if Gem.win_platform?
|
4
|
-
require 'execjs/xtrn'
|
5
|
-
require 'openssl/win/root'
|
6
|
-
end
|
7
|
-
|
8
|
-
class Rails::Application
|
9
|
-
initializer :assets_watchify do
|
10
|
-
require_relative 'watchify/boot'
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
module Assets::Watchify
|
15
|
-
Bundles={}
|
16
|
-
|
1
|
+
require_relative "watchify/version"
|
2
|
+
|
3
|
+
if Gem.win_platform?
|
4
|
+
require 'execjs/xtrn'
|
5
|
+
require 'openssl/win/root'
|
6
|
+
end
|
7
|
+
|
8
|
+
class Rails::Application
|
9
|
+
initializer :assets_watchify do
|
10
|
+
require_relative 'watchify/boot'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Assets::Watchify
|
15
|
+
Bundles={}
|
16
|
+
|
17
|
+
def self.defaults!
|
18
|
+
Bundles['application.js']=nil
|
19
|
+
end
|
20
|
+
end
|
data/lib/assets/watchify/boot.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
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
|
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
|
data/lib/assets/watchify/main.rb
CHANGED
@@ -1,87 +1,99 @@
|
|
1
|
-
require 'source_map'
|
2
|
-
require 'listen'
|
3
|
-
require 'wdm' if Gem.win_platform?
|
4
|
-
|
5
|
-
module Assets::Watchify
|
6
|
-
Helper=Sprockets::Helpers::RailsHelper rescue Sprockets::Rails::Helper
|
7
|
-
|
8
|
-
require_relative 'sprockets'
|
9
|
-
|
10
|
-
def self.clean
|
11
|
-
Dir.glob Root.join '**', '*' do |f|
|
12
|
-
File.delete f rescue nil
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.mkdir
|
17
|
-
FileUtils.mkpath Root
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.rmdir
|
21
|
-
FileUtils.remove_entry Root
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.ms seconds
|
25
|
-
seconds.round 3
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.jstag name
|
29
|
-
return unless String===name
|
30
|
-
t1 = Time.now
|
31
|
-
name+='.js' if File.extname(name).empty?
|
32
|
-
begin
|
33
|
-
z = Rails.application.assets[name]
|
34
|
-
rescue=> e
|
35
|
-
return "<div class='alert alert-error'><pre>#{e.message}</pre></div>"
|
36
|
-
end
|
37
|
-
|
38
|
-
t2 = Time.now
|
39
|
-
|
40
|
-
unless File.exist? js = Root.join(z.digest_path)
|
41
|
-
File.delete Bundles[name], "#{Bundles[name]}.map" rescue nil if Bundles[name]
|
42
|
-
Bundles[name] = js
|
43
|
-
FileUtils.mkpath js.dirname
|
44
|
-
jsf = File.open js, 'w+'
|
45
|
-
map = SourceMap.new file: js.basename, source_root: '/assets', generated_output: jsf
|
46
|
-
z.to_a.each {|d| map.add_generated d.source, source: d.logical_path+'?body=1'}
|
47
|
-
map.save "#{js}.map"
|
48
|
-
jsf.puts
|
49
|
-
jsf.puts "//# sourceMappingURL=#{File::basename js}.map"
|
50
|
-
jsf.close
|
51
|
-
t3 = Time.now
|
52
|
-
puts "#{self} built '#{name}' (#{ms t2-t1}+#{ms t3-t2}=#{ms t3-t1})..."
|
53
|
-
end
|
54
|
-
"<script src='/assets/#{Folder}/#{z.digest_path}'></script><!-- #{z.length}/#{z.to_a.length} -->"
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.ping
|
58
|
-
Bundles.keys.each{|name| jstag name}
|
59
|
-
end
|
60
|
-
|
61
|
-
def self.
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
1
|
+
require 'source_map'
|
2
|
+
require 'listen'
|
3
|
+
require 'wdm' if Gem.win_platform?
|
4
|
+
|
5
|
+
module Assets::Watchify
|
6
|
+
Helper=Sprockets::Helpers::RailsHelper rescue Sprockets::Rails::Helper
|
7
|
+
|
8
|
+
require_relative 'sprockets'
|
9
|
+
|
10
|
+
def self.clean
|
11
|
+
Dir.glob Root.join '**', '*' do |f|
|
12
|
+
File.delete f rescue nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.mkdir
|
17
|
+
FileUtils.mkpath Root
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.rmdir
|
21
|
+
FileUtils.remove_entry Root
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.ms seconds
|
25
|
+
seconds.round 3
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.jstag name
|
29
|
+
return unless String===name
|
30
|
+
t1 = Time.now
|
31
|
+
name+='.js' if File.extname(name).empty?
|
32
|
+
begin
|
33
|
+
z = Rails.application.assets[name]
|
34
|
+
rescue=> e
|
35
|
+
return "<div class='alert alert-error'><pre>#{e.message}</pre></div>"
|
36
|
+
end
|
37
|
+
|
38
|
+
t2 = Time.now
|
39
|
+
|
40
|
+
unless File.exist? js = Root.join(z.digest_path)
|
41
|
+
File.delete Bundles[name], "#{Bundles[name]}.map" rescue nil if Bundles[name]
|
42
|
+
Bundles[name] = js
|
43
|
+
FileUtils.mkpath js.dirname
|
44
|
+
jsf = File.open js, 'w+'
|
45
|
+
map = SourceMap.new file: js.basename, source_root: '/assets', generated_output: jsf
|
46
|
+
z.to_a.each {|d| map.add_generated d.source, source: d.logical_path+'?body=1'}
|
47
|
+
map.save "#{js}.map"
|
48
|
+
jsf.puts
|
49
|
+
jsf.puts "//# sourceMappingURL=#{File::basename js}.map"
|
50
|
+
jsf.close
|
51
|
+
t3 = Time.now
|
52
|
+
puts "#{self} built '#{name}' (#{ms t2-t1}+#{ms t3-t2}=#{ms t3-t1})..."
|
53
|
+
end
|
54
|
+
"<script src='/assets/#{Folder}/#{z.digest_path}'></script><!-- #{z.length}/#{z.to_a.length} -->"
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.ping
|
58
|
+
Bundles.keys.each{|name| jstag name}
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.path? f
|
62
|
+
Pathname.new(f).realpath.ascend do |z|
|
63
|
+
return false if Pathname.glob(z+'*.gemspec').any?
|
64
|
+
return true if z.join('Gemfile').file?
|
65
|
+
end
|
66
|
+
true
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.pathz
|
70
|
+
@paths||=Rails.application.config.assets.paths#.select{|f| path? f}
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.start!
|
74
|
+
clean
|
75
|
+
Rails.application.config.assets.debug = false # Let CSS to glue either
|
76
|
+
|
77
|
+
paths=pathz
|
78
|
+
|
79
|
+
Thread.new do
|
80
|
+
listener = Listen.to paths do |m,a,r|
|
81
|
+
m.each {|f| puts "~ #{f}"}
|
82
|
+
a.each {|f| puts "+ #{f}"}
|
83
|
+
r.each {|f| puts "- #{f}"}
|
84
|
+
ping
|
85
|
+
end
|
86
|
+
listener.start
|
87
|
+
puts "#{self} listening to changes in #{paths.count} folders..."
|
88
|
+
at_exit do
|
89
|
+
puts "#{self } stop listening to folders..."
|
90
|
+
listener.stop
|
91
|
+
clean
|
92
|
+
end
|
93
|
+
sleep 1
|
94
|
+
ping
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
start!
|
99
|
+
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
|
@@ -1,5 +1,5 @@
|
|
1
|
-
module Assets
|
2
|
-
module Watchify
|
3
|
-
VERSION = "0.1.
|
4
|
-
end
|
5
|
-
end
|
1
|
+
module Assets
|
2
|
+
module Watchify
|
3
|
+
VERSION = "0.1.1"
|
4
|
+
end
|
5
|
+
end
|
data/rakelib/apps.rake
CHANGED
@@ -5,15 +5,15 @@ namespace :apps do
|
|
5
5
|
FileUtils.mkdir_p "test"
|
6
6
|
html=File.open "test/index.html", 'a'
|
7
7
|
%w(3 4).each do |ver|
|
8
|
-
html.puts "<li><a href='http://localhost:300#{ver}'>v#{ver}</a>"
|
8
|
+
html.puts "<li><a href='http://localhost:300#{ver}' target='_blank'>v#{ver}</a>"
|
9
9
|
FileUtils.mkdir_p app="test/v#{ver}"
|
10
10
|
next if File.exists? gemfile="#{app}/Gemfile"
|
11
|
-
|
11
|
+
Bundler.clean_system *%w(bundle init), chdir: app
|
12
12
|
File.open gemfile, 'a' do |f|
|
13
13
|
f.puts "gem 'rails', '~>#{ver}'"
|
14
14
|
end
|
15
|
-
|
16
|
-
|
15
|
+
Bundler.clean_system *%w(bundle install), chdir: app
|
16
|
+
Bundler.clean_system *%w(bundle exec rails new . --force --skip-bundle), chdir: app
|
17
17
|
gf=File.read(gemfile).each_line.reject{|s|/tzinfo-data/.match s}+
|
18
18
|
<<-EOG.each_line.map(&:lstrip)
|
19
19
|
gem 'byebug', group: :development
|
@@ -22,13 +22,13 @@ namespace :apps do
|
|
22
22
|
gem 'tzinfo-data' if #{'3'==ver ? 'false' : 'Gem.win_platform?'}
|
23
23
|
EOG
|
24
24
|
File.write gemfile, gf*""
|
25
|
-
|
26
|
-
|
25
|
+
Bundler.clean_system *%w(bundle install), chdir: app
|
26
|
+
Bundler.clean_system *%w(bundle exec rails g controller welcome index), chdir: app
|
27
27
|
File.unlink "#{app}/public/index.html" rescue nil
|
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.defaults! rescue nil
|
32
32
|
EOF
|
33
33
|
end
|
34
34
|
File.open "#{app}/config/routes.rb", 'w' do |f|
|
@@ -41,7 +41,8 @@ end
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
desc 'Remove test Rails apps'
|
44
45
|
task :clear do
|
45
|
-
FileUtils.remove_dir 'test'
|
46
|
+
FileUtils.remove_dir 'test', true
|
46
47
|
end
|
47
48
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assets-watchify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stas Ukolov
|
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
162
|
version: '0'
|
163
163
|
requirements: []
|
164
164
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.
|
165
|
+
rubygems_version: 2.0.14
|
166
166
|
signing_key:
|
167
167
|
specification_version: 4
|
168
168
|
summary: Fast serving Rails assets in development
|