guard-sprockets2 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -22,30 +22,30 @@ Configure guard for your environment. The following options are available:
22
22
  - `assets_path` - Optional. The compiled assets path. Defaults to public/assets
23
23
  - `precompile` - Optional. An array of regex's or strings which match files
24
24
  that need compiling. Defaults to `[ /\w+\.(?!js|css).+/, /application.(css|js)$/ ]`
25
+ - `digest` - Optional. Whether to include the digest in the filename. Defaults to true.
25
26
 
26
27
  Example Rails and Sinatra apps can be found in the examples directory.
27
28
 
28
- # Rails
29
-
30
- When Rails is loaded the defaults come from Rails' configuration, so no
31
- additional configuration is necessary.
29
+ # Sinatra
32
30
 
33
31
  ```ruby
34
- require './config/environment'
32
+ require './app'
35
33
 
36
- guard 'sprockets2' do
37
- watch(%r{^app/assets/.+$})
38
- watch('config/application.rb')
34
+ guard 'sprockets2', :sprockets => App.sprockets do
35
+ watch(%r{^assets/.+$})
36
+ watch('app.rb')
39
37
  end
40
38
  ```
41
39
 
42
- # Sinatra
40
+ # Rails
41
+
42
+ When Rails is loaded the defaults come from Rails' configuration.
43
43
 
44
44
  ```ruby
45
- require './app'
45
+ require './config/environment'
46
46
 
47
- guard 'sprockets2', :sprockets => App.sprockets do
48
- watch(%r{^assets/.+$})
49
- watch('app.rb')
47
+ guard 'sprockets2' do
48
+ watch(%r{^app/assets/.+$})
49
+ watch('config/application.rb')
50
50
  end
51
51
  ```
@@ -28,6 +28,8 @@ module Guard
28
28
  @sprockets = options[:sprockets]
29
29
  @assets_path = options[:assets_path]
30
30
  @precompile = options[:precompile]
31
+ @digest = options[:digest]
32
+ @digest = true if @digest.nil?
31
33
  if defined?(Rails)
32
34
  @sprockets ||= Rails.application.assets
33
35
  @assets_path ||= File.join(Rails.public_path, Rails.application.config.assets.prefix)
@@ -53,7 +55,8 @@ module Guard
53
55
  end
54
56
 
55
57
  if asset = @sprockets.find_asset(logical_path)
56
- filename = target.join(asset.digest_path)
58
+ filename = @digest ? target.join(asset.digest_path) : target.join(asset.logical_path)
59
+
57
60
  FileUtils.mkdir_p filename.dirname
58
61
  asset.write_to(filename)
59
62
  asset.write_to("#{filename}.gz") if filename.to_s =~ /\.(css|js)$/
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module Sprockets2Version
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -6,19 +6,19 @@ describe Guard::Sprockets2::Compiler do
6
6
  File.open(path, "wb") {|f| f.write data }
7
7
  end
8
8
 
9
- let(:root) { Pathname.new(File.expand_path("../../../tmp", __FILE__)) }
10
- let(:sprockets) { Sprockets::Environment.new(root.to_s) }
11
- let(:assets_path) { root.join("assets") }
12
- let(:compiled_path) { root.join("compiled") }
9
+ let(:tmp) { Pathname.new(File.expand_path("../../../../tmp", __FILE__)) }
10
+ let(:sprockets) { Sprockets::Environment.new(tmp.to_s) }
11
+ let(:assets_path) { tmp.join("assets") }
12
+ let(:compiled_path) { tmp.join("compiled") }
13
13
 
14
14
  before do
15
+ FileUtils.rm_rf tmp, :secure => true
15
16
  FileUtils.mkdir_p assets_path
16
17
  FileUtils.mkdir_p compiled_path
17
18
  sprockets.append_path(assets_path)
18
19
  write_file(assets_path.join("application.js").to_s, "//= require_tree .")
19
20
  end
20
21
 
21
- after { FileUtils.rm_rf root, :secure => true }
22
22
 
23
23
  context 'preconfigured' do
24
24
  subject { Guard::Sprockets2::Compiler.new(:sprockets => sprockets, :assets_path => compiled_path.to_s) }
@@ -30,10 +30,21 @@ describe Guard::Sprockets2::Compiler do
30
30
  app_js_path = compiled_path.join(asset.digest_path)
31
31
 
32
32
  app_js_path.should exist
33
- app_js = app_js_path.read
34
- app_js.should include("console.log('hello')")
33
+ app_js_path.read.should include("console.log('hello')")
35
34
  end
35
+ end
36
36
 
