hsume2-browserify-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +25 -0
  3. data/.travis.yml +1 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +75 -0
  7. data/Rakefile +27 -0
  8. data/browserify-rails.gemspec +26 -0
  9. data/lib/browserify-rails/directive_processor.rb +70 -0
  10. data/lib/browserify-rails/railtie.rb +13 -0
  11. data/lib/browserify-rails/tasks/npm.rake +20 -0
  12. data/lib/browserify-rails/version.rb +3 -0
  13. data/lib/browserify-rails.rb +8 -0
  14. data/test/compilation_test.rb +38 -0
  15. data/test/dummy/Rakefile +7 -0
  16. data/test/dummy/app/assets/javascripts/application.js.example +1 -0
  17. data/test/dummy/app/assets/javascripts/foo.js.example +1 -0
  18. data/test/dummy/app/assets/stylesheets/application.css +7 -0
  19. data/test/dummy/app/controllers/application_controller.rb +3 -0
  20. data/test/dummy/app/controllers/home_controller.rb +5 -0
  21. data/test/dummy/app/helpers/application_helper.rb +2 -0
  22. data/test/dummy/app/helpers/home_helper.rb +2 -0
  23. data/test/dummy/app/mailers/.gitkeep +0 -0
  24. data/test/dummy/app/models/.gitkeep +0 -0
  25. data/test/dummy/app/views/home/index.html.erb +2 -0
  26. data/test/dummy/app/views/layouts/application.html.erb +15 -0
  27. data/test/dummy/config/application.rb +44 -0
  28. data/test/dummy/config/boot.rb +10 -0
  29. data/test/dummy/config/database.yml +25 -0
  30. data/test/dummy/config/environment.rb +5 -0
  31. data/test/dummy/config/environments/development.rb +27 -0
  32. data/test/dummy/config/environments/production.rb +54 -0
  33. data/test/dummy/config/environments/test.rb +39 -0
  34. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  35. data/test/dummy/config/initializers/inflections.rb +10 -0
  36. data/test/dummy/config/initializers/mime_types.rb +5 -0
  37. data/test/dummy/config/initializers/secret_token.rb +7 -0
  38. data/test/dummy/config/initializers/session_store.rb +8 -0
  39. data/test/dummy/config/initializers/wrap_parameters.rb +12 -0
  40. data/test/dummy/config/locales/en.yml +5 -0
  41. data/test/dummy/config/routes.rb +60 -0
  42. data/test/dummy/config.ru +4 -0
  43. data/test/dummy/package.json +13 -0
  44. data/test/dummy/public/404.html +26 -0
  45. data/test/dummy/public/422.html +26 -0
  46. data/test/dummy/public/500.html +26 -0
  47. data/test/dummy/public/favicon.ico +0 -0
  48. data/test/dummy/script/rails +6 -0
  49. data/test/test_helper.rb +14 -0
  50. metadata +184 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 469695df5508ae4f129ba905b0735f0926e54056
