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 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
- Also you can set the `:runner` option:
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
- `:rails_env` option is available that allows you to specify the Rails environment to use (defaults to 'test').
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:
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
 
16
16
  s.add_dependency 'guard'
17
17
  s.add_dependency 'rake'
18
- s.add_dependency 'rails', '>= 3.1.1.rc2'
18
+ s.add_dependency 'rails', '>= 3.1.1'
19
19
  s.add_development_dependency 'rspec'
20
20
 
21
21
  s.files = `git ls-files`.split("\n")
@@ -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
- system "RAILS_ENV=#{@rails_env} bundle exec rake assets:clean assets:precompile"
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
- # copy from the "assets:precompile" Rake task
48
-
49
- # Ensure that action view is loaded and the appropriate sprockets hooks get executed
50
- ActionView::Base
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
- config = ::Rails.application.config
53
- config.assets.compile = true
47
+ # Ensure that action view is loaded and the appropriate
48
+ # sprockets hooks get executed
49
+ _ = ActionView::Base
54
50
 
55
- env = ::Rails.application.assets
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
- target = File.join(::Rails.public_path, config.assets.prefix)
62
- static_compiler = Sprockets::StaticCompiler.new(env, target, :digest => config.assets.digest)
63
-
64
- manifest = static_compiler.precompile(config.assets.precompile)
65
- manifest_path = config.assets.manifest || target
66
- FileUtils.mkdir_p(manifest_path)
67
-
68
- File.open("#{manifest_path}/manifest.yml", 'wb') do |f|
69
- YAML.dump(manifest, f)
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
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module RailsAssetsVersion
3
- VERSION = "0.0.9"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
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.9
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-03 00:00:00.000000000Z
12
+ date: 2011-10-10 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard
16
- requirement: &70238059275400 !ruby/object:Gem::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: *70238059275400
24
+ version_requirements: *70092820854200
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70238059274540 !ruby/object:Gem::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: *70238059274540
35
+ version_requirements: *70092820853040
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rails
38
- requirement: &70238059269600 !ruby/object:Gem::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.rc2
43
+ version: 3.1.1
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70238059269600
46
+ version_requirements: *70092820852320
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &70238059269020 !ruby/object:Gem::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: *70238059269020
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