37
+ context 'with digest false' do
38
+ subject { Guard::Sprockets2::Compiler.new(:sprockets => sprockets, :assets_path => compiled_path.to_s, :digest => false) }
39
+
40
+ it "compiles assets without the digest" do
41
+ write_file(assets_path.join("hello.coffee").to_s, "console.log 'hello'")
42
+ subject.compile
43
+ app_js_path = compiled_path.join('application.js')
44
+
45
+ app_js_path.should exist
46
+ app_js_path.read.should include("console.log('hello')")
47
+ end
37
48
  end
38
49
 
39
50
  context 'with rails loaded' do
@@ -41,7 +52,7 @@ describe Guard::Sprockets2::Compiler do
41
52
  write_file(assets_path.join("hello.coffee").to_s, "console.log 'hello2'")
42
53
  module Rails
43
54
  end
44
- Rails.stub(:public_path => root)
55
+ Rails.stub(:public_path => tmp)
45
56
  Rails.stub_chain(:application, :assets).and_return(sprockets)
46
57
  Rails.stub_chain(:application, :config, :assets, :prefix).and_return('compiled')
47
58
  Rails.stub_chain(:application, :config, :assets, :precompile).and_return([ /\w+\.(?!js|css).+/, /application.(css|js)$/ ])
@@ -55,8 +66,7 @@ describe Guard::Sprockets2::Compiler do
55
66
  app_js_path = compiled_path.join(asset.digest_path)
56
67
 
57
68
  app_js_path.should exist
58
- app_js = app_js_path.read
59
- app_js.should include("console.log('hello2')")
69
+ app_js_path.read.should include("console.log('hello2')")
60
70
  end
61
71
 
62
72
  after { Object.send(:remove_const, :Rails) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-sprockets2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-05 00:00:00.000000000 +01:00
12
+ date: 2011-09-15 00:00:00.000000000 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: guard
17
- requirement: &2173263740 !ruby/object:Gem::Requirement
17
+ requirement: &2152993360 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2173263740
25
+ version_requirements: *2152993360
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: sprockets
28
- requirement: &2173261800 !ruby/object:Gem::Requirement
28
+ requirement: &2152992440 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '2.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *2173261800
36
+ version_requirements: *2152992440
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: rspec
39
- requirement: &2173261360 !ruby/object:Gem::Requirement
39
+ requirement: &2152992020 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2173261360
47
+ version_requirements: *2152992020
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: coffee-script
50
- requirement: &2173260660 !ruby/object:Gem::Requirement
50
+ requirement: &2152991560 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *2173260660
58
+ version_requirements: *2152991560
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: uglifier
61
- requirement: &2173260020 !ruby/object:Gem::Requirement
61
+ requirement: &2152991060 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: '0'
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *2173260020
69
+ version_requirements: *2152991060
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: sass
72
- requirement: &2173259580 !ruby/object:Gem::Requirement
72
+ requirement: &2152990320 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: '0'
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *2173259580
80
+ version_requirements: *2152990320
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: sinatra
83
- requirement: &2173259140 !ruby/object:Gem::Requirement
83
+ requirement: &2152989780 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ! '>='
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: '0'
89
89
  type: :development
90
90
  prerelease: false
91
- version_requirements: *2173259140
91
+ version_requirements: *2152989780
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: cucumber
94
- requirement: &2173258720 !ruby/object:Gem::Requirement
94
+ requirement: &2152989360 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ! '>='
@@ -99,10 +99,10 @@ dependencies:
99
99
  version: '0'
100
100
  type: :development
101
101
  prerelease: false
102
- version_requirements: *2173258720
102
+ version_requirements: *2152989360
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: aruba
105
- requirement: &2173258240 !ruby/object:Gem::Requirement
105
+ requirement: &2152988760 !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements:
108
108
  - - ! '>='
@@ -110,10 +110,10 @@ dependencies:
110
110
  version: '0'
111
111
  type: :development
112
112
  prerelease: false
113
- version_requirements: *2173258240
113
+ version_requirements: *2152988760
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: rails
116
- requirement: &2173257720 !ruby/object:Gem::Requirement
116
+ requirement: &2152988140 !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements:
119
119
  - - ~>
@@ -121,7 +121,7 @@ dependencies:
121
121
  version: '3.1'
122
122
  type: :development
123
123
  prerelease: false
124
- version_requirements: *2173257720
124
+ version_requirements: *2152988140
125
125
  description: ''
126
126
  email:
127
127
  - steve@hodgkiss.me
@@ -212,7 +212,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
212
212
  version: '0'
213
213
  segments:
214
214
  - 0
215
- hash: 154958776872281660
215
+ hash: 608752982821193138
216
216
  required_rubygems_version: !ruby/object:Gem::Requirement
217
217
  none: false
218
218
  requirements:
@@ -221,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
221
  version: '0'
222
222
  segments:
223
223
  - 0
224
- hash: 154958776872281660
224
+ hash: 608752982821193138
225
225
  requirements: []
226
226
  rubyforge_project: guard-sprockets2
227
227
  rubygems_version: 1.6.2