4
+ data.tar.gz: 507fde818f2e615d2eaa38b4175d7496aa177368
5
+ SHA512:
6
+ metadata.gz: 6d78c3dcb29c3882b5eccb993401b643945fbe9c94c82288ca5a3fbdbb7659382f1f832643b9ec9e87ad76cafd5a94294ce89451db43b9ef3cb33d817e638c61
7
+ data.tar.gz: 0c3406fb50d87677e2d623a8a418a6163fce0cd62279a42e66a6ea5ff86737208359d11f2d1da170817719d82077dc0d4d7e5f5f292ee08c8063aaeb9a012ffd
data/.gitignore ADDED
@@ -0,0 +1,25 @@
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
+ test/dummy/data
18
+ test/dummy/db/*.sqlite3
19
+ test/dummy/log/*
20
+ test/dummy/node_modules
21
+ test/dummy/public/assets
22
+ test/dummy/public/system
23
+ test/dummy/db/schema.rb
24
+ tmp
25
+ test/dummy/app/assets/javascripts/*.js
data/.travis.yml ADDED
@@ -0,0 +1 @@
1
+ language: ruby
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in browserify-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Henry Hsu
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
+ # browserify-rails
2
+
3
+ [![Build Status](https://travis-ci.org/hsume2/browserify-rails.png?branch=master)](https://travis-ci.org/hsume2/browserify-rails)
4
+
5
+ This library adds CommonJS module support to Sprockets (via Browserify).
6
+
7
+ It let's you mix and match `//= require` directives and `require()` calls for including plain javascript files as well as modules.
8
+
9
+ 1. Manage JS modules with `npm`
10
+ 2. Serve assets with Sprockets
11
+ 3. Require modules with `require()` (without separate `//= require` directives)
12
+ 4. Only build required modules
13
+
14
+ ## Getting Started
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ gem 'hsume2-browserify-rails'
19
+
20
+ Create `package.json` in your Rails root:
21
+
22
+ ```js
23
+ {
24
+ "name": "something",
25
+ "devDependencies" : {
26
+ "browserify": "2.13.x",
27
+ "module-deps": "1.7.x"
28
+ },
29
+ "license": "MIT",
30
+ "engines": {
31
+ "node": ">= 0.6"
32
+ }
33
+ }
34
+ ```
35
+ [TODO: Write a Rails generator for this]
36
+
37
+ Then run:
38
+
39
+ npm install
40
+
41
+ Then start writing CommonJS, and everything will magically work!:
42
+
43
+ ```js
44
+ // foo.js
45
+ module.exports = function (n) { return n * 11 }
46
+
47
+ // application.js
48
+ var foo = require('./foo');
49
+ console.log(foo(12));
50
+ ```
51
+
52
+ ## Coffeescript
53
+ If you want to use coffeescript files, add coffeeify as a dependency on `package.json`:
54
+ ```js
55
+ {
56
+ "name": "something",
57
+ "devDependencies" : {
58
+ "browserify": "2.13.x"
59
+ "coffeeify": "0.6.x"
60
+ },
61
+ "license": "MIT",
62
+ "engines": {
63
+ "node": ">= 0.6"
64
+ }
65
+ }
66
+ ```
67
+
68
+ ## Contributing
69
+
70
+ Pull requests appreciated.
71
+
72
+ ## Contributors
73
+
74
+ * [Henry Hsu](https://github.com/hsume2)
75
+ * [Cássio Souza](https://github.com/cassiozen)
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new(:test) do |t|
6
+ t.libs << 'lib'
7
+ t.libs << 'test'
8
+ t.pattern = 'test/**/*_test.rb'
9
+ t.verbose = false
10
+ end
11
+
12
+ namespace :dummy do
13
+ namespace :npm do
14
+ desc "Run npm install for dummy app"
15
+ task :install do
16
+ dummy_dir = Bundler.root.join 'test/dummy'
17
+
18
+ sh "cd #{dummy_dir} && npm install" do |ok, res|
19
+ fail "Error running npm install in #{dummy_dir}." unless ok
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ task :test => ['dummy:npm:install']
26
+
27
+ task :default => :test
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'browserify-rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "hsume2-browserify-rails"
8
+ spec.version = BrowserifyRails::VERSION
9
+ spec.authors = ["Henry Hsu"]
10
+ spec.email = ["hhsu@zendesk.com"]
11
+ spec.description = %q{Browserify + Rails = CommonJS Heaven}
12
+ spec.summary = %q{Get the best of both worlds: Browserify + Rails = CommonJS Heaven}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "sprockets", "~> 2.0"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rails", "~> 3.2"
26
+ end
@@ -0,0 +1,70 @@
1
+ require 'open3'
2
+ require 'json'
3
+
4
+ module BrowserifyRails
5
+ class DirectiveProcessor < Sprockets::DirectiveProcessor
6
+ BROWSERIFY_CMD = './node_modules/.bin/browserify'.freeze
7
+ MODULE_DEPS_CMD = './node_modules/.bin/module-deps'.freeze
8
+ COFFEEIFY_PATH = './node_modules/coffeeify'.freeze
9
+
10
+ class BrowserifyError < RuntimeError
11
+ end
12
+
13
+ class ModuleDepsError < RuntimeError
14
+ end
15
+
16
+ def evaluate(context, locals, &block)
17
+ super
18
+
19
+ if commonjs_module?(data)
20
+ browserify_cmd = File.join(context.environment.root, BROWSERIFY_CMD)
21
+ module_deps_cmd = File.join(context.environment.root, MODULE_DEPS_CMD)
22
+
23
+ raise ArgumentError, "#{browserify_cmd} could not be found. Please run npm install." unless File.exist?(browserify_cmd)
24
+ raise ArgumentError, "#{module_deps_cmd} could not be found. Please run npm install." unless File.exist?(module_deps_cmd)
25
+
26
+ deps = JSON.parse(run_command("#{module_deps_cmd} #{pathname}"))
27
+ deps.each do |dep|
28
+ path = File.basename(dep['id'], context.environment.root)
29
+ next if path == File.basename(pathname)
30
+
31
+ if path =~ /<([^>]+)>/
32
+ path = $1
33
+ else
34
+ path = "./#{path}" unless relative?(path)
35
+ end
36
+
37
+ context.depend_on_asset(path)
38
+ end
39
+
40
+ params = "-d"
41
+ params += " -t coffeeify --extension='.coffee'" if File.directory?(COFFEEIFY_PATH)
42
+
43
+ run_command("#{browserify_cmd} #{params} #{pathname}")
44
+ else
45
+ data
46
+ end
47
+ end
48
+
49
+ def commonjs_module?(data)
50
+ data.to_s.include?('module.exports') || data.to_s.include?('require')
51
+ end
52
+
53
+ def run_command(command)
54
+ stdin, stdout, stderr = Open3.popen3("#{command}")
55
+ begin
56
+ result = stdout.read
57
+ result_error = stderr.read.strip
58
+ if result_error.empty?
59
+ result
60
+ else
61
+ raise ModuleDepsError, result_error
62
+ end
63
+ ensure
64
+ stdin.close
65
+ stdout.close
66
+ stderr.close
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,13 @@
1
+ module BrowserifyRails
2
+ class Railtie < Rails::Engine
3
+
4
+ initializer :setup_browserify do |app|
5
+ app.assets.register_postprocessor 'application/javascript', BrowserifyRails::DirectiveProcessor
6
+ end
7
+
8
+ rake_tasks do
9
+ Dir[File.join(File.dirname(__FILE__),'tasks/*.rake')].each { |f| load f }
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,20 @@
1
+ namespace :npm do
2
+ desc "Run npm install"
3
+ task :install do
4
+ sh "npm install" do |ok, res|
5
+ fail "Error running npm install." unless ok
6
+ end
7
+ end
8
+
9
+ desc "Clean npm node_modules"
10
+ task :clean do
11
+ sh "rm -rf ./node_modules" do |ok, res|
12
+ fail "Error cleaning npm node_modules." unless ok
13
+ end
14
+ end
15
+
16
+ namespace :install do
17
+ desc "Run a clean npm install"
18
+ task :clean => ['npm:clean', 'npm:install']
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module BrowserifyRails
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,8 @@
1
+ require 'sprockets'
2
+
3
+ require 'browserify-rails/directive_processor'
4
+ require 'browserify-rails/railtie'
5
+ require 'browserify-rails/version'
6
+
7
+ module BrowserifyRails
8
+ end
@@ -0,0 +1,38 @@
1
+ require 'test_helper'
2
+
3
+ class BrowserifyTest < ActionController::IntegrationTest
4
+
5
+ setup do
6
+ FileUtils.rm_rf(File.join(Rails.root, 'tmp/cache'))
7
+ FileUtils.mkdir_p(File.join(Rails.root, 'tmp'))
8
+ FileUtils.cp(File.join(Rails.root, 'app/assets/javascripts/application.js.example'), File.join(Rails.root, 'app/assets/javascripts/application.js'))
9
+ FileUtils.cp(File.join(Rails.root, 'app/assets/javascripts/foo.js.example'), File.join(Rails.root, 'app/assets/javascripts/foo.js'))
10
+ end
11
+
12
+ test "asset pipeline should serve application.js" do
13
+ get "/assets/application.js"
14
+ assert_response :success
15
+ assert @response.body.include? ";(function(e,t,n){function i(n,s){if(!t[n]){if(!e[n]){var o=typeof require==\"function\"&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);throw new Error(\"Cannot find module '\"+n+\"'\")}var u=t[n]={exports:{}};e[n][0].call(u.exports,function(t){var r=e[n][1][t];return i(r?r:t)},u,u.exports)}return t[n].exports}var r=typeof require==\"function\"&&require;for(var s=0;s<n.length;s++)i(n[s]);return i})({1:[function(require,module,exports){\nvar foo = require('./foo');\n\n},{\"./foo\":2}],2:[function(require,module,exports){\nmodule.exports = function (n) { return n * 11 }\n\n},{}]},{},[1])\n"
16
+ end
17
+
18
+ test "asset pipeline should serve foo.js" do
19
+ get "/assets/foo.js"
20
+ assert_response :success
21
+ assert @response.body.include? ";(function(e,t,n){function i(n,s){if(!t[n]){if(!e[n]){var o=typeof require==\"function\"&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);throw new Error(\"Cannot find module '\"+n+\"'\")}var u=t[n]={exports:{}};e[n][0].call(u.exports,function(t){var r=e[n][1][t];return i(r?r:t)},u,u.exports)}return t[n].exports}var r=typeof require==\"function\"&&require;for(var s=0;s<n.length;s++)i(n[s]);return i})({1:[function(require,module,exports){\nmodule.exports = function (n) { return n * 11 }\n\n},{}]},{},[1])\n"
22
+ end
23
+
24
+ test "asset pipeline should regenerate application.js when foo.js changes" do
25
+ get "/assets/application.js"
26
+ assert_response :success
27
+ assert @response.body.include? ";(function(e,t,n){function i(n,s){if(!t[n]){if(!e[n]){var o=typeof require==\"function\"&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);throw new Error(\"Cannot find module '\"+n+\"'\")}var u=t[n]={exports:{}};e[n][0].call(u.exports,function(t){var r=e[n][1][t];return i(r?r:t)},u,u.exports)}return t[n].exports}var r=typeof require==\"function\"&&require;for(var s=0;s<n.length;s++)i(n[s]);return i})({1:[function(require,module,exports){\nvar foo = require('./foo');\n\n},{\"./foo\":2}],2:[function(require,module,exports){\nmodule.exports = function (n) { return n * 11 }\n\n},{}]},{},[1])\n"
28
+
29
+ File.open(File.join(Rails.root, 'app/assets/javascripts/foo.js'), 'w+') do |f|
30
+ f.puts "module.exports = function (n) { return n * 12 }"
31
+ end
32
+
33
+ get "/assets/application.js"
34
+ assert_response :success
35
+ assert @response.body.include? ";(function(e,t,n){function i(n,s){if(!t[n]){if(!e[n]){var o=typeof require==\"function\"&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);throw new Error(\"Cannot find module '\"+n+\"'\")}var u=t[n]={exports:{}};e[n][0].call(u.exports,function(t){var r=e[n][1][t];return i(r?r:t)},u,u.exports)}return t[n].exports}var r=typeof require==\"function\"&&require;for(var s=0;s<n.length;s++)i(n[s]);return i})({1:[function(require,module,exports){\nvar foo = require('./foo');\n\n},{\"./foo\":2}],2:[function(require,module,exports){\nmodule.exports = function (n) { return n * 12 }\n\n},{}]},{},[1])\n"
36
+ end
37
+
38
+ end
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ Dummy::Application.load_tasks
@@ -0,0 +1 @@
1
+ var foo = require('./foo');
@@ -0,0 +1 @@
1
+ module.exports = function (n) { return n * 11 }
@@ -0,0 +1,7 @@
1
+ /*
2
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
5
+ *= require_self
6
+ *= require_tree .
7
+ */
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,5 @@
1
+ class HomeController < ApplicationController
2
+ def index
3
+ end
4
+
5
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module HomeHelper
2
+ end
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ <h1>Home#index</h1>
2
+ <p>Find me in app/views/home/index.html.erb</p>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= javascript_include_tag "templates/test" %>
8
+ <%= csrf_meta_tags %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
@@ -0,0 +1,44 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require "action_controller/railtie"
4
+ require "rails/test_unit/railtie"
5
+ require 'sprockets/railtie'
6
+
7
+ Bundler.require
8
+ require "browserify-rails"
9
+
10
+ module Dummy
11
+ class Application < Rails::Application
12
+ # Settings in config/environments/* take precedence over those specified here.
13
+ # Application configuration should go into files in config/initializers
14
+ # -- all .rb files in that directory are automatically loaded.
15
+
16
+ # Custom directories with classes and modules you want to be autoloadable.
17
+ # config.autoload_paths += %W(#{config.root}/extras)
18
+
19
+ # Only load the plugins named here, in the order given (default is alphabetical).
20
+ # :all can be used as a placeholder for all plugins not explicitly named.
21
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
22
+
23
+ # Activate observers that should always be running.
24
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
25
+
26
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
27
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
28
+ # config.time_zone = 'Central Time (US & Canada)'
29
+
30
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
31
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
32
+ # config.i18n.default_locale = :de
33
+
34
+ # Configure the default encoding used in templates for Ruby 1.9.
35
+ config.encoding = "utf-8"
36
+
37
+ # Configure sensitive parameters which will be filtered from the log file.
38
+ config.filter_parameters += [:password]
39
+
40
+ # Enable the asset pipeline
41
+ config.assets.enabled = true
42
+ end
43
+ end
44
+
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ if File.exist?(gemfile)
5
+ ENV['BUNDLE_GEMFILE'] = gemfile
6
+ require 'bundler'
7
+ Bundler.setup
8
+ end
9
+
10
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ adapter: sqlite3
8
+ database: db/development.sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ # Warning: The database defined as "test" will be erased and
13
+ # re-generated from your development database when you run "rake".
14
+ # Do not set this db to the same as development or production.
15
+ test:
16
+ adapter: sqlite3
17
+ database: db/test.sqlite3
18
+ pool: 5
19
+ timeout: 5000
20
+
21
+ production:
22
+ adapter: sqlite3
23
+ database: db/production.sqlite3
24
+ pool: 5
25
+ timeout: 5000
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!
@@ -0,0 +1,27 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send
17
+ # config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger
20
+ config.active_support.deprecation = :log
21
+
22
+ # Only use best-standards-support built into browsers
23
+ config.action_dispatch.best_standards_support = :builtin
24
+
25
+ # Do not compress assets
26
+ config.assets.compress = false
27
+ end
@@ -0,0 +1,54 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # Code is not reloaded between requests
5
+ config.cache_classes = true
6
+
7
+ # Full error reports are disabled and caching is turned on
8
+ config.consider_all_requests_local = false
9
+ config.action_controller.perform_caching = true
10
+
11
+ # Disable Rails's static asset server (Apache or nginx will already do this)
12
+ config.serve_static_assets = false
13
+
14
+ # Compress JavaScripts and CSS
15
+ config.assets.compress = true
16
+
17
+ # Specify the default JavaScript compressor
18
+ config.assets.js_compressor = :uglifier
19
+
20
+ # Specifies the header that your server uses for sending files
21
+ # (comment out if your front-end server doesn't support this)
22
+ config.action_dispatch.x_sendfile_header = "X-Sendfile" # Use 'X-Accel-Redirect' for nginx
23
+
24
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
25
+ # config.force_ssl = true
26
+
27
+ # See everything in the log (default is :info)
28
+ # config.log_level = :debug
29
+
30
+ # Use a different logger for distributed setups
31
+ # config.logger = SyslogLogger.new
32
+
33
+ # Use a different cache store in production
34
+ # config.cache_store = :mem_cache_store
35
+
36
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
37
+ # config.action_controller.asset_host = "http://assets.example.com"
38
+
39
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
40
+ # config.assets.precompile += %w( search.js )
41
+
42
+ # Disable delivery errors, bad email addresses will be ignored
43
+ # config.action_mailer.raise_delivery_errors = false
44
+
45
+ # Enable threaded mode
46
+ # config.threadsafe!
47
+
48
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
49
+ # the I18n.default_locale when a translation can not be found)
50
+ config.i18n.fallbacks = true
51
+
52
+ # Send deprecation notices to registered listeners
53
+ config.active_support.deprecation = :notify
54
+ end
@@ -0,0 +1,39 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Configure static asset server for tests with Cache-Control for performance
11
+ config.serve_static_assets = true
12
+ config.static_cache_control = "public, max-age=3600"
13
+
14
+ # Log error messages when you accidentally call methods on nil
15
+ config.whiny_nils = true
16
+
17
+ # Show full error reports and disable caching
18
+ config.consider_all_requests_local = true
19
+ config.action_controller.perform_caching = false
20
+
21
+ # Raise exceptions instead of rendering exception templates
22
+ config.action_dispatch.show_exceptions = false
23
+
24
+ # Disable request forgery protection in test environment
25
+ config.action_controller.allow_forgery_protection = false
26
+
27
+ # Tell Action Mailer not to deliver emails to the real world.
28
+ # The :test delivery method accumulates sent emails in the
29
+ # ActionMailer::Base.deliveries array.
30
+ # config.action_mailer.delivery_method = :test
31
+
32
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
33
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
34
+ # like if you have constraints or database-specific column types
35
+ # config.active_record.schema_format = :sql
36
+
37
+ # Print deprecation notices to the stderr
38
+ config.active_support.deprecation = :stderr
39
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ Dummy::Application.config.secret_token = '717b5a4e715127fc72bb840a70685d6e'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rails generate session_migration")
8
+ # Dummy::Application.config.session_store :active_record_store
@@ -0,0 +1,12 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActionController::Base.wrap_parameters :format => [:json]
8
+
9
+ # Disable root element in JSON by default.
10
+ if defined?(ActiveRecord)
11
+ ActiveRecord::Base.include_root_in_json = false
12
+ end
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,60 @@
1
+ Dummy::Application.routes.draw do
2
+ get "home/index"
3
+
4
+ # The priority is based upon order of creation:
5
+ # first created -> highest priority.
6
+
7
+ # Sample of regular route:
8
+ # match 'products/:id' => 'catalog#view'
9
+ # Keep in mind you can assign values other than :controller and :action
10
+
11
+ # Sample of named route:
12
+ # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
13
+ # This route can be invoked with purchase_url(:id => product.id)
14
+
15
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
16
+ # resources :products
17
+
18
+ # Sample resource route with options:
19
+ # resources :products do
20
+ # member do
21
+ # get 'short'
22
+ # post 'toggle'
23
+ # end
24
+ #
25
+ # collection do
26
+ # get 'sold'
27
+ # end
28
+ # end
29
+
30
+ # Sample resource route with sub-resources:
31
+ # resources :products do
32
+ # resources :comments, :sales
33
+ # resource :seller
34
+ # end
35
+
36
+ # Sample resource route with more complex sub-resources
37
+ # resources :products do
38
+ # resources :comments
39
+ # resources :sales do
40
+ # get 'recent', :on => :collection
41
+ # end
42
+ # end
43
+
44
+ # Sample resource route within a namespace:
45
+ # namespace :admin do
46
+ # # Directs /admin/products/* to Admin::ProductsController
47
+ # # (app/controllers/admin/products_controller.rb)
48
+ # resources :products
49
+ # end
50
+
51
+ # You can have the root of your site routed with "root"
52
+ # just remember to delete public/index.html.
53
+ # root :to => 'welcome#index'
54
+
55
+ # See how all your routes lay out with "rake routes"
56
+
57
+ # This is a legacy wild controller route that's not recommended for RESTful applications.
58
+ # Note: This route will make all actions in every controller accessible via GET requests.
59
+ # match ':controller(/:action(/:id(.:format)))'
60
+ end
@@ -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 Dummy::Application
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "dummy",
3
+ "author": "Henry Hsu <hhsu@zendesk.com>",
4
+ "description": "a dummy Rails application",
5
+ "devDependencies" : {
6
+ "browserify": "2.13.x",
7
+ "module-deps": "1.7.x"
8
+ },
9
+ "license": "MIT",
10
+ "engines": {
11
+ "node": ">= 0.6"
12
+ }
13
+ }
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
+ </div>
25
+ </body>
26
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env rbx
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,14 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require "rails/test_help"
6
+ require "fileutils"
7
+
8
+ Rails.backtrace_cleaner.remove_silencers!
9
+
10
+ # Load support files
11
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
12
+
13
+ # Remove tmp dir of dummy app
14
+ FileUtils.rm_rf "#{File.dirname(__FILE__)}/dummy/tmp"
metadata ADDED
@@ -0,0 +1,184 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hsume2-browserify-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Henry Hsu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sprockets
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '3.2'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '3.2'
69
+ description: Browserify + Rails = CommonJS Heaven
70
+ email:
71
+ - hhsu@zendesk.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .travis.yml
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - browserify-rails.gemspec
83
+ - lib/browserify-rails.rb
84
+ - lib/browserify-rails/directive_processor.rb
85
+ - lib/browserify-rails/railtie.rb
86
+ - lib/browserify-rails/tasks/npm.rake
87
+ - lib/browserify-rails/version.rb
88
+ - test/compilation_test.rb
89
+ - test/dummy/Rakefile
90
+ - test/dummy/app/assets/javascripts/application.js.example
91
+ - test/dummy/app/assets/javascripts/foo.js.example
92
+ - test/dummy/app/assets/stylesheets/application.css
93
+ - test/dummy/app/controllers/application_controller.rb
94
+ - test/dummy/app/controllers/home_controller.rb
95
+ - test/dummy/app/helpers/application_helper.rb
96
+ - test/dummy/app/helpers/home_helper.rb
97
+ - test/dummy/app/mailers/.gitkeep
98
+ - test/dummy/app/models/.gitkeep
99
+ - test/dummy/app/views/home/index.html.erb
100
+ - test/dummy/app/views/layouts/application.html.erb
101
+ - test/dummy/config.ru
102
+ - test/dummy/config/application.rb
103
+ - test/dummy/config/boot.rb
104
+ - test/dummy/config/database.yml
105
+ - test/dummy/config/environment.rb
106
+ - test/dummy/config/environments/development.rb
107
+ - test/dummy/config/environments/production.rb
108
+ - test/dummy/config/environments/test.rb
109
+ - test/dummy/config/initializers/backtrace_silencers.rb
110
+ - test/dummy/config/initializers/inflections.rb
111
+ - test/dummy/config/initializers/mime_types.rb
112
+ - test/dummy/config/initializers/secret_token.rb
113
+ - test/dummy/config/initializers/session_store.rb
114
+ - test/dummy/config/initializers/wrap_parameters.rb
115
+ - test/dummy/config/locales/en.yml
116
+ - test/dummy/config/routes.rb
117
+ - test/dummy/package.json
118
+ - test/dummy/public/404.html
119
+ - test/dummy/public/422.html
120
+ - test/dummy/public/500.html
121
+ - test/dummy/public/favicon.ico
122
+ - test/dummy/script/rails
123
+ - test/test_helper.rb
124
+ homepage: ''
125
+ licenses:
126
+ - MIT
127
+ metadata: {}
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 2.0.14
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: 'Get the best of both worlds: Browserify + Rails = CommonJS Heaven'
148
+ test_files:
149
+ - test/compilation_test.rb
150
+ - test/dummy/Rakefile
151
+ - test/dummy/app/assets/javascripts/application.js.example
152
+ - test/dummy/app/assets/javascripts/foo.js.example
153
+ - test/dummy/app/assets/stylesheets/application.css
154
+ - test/dummy/app/controllers/application_controller.rb
155
+ - test/dummy/app/controllers/home_controller.rb
156
+ - test/dummy/app/helpers/application_helper.rb
157
+ - test/dummy/app/helpers/home_helper.rb
158
+ - test/dummy/app/mailers/.gitkeep
159
+ - test/dummy/app/models/.gitkeep
160
+ - test/dummy/app/views/home/index.html.erb
161
+ - test/dummy/app/views/layouts/application.html.erb
162
+ - test/dummy/config.ru
163
+ - test/dummy/config/application.rb
164
+ - test/dummy/config/boot.rb
165
+ - test/dummy/config/database.yml
166
+ - test/dummy/config/environment.rb
167
+ - test/dummy/config/environments/development.rb
168
+ - test/dummy/config/environments/production.rb
169
+ - test/dummy/config/environments/test.rb
170
+ - test/dummy/config/initializers/backtrace_silencers.rb
171
+ - test/dummy/config/initializers/inflections.rb
172
+ - test/dummy/config/initializers/mime_types.rb
173
+ - test/dummy/config/initializers/secret_token.rb
174
+ - test/dummy/config/initializers/session_store.rb
175
+ - test/dummy/config/initializers/wrap_parameters.rb
176
+ - test/dummy/config/locales/en.yml
177
+ - test/dummy/config/routes.rb
178
+ - test/dummy/package.json
179
+ - test/dummy/public/404.html
180
+ - test/dummy/public/422.html
181
+ - test/dummy/public/500.html
182
+ - test/dummy/public/favicon.ico
183
+ - test/dummy/script/rails
184
+ - test/test_helper.rb