classy_assets 0.9.4 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be0eec968fdf1170678ea939441edf11e9fe3629
4
- data.tar.gz: 8e58a263f3873ad6970f980dcee8aeb2269f0fc0
3
+ metadata.gz: 7ae68f4846cdfc63757cd698e09ccb68299ba1e1
4
+ data.tar.gz: bfcadb8dbf17457e24675413a9c4c77941ec3fb5
5
5
  SHA512:
6
- metadata.gz: cbe058fcda793e74912ae040469c25ada1c9b1503322933ef1206c299db05501fbbf3c10fb28c2289d10dd5fe78a8d0e879a322f2d530821dc3d2cb631309906
7
- data.tar.gz: c957764106f6bff9f9a04ffe67c4757ba7070b9b612261c74c3b892bdd1b22e781e00e75c8d378e846a64e2f01607b7e7833535f2647678d1b637408e79a5ad3
6
+ metadata.gz: 61802ad99b6dadbd523bcd0a69f84ef66f56f496f974914b2b88dae310e0d85fd95dc3ea65f883653d689a7f7a4bb8464ee596f6416246ef6f61e9299640537a
7
+ data.tar.gz: 83a22842adb3bcb5fe5aadc093a898211179f15ec1ed94876855a2fc28464d778c70eb2b04c59b7ba571e6045e1ac860592b53ae441bb9b15a77560b7849aeed
@@ -7,34 +7,24 @@ module ClassyAssets
7
7
  class Config
8
8
  include Singleton
9
9
 
10
- attr_accessor :asset_cache, :asset_compress, :css_compressor, :js_compressor
11
- attr_accessor :asset_debug, :asset_digest, :asset_host, :asset_paths, :asset_prefix, :asset_root
12
- attr_accessor :asset_precompile_folder, :asset_precompile_files
10
+ attr_accessor :asset_cache, :asset_compress, :asset_debug, :asset_digest,
11
+ :asset_host, :asset_manifest_path, :asset_paths,
12
+ :asset_precompile, :asset_precompile_keep,
13
+ :asset_precompile_path, :asset_prefix, :asset_public_path,
14
+ :asset_root, :asset_version, :css_compressor, :js_compressor
13
15
 
14
16
  def asset_cache
15
17
  @asset_cache = (ENV['RACK_ENV'] == 'production') unless defined? @asset_cache
16
18
  @asset_cache
17
19
  end
18
20
 
19
- def asset_compress
20
- @asset_compress if defined? @asset_compress
21
- end
22
-
23
- def css_compressor
24
- @css_compressor ||= :yui
25
- end
26
-
27
- def js_compressor
28
- @js_compressor ||= :uglifier
29
- end
30
-
31
21
  def asset_debug
32
22
  @asset_debug = (ENV['RACK_ENV'] == 'development') unless defined? @asset_debug
33
23
  @asset_debug
34
24
  end
35
25
 
36
- def asset_digest
37
- @asset_digest if defined? @asset_digest
26
+ def asset_manifest_path
27
+ @asset_manifest_path ||= File.join(asset_precompile_path, 'manifest.json')
38
28
  end
39
29
 
40
30
  def asset_paths
@@ -43,21 +33,41 @@ module ClassyAssets
43
33
  @asset_paths
44
34
  end
45
35
 
36
+ def asset_precompile
37
+ @asset_precompile ||= [/\w+\.(?!js|css).+/, /application.(css|js)$/]
38
+ end
39
+
40
+ def asset_precompile_keep
41
+ @asset_precompile_keep ||= 2
42
+ end
43
+
44
+ def asset_precompile_path
45
+ @asset_precompile_path ||= File.join(asset_public_path, asset_prefix)
46
+ end
47
+
46
48
  def asset_prefix
47
49
  @asset_prefix ||= 'assets'
48
50
  end
49
51
 
52
+ def asset_public_path
53
+ @asset_public_path ||= File.join(asset_root, 'public')
54
+ end
55
+
50
56
  def asset_root
51
57
  raise Errors::NilAssetRoot.new if @asset_root.nil?
