coffee-react 3.0.1 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/coffee_react.rb CHANGED
@@ -7,21 +7,20 @@ module CoffeeReact
7
7
  CompilationError = ExecJS::ProgramError
8
8
 
9
9
  module Source
10
- def self.path
11
- @path ||= File.expand_path('../coffee-react-transform.js', File.dirname(__FILE__))
10
+ def self.path(filename)
11
+ File.expand_path("../#{filename}", File.dirname(__FILE__))
12
12
  end
13
13
 
14
- def self.path=(path)
15
- @contents = @context = nil
16
- @path = path
14
+ def self.context(filename)
15
+ ExecJS.compile(File.read(self.path(filename)))
17
16
  end
18
17
 
19
- def self.contents
20
- @contents ||= File.read(path)
18
+ def self.transform_context
19
+ @transform_context ||= self.context('coffee-react-transform.js')
21
20
  end
22
21
 
23
- def self.context
24
- @context ||= ExecJS.compile(contents)
22
+ def self.jstransform_context
23
+ @jstransform_context ||= self.context('js-syntax-transform.js')
25
24
  end
26
25
  end
27
26
 
@@ -35,7 +34,13 @@ module CoffeeReact
35
34
  def transform(script, options = {})
36
35
  script = script.read if script.respond_to?(:read)
37
36
 
38
- Source.context.call("coffeeReactTransform", script, options)
37
+ Source.transform_context.call("coffeeReactTransform", script, options)
38
+ end
39
+
40
+ def jstransform(script)
41
+ script = script.read if script.respond_to?(:read)
42
+
43
+ Source.jstransform_context.call("coffeeReactJSSyntaxTransform", script)
39
44
  end
40
45
  end
41
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coffee-react
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Friend
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-24 00:00:00.000000000 Z
11
+ date: 2015-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: execjs
@@ -64,6 +64,7 @@ files:
64
64
  - LICENSE
65
65
  - README.md
66
66
  - coffee-react-transform.js
67
+ - js-syntax-transform.js
67
68
  - lib/coffee-react.rb
68
69
  - lib/coffee_react.rb
69
70
  homepage: http://github.com/jsdf/ruby-coffee-react