assette 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/assette.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{assette}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Tal Atlas}]
12
- s.date = %q{2011-12-29}
12
+ s.date = %q{2012-01-02}
13
13
  s.description = %q{Renders all asset types (coffeescript/sass/scss) as equals}
14
14
  s.email = %q{me@tal.by}
15
15
  s.executables = [%q{assette}]
data/lib/assette.rb CHANGED
@@ -28,6 +28,8 @@ module Assette
28
28
  def logger=(l)
29
29
  @logger = l
30
30
  end
31
+
32
+ class CompilationError < StandardError; end;
31
33
  end
32
34
 
33
35
  %w{config reader readers post_processor post_processors
data/lib/assette/file.rb CHANGED
@@ -141,7 +141,7 @@ class Assette::File < ::File
141
141
  if ::File.exist?(p2)
142
142
  p = p2
143
143
  else
144
- raise "Cannot find dependancy #{p} or #{p2} as required in #{path}"
144
+ raise UnknownDependency, "Cannot find dependancy #{p} or #{p2} as required in #{path}"
145
145
  end
146
146
  end
147
147
 
@@ -229,40 +229,46 @@ class Assette::File < ::File
229
229
  return unless File.exist?(path)
230
230
  start = Time.now
231
231
  f = open(path)
232
-
233
- if opts[:deparr]
234
- code = f.path_array
235
-
236
- resp = {:dependencies => code, :target_type => f.target_class.mime_type, :target_extension => f.extension}
237
-
238
- resp[:generation_time] = Time.now-start
232
+ begin
233
+ if opts[:deparr]
234
+ code = f.path_array
235
+
236
+ resp = {:dependencies => code, :target_type => f.target_class.mime_type, :target_extension => f.extension}
237
+
238
+ resp[:generation_time] = Time.now-start
239
+
240
+ return [200,{"Content-Type" => 'application/json'}, [resp.to_json]]
241
+ end
239
242
 
240
- return [200,{"Content-Type" => 'application/json'}, [resp.to_json]]
241
- end
242
-
243
- if opts[:nodep]
244
- code = [f.code]
245
- type = f.target_class.mime_type
246
- elsif opts[:dev]
243
+ if opts[:nodep]
244
+ code = [f.code]
245
+ type = f.target_class.mime_type
246
+ elsif opts[:dev]
247
247
 
248
- code = f.path_array.collect do |path|
249
- path = "http://#{opts[:env]['HTTP_HOST']}#{path}"
250
- f.target_class.include(path)
251
- end
248
+ code = f.path_array.collect do |path|
249
+ path = "http://#{opts[:env]['HTTP_HOST']}#{path}"
250
+ f.target_class.include(path)
251
+ end
252
252
 
253
- type = f.target_class.mime_type
253
+ type = f.target_class.mime_type
254
254
 
255
- else
256
- code = f.all_code_array
257
- type = f.target_class.mime_type
255
+ else
256
+ code = f.all_code_array
257
+ type = f.target_class.mime_type
258
+ end
259
+
260
+ code << "\n"
261
+ code << f.comment_str % "Time taken to generate: #{Time.now-start}s"
262
+
263
+ [200,{"Content-Type" => type.content_type},code]
264
+ rescue Assette::CompilationError => e
265
+ target = f.target_class
266
+ [200,{"Content-Type" => target.mime_type.content_type},target.error(e.to_s,path)]
258
267
  end
259
-
260
- code << "\n"
261
- code << f.comment_str % "Time taken to generate: #{Time.now-start}s"
262
-
263
- [200,{"Content-Type" => type.content_type},code]
264
268
  end
265
269
 
266
270
  end
271
+
272
+ class UnknownDependency < Assette::CompilationError; end
267
273
 
268
274
  end
@@ -91,7 +91,7 @@ module Assette
91
91
 
92
92
  end
93
93
 
94
- class UnknownReader < StandardError; end
94
+ class UnknownReader < CompilationError; end
95
95
  end
96
96
 
97
97
  def self.Reader(type)
@@ -16,6 +16,8 @@ class Assette::Reader::Js < Assette::Reader(:js)
16
16
  else
17
17
  "console.error(#{str.to_json});"
18
18
  end
19
+
20
+ "console.error(#{str.to_json});alert(#{str.inspect.to_json});"
19
21
  end
20
22
 
21
23
  def comment_str
@@ -84,16 +84,18 @@ module Assette
84
84
  return [200,{"Content-Type" => Reader::Js.mime_type.content_type},[set.compile]]
85
85
  end
86
86
 
87
- if has_registered_reader? && (f = find_compiled_file)
88
- f
89
- elsif f = find_file
90
- f
91
- else
92
- possible_paths = Assette.config.file_paths.collect do |p|
93
- File.join(Dir.pwd,p,path)
94
- end
95
-
96
- [404,{"Content-Type" => "text/plain"},["File Not Found\n#{possible_paths.join("\n")}"]]
87
+ begin
88
+ if has_registered_reader? && (f = find_compiled_file)
89
+ f
90
+ elsif f = find_file
91
+ f
92
+ else
93
+ possible_paths = Assette.config.file_paths.collect do |p|
94
+ File.join(Dir.pwd,p,path)
95
+ end
96
+
97
+ [404,{"Content-Type" => "text/plain"},["File Not Found\n#{possible_paths.join("\n")}"]]
98
+ end
97
99
  end
98
100
  end
99
101
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assette
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tal Atlas
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-12-29 00:00:00 Z
18
+ date: 2012-01-02 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  version_requirements: &id001 !ruby/object:Gem::Requirement