browserify-rails 0.0.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.travis.yml +1 -0
  4. data/LICENSE.txt +2 -2
  5. data/README.md +83 -15
  6. data/Rakefile +26 -0
  7. data/browserify-rails.gemspec +21 -16
  8. data/lib/browserify-rails.rb +8 -0
  9. data/lib/browserify-rails/browserify_error.rb +5 -0
  10. data/lib/browserify-rails/browserify_processor.rb +109 -0
  11. data/lib/browserify-rails/railtie.rb +20 -0
  12. data/lib/browserify-rails/tasks/npm.rake +20 -0
  13. data/lib/browserify-rails/version.rb +3 -0
  14. data/test/browserify_processor_test.rb +46 -0
  15. data/test/compilation_test.rb +82 -0
  16. data/test/dummy/Rakefile +7 -0
  17. data/test/dummy/app/assets/javascripts/application.js.example +1 -0
  18. data/test/dummy/app/assets/javascripts/foo.js.example +2 -0
  19. data/test/dummy/app/assets/javascripts/nested/index.js.example +1 -0
  20. data/test/dummy/app/assets/stylesheets/application.css +7 -0
  21. data/test/dummy/app/controllers/application_controller.rb +3 -0
  22. data/test/dummy/app/controllers/home_controller.rb +5 -0
  23. data/test/dummy/app/helpers/application_helper.rb +2 -0
  24. data/test/dummy/app/helpers/home_helper.rb +2 -0
  25. data/test/dummy/app/mailers/.gitkeep +0 -0
  26. data/test/dummy/app/models/.gitkeep +0 -0
  27. data/test/dummy/app/views/home/index.html.erb +2 -0
  28. data/test/dummy/app/views/layouts/application.html.erb +15 -0
  29. data/test/dummy/config.ru +4 -0
  30. data/test/dummy/config/application.rb +44 -0
  31. data/test/dummy/config/boot.rb +10 -0
  32. data/test/dummy/config/database.yml +25 -0
  33. data/test/dummy/config/environment.rb +5 -0
  34. data/test/dummy/config/environments/development.rb +27 -0
  35. data/test/dummy/config/environments/production.rb +54 -0
  36. data/test/dummy/config/environments/test.rb +39 -0
  37. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  38. data/test/dummy/config/initializers/inflections.rb +10 -0
  39. data/test/dummy/config/initializers/mime_types.rb +5 -0
  40. data/test/dummy/config/initializers/secret_token.rb +7 -0
  41. data/test/dummy/config/initializers/session_store.rb +8 -0
  42. data/test/dummy/config/initializers/wrap_parameters.rb +12 -0
  43. data/test/dummy/config/locales/en.yml +5 -0
  44. data/test/dummy/config/routes.rb +60 -0
  45. data/test/dummy/package.json +12 -0
  46. data/test/dummy/public/404.html +26 -0
  47. data/test/dummy/public/422.html +26 -0
  48. data/test/dummy/public/500.html +26 -0
  49. data/test/dummy/public/favicon.ico +0 -0
  50. data/test/dummy/script/rails +6 -0
  51. data/test/fixtures/application.changed.out.js +12 -0
  52. data/test/fixtures/application.foo_changed.out.js +11 -0
  53. data/test/fixtures/application.out.js +11 -0
  54. data/test/fixtures/empty_module.js +2 -0
  55. data/test/fixtures/foo.out.js +9 -0
  56. data/test/test_helper.rb +20 -0
  57. metadata +151 -29
  58. data/.rspec +0 -2
  59. data/spec/browserify/rails_spec.rb +0 -11
  60. data/spec/spec_helper.rb +0 -2
