ramaze-asset 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -290,7 +290,7 @@ module Ramaze
290
290
  end
291
291
 
292
292
  @files[type] ||= {:global => {:__all => []}}
293
- @added_files[type] ||= []
293
+ @added_files[type] ||= {}
294
294
 
295
295
  options, controller, methods = prepare_options(options)
296
296
  file_group = Types[type].new(files, options)
@@ -376,7 +376,7 @@ module Ramaze
376
376
  end
377
377
 
378
378
  @added_files.each do |type, files|
379
- @added_files[type] = []
379
+ @added_files[type] = {}
380
380
  end
381
381
  end
382
382
 
@@ -397,8 +397,11 @@ module Ramaze
397
397
  def store_group(key, file_group, controller, methods)
398
398
  # Remove all files from the group that have already been loaded.
399
399
  file_group.files.each_with_index do |file, index|
400
- if @added_files.key?(key) and @added_files[key].include?(file)
401
- file_group.files.delete_at(index)
400
+ if @added_files.key?(key)
401
+ if @added_files[key].key?(controller) \
402
+ and @added_files[key][controller].include?(file)
403
+ file_group.files.delete_at(index)
404
+ end
402
405
  end
403
406
  end
404
407
 
@@ -412,7 +415,9 @@ module Ramaze
412
415
  @files[key][controller][m].push(file_group)
413
416
  end
414
417
 
415
- @added_files[key] += file_group.files
418
+ @added_files[key] ||= {}
419
+ @added_files[key][controller] ||= []
420
+ @added_files[key][controller] += file_group.files
416
421
  end
417
422
 
418
423
  ##
@@ -1,5 +1,5 @@
1
1
  module Ramaze
2
2
  module Asset
3
- Version = '0.2.1'
3
+ Version = '0.2.2'
4
4
  end # Asset
5
5
  end # Ramaze
@@ -147,4 +147,52 @@ describe('Ramaze::Asset::Environment') do
147
147
  files.include?('/css/github.css').should === true
148
148
  files.include?('/css/reset.css').should === true
149
149
  end
150
+
151
+ it('Load multiple files for the same controller') do
152
+ SpecEnv.serve(
153
+ :javascript,
154
+ ['js/mootools_core'],
155
+ :controller => SpecEnvironment
156
+ )
157
+
158
+ SpecEnv.serve(
159
+ :javascript,
160
+ ['js/mootools_more'],
161
+ :controller => SpecEnvironment
162
+ )
163
+
164
+ SpecEnv.serve(
165
+ :javascript,
166
+ ['js/mootools_core'],
167
+ :controller => SpecEnvironment2
168
+ )
169
+
170
+ SpecEnv.files[:javascript].keys.include?(:SpecEnvironment).should === true
171
+ SpecEnv.files[:javascript].keys.include?(:SpecEnvironment2).should === true
172
+
173
+ SpecEnv.files[:javascript][:SpecEnvironment][:__all].length.should === 2
174
+ SpecEnv.files[:javascript][:SpecEnvironment2][:__all].length.should === 1
175
+
176
+ body1 = get('/').body
177
+ body2 = get('/2').body
178
+
179
+ body1.should != body2
180
+
181
+ body1.include?('js/mootools_core').should === true
182
+ body1.include?('js/mootools_more').should === true
183
+ body2.include?('js/mootools_core').should === true
184
+ body2.include?('js/mootools_more').should === false
185
+ end
186
+
187
+ it('Files should only be loaded once for the same controller') do
188
+ 3.times do
189
+ SpecEnv.serve(
190
+ :javascript,
191
+ ['js/mootools_core'],
192
+ :controller => SpecEnvironment
193
+ )
194
+ end
195
+
196
+ SpecEnv.files[:javascript][:SpecEnvironment][:__all].length.should === 1
197
+ end
150
198
  end
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.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ramaze
17
- requirement: &2156392100 !ruby/object:Gem::Requirement
17
+ requirement: &2152570740 !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: *2156392100
25
+ version_requirements: *2152570740
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rake
28
- requirement: &2156391580 !ruby/object:Gem::Requirement
28
+ requirement: &2152570220 !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: *2156391580
36
+ version_requirements: *2152570220
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: yard
39
- requirement: &2156391100 !ruby/object:Gem::Requirement
39
+ requirement: &2152569740 !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: *2156391100
47
+ version_requirements: *2152569740
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: bacon
50
- requirement: &2156390620 !ruby/object:Gem::Requirement
50
+ requirement: &2152569260 !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: *2156390620
58
+ version_requirements: *2152569260
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: rdiscount
61
- requirement: &2156390140 !ruby/object:Gem::Requirement
61
+ requirement: &2152568780 !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: *2156390140
69
+ version_requirements: *2152568780
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rack-test
72
- requirement: &2156389660 !ruby/object:Gem::Requirement
72
+ requirement: &2152599780 !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: *2156389660
80
+ version_requirements: *2152599780
81
81
  description: A simple yet powerful asset manager for Ramaze.
82
82
  email: yorickpeterse@gmail.com
83
83
  executables: []