guard-rails-assets 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -2
- data/guard-rails-assets.gemspec +1 -1
- data/lib/guard/rails-assets/cli_runner.rb +5 -1
- data/lib/guard/rails-assets/rails_runner.rb +21 -27
- data/lib/guard/version.rb +1 -1
- metadata +17 -11
data/README.md
CHANGED
@@ -32,12 +32,15 @@ In addition to the guard configuration, `guard-rails-assets` has options to spec
|
|
32
32
|
- `:reload` - compile assets when the guard quites (Ctrl-C) (not enabled by default)
|
33
33
|
- `:all` - compile assets when running all the guards (Ctrl-/) (not enabled by default)
|
34
34
|
|
35
|
-
|
35
|
+
You can also set the `:runner` option:
|
36
36
|
|
37
37
|
- `:cli` - compile assets using the rake task - the most correct method, but slow.
|
38
38
|
- `:rails` - compile assets by loading rails environment (default) - fast, but does not pick up changes. Additionally it relies on a single instance of your app to be loaded, so you can't have multiple guards with different rails configurations.
|
39
39
|
|
40
|
-
|
40
|
+
Additional options are:
|
41
|
+
|
42
|
+
- `:rails_env` - specify the Rails environment to use (defaults to 'test').
|
43
|
+
- `:digest` - overrides the `config.asset.digest` setting (for production env it is usually `true`, for test - `false`).
|
41
44
|
|
42
45
|
|
43
46
|
For example:
|
data/guard-rails-assets.gemspec
CHANGED
@@ -2,10 +2,14 @@ module Guard
|
|
2
2
|
class RailsAssets::CliRunner
|
3
3
|
def initialize(options={})
|
4
4
|
@rails_env = (options[:rails_env] || 'test').to_s
|
5
|
+
@digest = options[:digest]
|
6
|
+
@digest = true if @digest.nil?
|
5
7
|
end
|
6
8
|
|
7
9
|
def compile_assets
|
8
|
-
|
10
|
+
task = "assets:precompile"
|
11
|
+
task += ":nondigest" unless @digest
|
12
|
+
system "RAILS_ENV=#{@rails_env} bundle exec rake assets:clean #{task}"
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
@@ -6,9 +6,11 @@ module Guard
|
|
6
6
|
|
7
7
|
@@rails_booted = false # Only one rails app is allowed, so make it a class var
|
8
8
|
@@rails_env = nil
|
9
|
+
@@digest = nil
|
9
10
|
|
10
11
|
def initialize(options={})
|
11
12
|
@@rails_env = (options[:rails_env] || 'test').to_s unless @@rails_booted
|
13
|
+
@@digest = options[:digest]
|
12
14
|
end
|
13
15
|
|
14
16
|
def self.apply_hacks
|
@@ -35,39 +37,32 @@ module Guard
|
|
35
37
|
end
|
36
38
|
|
37
39
|
|
38
|
-
def clean
|
39
|
-
Rake::Task["tmp:cache:clear"].execute
|
40
|
-
# copy from the "assets:clean" Rake task
|
41
|
-
config = ::Rails.application.config
|
42
|
-
public_asset_path = File.join(Rails.public_path, config.assets.prefix)
|
43
|
-
rm_rf public_asset_path, :secure => true
|
44
|
-
end
|
45
|
-
|
46
40
|
def precompile
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
41
|
+
config = Rails.application.config
|
42
|
+
unless config.assets.enabled
|
43
|
+
warn "Cannot precompile assets if sprockets is disabled. Enabling it."
|
44
|
+
config.assets.enabled = true
|
45
|
+
end
|
51
46
|
|
52
|
-
|
53
|
-
|
47
|
+
# Ensure that action view is loaded and the appropriate
|
48
|
+
# sprockets hooks get executed
|
49
|
+
_ = ActionView::Base
|
54
50
|
|
55
|
-
|
51
|
+
digest = @@digest.nil? ? config.assets.digest : @@digest
|
56
52
|
|
57
|
-
# Always compile files and avoid use of existing precompiled assets
|
58
53
|
config.assets.compile = true
|
54
|
+
config.assets.digest = digest
|
59
55
|
config.assets.digests = {}
|
60
56
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
end
|
57
|
+
env = Rails.application.assets
|
58
|
+
target = File.join(Rails.public_path, config.assets.prefix)
|
59
|
+
compiler = Sprockets::StaticCompiler.new(env,
|
60
|
+
target,
|
61
|
+
config.assets.precompile,
|
62
|
+
:manifest_path => config.assets.manifest,
|
63
|
+
:digest => config.assets.digest,
|
64
|
+
:manifest => config.assets.digest.nil?)
|
65
|
+
compiler.compile
|
71
66
|
end
|
72
67
|
|
73
68
|
|
@@ -78,7 +73,6 @@ module Guard
|
|
78
73
|
self.class.boot_rails
|
79
74
|
return false unless @@rails_booted
|
80
75
|
begin
|
81
|
-
clean
|
82
76
|
precompile
|
83
77
|
true
|
84
78
|
rescue => e
|
data/lib/guard/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-rails-assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-10-
|
12
|
+
date: 2011-10-10 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guard
|
16
|
-
requirement: &
|
16
|
+
requirement: &70092820854200 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70092820854200
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70092820853040 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,21 +32,21 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70092820853040
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rails
|
38
|
-
requirement: &
|
38
|
+
requirement: &70092820852320 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 3.1.1
|
43
|
+
version: 3.1.1
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70092820852320
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &70092820851240 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70092820851240
|
58
58
|
description: guard-rails-assets automatically generates JavaScript, CSS, Image files
|
59
59
|
using Rails assets pipelie
|
60
60
|
email:
|
@@ -91,12 +91,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
91
|
- - ! '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
|
+
segments:
|
95
|
+
- 0
|
96
|
+
hash: -3147666499136305836
|
94
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
98
|
none: false
|
96
99
|
requirements:
|
97
100
|
- - ! '>='
|
98
101
|
- !ruby/object:Gem::Version
|
99
102
|
version: '0'
|
103
|
+
segments:
|
104
|
+
- 0
|
105
|
+
hash: -3147666499136305836
|
100
106
|
requirements: []
|
101
107
|
rubyforge_project: guard-rails-assets
|
102
108
|
rubygems_version: 1.8.10
|