@@ -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,12 @@
1
+ {
2
+ "name": "dummy",
3
+ "author": "Henry Hsu <hhsu@zendesk.com>",
4
+ "description": "a dummy Rails application",
5
+ "devDependencies" : {
6
+ "browserify": "~> 4.1"
7
+ },
8
+ "license": "MIT",
9
+ "engines": {
10
+ "node": ">= 0.10"
11
+ }
12
+ }
@@ -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,12 @@
1
+ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
+ var foo = require('./foo');
3
+ console.log(foo(11));
4
+
5
+ },{"./foo":2}],2:[function(require,module,exports){
6
+ require('./nested');
7
+ module.exports = function (n) { return n * 11 }
8
+
9
+ },{"./nested":3}],3:[function(require,module,exports){
10
+ module.exports.NESTED = true;
11
+
12
+ },{}]},{},[1])
@@ -0,0 +1,11 @@
1
+ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
+ var foo = require('./foo');
3
+
4
+ },{"./foo":2}],2:[function(require,module,exports){
5
+ require('./nested');
6
+ module.exports = function (n) { return n * 12 }
7
+
8
+ },{"./nested":3}],3:[function(require,module,exports){
9
+ module.exports.NESTED = true;
10
+
11
+ },{}]},{},[1])
@@ -0,0 +1,11 @@
1
+ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
+ var foo = require('./foo');
3
+
4
+ },{"./foo":2}],2:[function(require,module,exports){
5
+ require('./nested');
6
+ module.exports = function (n) { return n * 11 }
7
+
8
+ },{"./nested":3}],3:[function(require,module,exports){
9
+ module.exports.NESTED = true;
10
+
11
+ },{}]},{},[1])
@@ -0,0 +1,2 @@
1
+ // minimal js fixture that passes common_js_module? test
2
+ module.exports = {}
@@ -0,0 +1,9 @@
1
+ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
+ require('./nested');
3
+ module.exports = function (n) { return n * 11 }
4
+ ;
5
+
6
+ },{"./nested":2}],2:[function(require,module,exports){
7
+ module.exports.NESTED = true;
8
+
9
+ },{}]},{},[1])
@@ -0,0 +1,20 @@
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"
15
+
16
+ ActiveSupport::TestCase.class_eval do
17
+ def fixture(filename)
18
+ File.open(File.join(File.dirname(__FILE__), "/fixtures/#{filename}")).read.strip
19
+ end
20
+ end
metadata CHANGED
@@ -1,91 +1,213 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browserify-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
- - Aaron Rutkovsky
7
+ - Henry Hsu
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-17 00:00:00.000000000 Z
11
+ date: 2014-05-28 00:00:00.000000000 Z
13
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'
14
41
  - !ruby/object:Gem::Dependency
15
42
  name: rake
16
43
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
44
  requirements:
19
- - - ! '>='
45
+ - - ">="
20
46
  - !ruby/object:Gem::Version
21
47
  version: '0'
22
48
  type: :development
23
49
  prerelease: false
24
50
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
51
  requirements:
27
- - - ! '>='
52
+ - - ">="
28
53
  - !ruby/object:Gem::Version
29
54
  version: '0'
30
55
  - !ruby/object:Gem::Dependency
31
- name: rspec
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
+ - !ruby/object:Gem::Dependency
70
+ name: mocha
32
71
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
72
  requirements:
35
- - - ! '>='
73
+ - - ">="
36
74
  - !ruby/object:Gem::Version
37
75
  version: '0'
38
76
  type: :development
39
77
  prerelease: false
40
78
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
79
  requirements:
43
- - - ! '>='
80
+ - - ">="
44
81
  - !ruby/object:Gem::Version
45
82
  version: '0'
46
- description: Rails + Browserify
83
+ description: Browserify + Rails = CommonJS Heaven
47
84
  email:
48
- - aaron.rutkovsky@gmail.com
85
+ - hhsu@zendesk.com
49
86
  executables: []
50
87
  extensions: []
51
88
  extra_rdoc_files: []
52
89
  files:
53
- - .gitignore
54
- - .rspec
90
+ - ".gitignore"
91
+ - ".travis.yml"
55
92
  - Gemfile
56
93
  - LICENSE.txt
57
94
  - README.md
58
95
  - Rakefile
59
96
  - browserify-rails.gemspec
60
97
  - lib/browserify-rails.rb
61
- - spec/browserify/rails_spec.rb
62
- - spec/spec_helper.rb
98
+ - lib/browserify-rails/browserify_error.rb
99
+ - lib/browserify-rails/browserify_processor.rb
100
+ - lib/browserify-rails/railtie.rb
101
+ - lib/browserify-rails/tasks/npm.rake
102
+ - lib/browserify-rails/version.rb
103
+ - test/browserify_processor_test.rb
104
+ - test/compilation_test.rb
105
+ - test/dummy/Rakefile
106
+ - test/dummy/app/assets/javascripts/application.js.example
107
+ - test/dummy/app/assets/javascripts/foo.js.example
108
+ - test/dummy/app/assets/javascripts/nested/index.js.example
109
+ - test/dummy/app/assets/stylesheets/application.css
110
+ - test/dummy/app/controllers/application_controller.rb
111
+ - test/dummy/app/controllers/home_controller.rb
112
+ - test/dummy/app/helpers/application_helper.rb
113
+ - test/dummy/app/helpers/home_helper.rb
114
+ - test/dummy/app/mailers/.gitkeep
115
+ - test/dummy/app/models/.gitkeep
116
+ - test/dummy/app/views/home/index.html.erb
117
+ - test/dummy/app/views/layouts/application.html.erb
118
+ - test/dummy/config.ru
119
+ - test/dummy/config/application.rb
120
+ - test/dummy/config/boot.rb
121
+ - test/dummy/config/database.yml
122
+ - test/dummy/config/environment.rb
123
+ - test/dummy/config/environments/development.rb
124
+ - test/dummy/config/environments/production.rb
125
+ - test/dummy/config/environments/test.rb
126
+ - test/dummy/config/initializers/backtrace_silencers.rb
127
+ - test/dummy/config/initializers/inflections.rb
128
+ - test/dummy/config/initializers/mime_types.rb
129
+ - test/dummy/config/initializers/secret_token.rb
130
+ - test/dummy/config/initializers/session_store.rb
131
+ - test/dummy/config/initializers/wrap_parameters.rb
132
+ - test/dummy/config/locales/en.yml
133
+ - test/dummy/config/routes.rb
134
+ - test/dummy/package.json
135
+ - test/dummy/public/404.html
136
+ - test/dummy/public/422.html
137
+ - test/dummy/public/500.html
138
+ - test/dummy/public/favicon.ico
139
+ - test/dummy/script/rails
140
+ - test/fixtures/application.changed.out.js
141
+ - test/fixtures/application.foo_changed.out.js
142
+ - test/fixtures/application.out.js
143
+ - test/fixtures/empty_module.js
144
+ - test/fixtures/foo.out.js
145
+ - test/test_helper.rb
63
146
  homepage: ''
