sprockets-traceur 0.0.1

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.
Files changed (76) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +22 -0
  3. data/.rspec +1 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +6 -0
  7. data/Guardfile +5 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +75 -0
  10. data/Rakefile +2 -0
  11. data/lib/sprockets-traceur.rb +1 -0
  12. data/lib/sprockets/traceur.rb +46 -0
  13. data/lib/sprockets/traceur/version.rb +5 -0
  14. data/spec/rails4/Gemfile +6 -0
  15. data/spec/rails4/README.rdoc +28 -0
  16. data/spec/rails4/Rakefile +6 -0
  17. data/spec/rails4/app/assets/images/.keep +0 -0
  18. data/spec/rails4/app/assets/javascripts/application.js +4 -0
  19. data/spec/rails4/app/assets/javascripts/bind_polyfill.js +24 -0
  20. data/spec/rails4/app/assets/javascripts/init.js.next +7 -0
  21. data/spec/rails4/app/assets/javascripts/my_app/greeter.js.next +9 -0
  22. data/spec/rails4/app/assets/stylesheets/application.css +15 -0
  23. data/spec/rails4/app/controllers/application_controller.rb +5 -0
  24. data/spec/rails4/app/controllers/concerns/.keep +0 -0
  25. data/spec/rails4/app/controllers/welcome_controller.rb +4 -0
  26. data/spec/rails4/app/helpers/application_helper.rb +2 -0
  27. data/spec/rails4/app/mailers/.keep +0 -0
  28. data/spec/rails4/app/models/.keep +0 -0
  29. data/spec/rails4/app/models/concerns/.keep +0 -0
  30. data/spec/rails4/app/views/layouts/application.html.erb +14 -0
  31. data/spec/rails4/app/views/welcome/index.html.erb +1 -0
  32. data/spec/rails4/bin/bundle +3 -0
  33. data/spec/rails4/bin/rails +4 -0
  34. data/spec/rails4/bin/rake +4 -0
  35. data/spec/rails4/config.ru +4 -0
  36. data/spec/rails4/config/application.rb +30 -0
  37. data/spec/rails4/config/boot.rb +4 -0
  38. data/spec/rails4/config/environment.rb +5 -0
  39. data/spec/rails4/config/environments/development.rb +34 -0
  40. data/spec/rails4/config/environments/production.rb +80 -0
  41. data/spec/rails4/config/environments/test.rb +39 -0
  42. data/spec/rails4/config/initializers/backtrace_silencers.rb +7 -0
  43. data/spec/rails4/config/initializers/cookies_serializer.rb +3 -0
  44. data/spec/rails4/config/initializers/filter_parameter_logging.rb +4 -0
  45. data/spec/rails4/config/initializers/inflections.rb +16 -0
  46. data/spec/rails4/config/initializers/mime_types.rb +4 -0
  47. data/spec/rails4/config/initializers/session_store.rb +3 -0
  48. data/spec/rails4/config/initializers/wrap_parameters.rb +9 -0
  49. data/spec/rails4/config/locales/en.yml +23 -0
  50. data/spec/rails4/config/routes.rb +3 -0
  51. data/spec/rails4/config/secrets.yml +22 -0
  52. data/spec/rails4/db/seeds.rb +7 -0
  53. data/spec/rails4/lib/assets/.keep +0 -0
  54. data/spec/rails4/lib/tasks/.keep +0 -0
  55. data/spec/rails4/log/.keep +0 -0
  56. data/spec/rails4/log/development.log +58 -0
  57. data/spec/rails4/log/test.log +6 -0
  58. data/spec/rails4/public/404.html +67 -0
  59. data/spec/rails4/public/422.html +67 -0
  60. data/spec/rails4/public/500.html +66 -0
  61. data/spec/rails4/public/favicon.ico +0 -0
  62. data/spec/rails4/public/robots.txt +5 -0
  63. data/spec/rails4/vendor/assets/javascripts/.keep +0 -0
  64. data/spec/rails4/vendor/assets/stylesheets/.keep +0 -0
  65. data/spec/rails_integration_spec.rb +13 -0
  66. data/spec/sinatra/app.rb +24 -0
  67. data/spec/sinatra/config.ru +3 -0
  68. data/spec/sinatra/js/application.js +4 -0
  69. data/spec/sinatra/js/bind_polyfill.js +24 -0
  70. data/spec/sinatra/js/init.js.next +7 -0
  71. data/spec/sinatra/js/my_app/greeter.js.next +9 -0
  72. data/spec/sinatra/sinatra_integration_spec.rb +13 -0
  73. data/spec/sinatra/views/index.erb +9 -0
  74. data/spec/spec_helper.rb +5 -0
  75. data/sprockets-traceur.gemspec +33 -0
  76. metadata +319 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NzZhOGQ3ZDUwNDAxNGNjNWYxZTEyNWI3MTBiOGI0NjE0NzQ3NDc1MQ==