52
58
  @asset_root
53
59
  end
54
60
 
55
- def asset_precompile_files
56
- @asset_precompile_files ||= [/\w+\.(?!js|css).+/, /application.(css|js)$/]
61
+ def asset_version
62
+ @asset_version ||= ClassyAssets::VERSION
57
63
  end
58
64
 
59
- def asset_precompile_folder
60
- @asset_precompile_folder ||= "./public/#{ClassyAssets.config.asset_prefix}"
65
+ def css_compressor
66
+ @css_compressor ||= :yui
67
+ end
68
+
69
+ def js_compressor
70
+ @js_compressor ||= :uglifier
61
71
  end
62
72
 
63
73
  private
@@ -6,31 +6,34 @@ module ClassyAssets
6
6
  class Sprockets
7
7
  attr_accessor :asset_root, :environment
8
8
  def initialize
9
- @asset_root = ClassyAssets.config.asset_root
9
+ @config = ClassyAssets.config
10
+ @asset_root = @config.asset_root
10
11
  @environment = new_sprockets_environment
11
12
  end
12
13
 
13
14
  private
14
15
 
15
16
  def new_sprockets_environment
16
- @environment = ::Sprockets::Environment.new(asset_root) { @version = ClassyAssets::VERSION }
17
+ sprockets_environment = ::Sprockets::Environment.new(asset_root) do
18
+ @version = @config.asset_version
19
+ end
17
20
 
18
- ClassyAssets.config.asset_paths.each do |asset_path|
19
- @environment.append_path asset_path
21
+ @config.asset_paths.each do |asset_path|
22
+ sprockets_environment.append_path asset_path
20
23
  end
21
24
 
22
- if ClassyAssets.config.asset_compress
23
- @environment.css_compressor = ClassyAssets.config.css_compressor
24
- @environment.js_compressor = ClassyAssets.config.css_compressor
25
+ if @config.asset_compress
26
+ sprockets_environment.css_compressor = @config.css_compressor
27
+ sprockets_environment.js_compressor = @config.css_compressor
25
28
  end
26
29
 
27
- @environment.context_class.class_eval do
30
+ sprockets_environment.context_class.class_eval do
28
31
  def asset_path(path, options = {})
29
32
  ClassyAssets.asset_url_for(path)
30
33
  end
31
34
  end
32
35
 
33
- @environment
36
+ sprockets_environment
34
37
  end
35
38
  end
36
39
  end
@@ -5,16 +5,18 @@ require 'rake/sprocketstask'
5
5
  require 'classy_assets'
6
6
 
7
7
  module ClassyAssets
8
- class Tasks < Rake::SprocketsTask
9
- def precompile
8
+ class Tasks < Rake::SprocketsTask
9
+ def define_precompile_task
10
10
  task "assets:precompile" => [:clean_assets, :assets]
11
11
  end
12
12
  end
13
13
  end
14
14
 
15
15
  ClassyAssets::Tasks.new do |t|
16
+ t.define_precompile_task
16
17
  t.environment = ClassyAssets.sprockets
17
- t.output = ClassyAssets.config.asset_precompile_folder
18
- t.assets = ClassyAssets.config.asset_precompile_files
19
- t.precompile
18
+ t.output = ClassyAssets.config.asset_precompile_path
19
+ t.assets = ClassyAssets.config.asset_precompile
20
+ t.keep = ClassyAssets.config.asset_precompile_keep
21
+ t.manifest = ::Sprockets::Manifest.new(t.environment, ClassyAssets.config.asset_manifest_path)
20
22
  end
@@ -1,3 +1,3 @@
1
1
  module ClassyAssets
2
- VERSION = "0.9.4"
2
+ VERSION = "0.10.0"
3
3
  end
@@ -4,15 +4,18 @@ require 'spec_helper'
4
4
 
5
5
  describe ClassyAssets::Config do
6
6
  before(:all) do
7
+ @asset_prefix = 'assets'
7
8
  @asset_root = File.expand_path('../../support', __FILE__)
8
9
  @asset_host = 'http://example.com'