64
147
  licenses:
65
148
  - MIT
149
+ metadata: {}
66
150
  post_install_message:
67
151
  rdoc_options: []
68
152
  require_paths:
69
153
  - lib
70
154
  required_ruby_version: !ruby/object:Gem::Requirement
71
- none: false
72
155
  requirements:
73
- - - ! '>='
156
+ - - ">="
74
157
  - !ruby/object:Gem::Version
75
158
  version: '0'
76
159
  required_rubygems_version: !ruby/object:Gem::Requirement
77
- none: false
78
160
  requirements:
79
- - - ! '>='
161
+ - - ">="
80
162
  - !ruby/object:Gem::Version
81
163
  version: '0'
82
164
  requirements: []
83
165
  rubyforge_project:
84
- rubygems_version: 1.8.24
166
+ rubygems_version: 2.2.2
85
167
  signing_key:
86
- specification_version: 3
87
- summary: summary
168
+ specification_version: 4
169
+ summary: 'Get the best of both worlds: Browserify + Rails = CommonJS Heaven'
88
170
  test_files:
89
- - spec/browserify/rails_spec.rb
90
- - spec/spec_helper.rb
91
- has_rdoc:
171
+ - test/browserify_processor_test.rb
172
+ - test/compilation_test.rb
173
+ - test/dummy/Rakefile
174
+ - test/dummy/app/assets/javascripts/application.js.example
175
+ - test/dummy/app/assets/javascripts/foo.js.example
176
+ - test/dummy/app/assets/javascripts/nested/index.js.example
177
+ - test/dummy/app/assets/stylesheets/application.css
178
+ - test/dummy/app/controllers/application_controller.rb
179
+ - test/dummy/app/controllers/home_controller.rb
180
+ - test/dummy/app/helpers/application_helper.rb
181
+ - test/dummy/app/helpers/home_helper.rb
182
+ - test/dummy/app/mailers/.gitkeep
183
+ - test/dummy/app/models/.gitkeep
184
+ - test/dummy/app/views/home/index.html.erb
185
+ - test/dummy/app/views/layouts/application.html.erb
186
+ - test/dummy/config.ru
187
+ - test/dummy/config/application.rb
188
+ - test/dummy/config/boot.rb
189
+ - test/dummy/config/database.yml
190
+ - test/dummy/config/environment.rb
191
+ - test/dummy/config/environments/development.rb
192
+ - test/dummy/config/environments/production.rb
193
+ - test/dummy/config/environments/test.rb
194
+ - test/dummy/config/initializers/backtrace_silencers.rb
195
+ - test/dummy/config/initializers/inflections.rb
196
+ - test/dummy/config/initializers/mime_types.rb
197
+ - test/dummy/config/initializers/secret_token.rb
198
+ - test/dummy/config/initializers/session_store.rb
199
+ - test/dummy/config/initializers/wrap_parameters.rb
200
+ - test/dummy/config/locales/en.yml
201
+ - test/dummy/config/routes.rb
202
+ - test/dummy/package.json
203
+ - test/dummy/public/404.html
204
+ - test/dummy/public/422.html
205
+ - test/dummy/public/500.html
206
+ - test/dummy/public/favicon.ico
207
+ - test/dummy/script/rails
208
+ - test/fixtures/application.changed.out.js
209
+ - test/fixtures/application.foo_changed.out.js
210
+ - test/fixtures/application.out.js
211
+ - test/fixtures/empty_module.js
212
+ - test/fixtures/foo.out.js
213
+ - test/test_helper.rb