This repository has been archived by the owner on Jun 13, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bpm now passes a context object with build settings and a minify opti…
…on to plugins - this will allow spade to support string loading.
- Loading branch information
Charles Jolley
committed
Jul 21, 2011
1 parent
6abc8db
commit 36617b0
Showing
21 changed files
with
236 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module BPM | ||
|
||
class PluginContext | ||
|
||
attr_reader :moduleId | ||
attr_reader :package | ||
|
||
def initialize(pkg, module_id=nil) | ||
@generating_asset = BPM::GeneratedAsset.generating_asset | ||
@package = pkg.as_json | ||
@moduleId = module_id | ||
end | ||
|
||
def minify(body) | ||
@generating_asset ? @generating_asset.minify_body(body) : body | ||
end | ||
|
||
def settings | ||
@generating_asset ? @generating_asset.build_settings : {} | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
spec/fixtures/projects/minitest/packages/uglyduck/minifier/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/*globals BPM_PLUGIN UGLYDUCK */ | ||
|
||
BPM_PLUGIN.minify = function(body, pkg, moduleId, pathname) { | ||
BPM_PLUGIN.minify = function(body, context, pathname) { | ||
var whatIsUglyDuck = 'undefined' === typeof UGLYDUCK ? '(main not loaded)' : UGLYDUCK; | ||
return "//MINIFIED START\nUGLY DUCK "+UGLYDUCK+"\n"+body+"\n//MINIFIED END\n"; | ||
var whereIsUglyDuck = context.settings['uglyduck:where'] || '(build settings not found)' | ||
return "//MINIFIED START\nUGLY DUCK "+whatIsUglyDuck+whereIsUglyDuck+"\n"+body+"\n//MINIFIED END\n"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
//TRANSPORT | ||
transporter(); | ||
//TRANSPORT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "minitrans", | ||
"version": "2.0.0", | ||
"bpm": "0.1.0", | ||
|
||
"description": "DESCRIPTION HERE", | ||
"author": "YOUR NAME HERE", | ||
"homepage": "URL", | ||
|
||
"directories": { | ||
"lib": "lib" | ||
}, | ||
|
||
"dependencies": { | ||
"transport": "0.5.0" | ||
}, | ||
|
||
"bpm:build": { | ||
"bpm_libs.js": { | ||
"directories": ["lib"], | ||
"minifier": "uglyduck" | ||
} | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
spec/fixtures/projects/minitrans/packages/transport/lib/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// TRANSPORT DEMO |
21 changes: 21 additions & 0 deletions
21
spec/fixtures/projects/minitrans/packages/transport/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "transport", | ||
"version": "0.5.0", | ||
"bpm": "0.1.0", | ||
|
||
"description": "DESCRIPTION HERE", | ||
"author": "YOUR NAME HERE", | ||
"homepage": "URL", | ||
|
||
"directories": { | ||
"lib": "./lib", | ||
"test": "./tests" | ||
}, | ||
|
||
"dependencies": { | ||
|
||
}, | ||
|
||
"bpm:transport": "transport/transports/wrapper" | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
spec/fixtures/projects/minitrans/packages/transport/transports/wrapper.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
BPM_PLUGIN.compileTransport = function(body, context, filename) { | ||
body = JSON.stringify("(function() { "+context.minify(body)+" })()\n"); | ||
return "define_transport("+body+"), '"+context['package'].name+"', '"+context.moduleId+"', '"+filename+"');"; | ||
}; | ||
|
3 changes: 3 additions & 0 deletions
3
spec/fixtures/projects/minitrans/packages/uglyduck/lib/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
//UGLY DUCK | ||
UGLYDUCK = "IS UGLY"; | ||
|
6 changes: 6 additions & 0 deletions
6
spec/fixtures/projects/minitrans/packages/uglyduck/minifier/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/*globals BPM_PLUGIN UGLYDUCK */ | ||
|
||
BPM_PLUGIN.minify = function(body, pkg, moduleId, pathname) { | ||
var whatIsUglyDuck = 'undefined' === typeof UGLYDUCK ? '(main not loaded)' : UGLYDUCK; | ||
return "//MINIFIED START\nUGLY DUCK "+UGLYDUCK+"\n"+body+"\n//MINIFIED END\n"; | ||
}; |
21 changes: 21 additions & 0 deletions
21
spec/fixtures/projects/minitrans/packages/uglyduck/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "uglyduck", | ||
"version": "1.0.0", | ||
"bpm": "0.1.0", | ||
|
||
"description": "DESCRIPTION HERE", | ||
"author": "YOUR NAME HERE", | ||
"homepage": "URL", | ||
|
||
"directories": { | ||
"lib": "lib", | ||
"minifier": "minifier", | ||
"test": "tests" | ||
}, | ||
|
||
"dependencies": { | ||
}, | ||
|
||
"bpm:minifier": "uglyduck/minifier/main" | ||
|
||
} |
4 changes: 2 additions & 2 deletions
4
spec/fixtures/projects/transporter/packages/transport/transports/wrapper.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
BPM_PLUGIN.compileTransport = function(body, pkg, moduleId, filename) { | ||
return "define_transport(function() {\n"+body+"\n}), '"+pkg.name+"', '"+moduleId+"', '"+filename+"');"; | ||
BPM_PLUGIN.compileTransport = function(body, context, filename) { | ||
return "define_transport(function() {\n"+body+"\n}), '"+context['package'].name+"', '"+context.moduleId+"', '"+filename+"');"; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters