rake-sprockets 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 96a1a01ec09508d4fa2955c6b0eb7a27b9df5b31
4
- data.tar.gz: f5b0b11c3e876e069ae62636794d5c9fde8f543d
3
+ metadata.gz: f1709224381a55728faeea0190849e626ba80bd6
4
+ data.tar.gz: 0eef947b307984dc682bc895b74a0c20c6c698a1
5
5
  SHA512:
6
- metadata.gz: 8139dc6df744ff4edb7bfc54cc4960e8d7bd182a01f97b80fe243d40ebcffe09dbae0e17974b0e49695e30272bda5f4615196b7a9a55ec3bb7b7606896d05193
7
- data.tar.gz: 8ffd9463e0c06fb657043e32a8fe780f0a8cf4d510c85b7569df26ae1f90b5e64733cc952e92053db4e22ae39dd407433dc79cb608a07cebca45e48adb4501ff
6
+ metadata.gz: 323bfd8408a2be0f40ca4184b3a87c725bb8a96bf472f79bbf137ef9726e43044c5fee0d91457c6c743baf760496f219fc8f5c7c2f1d4b22c59b70179bae753a
7
+ data.tar.gz: 2e501433e6a1ace0ea2fb16987040fc3a0a1b2b8cf2cdd34132165056f4735d055c70e120051732be445c4111cdb1b1fb8409c9fcce3b5f11025e89947210ac3
@@ -47,6 +47,20 @@ module Rake
47
47
  @sprockets ||= create_sprockets_env
48
48
  end
49
49
 
50
+ def filename(file)
51
+ asset = sprockets[file]
52
+
53
+ if env.production?
54
+ asset.digest_path
55
+ else
56
+ asset.logical_path
57
+ end
58
+ end
59
+
60
+ def url(file)
61
+ "/assets/#{filename(file)}"
62
+ end
63
+
50
64
  def create_sprockets_env
51
65
  ::Sprockets::Environment.new(root) do |s_env|
52
66
  s_env.logger = logger
@@ -65,14 +79,13 @@ module Rake
65
79
  def compile
66
80
  public_assets.mkpath
67
81
  precompile.each do |file|
68
- assets = sprockets.find_asset file
69
- filename = public_assets.join file
70
- assets.write_to filename
82
+ public_filename = public_assets.join filename(file)
83
+ sprockets[file].write_to public_filename
71
84
  end
72
85
  end
73
86
 
74
87
  def clean
75
- public_assets.rmtree
88
+ public_assets.rmtree if public_assets.exist?
76
89
  end
77
90
  end
78
91
  end
@@ -1,5 +1,5 @@
1
1
  module Rake
2
2
  module Sprockets
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -1,11 +1,11 @@
1
- desc "Build all assets into public"
2
- task :build do
3
- Rake::Sprockets.compile
4
- end
5
-
6
- task :compile => :build
1
+ namespace :assets do
2
+ desc "Build all assets into public"
3
+ task :compile do
4
+ Rake::Sprockets.compile
5
+ end
7
6
 
8
- desc "Remove all asset files in public"
9
- task :clean do
10
- Rake::Sprockets.clean
7
+ desc "Remove all asset files in public"
8
+ task :clean do
9
+ Rake::Sprockets.clean
10
+ end
11
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake-sprockets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - myobie