browserify_sprockets 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +43 -0
- data/Rakefile +2 -0
- data/bin/browserify_build +40 -0
- data/browserify_sprockets.gemspec +24 -0
- data/lib/browserify_sprockets.rb +55 -0
- data/lib/browserify_sprockets/version.rb +3 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b95c1ff8b0a3dd119c4cddedb0a4ce81abf42a87
|
4
|
+
data.tar.gz: 551b3cc3995484c98a0090983981e0ed12c9a4dd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 50ef7f4670ebdf75717d7f87d6df7685b45cb789a34e4bdf9087f5e8a04bb8164395250d093b0c62ee93ff9bc097835e7107e4f7f410cb27e55d164a7ded0a22
|
7
|
+
data.tar.gz: 75c9d99054622fa19bcf288b8efc385aed1e10da7f09520122e5d8a0da60364135378cacc3862f83dbb2da410e9c90cb44566d0198ee8eb9aa022cd4f61c9979
|
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/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014-2016 Scott Bader
|
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,43 @@
|
|
1
|
+
# BrowserifySprockets
|
2
|
+
|
3
|
+
Implements a Sprockets Engine that allows for files with the extension `.browserify` to be processed by `browserify`.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
You can add the gem to your Gemfile with:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'browserify-sprockets'
|
11
|
+
```
|
12
|
+
|
13
|
+
## Requirements
|
14
|
+
|
15
|
+
`node` and `npm` must be installed and Browserify should be included as a dependency in your `package.json`.
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
To use the module, first import it:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require "browserify-sprockets"
|
23
|
+
```
|
24
|
+
|
25
|
+
Then bootstrap the Sprockets engine by calling `BrowserifySprockets.boostrap` with the locations of your `node_modules` directory and an array of directories where Browserify transforms may be located:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
node_path = File.expand_path("../../../node_modules/", __FILE__)
|
29
|
+
|
30
|
+
transform_paths = [
|
31
|
+
File.expand_path("../vendor/javascripts/", __FILE__),
|
32
|
+
File.expand_path("../app/assets/javascripts/lib/", __FILE__)
|
33
|
+
]
|
34
|
+
|
35
|
+
BrowserifySprockets.bootstrap(node_path, transform_paths)
|
36
|
+
```
|
37
|
+
|
38
|
+
(see: [browserify-handbook#transforms](https://github.com/substack/browserify-handbook#transforms) for more information on transforms)
|
39
|
+
|
40
|
+
## License
|
41
|
+
|
42
|
+
BrowserifySprockets is released under the MIT license. See LICENSE for details.
|
43
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
var util = require('util'),
|
4
|
+
path = require('path'),
|
5
|
+
exec = require('child_process').exec;
|
6
|
+
|
7
|
+
var errorMessage = function(message) {
|
8
|
+
process.stdout.write(util.format("console.error('Browserify %s');", message));
|
9
|
+
};
|
10
|
+
|
11
|
+
var browserLog = function(message) {
|
12
|
+
process.stdout.write(util.format("console.log('Browserify %s');", message));
|
13
|
+
};
|
14
|
+
|
15
|
+
try {
|
16
|
+
var browserify = require('browserify'),
|
17
|
+
fs = require('fs');
|
18
|
+
|
19
|
+
var debug = (process.argv[2] === "--debug");
|
20
|
+
var basedir = process.argv[3];
|
21
|
+
|
22
|
+
var transforms = process.argv[4];
|
23
|
+
var b = browserify(process.stdin, {basedir: basedir, debug: debug})
|
24
|
+
|
25
|
+
if (transforms.length > 0) {
|
26
|
+
var names = transforms.split(',');
|
27
|
+
names.forEach(function(name, i) {
|
28
|
+
if (name.length > 0) {
|
29
|
+
b.transform(name);
|
30
|
+
}
|
31
|
+
});
|
32
|
+
}
|
33
|
+
|
34
|
+
b.bundle()
|
35
|
+
.on('error', errorMessage)
|
36
|
+
.pipe(process.stdout);
|
37
|
+
}
|
38
|
+
catch(err) {
|
39
|
+
errorMessage(err);
|
40
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'browserify_sprockets/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "browserify_sprockets"
|
8
|
+
spec.version = BrowserifySprockets::VERSION
|
9
|
+
spec.authors = ["Scott Bader"]
|
10
|
+
spec.email = ["sb@scottbader.org"]
|
11
|
+
spec.summary = %q{Browserify engine for sprockets}
|
12
|
+
spec.description = %q{Browserify engine for sprockets}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
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_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_dependency "sprockets", "~> 2.12"
|
24
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "sprockets"
|
2
|
+
require "browserify_sprockets/version"
|
3
|
+
require "open3"
|
4
|
+
|
5
|
+
module BrowserifySprockets
|
6
|
+
def self.bootstrap(node_path, transforms = [])
|
7
|
+
Engine.node_path = node_path
|
8
|
+
Engine.transforms = transforms
|
9
|
+
Sprockets.register_engine(".browserify", Engine)
|
10
|
+
end
|
11
|
+
|
12
|
+
class Engine
|
13
|
+
class << self
|
14
|
+
attr_accessor :transforms
|
15
|
+
attr_accessor :node_path
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(pathname, &block)
|
19
|
+
@pathname = pathname
|
20
|
+
end
|
21
|
+
|
22
|
+
def render(context, locals)
|
23
|
+
data = File.open(context.pathname, 'rb') { |io| io.read }
|
24
|
+
browserify_build(context.pathname, data)
|
25
|
+
end
|
26
|
+
|
27
|
+
def browserify_build(pathname, data)
|
28
|
+
build_script = File.expand_path("../../bin/browserify_build", __FILE__)
|
29
|
+
base_directory = File.expand_path(pathname.dirname)
|
30
|
+
|
31
|
+
debug = (ENV['RACK_ENV'] == "production") ? "" : "--debug"
|
32
|
+
|
33
|
+
transforms = self.class.transforms.join(',')
|
34
|
+
|
35
|
+
output = ""
|
36
|
+
|
37
|
+
Open3.popen3({"NODE_PATH" => self.class.node_path}, build_script, debug, base_directory, transforms) do |stdin, stdout, stderr|
|
38
|
+
stdin.puts data
|
39
|
+
stdin.close
|
40
|
+
|
41
|
+
output = stdout.gets(nil)
|
42
|
+
|
43
|
+
unless output
|
44
|
+
output = stderr.gets(nil)
|
45
|
+
end
|
46
|
+
|
47
|
+
stdout.close
|
48
|
+
stderr.close
|
49
|
+
end
|
50
|
+
|
51
|
+
output
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: browserify_sprockets
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Scott Bader
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sprockets
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.12'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.12'
|
55
|
+
description: Browserify engine for sprockets
|
56
|
+
email:
|
57
|
+
- sb@scottbader.org
|
58
|
+
executables:
|
59
|
+
- browserify_build
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/browserify_build
|
69
|
+
- browserify_sprockets.gemspec
|
70
|
+
- lib/browserify_sprockets.rb
|
71
|
+
- lib/browserify_sprockets/version.rb
|
72
|
+
homepage: ''
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.5.1
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Browserify engine for sprockets
|
96
|
+
test_files: []
|