guard-rails-assets 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ .DS_Store
1
2
  pkg/*
2
3
  *.gem
3
4
  *.rbc
@@ -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.0'
18
+ s.add_dependency 'rails', '>= 3.1.1.rc2'
19
19
  s.add_development_dependency 'rspec'
20
20
 
21
21
  s.files = `git ls-files`.split("\n")
File without changes
File without changes
@@ -2,6 +2,8 @@ require 'rake/dsl_definition'
2
2
  module Guard
3
3
 
4
4
  class RailsAssets::RailsRunner
5
+ include Rake::DSL
6
+
5
7
  @@rails_booted = false # Only one rails app is allowed, so make it a class var
6
8
  @@rails_env = nil
7
9
 
@@ -13,14 +15,6 @@ module Guard
13
15
  # TODO: Hack due to Rails 3.1 issue: https://github.com/rails/rails/issues/2663#issuecomment-1990121
14
16
  ENV["RAILS_GROUPS"] ||= "assets"
15
17
  ENV["RAILS_ENV"] ||= @@rails_env
16
-
17
- # TODO: Now another hack: Rails replaces Rails.application.assets with Rails.applciation.assets.index
18
- # (this happens when config.action_controller.perform_caching is true)
19
- # It caches all the assets, so that the Rake task can't be run multiple times
20
- require 'sprockets/environment'
21
- Sprockets::Environment.class_eval do
22
- def index; self; end # instead of Index.new(self)
23
- end
24
18
  end
25
19
 
26
20
  # Methods to run the asset pipeline
@@ -28,6 +22,8 @@ module Guard
28
22
  def self.boot_rails
29
23
  return if @@rails_booted
30
24
  puts "Booting Rails for #{@@rails_env} environment."
25
+ require "fileutils"
26
+
31
27
  apply_hacks
32
28
  require 'rake'
33
29
  require "#{Dir.pwd}/config/environment.rb"
@@ -39,6 +35,42 @@ module Guard
39
35
  end
40
36
 
41
37
 
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
+ 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
51
+
52
+ config = ::Rails.application.config
53
+ config.assets.compile = true
54
+
55
+ env = ::Rails.application.assets
56
+
57
+ # Always compile files and avoid use of existing precompiled assets
58
+ config.assets.compile = true
59
+ config.assets.digests = {}
60
+
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
71
+ end
72
+
73
+
42
74
  # Runs the asset pipeline compiler.
43
75
  #
44
76
  # @return [ Boolean ] Whether the compilation was successful or not
@@ -46,13 +78,14 @@ module Guard
46
78
  self.class.boot_rails
47
79
  return false unless @@rails_booted
48
80
  begin
49
- Rake::Task['assets:clean'].execute
50
- ::Rails.application.assets.instance_eval { expire_index! }
51
- Rake::Task['assets:precompile'].execute
81
+ clean
82
+ precompile
52
83
  true
53
84
  rescue => e
54
85
  puts "An error occurred compiling assets: #{e}"
55
86
  false
87
+ ensure
88
+ ::Rails.application.assets.instance_eval { expire_index! }
56
89
  end
57
90
  end
58
91
  end
File without changes
data/lib/guard/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module RailsAssetsVersion
3
- VERSION = "0.0.8"
3
+ VERSION = "0.0.9"
4
4
  end
5
5
  end
File without changes
File without changes
File without changes
data/spec/spec_helper.rb CHANGED
File without changes
File without changes
File without changes
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.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-20 00:00:00.000000000 +10:00
13
- default_executable:
12
+ date: 2011-10-03 00:00:00.000000000Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: guard
17
- requirement: &18832300 !ruby/object:Gem::Requirement
16
+ requirement: &70238059275400 !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
19
  - - ! '>='
@@ -22,10 +21,10 @@ dependencies:
22
21
  version: '0'
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *18832300
24
+ version_requirements: *70238059275400
26
25
  - !ruby/object:Gem::Dependency
27
26
  name: rake
28
- requirement: &18831880 !ruby/object:Gem::Requirement
27
+ requirement: &70238059274540 !ruby/object:Gem::Requirement
29
28
  none: false
30
29
  requirements:
31
30
  - - ! '>='
@@ -33,21 +32,21 @@ dependencies:
33
32
  version: '0'
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: *18831880
35
+ version_requirements: *70238059274540
37
36
  - !ruby/object:Gem::Dependency
38
37
  name: rails
39
- requirement: &18831380 !ruby/object:Gem::Requirement
38
+ requirement: &70238059269600 !ruby/object:Gem::Requirement
40
39
  none: false
41
40
  requirements:
42
41
  - - ! '>='
43
42
  - !ruby/object:Gem::Version
44
- version: 3.1.0
43
+ version: 3.1.1.rc2
45
44
  type: :runtime
46
45
  prerelease: false
47
- version_requirements: *18831380
46
+ version_requirements: *70238059269600
48
47
  - !ruby/object:Gem::Dependency
49
48
  name: rspec
50
- requirement: &18830960 !ruby/object:Gem::Requirement
49
+ requirement: &70238059269020 !ruby/object:Gem::Requirement
51
50
  none: false
52
51
  requirements:
53
52
  - - ! '>='
@@ -55,7 +54,7 @@ dependencies:
55
54
  version: '0'
56
55
  type: :development
57
56
  prerelease: false
58
- version_requirements: *18830960
57
+ version_requirements: *70238059269020
59
58
  description: guard-rails-assets automatically generates JavaScript, CSS, Image files
60
59
  using Rails assets pipelie
61
60
  email:
@@ -80,7 +79,6 @@ files:
80
79
  - spec/spec_helper.rb
81
80
  - spec/support/shared_examples.rb
82
81
  - spec/support/stdout_helper.rb
83
- has_rdoc: true
84
82
  homepage: http://github.com/dnagir/guard-rails-assets
85
83
  licenses: []
86
84
  post_install_message:
@@ -101,8 +99,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
99
  version: '0'
102
100
  requirements: []
103
101
  rubyforge_project: guard-rails-assets
104
- rubygems_version: 1.6.2
102
+ rubygems_version: 1.8.10
105
103
  signing_key:
106
104
  specification_version: 3
107
105
  summary: Guard for compiling Rails assets
108
- test_files: []
106
+ test_files:
107
+ - spec/guard/rails-assets/cli_runner_spec.rb
108
+ - spec/guard/rails-assets/rails_runner_spec.rb
109
+ - spec/guard/rails-assets_spec.rb
110
+ - spec/spec_helper.rb
111
+ - spec/support/shared_examples.rb
112
+ - spec/support/stdout_helper.rb