9
- @asset_prefix = 'assets'
10
-
10
+ @asset_public_path = File.join(@asset_root, 'public')
11
+ @asset_precompile_path = File.join(@asset_public_path, @asset_prefix)
12
+ @asset_manifest_path = File.join(@asset_precompile_path, 'manifest.json')
13
+ @asset_precompile = %w(application.css application.js)
14
+ @asset_version = ClassyAssets::VERSION
15
+
11
16
  @asset_paths = Dir.glob(File.join(@asset_root, @asset_prefix, '*'))
12
17
  @vendor_path = File.expand_path('../../support/vendor', __FILE__)
13
18
  @asset_paths << @vendor_path
14
- @asset_precompile_files = %w(application.css application.js)
15
- @asset_precompile_folder = "./public/#{@asset_prefix}"
16
19
 
17
20
  ClassyAssets.config do |config|
18
21
  config.asset_root = @asset_root # must be configured first
@@ -20,7 +23,7 @@ describe ClassyAssets::Config do
20
23
  config.asset_digest = true
21
24
  config.asset_host = @asset_host
22
25
  config.asset_paths << @vendor_path
23
- config.asset_precompile_files = @asset_precompile_files
26
+ config.asset_precompile = @asset_precompile
24
27
  end
25
28
 
26
29
  @configuration = ClassyAssets.config
@@ -34,14 +37,6 @@ describe ClassyAssets::Config do
34
37
  @configuration.asset_compress.must_equal nil
35
38
  end
36
39
 
37
- it "returns the configured css_compressor" do
38
- @configuration.css_compressor.must_equal :yui
39
- end
40
-
41
- it "returns the configured js_compressor" do
42
- @configuration.js_compressor.must_equal :uglifier
43
- end
44
-
45
40
  it "returns the configured asset_debug" do
46
41
  @configuration.asset_debug.must_equal true
47
42
  end
@@ -54,23 +49,47 @@ describe ClassyAssets::Config do
54
49
  @configuration.asset_host.must_equal @asset_host
55
50
  end
56
51
 
52
+ it "returns the configured asset_manifest_path" do
53
+ @configuration.asset_manifest_path.must_equal @asset_manifest_path
54
+ end
55
+
56
+ it "returns the configured asset_paths" do
57
+ @configuration.asset_paths.must_equal @asset_paths
58
+ end
59
+
60
+ it "returns the configured asset_precompile" do
61
+ @configuration.asset_precompile.must_equal @asset_precompile
62
+ end
63
+
64
+ it "returns the configured asset_precompile_keep" do
65
+ @configuration.asset_precompile_keep.must_equal 2
66
+ end
67
+
68
+ it "returns the configured asset_precompile_path" do
69
+ @configuration.asset_precompile_path.must_equal @asset_precompile_path
70
+ end
71
+
57
72
  it "returns the configured asset_prefix" do
58
73
  @configuration.asset_prefix.must_equal @asset_prefix
59
74
  end
60
75
 
76
+ it "returns the configured asset_public_path" do
77
+ @configuration.asset_public_path.must_equal @asset_public_path
78
+ end
79
+
61
80
  it "returns the configured asset_root" do
62
81
  @configuration.asset_root.must_equal @asset_root
63
82
  end
64
-
65
- it "returns the configured asset_paths" do
66
- @configuration.asset_paths.must_equal @asset_paths
83
+
84
+ it "returns the configured asset_version" do
85
+ @configuration.asset_version.must_equal @asset_version
67
86
  end
68
87
 
69
- it "returns the configured asset_precompile_files" do
70
- @configuration.asset_precompile_files.must_equal @asset_precompile_files
88
+ it "returns the configured css_compressor" do
89
+ @configuration.css_compressor.must_equal :yui
71
90
  end
72
91
 
73
- it "returns the configured asset_precompile_folder" do
74
- @configuration.asset_precompile_folder.must_equal @asset_precompile_folder
92
+ it "returns the configured js_compressor" do
93
+ @configuration.js_compressor.must_equal :uglifier
75
94
  end
76
95
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: classy_assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - StyleSeek Engineering