es6-rails 0.1.1 → 0.2.0

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: 8988f21ddf9de6fdeb05e2f23b097b92ddbc4c49
4
- data.tar.gz: f08fcd75d1bc70271017f1fc8fe5df13b4d40a55
3
+ metadata.gz: ee000840a43208cf832b0ddbcc865b6ee0e219c4
4
+ data.tar.gz: 6c33e586cf267c831d44e4f60b48a5fe484602b5
5
5
  SHA512:
6
- metadata.gz: 3d57549c719220e61082499940bace7327f9d511de4a73f4303540e824a878be126a8e448e37996c752cf6318dc786ac764f7f4a984b3152ef742624d4b5839f
7
- data.tar.gz: e420a4ab84957a6c43144f11628b58efa5886da3046541009bacb244d69fdbc86d29915b1af1354b8346a254ca3311830546616e0c58175c229e87f158305a35
6
+ metadata.gz: 4bdd6a5d16e857b9dec4bea49c2d1484689a3c27e3f487e013a8a7b8a537cd05b8fd4906c8ba08a9d48b428e8746a4db9795f087a320b508890f47901d6ce3f8
7
+ data.tar.gz: 03b84723a9b2b1aabc8a5321d422ec7676c13a8421c71ccfa00e98cc2d27757d59d598f337554df6bdbc1bb05d416bd199f92c329e97db4fcdf348aaea6a6bfd
data/README.md CHANGED
@@ -1,16 +1,27 @@
1
- # ES6-Rails with Babel
2
- ES6 (EcmaScript 6) adapter for Rails. Use ES6 in the assets, view files and inline.
1
+ # Use ES6 in Rails everywhere
2
+ ES6 (EcmaScript 2015) adapter for Rails. It transpiles all ES6 code to ES5 (JavaScript) using [ruby-babel-transpiler](https://github.com/babel/ruby-babel-transpiler).
3
+
4
+ ## Write ES6 in:
5
+
6
+ - assets
7
+ - views as remote es6 script
8
+ - views as inline html
9
+
10
+ ## Example app
11
+
12
+ [es6-rails-example](https://github.com/es6-rails/es6-rails-example)
3
13
 
4
14
  ## Use
5
- Asset pipeline:
6
- - add ES6 code in `.es6` files
15
+ Assets:
16
+ - add ES6 code as `.es6` files in `/app/assets/javascripts/`
17
+ - use rails generator: `rails g es6:assets my_file`
7
18
 
8
- Views:
9
- - add ES6 code in `.es6` files.
10
- - also use ERB code in the `.es6` file
19
+ ES6 views:
20
+ - add ES6 code as `.es6` files in `/app/views/` (you can include `erb` code too)
21
+
22
+ HTML views:
23
+ - add ES6 code in any HTML(ERB) file in `/app/views/` using: `<%= es6_transform do %> .. es6 code .. <% end %>`
11
24
 
12
- Inline:
13
- - use with: `<%= es6_transform do %> .. es6 code .. <% end %>`
14
25
  E.g.:
15
26
  ```
16
27
  <script>
@@ -22,8 +33,13 @@ E.g.:
22
33
  ```
23
34
 
24
35
  ## Installation
25
- Add the es6-rails to your Gemfile:
36
+
37
+ Add the `es6-rails` to your Gemfile:
26
38
 
27
39
  ~~~ruby
28
40
  gem 'es6-rails'
29
41
  ~~~
42
+
43
+ ## Test
44
+
45
+ - for testing the gem please run the tests in the [es6-rails-example](https://github.com/es6-rails/es6-rails-example) example application with tests all use cases
@@ -3,4 +3,7 @@ require 'sprockets'
3
3
  require 'sprockets/es6'
4
4
  require 'es6/rails/template_handler'
5
5
  require 'es6/rails/inline_handler'
6
+ require 'rails/generators'
7
+ require 'es6/rails/generators/assets_generator'
8
+ require 'es6/rails/railtie'
6
9
  require 'es6/rails/version'
@@ -0,0 +1,11 @@
1
+ module Es6
2
+ module Generators
3
+ class AssetsGenerator < ::Rails::Generators::NamedBase
4
+ source_root File.expand_path("../templates", __FILE__)
5
+
6
+ def copy_es6
7
+ template "javascript.es6", File.join('app/assets/javascripts', class_path, "#{file_name}.es6")
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ module Es6
2
+ module Rails
3
+ module JsHook
4
+ extend ActiveSupport::Concern
5
+ included do
6
+ no_tasks do
7
+ redefine_method :js_template do |source, destination|
8
+ template(source + '.es6', destination + '.es6')
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,22 @@
1
+ require 'rails/engine'
2
+ require 'rails/generators'
3
+ require 'es6/rails/js_hook'
4
+ require 'rails/railtie'
5
+
6
+ module Es6
7
+ module Rails
8
+ class Railtie < ::Rails::Railtie
9
+ config.app_generators.javascript_engine :es6
10
+
11
+ if config.respond_to?(:annotations)
12
+ config.annotations.register_extensions("es6") { |annotation| /#\s*(#{annotation}):?\s*(.*)$/ }
13
+ end
14
+
15
+ initializer 'override js_template hook' do |app|
16
+ if app.config.generators.rails[:javascript_engine] == :es6
17
+ ::Rails::Generators::NamedBase.send :include, Es6::Rails::JsHook
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,5 +1,5 @@
1
1
  module Es6
2
2
  module Rails
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: es6-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cristian Dugacicu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-19 00:00:00.000000000 Z
11
+ date: 2016-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -96,12 +96,14 @@ executables: []
96
96
  extensions: []
97
97
  extra_rdoc_files: []
98
98
  files:
99
- - ".gitignore"
100
99
  - LICENSE.txt
101
100
  - README.md
102
- - es6-rails.gemspec
103
101
  - lib/es6-rails.rb
102
+ - lib/es6/rails/generators/assets_generator.rb
103
+ - lib/es6/rails/generators/templates/javascript.es6
104
104
  - lib/es6/rails/inline_handler.rb
105
+ - lib/es6/rails/js_hook.rb
106
+ - lib/es6/rails/railtie.rb
105
107
  - lib/es6/rails/template_handler.rb
106
108
  - lib/es6/rails/version.rb
107
109
  homepage: https://github.com/es6-rails/es6-rails
@@ -124,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
126
  version: '0'
125
127
  requirements: []
126
128
  rubyforge_project:
127
- rubygems_version: 2.4.6
129
+ rubygems_version: 2.5.1
128
130
  signing_key:
129
131
  specification_version: 4
130
132
  summary: ES6 adapter for Rails
data/.gitignore DELETED
@@ -1 +0,0 @@
1
- *.gem
@@ -1,27 +0,0 @@
1
- lib = File.expand_path('../lib', __FILE__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require "es6/rails/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = 'es6-rails'
7
- s.version = Es6::Rails::VERSION
8
- s.date = '2015-10-19'
9
- s.summary = "ES6 adapter for Rails"
10
- s.description = "Enables use of ES6 in assets, views and inline."
11
- s.files = `git ls-files`.split($/)
12
- 'http://rubygems.org'
13
- s.homepage = "https://github.com/es6-rails/es6-rails"
14
- s.license = 'MIT'
15
-
16
- s.require_paths = ["lib"]
17
- s.required_ruby_version = '>= 2.0.0'
18
-
19
- s.add_dependency 'rails', '>= 4.0', '< 5.0'
20
- s.add_dependency 'babel-transpiler', '~> 0.7', '>= 0.7.0'
21
- s.add_dependency 'sprockets', '~> 3.0', '>= 3.0.0'
22
- s.add_dependency 'sprockets-es6', '~> 0.8', '>= 0.8.1'
23
-
24
- s.authors = ["Cristian Dugacicu"]
25
- s.email = 'razorcd@yahoo.com'
26
- end
27
-