sprockets-coffee-react 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e5e6dc4bee9ac2e5d107c5eb7ddd599c1bb81cf
4
- data.tar.gz: 9055ab88079631adde0b3a3c01724518261bef52
3
+ metadata.gz: 3bce05a34bf725bd3bb9bf8f56866faddf0e9115
4
+ data.tar.gz: 9562cf8a2086ca20572b3392b7fa6d0a6f90373a
5
5
  SHA512:
6
- metadata.gz: acc8cb64bb203667bae90f0860ff815a3ca6351c53c34de2cfc4b8093efd8f975cf12925f0113407b21a74a40486ee927ce629a133019daff92fff124466eed1
7
- data.tar.gz: 7a0a294896bd3483a61a200564f9efb9887afe93240f9b2982b887e5c50af76498c3d05981e6099f78cfe4f897c8e1c82b2166e54cc4e02b5aceb7ef876d778a
6
+ metadata.gz: d4cbef8ce973419054289cfb79bf2b22d030a65393638e46cf071b2d829b4bddca701e7085a87c73e2026b75d42ddc358d1f274056de8db14fe01bee02eaf202
7
+ data.tar.gz: c2895a7d23de48da3d380151e26104cdf6fb2a033f9d930a890f57c75fbf127e17a217653ad5ea468c07fda22703709702c7d1f1c4204457acc9817c61fda012
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2013 James Friend <james@jsdf.co>
1
+ Copyright 2014 James Friend <james@jsdf.co>
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -6,16 +6,16 @@ Add this to your Gemfile:
6
6
 
7
7
  gem 'sprockets-coffee-react'
8
8
 
9
- Place a <tt>.js.coffee.cjsx</tt> or a <tt>.js.coffee</tt> file with a <tt>@cjsx</tt> pragma in your assets directory.
9
+ Place a <tt>.js.coffee.cjsx</tt> or <tt>.js.cjsx</tt> (or a <tt>.js.coffee</tt> file with a
10
+ <tt>@cjsx</tt> pragma) in your assets directory.
10
11
 
11
- Require within your <tt>application.js</tt> or somewhere else:
12
+ Eg. if you have a file called <tt>my-component.js.coffee</tt> which contains
13
+ some CJSX code, require it from <tt>application.js</tt> or somewhere else:
12
14
 
13
- //
14
15
  //= require my-component
15
- //
16
-
17
- Done.
18
16
 
17
+ It it will be automatically transformed to Coffeescript, then compiled to
18
+ Javascript.
19
19
 
20
20
  == License
21
21
 
@@ -1,3 +1,4 @@
1
+ require 'sprockets'
1
2
  require 'sprockets/coffee-react'
2
3
 
3
4
  if defined?(Rails)
@@ -6,6 +7,18 @@ if defined?(Rails)
6
7
  class Engine < ::Rails::Engine
7
8
  initializer :setup_coffee_react, :after => "sprockets.environment", :group => :all do |app|
8
9
  app.assets.register_preprocessor 'application/javascript', Sprockets::CoffeeReact
10
+
11
+ # unless app.assets.engines['.coffee']
12
+ # if defined?(Sprockets::CoffeeScriptTemplate)
13
+ # app.assets.register_engine '.coffee', Sprockets::CoffeeScriptTemplate
14
+ # else
15
+ # app.assets.register_engine '.coffee', Tilt::CoffeeScriptTemplate
16
+ # end
17
+ # end
18
+
19
+ # app.assets.register_preprocessor '.coffee', Sprockets::CoffeeReact
20
+ app.assets.register_engine '.cjsx', Sprockets::CoffeeReactScript
21
+ app.assets.register_engine '.js.cjsx', Sprockets::CoffeeReactScript
9
22
  end
10
23
  end
11
24
  end
@@ -0,0 +1,27 @@
1
+ require 'sprockets'
2
+ require 'tilt'
3
+ require 'coffee-react'
4
+ require 'coffee_script'
5
+
6
+ module Sprockets
7
+ # Preprocessor that runs CJSX source files through coffee-react-transform
8
+ # then compiles with coffee-script
9
+ class CoffeeReactScript < Tilt::Template
10
+ CJSX_EXTENSION = /\.cjsx[^\/]*?$/
11
+ CJSX_PRAGMA = /^\s*#[ \t]*@cjsx/i
12
+
13
+ def prepare
14
+ end
15
+
16
+ def evaluate(scope, locals, &block)
17
+ if scope.pathname.to_s =~ /js\.coffee\.cjsx/
18
+ ::CoffeeReact.transform(data)
19
+ elsif scope.pathname.to_s =~ CJSX_EXTENSION || data =~ CJSX_PRAGMA
20
+ ::CoffeeScript.compile(::CoffeeReact.transform(data))
21
+ else
22
+ data
23
+ end
24
+ end
25
+
26
+ end
27
+ end
@@ -1,2 +1,3 @@
1
1
  require 'sprockets/coffee-react'
2
+ require 'sprockets/coffee-react-script'
2
3
  require 'sprockets/coffee-react/engine'
metadata CHANGED
@@ -1,49 +1,77 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-coffee-react
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Friend
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-30 00:00:00.000000000 Z
11
+ date: 2014-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: sprockets
14
+ name: coffee-react
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.1'
19
+ version: '0.4'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.4.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: '2.1'
29
+ version: '0.4'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.4.0
27
33
  - !ruby/object:Gem::Dependency
28
- name: coffee-react
34
+ name: coffee-script
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - "~>"
37
+ - - ">="
32
38
  - !ruby/object:Gem::Version
33
- version: '0.4'
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
34
44
  - - ">="
35
45
  - !ruby/object:Gem::Version
36
- version: 0.4.0
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: tilt
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
37
54
  type: :runtime
38
55
  prerelease: false
39
56
  version_requirements: !ruby/object:Gem::Requirement
40
57
  requirements:
41
- - - "~>"
58
+ - - ">="
42
59
  - !ruby/object:Gem::Version
43
- version: '0.4'
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: sprockets
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
44
65
  - - ">="
45
66
  - !ruby/object:Gem::Version
46
- version: 0.4.0
67
+ version: '0'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
47
75
  description: " Preprocessor for Coffeescript with React JSX (CJSX). \n This
48
76
  gem makes it easy to integrate this into the Rails asset pipeline or other Sprockets
49
77
  chains.\n If you want to use CJSX without Sprockets, see the coffee-react gem,
@@ -57,6 +85,7 @@ files:
57
85
  - README.rdoc
58
86
  - Rakefile
59
87
  - lib/sprockets-coffee-react.rb
88
+ - lib/sprockets/coffee-react-script.rb
60
89
  - lib/sprockets/coffee-react.rb
61
90
  - lib/sprockets/coffee-react/engine.rb
62
91
  - lib/tasks/sprockets-coffee-react_tasks.rake