5
+ data.tar.gz: !binary |-
6
+ NDI3MGFkODhiNGE4YWQyMTAzMTYyMWJlNWJlNmUyOTU3MTk3YzVhMA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ OTJkMzI1YjY4ZWIwOGRmYmE5MDk3NzVlZWFkYWM3YTJmNDU2ZDk4YWQ2OThj
10
+ ZjNlMmIxZjllODFlOGQ3NmJjYzVhMjBlZDM5ODkzMzhiMjBmMGNjMjBjYjBi
11
+ NjgzNzE4ZGNiMTRmZTZlNjcwZmNkYWMwMDdlYjgwMTNjZGMxOTA=
12
+ data.tar.gz: !binary |-
13
+ ZDc2NTI2OGEwZmIxOTY3MDgyOTAyNDM1MmY3MmM1ODgxYWI3OGU0ZmFkOTQ0
14
+ ODkwN2QyZDA4ZmExMTNiMmM5ZDVmZDkzYjU4NDBhMzYyNGNiMGZjNThkM2My
15
+ MWUyZjNiNWRiM2RiMTNiZTk5NTgwMDFlOGIxNWVhNTRjZWY5NWM=
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ traceur
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sprockets-traceur.gemspec
4
+ gemspec
5
+
6
+ # gem "traceur-rb", path: "../traceur-rb"
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard :rspec do
2
+ watch(%r{^spec/.+\.rb$}) { "spec" }
3
+ watch(%r{^lib/(.+)\.rb$}) { "spec" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Adam Pohorecki
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # Sprockets::Traceur
2
+
3
+ This gem integrates [traceur-rb](https://github.com/gunpowderlabs/traceur-rb) with Sprockets (and through Sprockets, with Rails Asset Pipeline).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'sprockets-traceur'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install sprockets-traceur
18
+
19
+ ## Usage with Rails
20
+
21
+ 1. Add `sprockets-traceur` to your Gemfile.
22
+ 2. Add the following line in `app/assets/javascripts/application.js`:
23
+
24
+ ```javascript
25
+ //= require traceur-runtime
26
+ ```
27
+
28
+ 3. Add `.js.es6` or `.js.next` extension to the files you wish to have transipled.
29
+ 4. Profit!
30
+
31
+ ## Usage with Sinatra/Rack
32
+
33
+ 1. Add `sprockets-traceur` to your Gemfile.
34
+ 2. Configure Rack to use Sprockets (in `config.ru`):
35
+
36
+ ```ruby
37
+ require "my_rack_application"
38
+
39
+ map "/assets" do
40
+ root = File.dirname(__FILE__)
41
+ environment = Sprockets::Environment.new
42
+ environment.append_path root + '/assets/javascripts'
43
+ environment.append_path root + '/assets/stylesheets'
44
+ run environment
45
+ end
46
+
47
+ map "/" do
48
+ run MyRackApplication
49
+ end
50
+ ```
51
+
52
+ 3. Add `.js.es6` or `.js.next` extension to the files you wish to have transipled.
53
+ 4. Add the following line in `assets/javascripts/application.js`:
54
+
55
+ ```javascript
56
+ //= require traceur-runtime
57
+ ```
58
+
59
+ 5. Reference the JS files in your views
60
+
61
+ ```html
62
+ <!-- /assets/application.js
63
+ maps to /assets/javascripts/application.js[.next|.es6] -->
64
+ <script type="text/javascript" src="/assets/application.js"></script>
65
+ ```
66
+
67
+ 6. Profit!
68
+
69
+ ## Contributing
70
+
71
+ 1. Fork it ( https://github.com/[my-github-username]/sprockets-traceur/fork )
72
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
73
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
74
+ 4. Push to the branch (`git push origin my-new-feature`)
75
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1 @@
1
+ require "sprockets/traceur"
@@ -0,0 +1,46 @@
1
+ require "sprockets"
2
+ require "sprockets/traceur/version"
3
+ require "traceur-rb"
4
+
5
+ module Sprockets
6
+ module Traceur
7
+ class Template < Tilt::Template
8
+ self.default_mime_type = 'application/javascript'
9
+
10
+ def self.engine_initialized?
11
+ true
12
+ end
13
+
14
+ def initialize_engine
15
+ end
16
+
17
+ def prepare
18
+ end
19
+
20
+ def evaluate(scope, locals, &block)
21
+ name = module_name(scope)
22
+ ::Traceur.compile(data, module_name: name, filename: name)
23
+ end
24
+
25
+ private
26
+
27
+ def module_name(scope)
28
+ asset_paths = scope.environment.paths
29
+ asset_paths.each do |path|
30
+ if file.start_with?(path)
31
+ return basename(file.gsub(path, ''))
32
+ end
33
+ end
34
+ basename(file)
35
+ end
36
+
37
+ def basename(file)
38
+ file.gsub(/\.[^\/]+$/, '').gsub(/^\//, '')
39
+ end
40
+ end
41
+ end
42
+
43
+ register_engine '.next', Traceur::Template
44
+ register_engine '.es6', Traceur::Template
45
+ append_path ::Traceur.assets_path
46
+ end
@@ -0,0 +1,5 @@
1
+ module Sprockets
2
+ module Traceur
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
4
+ gem 'rails', '4.1.1'
5
+ gem 'sprockets-traceur', path: '../..'
6
+ gem 'traceur-rb', path: '../../../traceur-rb'
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
File without changes
@@ -0,0 +1,4 @@
1
+ //= require bind_polyfill
2
+ //= require traceur-runtime
3
+ //= require my_app/greeter
4
+ //= require init
@@ -0,0 +1,24 @@
1
+ if (!Function.prototype.bind) {
2
+ Function.prototype.bind = function (oThis) {
3
+ if (typeof this !== "function") {
4
+ // closest thing possible to the ECMAScript 5
5
+ // internal IsCallable function
6
+ throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
7
+ }
8
+
9
+ var aArgs = Array.prototype.slice.call(arguments, 1),
10
+ fToBind = this,
11
+ fNOP = function () {},
12
+ fBound = function () {
13
+ return fToBind.apply(this instanceof fNOP && oThis
14
+ ? this
15
+ : oThis,
16
+ aArgs.concat(Array.prototype.slice.call(arguments)));
17
+ };
18
+
19
+ fNOP.prototype = this.prototype;
20
+ fBound.prototype = new fNOP();
21
+
22
+ return fBound;
23
+ };
24
+ }
@@ -0,0 +1,7 @@
1
+ import {Greeter} from './my_app/greeter';
2
+
3
+ window.onload = function() {
4
+ var greeter = new Greeter("Hello");
5
+ var greeting = greeter.greet("World");
6
+ document.getElementById("hello").innerHTML = greeting;
7
+ };
@@ -0,0 +1,9 @@
1
+ export class Greeter {
2
+ constructor(greeting) {
3
+ this.greeting = greeting;
4
+ }
5
+
6
+ greet(name) {
7
+ return `${this.greeting}, ${name}!`;
8
+ }
9
+ }
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
File without changes
@@ -0,0 +1,4 @@
1
+ class WelcomeController < ApplicationController
2
+ def index
3
+ end
4
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>TraceurTest</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1 @@
1
+ <h1 id="hello">This should get replaced by JavaScript.</h1>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,30 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ # Pick the frameworks you want:
4
+ require "active_model/railtie"
5
+ # require "active_record/railtie"
6
+ require "action_controller/railtie"
7
+ require "action_mailer/railtie"
8
+ require "action_view/railtie"
9
+ require "sprockets/railtie"
10
+ # require "rails/test_unit/railtie"
11
+
12
+ # Require the gems listed in Gemfile, including any gems
13
+ # you've limited to :test, :development, or :production.
14
+ Bundler.require(*Rails.groups)
15
+
16
+ module TraceurTest
17
+ class Application < Rails::Application
18
+ # Settings in config/environments/* take precedence over those specified here.
19
+ # Application configuration should go into files in config/initializers
20
+ # -- all .rb files in that directory are automatically loaded.
21
+
22
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
23
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
24
+ # config.time_zone = 'Central Time (US & Canada)'
25
+
26
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
27
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
28
+ # config.i18n.default_locale = :de
29
+ end
30
+ end