Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support for json package files

  • Loading branch information...
commit 5e5161aa5201b02f2518b9b320bcbcfa1241bfd2 1 parent 46f9c07
@markiz markiz authored
View
3  CHANGELOG
@@ -1,4 +1,7 @@
= Jsus Changelog
+== Version 0.1.10
+* Package.json files are now supported too (with the same format as yaml packages)
+
== Version 0.1.9
* Benchmarking results are now more verbose.
== Version 0.1.8
View
5 Manifest
@@ -43,6 +43,11 @@ spec/data/ExternalInternalDependencies/Test/Source/Widget/Input/Input.Color.js
spec/data/ExternalInternalDependencies/Test/Source/Widget/Input/Input.js
spec/data/ExternalInternalDependencies/Test/Source/Widget/Widget.js
spec/data/ExternalInternalDependencies/Test/package.yml
+spec/data/JsonPackage/Source/Sheet.DOM.js
+spec/data/JsonPackage/Source/Sheet.js
+spec/data/JsonPackage/Source/SheetParser.CSS.js
+spec/data/JsonPackage/Source/sg-regex-tools.js
+spec/data/JsonPackage/package.json
spec/data/OutsideDependencies/README
spec/data/OutsideDependencies/app/javascripts/Core/Source/Class/Class.Extras.js
spec/data/OutsideDependencies/app/javascripts/Core/Source/Class/Class.js
View
2  Rakefile
@@ -1,7 +1,7 @@
require 'rubygems'
require 'rake'
require 'echoe'
-Echoe.new('jsus', '0.1.9') do |g|
+Echoe.new('jsus', '0.1.10') do |g|
g.description = "Packager/compiler for js-files that resolves dependencies and can compile everything into one file, providing all the neccessary meta-info."
g.url = "http://github.com/markiz/jsus"
g.author = "Markiz, idea by Inviz (http://github.com/Inviz)"
View
6 jsus.gemspec
@@ -2,17 +2,17 @@
Gem::Specification.new do |s|
s.name = %q{jsus}
- s.version = "0.1.9"
+ s.version = "0.1.10"
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
s.authors = ["Markiz, idea by Inviz (http://github.com/Inviz)"]
- s.date = %q{2010-08-30}
+ s.date = %q{2010-09-11}
s.default_executable = %q{jsus}
s.description = %q{Packager/compiler for js-files that resolves dependencies and can compile everything into one file, providing all the neccessary meta-info.}
s.email = %q{markizko@gmail.com}
s.executables = ["jsus"]
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "TODO", "bin/jsus", "lib/jsus.rb", "lib/jsus/container.rb", "lib/jsus/package.rb", "lib/jsus/packager.rb", "lib/jsus/pool.rb", "lib/jsus/source_file.rb", "lib/jsus/tag.rb"]
- s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "TODO", "bin/jsus", "lib/jsus.rb", "lib/jsus/container.rb", "lib/jsus/package.rb", "lib/jsus/packager.rb", "lib/jsus/pool.rb", "lib/jsus/source_file.rb", "lib/jsus/tag.rb", "spec/data/Basic/README", "spec/data/Basic/app/javascripts/Orwik/Source/Library/Color.js", "spec/data/Basic/app/javascripts/Orwik/Source/Widget/Input/Input.Color.js", "spec/data/Basic/app/javascripts/Orwik/Source/Widget/Input/Input.js", "spec/data/Basic/app/javascripts/Orwik/Source/Widget/Widget.js", "spec/data/Basic/app/javascripts/Orwik/package.yml", "spec/data/ChainDependencies/app/javascripts/Class/Source/Class.js", "spec/data/ChainDependencies/app/javascripts/Class/package.yml", "spec/data/ChainDependencies/app/javascripts/Hash/Source/Hash.js", "spec/data/ChainDependencies/app/javascripts/Hash/package.yml", "spec/data/ChainDependencies/app/javascripts/Mash/Source/Mash.js", "spec/data/ChainDependencies/app/javascripts/Mash/package.yml", "spec/data/Extensions/app/javascripts/Core/Source/Class.js", "spec/data/Extensions/app/javascripts/Core/package.yml", "spec/data/Extensions/app/javascripts/Orwik/Extensions/Class.js", "spec/data/Extensions/app/javascripts/Orwik/package.yml", "spec/data/ExternalDependencies/app/javascripts/Orwik/Source/Test.js", "spec/data/ExternalDependencies/app/javascripts/Orwik/package.yml", "spec/data/ExternalInternalDependencies/Core/Class/Source/Class.js", "spec/data/ExternalInternalDependencies/Core/Class/Source/Type.js", "spec/data/ExternalInternalDependencies/Core/Class/package.yml", "spec/data/ExternalInternalDependencies/Core/Hash/Source/Hash.js", "spec/data/ExternalInternalDependencies/Core/Hash/package.yml", "spec/data/ExternalInternalDependencies/Core/Mash/Source/Mash.js", "spec/data/ExternalInternalDependencies/Core/Mash/package.yml", "spec/data/ExternalInternalDependencies/Test/Source/Library/Color.js", "spec/data/ExternalInternalDependencies/Test/Source/Widget/Input/Input.Color.js", "spec/data/ExternalInternalDependencies/Test/Source/Widget/Input/Input.js", "spec/data/ExternalInternalDependencies/Test/Source/Widget/Widget.js", "spec/data/ExternalInternalDependencies/Test/package.yml", "spec/data/OutsideDependencies/README", "spec/data/OutsideDependencies/app/javascripts/Core/Source/Class/Class.Extras.js", "spec/data/OutsideDependencies/app/javascripts/Core/Source/Class/Class.js", "spec/data/OutsideDependencies/app/javascripts/Core/Source/Native/Hash.js", "spec/data/OutsideDependencies/app/javascripts/Core/package.yml", "spec/data/OutsideDependencies/app/javascripts/Orwik/Source/Library/Color.js", "spec/data/OutsideDependencies/app/javascripts/Orwik/Source/Widget/Input/Input.Color.js", "spec/data/OutsideDependencies/app/javascripts/Orwik/Source/Widget/Input/Input.js", "spec/data/OutsideDependencies/app/javascripts/Orwik/Source/Widget/Widget.js", "spec/data/OutsideDependencies/app/javascripts/Orwik/package.yml", "spec/data/bad_test_source_one.js", "spec/data/bad_test_source_two.js", "spec/data/test_source_one.js", "spec/lib/jsus/container_spec.rb", "spec/lib/jsus/package_spec.rb", "spec/lib/jsus/packager_spec.rb", "spec/lib/jsus/pool_spec.rb", "spec/lib/jsus/source_file_spec.rb", "spec/lib/jsus/tag_spec.rb", "spec/shared/class_stubs.rb", "spec/spec_helper.rb", "jsus.gemspec"]
+ s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "TODO", "bin/jsus", "jsus.gemspec", "lib/jsus.rb", "lib/jsus/container.rb", "lib/jsus/package.rb", "lib/jsus/packager.rb", "lib/jsus/pool.rb", "lib/jsus/source_file.rb", "lib/jsus/tag.rb", "spec/data/Basic/README", "spec/data/Basic/app/javascripts/Orwik/Source/Library/Color.js", "spec/data/Basic/app/javascripts/Orwik/Source/Widget/Input/Input.Color.js", "spec/data/Basic/app/javascripts/Orwik/Source/Widget/Input/Input.js", "spec/data/Basic/app/javascripts/Orwik/Source/Widget/Widget.js", "spec/data/Basic/app/javascripts/Orwik/package.yml", "spec/data/ChainDependencies/app/javascripts/Class/Source/Class.js", "spec/data/ChainDependencies/app/javascripts/Class/package.yml", "spec/data/ChainDependencies/app/javascripts/Hash/Source/Hash.js", "spec/data/ChainDependencies/app/javascripts/Hash/package.yml", "spec/data/ChainDependencies/app/javascripts/Mash/Source/Mash.js", "spec/data/ChainDependencies/app/javascripts/Mash/package.yml", "spec/data/Extensions/app/javascripts/Core/Source/Class.js", "spec/data/Extensions/app/javascripts/Core/package.yml", "spec/data/Extensions/app/javascripts/Orwik/Extensions/Class.js", "spec/data/Extensions/app/javascripts/Orwik/package.yml", "spec/data/ExternalDependencies/app/javascripts/Orwik/Source/Test.js", "spec/data/ExternalDependencies/app/javascripts/Orwik/package.yml", "spec/data/ExternalInternalDependencies/Core/Class/Source/Class.js", "spec/data/ExternalInternalDependencies/Core/Class/Source/Type.js", "spec/data/ExternalInternalDependencies/Core/Class/package.yml", "spec/data/ExternalInternalDependencies/Core/Hash/Source/Hash.js", "spec/data/ExternalInternalDependencies/Core/Hash/package.yml", "spec/data/ExternalInternalDependencies/Core/Mash/Source/Mash.js", "spec/data/ExternalInternalDependencies/Core/Mash/package.yml", "spec/data/ExternalInternalDependencies/Test/Source/Library/Color.js", "spec/data/ExternalInternalDependencies/Test/Source/Widget/Input/Input.Color.js", "spec/data/ExternalInternalDependencies/Test/Source/Widget/Input/Input.js", "spec/data/ExternalInternalDependencies/Test/Source/Widget/Widget.js", "spec/data/ExternalInternalDependencies/Test/package.yml", "spec/data/JsonPackage/Source/Sheet.DOM.js", "spec/data/JsonPackage/Source/Sheet.js", "spec/data/JsonPackage/Source/SheetParser.CSS.js", "spec/data/JsonPackage/Source/sg-regex-tools.js", "spec/data/JsonPackage/package.json", "spec/data/OutsideDependencies/README", "spec/data/OutsideDependencies/app/javascripts/Core/Source/Class/Class.Extras.js", "spec/data/OutsideDependencies/app/javascripts/Core/Source/Class/Class.js", "spec/data/OutsideDependencies/app/javascripts/Core/Source/Native/Hash.js", "spec/data/OutsideDependencies/app/javascripts/Core/package.yml", "spec/data/OutsideDependencies/app/javascripts/Orwik/Source/Library/Color.js", "spec/data/OutsideDependencies/app/javascripts/Orwik/Source/Widget/Input/Input.Color.js", "spec/data/OutsideDependencies/app/javascripts/Orwik/Source/Widget/Input/Input.js", "spec/data/OutsideDependencies/app/javascripts/Orwik/Source/Widget/Widget.js", "spec/data/OutsideDependencies/app/javascripts/Orwik/package.yml", "spec/data/bad_test_source_one.js", "spec/data/bad_test_source_two.js", "spec/data/test_source_one.js", "spec/lib/jsus/container_spec.rb", "spec/lib/jsus/package_spec.rb", "spec/lib/jsus/packager_spec.rb", "spec/lib/jsus/pool_spec.rb", "spec/lib/jsus/source_file_spec.rb", "spec/lib/jsus/tag_spec.rb", "spec/shared/class_stubs.rb", "spec/spec_helper.rb"]
s.homepage = %q{http://github.com/markiz/jsus}
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Jsus", "--main", "README"]
s.require_paths = ["lib"]
View
9 lib/jsus/package.rb
@@ -15,12 +15,17 @@ class Package
# Accepts options:
# * +:pool:+ — which pool the package should belong to.
#
- # Raises an error when the given directory doesn't contain a package.yml
+ # Raises an error when the given directory doesn't contain a package.yml or package.json
# file with meta info.
#
def initialize(directory, options = {})
self.directory = File.expand_path(directory)
- self.header = YAML.load_file(File.join(directory, 'package.yml'))
+ if File.exists?(File.join(directory, 'package.yml'))
+ self.header = YAML.load_file(File.join(directory, 'package.yml'))
+ elsif File.exists?(File.join(directory, 'package.json'))
+ self.header = JSON.load(IO.read(File.join(directory, 'package.json')))
+ else
+ end
Dir.chdir(directory) do
files.each do |source|
source_file = SourceFile.from_file(source, :package => self)
View
2  lib/jsus/pool.rb
@@ -22,7 +22,7 @@ class Pool
#
def initialize(dir = nil)
if dir
- Dir[File.join(dir, '**', 'package.yml')].each do |package_path|
+ Dir[File.join(dir, '**', 'package.{yml,json}')].each do |package_path|
Package.new(File.dirname(package_path), :pool => self)
end
end
View
61 spec/data/JsonPackage/Source/Sheet.DOM.js
@@ -0,0 +1,61 @@
+/*
+---
+name : Sheet.DOM
+description : Sheet.DOM adds some handy stuff for working with the browser's native CSS capabilities.
+
+authors : Thomas Aylott
+copyright : © 2010 Thomas Aylott
+license : MIT
+
+provides : Sheet.DOM
+...
+*/
+;(function(document,styleSheets){
+
+if (typeof Sheet == 'undefined') Sheet = {}
+if (Sheet.DOM == null) Sheet.DOM = {}
+
+Sheet.DOM.createSheet = function(raw){
+ var oldLength = styleSheets.length
+ , style
+ , sheet
+
+ if (document.createStyleSheet){
+ document.createStyleSheet()
+ styleSheets[styleSheets.length - 1].cssText = raw
+ }
+
+ if (oldLength >= styleSheets.length){
+ style = document.createElement('style')
+ style.setAttribute('type','text/css')
+ style.appendChild(document.createTextNode(raw))
+ document.getElementsByTagName('head')[0].appendChild(style)
+ }
+
+ if (oldLength >= styleSheets.length){
+ style = document.createElement('div')
+ style.innerHTML = '<style type="text/css">' + String_escapeHTML.call(raw) + '</style>'
+ document.getElementsByTagName('head')[0].appendChild(style)
+ }
+
+ if (oldLength >= styleSheets.length)
+ throw new Error('no styleSheet added :(')
+
+ sheet = styleSheets[styleSheets.length - 1]
+ sheet.cssText = raw
+
+ return sheet
+}
+
+Sheet.DOM.createStyle = function(raw){
+ var div = document.createElement('div')
+ div.innerHTML = '<p style="' + String_escapeHTML.call(raw) + '"></p>'
+ return {style:div.firstChild.style}
+}
+
+function String_escapeHTML(){
+ return ('' + this).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/"/g,'&quot;')
+}
+
+
+}(document, document.styleSheets));
View
80 spec/data/JsonPackage/Source/Sheet.js
@@ -0,0 +1,80 @@
+/*
+---
+name : Sheet
+
+authors : Thomas Aylott
+copyright : © 2010 Thomas Aylott
+license : MIT
+
+provides : Sheet
+requires : SheetParser.CSS
+...
+*/
+;(function(exports){
+
+
+/*<depend>*/
+var UNDEF = {undefined:1}
+
+/*<CommonJS>*/
+var SheetParser = UNDEF[typeof require]
+ ? exports.SheetParser
+ : require('./SheetParser.CSS').SheetParser
+
+exports.Sheet = Sheet
+/*</CommonJS>*/
+
+/*<debug>*/;if (!(!UNDEF[typeof SheetParser] && SheetParser.CSS)) throw new Error('Missing required function: "SheetParser.CSS"');/*</debug>*/
+/*</depend>*/
+
+
+Sheet.version = '1.0.1'
+
+function Sheet(cssText){
+ if (this instanceof Sheet) this.initialize(cssText)
+ else return Sheet.from(cssText)
+}
+
+Sheet.from = function(cssText){
+ return new Sheet(cssText)
+}
+
+Sheet.prototype = {
+
+ parser: SheetParser.CSS,
+
+ initialize: function(cssText){
+ this.cssText = cssText || ''
+ this.style = this.rules = this.cssRules = this.parser.parse(this.cssText)
+ var self = this
+ },
+
+ update: function(){
+ var cssText = '',
+ i = -1,
+ rule,
+ rules = this.style || this.rules || this.cssRules
+
+ while ((rule = rules[++i])){
+ if (typeof rule == 'object'){
+ // cssRule
+ if (this.update) rule.cssText = this.update.call(rule)
+ cssText += rule.cssText = rule.selectorText + '{' + rule.cssText + '}'
+ } else {
+ // style key/value
+ cssText += rule + ':'
+ cssText += rules[rule] + ';'
+ }
+ }
+
+ if (rules.selectorText)
+ return rules.cssText = rules.selectorText + '{' + cssText + '}'
+ return rules.cssText = cssText
+ }
+
+}
+
+Sheet.prototype.toString = Sheet.prototype.update
+
+
+}(typeof exports != 'undefined' ? exports : this));
View
127 spec/data/JsonPackage/Source/SheetParser.CSS.js
@@ -0,0 +1,127 @@
+/*
+---
+name : SheetParser.CSS
+
+authors : Thomas Aylott
+copyright : © 2010 Thomas Aylott
+license : MIT
+
+provides : SheetParser.CSS
+requires : combineRegExp
+...
+*/
+;(function(exports){
+
+
+/*<depend>*/
+var UNDEF = {undefined:1}
+if (!exports.SheetParser) exports.SheetParser = {}
+
+/*<CommonJS>*/
+var combineRegExp = UNDEF[typeof require]
+ ? exports.combineRegExp
+ : require('./sg-regex-tools').combineRegExp
+var SheetParser = exports.SheetParser
+/*</CommonJS>*/
+
+/*<debug>*/;if (UNDEF[typeof combineRegExp]) throw new Error('Missing required function: "combineRegExp"');/*</debug>*/
+/*</depend>*/
+
+
+var CSS = SheetParser.CSS = {version: '1.0.1'}
+
+CSS.camelCase = function(string){
+ return ('' + string).replace(camelCaseSearch, camelCaseReplace)
+}
+var camelCaseSearch = /-\D/g
+function camelCaseReplace(match){
+ return match.charAt(1).toUpperCase()
+}
+
+CSS.parse = function(cssText){
+ var found
+ , rule
+ , rules = {length:0}
+ , keyIndex = -1
+ , regex = this.parser
+ , names = CSS.parser.names
+ , i,r,l
+ , ruleCount
+
+ rules.cssText = cssText = ('' + cssText)
+
+ regex.lastIndex = 0
+ while ((found = regex.exec(cssText))){
+ // avoid an infinite loop on zero-length keys
+ if (regex.lastIndex == found.index) ++ regex.lastIndex
+
+ // key:value
+ if (found[names._key]){
+ rules[rules.length ++] = found[names._key]
+ rules[found[names._key]] = found[names._value]
+ rules[CSS.camelCase(found[names._key])] = found[names._value]
+ continue
+ }
+
+ rules[rules.length++] = rule = {}
+ for (i = -1, l = names.length; i < l; ++i){
+ if (!found[i]) continue
+ rule[names[i-1]] = found[i]
+ }
+ }
+
+ for (i = -1, l = rules.length; i < l; ++i){
+ if (!rules[i] || !rules[i].style_cssText) continue
+
+ rules[i].style = CSS.parse(rules[i].style_cssText)
+
+ for (ruleCount = -1, r = -1, rule; rule = rules[i].style[++r];){
+ if (typeof rule == 'string') continue
+ rules[i][r] = (rules[i].cssRules || (rules[i].cssRules = {}))[++ ruleCount] = rule
+ rules[i].cssRules.length = ruleCount + 1
+ rules[i].rules = rules[i].cssRules
+ }
+ }
+
+ return rules
+}
+
+var x = combineRegExp
+
+;(CSS.at = x(/\s*(@[-a-zA-Z0-9]+)\s+([^;{]*)/))
+.names=[ 'kind', 'name']
+
+CSS.atRule = x([CSS.at, ';'])
+
+;(CSS.keyValue = x(/\s*([-a-zA-Z0-9]+):\s*(.*?)(?:;|(?=\})|$)/))
+.names=[ '_key', '_value']
+
+;(CSS.comment = x(/\/\*\s*((?:[^*]|\*(?!\/))*)\s*\*\//))
+.names=[ 'comment']
+
+;(CSS.selector = x(/\s*((\d+%)|[^\{}]+?)\s*/))
+.names=[ 'selectorText','keyText']
+
+;(CSS.block = x(/\{\s*((?:[^{}]|\{(?:[^{}]|\{(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\})*\})*)\s*\}/))
+.names=[ 'style_cssText']
+
+CSS.selectorBlock = x([CSS.selector, CSS.block])
+
+CSS.atBlock = x([CSS.at, CSS.block])
+
+var OR = '|'
+
+CSS.parser = x([
+ x(CSS.comment)
+ ,OR
+ ,x(CSS.atBlock)
+ ,OR
+ ,x(CSS.atRule)
+ ,OR
+ ,x(CSS.selectorBlock)
+ ,OR
+ ,x(CSS.keyValue)
+],'cssText')
+
+
+})(typeof exports != 'undefined' ? exports : this);
View
37 spec/data/JsonPackage/Source/sg-regex-tools.js
@@ -0,0 +1,37 @@
+/*
+---
+name : sg-regex-tools
+description : A few super-handy tools for messing around with RegExp
+
+authors : Thomas Aylott
+copyright : © 2010 Thomas Aylott
+license : MIT
+
+provides : [combineRegExp]
+...
+*/
+;(function(exports){
+
+exports.combineRegExp = function(regex, group){
+ if (regex.source) regex = [regex]
+
+ var names = [], i, source = '', this_source
+
+ for (i = 0; i < regex.length; ++i){ if (!regex[i]) continue
+ this_source = regex[i].source || ''+regex[i]
+ if (this_source == '|') source += '|'
+ else {
+ source += (group?'(':'') + this_source.replace(/\s/g,'') + (group?')':'')
+ if (group) names.push(group)
+ }
+ if (regex[i].names) names = names.concat(regex[i].names)
+ }
+ regex = new RegExp(source,'gm')
+ // [key] → 1
+ for (i = -1; i < names.length; ++i) names[names[i]] = i + 1
+ // [1] → key
+ regex.names = names
+ return regex
+}
+
+}(typeof exports != 'undefined' ? exports : this))
View
56 spec/data/JsonPackage/package.json
@@ -0,0 +1,56 @@
+{
+
+ "name": "Sheet",
+ "version": "1.0.1",
+
+ "description": "100% DOM-less JavaScript implementation of the styleSheets, cssRule & style APIs \nSupports custom and browser-incompatible CSS syntax like nested rules",
+ "keywords": [
+ "CSS",
+ "CSSOM",
+ "styleSheet",
+ "cssRule",
+ "style",
+ "parse"
+ ],
+
+ "authors": ["Thomas Aylott"],
+ "contributors": [
+ {
+ "name": "Thomas Aylott",
+ "email": "thomas@subtlegradient.com",
+ "web": "http://subtlegradient.com"
+ }
+ ],
+
+ "copyright": "© 2010 Thomas Aylott",
+ "license": "MIT License",
+ "licenses": [
+ {
+ "type": "MIT",
+ "url": "http://creativecommons.org/licenses/MIT/"
+ }
+ ],
+
+ "repositories": [{
+ "type": "git",
+ "url": "http://github.com/subtleGradient/Sheet.js/"
+ }],
+
+ "bugs": {
+ "web": "http://github.com/subtleGradient/Sheet.js/issues"
+ },
+
+ "directories": {
+ "src": "./Source",
+ "lib": "./Source",
+ "doc": ".",
+ "test": "./Test"
+ },
+
+ "sources": [
+ "Source/Sheet.js",
+ "Source/SheetParser.CSS.js"
+ ],
+
+ "main":"./Source/Sheet"
+}
View
57 spec/lib/jsus/package_spec.rb
@@ -8,32 +8,47 @@
before(:each) { cleanup }
after(:all) { cleanup }
context "initialization" do
- let(:input_dir) { "spec/data/OutsideDependencies/app/javascripts/Orwik" }
- let(:output_dir) { "spec/data/OutsideDependencies/public/javascripts/Orwik" }
context "from a directory" do
- it "should load header from package.yml" do
- subject.name.should == "orwik"
- subject.filename.should == "orwik.js"
+ context "with a package.yml" do
+ let(:input_dir) { "spec/data/OutsideDependencies/app/javascripts/Orwik" }
+ let(:output_dir) { "spec/data/OutsideDependencies/public/javascripts/Orwik" }
+
+ it "should load header from package.yml" do
+ subject.name.should == "orwik"
+ subject.filename.should == "orwik.js"
+ end
+
+ it "should pass pool in options and register itself in the pool" do
+ pool = Jsus::Pool.new
+ package = Jsus::Package.new(input_dir, :pool => pool)
+ package.pool.should == pool
+ pool.packages.should include(package)
+ end
+
+ it "should set provided modules from source files" do
+ subject.provides.should have_exactly(4).items
+ subject.provides_names.should include("Color", "Input", "Input.Color", "Widget")
+ end
+
+ it "should set up outside dependencies" do
+ subject.dependencies_names.should == ['core/Class']
+ end
+
+ it "should set directory field" do
+ subject.directory.should == File.expand_path(input_dir)
+ end
end
- it "should pass pool in options and register itself in the pool" do
- pool = Jsus::Pool.new
- package = Jsus::Package.new(input_dir, :pool => pool)
- package.pool.should == pool
- pool.packages.should include(package)
- end
-
- it "should set provided modules from source files" do
- subject.provides.should have_exactly(4).items
- subject.provides_names.should include("Color", "Input", "Input.Color", "Widget")
- end
+ context "with a package.json" do
+ let(:input_dir) { "spec/data/JsonPackage" }
+ let(:output_dir) { "spec/data/JsonPackage" }
- it "should set up outside dependencies" do
- subject.dependencies_names.should == ['core/Class']
- end
+ it "should load header from package.json" do
+ subject.name.should == "Sheet"
+ subject.provides_names.should =~ ["Sheet", "SheetParser.CSS"]
+ subject.dependencies_names.should =~ ["combineRegExp"]
+ end
- it "should set directory field" do
- subject.directory.should == File.expand_path(input_dir)
end
end
end
View
5 spec/lib/jsus/pool_spec.rb
@@ -41,6 +41,11 @@
pool = Jsus::Pool.new("spec/data/Extensions/app/javascripts")
pool.send(:extensions_map).keys.should include(Jsus::Tag["Core/Class"])
end
+
+ it "should load package.json packages too" do
+ pool = Jsus::Pool.new("spec/data/JsonPackage")
+ pool.should have_exactly(1).packages
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.