react-jsx 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +20 -0
  3. data/README.md +44 -0
  4. data/lib/react/jsx.rb +16 -8
  5. metadata +4 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5736e42794e08f9a22f83f3ccf886ae9cce0837d
4
- data.tar.gz: c1bcc4da145913111408b01443d82d80c5d39342
3
+ metadata.gz: 3fecd6a94e53fed4a41434569e8f60f9c9e2ecce
4
+ data.tar.gz: 27db4fbe57d62863742dbd35e2e1a88eb93b8e0e
5
5
  SHA512:
6
- metadata.gz: 2891d75b2472780c91c4642e6e5905cd724e5827dd3b7cae4161d51b852a9c581fffa3cf124ee341c177d7c8b639cb7f9c12004323a5d9405676677ce458ea05
7
- data.tar.gz: 7b00a916fa7eb0ba313fef8e77866e7797df39048eea89da18552f94911ee08d5de2c2e694f9ac3bef60fee18a32456de9b159f7d37999a492d667b322399dc4
6
+ metadata.gz: d0ef315852219ddfc9d37921ea0f6f7ce11939afb760b5fe17eb8fef905928bb6f7306f24d0eef0b7b3bdca358afaab98977bbe39c9d98a32973f59bcee21f22
7
+ data.tar.gz: b7b3000195b39fe8267fc53344c276d12e513e0be84066e6cd9267e9bcf98b0c459884ce1c8cccf7e6fce3a022a25d336d0a817198feba5cef7dc24372e3cb09
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Alexey Demin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,44 @@
1
+ [![Gem Version](https://badge.fury.io/rb/react-jsx.png)](http://badge.fury.io/rb/react-jsx) [![Build Status](https://secure.travis-ci.org/ademin/react-jsx.png)](http://travis-ci.org/ademin/react-jsx) [![Code Climate](https://codeclimate.com/github/ademin/react-jsx.png)](https://codeclimate.com/github/ademin/react-jsx) [![Coverage Status](https://coveralls.io/repos/ademin/react-jsx/badge.png)](https://coveralls.io/r/ademin/react-jsx) [![Dependency Status](https://gemnasium.com/ademin/react-jsx.png)](https://gemnasium.com/ademin/react-jsx)
2
+
3
+ ***
4
+
5
+ # Ruby React JSX Compiler
6
+
7
+ Ruby React JSX Compiler is a bridge to the official React JSX compiler
8
+
9
+ (Please, refer to http://facebook.github.io/react/docs/getting-started.html for more details)
10
+
11
+ ## Installation
12
+
13
+ Run the command below to install the gem:
14
+
15
+ gem install react-jsx
16
+
17
+ or add the line below to your Gemfile:
18
+
19
+ gem 'react-jsx', require: 'react/jsx'
20
+
21
+ ## Usage
22
+
23
+ require 'react/jsx'
24
+
25
+ # Some JSX code
26
+ jsx = <<-EOF
27
+ /** @jsx React.DOM */
28
+ React.renderComponent(
29
+ <h1>Hello, world!</h1>,
30
+ document.getElementById('example')
31
+ );
32
+ EOF
33
+
34
+ js = React::JSX.compile(jsx)
35
+
36
+ ## React sources
37
+
38
+ This library depends on the `react-source` gem which is updated any time a new version of React is released.
39
+
40
+ (Please, refer to https://github.com/facebook/react for more details)
41
+
42
+ # License
43
+
44
+ Copyright &#169; 2013 Alexey Demin, MIT License
@@ -3,20 +3,14 @@ require 'react/source'
3
3
 
4
4
  module React
5
5
  module JSX
6
- def self.compile(code)
7
- if rubyracer?
8
- context.transform(code)['code']
9
- else
10
- context.call('JSXTransformer.transform', code)['code']
11
- end
12
- end
13
-
14
6
  def self.context
15
7
  unless @context
16
8
  content = File.read(React::Source.bundled_path_for('JSXTransformer.js'))
17
9
 
18
10
  @context = if rubyracer?
19
11
  V8::Context.new.eval("module={}; exports={}; #{content}; module.exports")
12
+ elsif rubyrhino?
13
+ Rhino::Context.new.eval("module={}; exports={}; #{content}; module.exports")
20
14
  else
21
15
  ExecJS.compile(content)
22
16
  end
@@ -27,6 +21,20 @@ module React
27
21
  def self.rubyracer?
28
22
  ExecJS.runtime == ExecJS::Runtimes::RubyRacer
29
23
  end
24
+
25
+ def self.rubyrhino?
26
+ ExecJS.runtime == ExecJS::Runtimes::RubyRhino
27
+ end
28
+
29
+ def self.compile(code)
30
+ if rubyracer?
31
+ context.transform(code)['code']
32
+ elsif rubyrhino?
33
+ context['transform'].new(code)['code']
34
+ else
35
+ context.call('JSXTransformer.transform', code)['code']
36
+ end
37
+ end
30
38
  end
31
39
  end
32
40
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: react-jsx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Demin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-18 00:00:00.000000000 Z
11
+ date: 2013-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -101,6 +101,8 @@ extensions: []
101
101
  extra_rdoc_files: []
102
102
  files:
103
103
  - lib/react/jsx.rb
104
+ - LICENSE
105
+ - README.md
104
106
  homepage: https://github.com/ademin/react-jsx
105
107
  licenses:
106
108
  - MIT