coffee-processing 0.0.3 → 0.0.4

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.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ 0.0.4
2
+ =====
3
+ - Correctly adjusts line number in parse error message
4
+
1
5
  0.0.3
2
6
  =====
3
7
  - Constants (e.g. `P3D`, `RGB`) are now directly accessible without `processing` variable or shortcut methods.
@@ -1,3 +1,3 @@
1
1
  module CoffeeProcessing
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -13,15 +13,24 @@ module CoffeeProcessing
13
13
  code = code.lines.map { |line| "#{line} " }.join
14
14
  code = code.strip
15
15
 
16
- CoffeeScript.compile(
17
- Erubis::Eruby.new(
18
- File.read File.join(
19
- File.dirname(__FILE__),
20
- 'coffee-processing',
21
- 'boilerplate.coffee.erb'
22
- )
23
- ).result(binding)
24
- )
16
+ begin
17
+ CoffeeScript.compile(
18
+ Erubis::Eruby.new(
19
+ File.read File.join(
20
+ File.dirname(__FILE__),
21
+ 'coffee-processing',
22
+ 'boilerplate.coffee.erb'
23
+ )
24
+ ).result(binding)
25
+ )
26
+ rescue ExecJS::ProgramError => e
27
+ message = e.message
28
+ if match = message.match(/line ([1-9][0-9]*):/)
29
+ range = Range.new(*match.offset(1), true)
30
+ message[ range ] = (match[1].to_i - 15).to_s
31
+ end
32
+ raise e, message, e.backtrace
33
+ end
25
34
  end
26
35
 
27
36
  def self.generate_template_page javascript_object, code, output_dir
@@ -36,8 +36,11 @@ draw = ->
36
36
  end
37
37
 
38
38
  def test_error
39
- pend('Need to adjust line number (-8) in exception message') do
40
- CoffeeProcessing.compile 'this.sketch', '-> = ->'
39
+ begin
40
+ CoffeeProcessing.compile 'this.sketch', %w[1 2 3 ? 5].join($/)
41
+ assert false, 'Exception should have been raised'
42
+ rescue ExecJS::ProgramError => e
43
+ assert e.to_s =~ /line 4:/, 'Unadjusted line number'
41
44
  end
42
45
  end
43
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coffee-processing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-20 00:00:00.000000000 Z
12
+ date: 2012-05-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: coffee-script