browserify-sprockets 0.0.1
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.txt +22 -0
- data/README.md +1 -0
- data/Rakefile +2 -0
- data/bin/browserify_build +53 -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: 8184f8c8f8fc15b2b9610ef107b5de8eae3eb8da
|
4
|
+
data.tar.gz: 2c2c6b96d396d678df860f71e1cda8a4b084539c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2c13eacd080f900ee59f02d4207ab340556cfff011f0578424e13e5ec9c67af892ba7a614867b8e059dd2c5f888e04a83a3bb0e5481d6d18ffbd704d8a5fb497
|
7
|
+
data.tar.gz: 796b2f17f29d0ed115e13b5850b017d50ad1fb5f906ebd6ca4dd026f7f5f43226dc29799786e9de1213cd2c438c60dbcec856015682d401f3db6a863f2e17c12
|
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.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 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 @@
|
|
1
|
+
# BrowserifySprockets
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
var util = require('util'),
|
4
|
+
glob = require('glob'),
|
5
|
+
_ = require('underscore'),
|
6
|
+
path = require('path'),
|
7
|
+
exec = require('child_process').exec;
|
8
|
+
|
9
|
+
var errorMessage = function(message) {
|
10
|
+
process.stdout.write(util.format("console.error('Browserify %s');", message));
|
11
|
+
};
|
12
|
+
|
13
|
+
try {
|
14
|
+
var browserify = require('browserify'),
|
15
|
+
fs = require('fs');
|
16
|
+
|
17
|
+
var debug = (process.argv[2] === "--debug");
|
18
|
+
var paths = process.argv[3].split(",")
|
19
|
+
var basedir = process.argv[4];
|
20
|
+
|
21
|
+
var b = browserify(process.stdin, {basedir: basedir});
|
22
|
+
|
23
|
+
var globPaths = _.map(paths, function(p) {
|
24
|
+
return path.join(p, "**/*.js");
|
25
|
+
});
|
26
|
+
|
27
|
+
glob("{" + globPaths.join(",") + "}", function(er, files) {
|
28
|
+
_.each(files, function(file) {
|
29
|
+
var exposedName = file;
|
30
|
+
|
31
|
+
_.each(paths, function(pathName) {
|
32
|
+
exposedName = exposedName.replace(path.resolve(__dirname + pathName) + "/", "");
|
33
|
+
});
|
34
|
+
|
35
|
+
exposedName = path.basename(exposedName, ".js");
|
36
|
+
|
37
|
+
b.require(file, {expose: exposedName});
|
38
|
+
});
|
39
|
+
|
40
|
+
b.bundle({debug: debug}, function(err, src) {
|
41
|
+
if (err) {
|
42
|
+
// Send the browserify error message to the browser console
|
43
|
+
errorMessage(err);
|
44
|
+
}
|
45
|
+
else {
|
46
|
+
process.stdout.write(src);
|
47
|
+
}
|
48
|
+
});
|
49
|
+
});
|
50
|
+
}
|
51
|
+
catch(err) {
|
52
|
+
errorMessage(err);
|
53
|
+
}
|
@@ -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, load_paths = [])
|
7
|
+
Engine.node_path = node_path
|
8
|
+
Engine.load_paths = load_paths
|
9
|
+
Sprockets.register_engine(".browserify", Engine)
|
10
|
+
end
|
11
|
+
|
12
|
+
class Engine
|
13
|
+
class << self
|
14
|
+
attr_accessor :load_paths
|
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
|
+
paths = self.class.load_paths.join(",")
|
34
|
+
|
35
|
+
output = ""
|
36
|
+
|
37
|
+
Open3.popen3({"NODE_PATH" => self.class.node_path}, build_script, debug, paths, base_directory) 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.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Scott Bader
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-08 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.txt
|
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.2.2
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Browserify engine for sprockets
|
96
|
+
test_files: []
|