ramaze-asset 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -162,28 +162,6 @@ module Ramaze
162
162
  @files = {}
163
163
  @added_files = {}
164
164
  @asset_groups = {}
165
- @file_group_options = {
166
- :paths => [],
167
- :cache_path => @options[:cache_path]
168
- }
169
-
170
- # Get all the public directories to serve files from.
171
- Ramaze.options.roots.each do |root|
172
- Ramaze.options.publics.each do |pub|
173
- pub = File.join(root, pub)
174
-
175
- if File.directory?(pub)
176
- @file_group_options[:paths].push(pub)
177
- end
178
- end
179
- end
180
-
181
- if @file_group_options[:paths].empty?
182
- raise(
183
- Ramaze::Asset::AssetError,
184
- 'No existing public directories were found'
185
- )
186
- end
187
165
  end
188
166
 
189
167
  ##
@@ -278,13 +256,16 @@ module Ramaze
278
256
  # controller set in :controller. When setting these methods the files
279
257
  # will only be served when those methods are executed. This option is
280
258
  # completely ignored if :controller is set to :global.
259
+ # @option options :force When set to true the files will be minified
260
+ # regardless of the (global) :minify option. This is useful for files such
261
+ # as Coffeescript or Less files.
281
262
  #
282
263
  def serve(type, files, options = {})
283
264
  type = type.to_sym
284
265
 
285
266
  if !Types.key?(type)
286
267
  raise(
287
- Zen::Asset::AssetError,
268
+ Ramaze::Asset::AssetError,
288
269
  "The type \"#{type}\" doesn't exist"
289
270
  )
290
271
  end
@@ -464,10 +445,32 @@ module Ramaze
464
445
  options[:minify] = false
465
446
  end
466
447
 
467
- controller = options.delete(:controller) || :global
468
- methods = options.delete(:methods) || [:__all]
469
- options = options.merge(@file_group_options)
448
+ if options.key?(:force) and options[:force] === true
449
+ options[:minify] = true
450
+ end
451
+
452
+ controller = options[:controller] || :global
453
+ methods = options[:methods] || [:__all]
454
+ options[:cache_path] = @options[:cache_path]
455
+ options[:paths] = []
470
456
 
457
+ # Get all the public directories to serve files from.
458
+ Ramaze.options.roots.each do |root|
459
+ Ramaze.options.publics.each do |pub|
460
+ pub = File.join(root, pub)
461
+
462
+ if File.directory?(pub)
463
+ options[:paths].push(pub)
464
+ end
465
+ end
466
+ end
467
+
468
+ if options[:paths].empty?
469
+ raise(
470
+ Ramaze::Asset::AssetError,
471
+ 'No existing public directories were found'
472
+ )
473
+ end
471
474
 
472
475
  if !controller.is_a?(Symbol)
473
476
  controller = controller.to_s.to_sym
@@ -1,5 +1,5 @@
1
1
  module Ramaze
2
2
  module Asset
3
- Version = '0.2.2'
3
+ Version = '0.2.3'
4
4
  end # Asset
5
5
  end # Ramaze
@@ -5,7 +5,7 @@ path = File.expand_path('../', __FILE__)
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'ramaze-asset'
7
7
  s.version = Ramaze::Asset::Version
8
- s.date = '2011-09-14'
8
+ s.date = '2011-09-16'
9
9
  s.authors = ['Yorick Peterse']
10
10
  s.email = 'yorickpeterse@gmail.com'
11
11
  s.summary = 'A simple yet powerful asset manager for Ramaze.'
@@ -45,19 +45,13 @@ describe('Ramaze::Asset::Environment') do
45
45
  env = Ramaze::Asset::Environment.new(
46
46
  :cache_path => __DIR__('../fixtures/public')
47
47
  )
48
+
49
+ env.serve(:javascript, ['js/mootools_core'])
48
50
  end
49
51
 
50
52
  Ramaze.options.publics = old_publics
51
53
  end
52
54
 
53
- it('Generate the possible paths') do
54
- path = __DIR__('../fixtures/public')
55
- env = Ramaze::Asset::Environment.new(:cache_path => path)
56
-
57
- env.instance_variable_get(:@file_group_options)[:paths].include?(path) \
58
- .should === true
59
- end
60
-
61
55
  it('Register a new type') do
62
56
  Ramaze::Asset::Environment.register_type(:struct, Struct)
63
57
 
@@ -84,6 +78,17 @@ describe('Ramaze::Asset::Environment') do
84
78
  env.files[:css][:global][:__all][0].options[:minify].should === false
85
79
  end
86
80
 
81
+ it('Force minifying a file') do
82
+ env = Ramaze::Asset::Environment.new(
83
+ :cache_path => __DIR__('../fixtures/public/minified'),
84
+ :minify => false
85
+ )
86
+
87
+ env.serve(:javascript, ['js/mootools_core'], :force => true)
88
+
89
+ env.files[:javascript][:global][:__all][0].options[:minify].should === true
90
+ end
91
+
87
92
  it('Serve a file globally') do
88
93
  SpecEnv.serve(:javascript, ['js/mootools_core'], :controller => :global)
89
94
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ramaze-asset
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.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-14 00:00:00.000000000 +02:00
12
+ date: 2011-09-16 00:00:00.000000000 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ramaze
17
- requirement: &2152570740 !ruby/object:Gem::Requirement
17
+ requirement: &2153718420 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 2011.07.25
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2152570740
25
+ version_requirements: *2153718420
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rake
28
- requirement: &2152570220 !ruby/object:Gem::Requirement
28
+ requirement: &2153717900 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 0.9.2
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *2152570220
36
+ version_requirements: *2153717900
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: yard
39
- requirement: &2152569740 !ruby/object:Gem::Requirement
39
+ requirement: &2153717420 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 0.7.2
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2152569740
47
+ version_requirements: *2153717420
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: bacon
50
- requirement: &2152569260 !ruby/object:Gem::Requirement
50
+ requirement: &2153716940 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 1.1.0
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *2152569260
58
+ version_requirements: *2153716940
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: rdiscount
61
- requirement: &2152568780 !ruby/object:Gem::Requirement
61
+ requirement: &2153716460 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 1.6.8
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *2152568780
69
+ version_requirements: *2153716460
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rack-test
72
- requirement: &2152599780 !ruby/object:Gem::Requirement
72
+ requirement: &2153715980 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,7 +77,7 @@ dependencies:
77
77
  version: 0.6.1
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *2152599780
80
+ version_requirements: *2153715980
81
81
  description: A simple yet powerful asset manager for Ramaze.
82
82
  email: yorickpeterse@gmail.com
83
83
  executables: []