jsus 0.1.9 → 0.1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +3 -0
- data/Manifest +5 -0
- data/Rakefile +1 -1
- data/bin/jsus +1 -1
- data/jsus.gemspec +3 -3
- data/lib/jsus/package.rb +7 -2
- data/lib/jsus/pool.rb +1 -1
- data/spec/data/JsonPackage/Source/Sheet.DOM.js +61 -0
- data/spec/data/JsonPackage/Source/Sheet.js +80 -0
- data/spec/data/JsonPackage/Source/SheetParser.CSS.js +127 -0
- data/spec/data/JsonPackage/Source/sg-regex-tools.js +37 -0
- data/spec/data/JsonPackage/package.json +56 -0
- data/spec/lib/jsus/package_spec.rb +36 -21
- data/spec/lib/jsus/pool_spec.rb +5 -0
- metadata +9 -3
data/CHANGELOG
CHANGED
data/Manifest
CHANGED
@@ -43,6 +43,11 @@ spec/data/ExternalInternalDependencies/Test/Source/Widget/Input/Input.Color.js
|
|
43
43
|
spec/data/ExternalInternalDependencies/Test/Source/Widget/Input/Input.js
|
44
44
|
spec/data/ExternalInternalDependencies/Test/Source/Widget/Widget.js
|
45
45
|
spec/data/ExternalInternalDependencies/Test/package.yml
|
46
|
+
spec/data/JsonPackage/Source/Sheet.DOM.js
|
47
|
+
spec/data/JsonPackage/Source/Sheet.js
|
48
|
+
spec/data/JsonPackage/Source/SheetParser.CSS.js
|
49
|
+
spec/data/JsonPackage/Source/sg-regex-tools.js
|
50
|
+
spec/data/JsonPackage/package.json
|
46
51
|
spec/data/OutsideDependencies/README
|
47
52
|
spec/data/OutsideDependencies/app/javascripts/Core/Source/Class/Class.Extras.js
|
48
53
|
spec/data/OutsideDependencies/app/javascripts/Core/Source/Class/Class.js
|
data/Rakefile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
|
-
Echoe.new('jsus', '0.1.
|
4
|
+
Echoe.new('jsus', '0.1.10.1') do |g|
|
5
5
|
g.description = "Packager/compiler for js-files that resolves dependencies and can compile everything into one file, providing all the neccessary meta-info."
|
6
6
|
g.url = "http://github.com/markiz/jsus"
|
7
7
|
g.author = "Markiz, idea by Inviz (http://github.com/Inviz)"
|
data/bin/jsus
CHANGED
@@ -76,7 +76,7 @@ if Choice.choices[:generate_includes]
|
|
76
76
|
c = Jsus::Container.new(*(package.source_files.to_a + package.linked_external_dependencies.to_a))
|
77
77
|
script = %{(function(prefix) {
|
78
78
|
var sources = %sources%;
|
79
|
-
for (var i = 0, j = sources.length; i < j; i++) document.write('<scr' + 'ipt src="' + (prefix || '') + sources[i] + "></script>
|
79
|
+
for (var i = 0, j = sources.length; i < j; i++) document.write('<scr' + 'ipt src="' + (prefix || '') + sources[i] + "></script>');
|
80
80
|
})(window.prefix);}.sub("%sources%", JSON.pretty_generate(c.required_files(root)))
|
81
81
|
f.puts script
|
82
82
|
end
|
data/jsus.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{jsus}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.10.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Markiz, idea by Inviz (http://github.com/Inviz)"]
|
9
|
-
s.date = %q{2010-
|
9
|
+
s.date = %q{2010-09-11}
|
10
10
|
s.default_executable = %q{jsus}
|
11
11
|
s.description = %q{Packager/compiler for js-files that resolves dependencies and can compile everything into one file, providing all the neccessary meta-info.}
|
12
12
|
s.email = %q{markizko@gmail.com}
|
13
13
|
s.executables = ["jsus"]
|
14
14
|
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"]
|
15
|
-
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/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"]
|
15
|
+
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"]
|
16
16
|
s.homepage = %q{http://github.com/markiz/jsus}
|
17
17
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Jsus", "--main", "README"]
|
18
18
|
s.require_paths = ["lib"]
|
data/lib/jsus/package.rb
CHANGED
@@ -15,12 +15,17 @@ module Jsus
|
|
15
15
|
# Accepts options:
|
16
16
|
# * +:pool:+ — which pool the package should belong to.
|
17
17
|
#
|
18
|
-
# Raises an error when the given directory doesn't contain a package.yml
|
18
|
+
# Raises an error when the given directory doesn't contain a package.yml or package.json
|
19
19
|
# file with meta info.
|
20
20
|
#
|
21
21
|
def initialize(directory, options = {})
|
22
22
|
self.directory = File.expand_path(directory)
|
23
|
-
|
23
|
+
if File.exists?(File.join(directory, 'package.yml'))
|
24
|
+
self.header = YAML.load_file(File.join(directory, 'package.yml'))
|
25
|
+
elsif File.exists?(File.join(directory, 'package.json'))
|
26
|
+
self.header = JSON.load(IO.read(File.join(directory, 'package.json')))
|
27
|
+
else
|
28
|
+
end
|
24
29
|
Dir.chdir(directory) do
|
25
30
|
files.each do |source|
|
26
31
|
source_file = SourceFile.from_file(source, :package => self)
|
data/lib/jsus/pool.rb
CHANGED
@@ -22,7 +22,7 @@ module Jsus
|
|
22
22
|
#
|
23
23
|
def initialize(dir = nil)
|
24
24
|
if dir
|
25
|
-
Dir[File.join(dir, '**', 'package.yml')].each do |package_path|
|
25
|
+
Dir[File.join(dir, '**', 'package.{yml,json}')].each do |package_path|
|
26
26
|
Package.new(File.dirname(package_path), :pool => self)
|
27
27
|
end
|
28
28
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
/*
|
2
|
+
---
|
3
|
+
name : Sheet.DOM
|
4
|
+
description : Sheet.DOM adds some handy stuff for working with the browser's native CSS capabilities.
|
5
|
+
|
6
|
+
authors : Thomas Aylott
|
7
|
+
copyright : © 2010 Thomas Aylott
|
8
|
+
license : MIT
|
9
|
+
|
10
|
+
provides : Sheet.DOM
|
11
|
+
...
|
12
|
+
*/
|
13
|
+
;(function(document,styleSheets){
|
14
|
+
|
15
|
+
if (typeof Sheet == 'undefined') Sheet = {}
|
16
|
+
if (Sheet.DOM == null) Sheet.DOM = {}
|
17
|
+
|
18
|
+
Sheet.DOM.createSheet = function(raw){
|
19
|
+
var oldLength = styleSheets.length
|
20
|
+
, style
|
21
|
+
, sheet
|
22
|
+
|
23
|
+
if (document.createStyleSheet){
|
24
|
+
document.createStyleSheet()
|
25
|
+
styleSheets[styleSheets.length - 1].cssText = raw
|
26
|
+
}
|
27
|
+
|
28
|
+
if (oldLength >= styleSheets.length){
|
29
|
+
style = document.createElement('style')
|
30
|
+
style.setAttribute('type','text/css')
|
31
|
+
style.appendChild(document.createTextNode(raw))
|
32
|
+
document.getElementsByTagName('head')[0].appendChild(style)
|
33
|
+
}
|
34
|
+
|
35
|
+
if (oldLength >= styleSheets.length){
|
36
|
+
style = document.createElement('div')
|
37
|
+
style.innerHTML = '<style type="text/css">' + String_escapeHTML.call(raw) + '</style>'
|
38
|
+
document.getElementsByTagName('head')[0].appendChild(style)
|
39
|
+
}
|
40
|
+
|
41
|
+
if (oldLength >= styleSheets.length)
|
42
|
+
throw new Error('no styleSheet added :(')
|
43
|
+
|
44
|
+
sheet = styleSheets[styleSheets.length - 1]
|
45
|
+
sheet.cssText = raw
|
46
|
+
|
47
|
+
return sheet
|
48
|
+
}
|
49
|
+
|
50
|
+
Sheet.DOM.createStyle = function(raw){
|
51
|
+
var div = document.createElement('div')
|
52
|
+
div.innerHTML = '<p style="' + String_escapeHTML.call(raw) + '"></p>'
|
53
|
+
return {style:div.firstChild.style}
|
54
|
+
}
|
55
|
+
|
56
|
+
function String_escapeHTML(){
|
57
|
+
return ('' + this).replace(/&/g,'&').replace(/</g,'<').replace(/"/g,'"')
|
58
|
+
}
|
59
|
+
|
60
|
+
|
61
|
+
}(document, document.styleSheets));
|
@@ -0,0 +1,80 @@
|
|
1
|
+
/*
|
2
|
+
---
|
3
|
+
name : Sheet
|
4
|
+
|
5
|
+
authors : Thomas Aylott
|
6
|
+
copyright : © 2010 Thomas Aylott
|
7
|
+
license : MIT
|
8
|
+
|
9
|
+
provides : Sheet
|
10
|
+
requires : SheetParser.CSS
|
11
|
+
...
|
12
|
+
*/
|
13
|
+
;(function(exports){
|
14
|
+
|
15
|
+
|
16
|
+
/*<depend>*/
|
17
|
+
var UNDEF = {undefined:1}
|
18
|
+
|
19
|
+
/*<CommonJS>*/
|
20
|
+
var SheetParser = UNDEF[typeof require]
|
21
|
+
? exports.SheetParser
|
22
|
+
: require('./SheetParser.CSS').SheetParser
|
23
|
+
|
24
|
+
exports.Sheet = Sheet
|
25
|
+
/*</CommonJS>*/
|
26
|
+
|
27
|
+
/*<debug>*/;if (!(!UNDEF[typeof SheetParser] && SheetParser.CSS)) throw new Error('Missing required function: "SheetParser.CSS"');/*</debug>*/
|
28
|
+
/*</depend>*/
|
29
|
+
|
30
|
+
|
31
|
+
Sheet.version = '1.0.1'
|
32
|
+
|
33
|
+
function Sheet(cssText){
|
34
|
+
if (this instanceof Sheet) this.initialize(cssText)
|
35
|
+
else return Sheet.from(cssText)
|
36
|
+
}
|
37
|
+
|
38
|
+
Sheet.from = function(cssText){
|
39
|
+
return new Sheet(cssText)
|
40
|
+
}
|
41
|
+
|
42
|
+
Sheet.prototype = {
|
43
|
+
|
44
|
+
parser: SheetParser.CSS,
|
45
|
+
|
46
|
+
initialize: function(cssText){
|
47
|
+
this.cssText = cssText || ''
|
48
|
+
this.style = this.rules = this.cssRules = this.parser.parse(this.cssText)
|
49
|
+
var self = this
|
50
|
+
},
|
51
|
+
|
52
|
+
update: function(){
|
53
|
+
var cssText = '',
|
54
|
+
i = -1,
|
55
|
+
rule,
|
56
|
+
rules = this.style || this.rules || this.cssRules
|
57
|
+
|
58
|
+
while ((rule = rules[++i])){
|
59
|
+
if (typeof rule == 'object'){
|
60
|
+
// cssRule
|
61
|
+
if (this.update) rule.cssText = this.update.call(rule)
|
62
|
+
cssText += rule.cssText = rule.selectorText + '{' + rule.cssText + '}'
|
63
|
+
} else {
|
64
|
+
// style key/value
|
65
|
+
cssText += rule + ':'
|
66
|
+
cssText += rules[rule] + ';'
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
if (rules.selectorText)
|
71
|
+
return rules.cssText = rules.selectorText + '{' + cssText + '}'
|
72
|
+
return rules.cssText = cssText
|
73
|
+
}
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
Sheet.prototype.toString = Sheet.prototype.update
|
78
|
+
|
79
|
+
|
80
|
+
}(typeof exports != 'undefined' ? exports : this));
|
@@ -0,0 +1,127 @@
|
|
1
|
+
/*
|
2
|
+
---
|
3
|
+
name : SheetParser.CSS
|
4
|
+
|
5
|
+
authors : Thomas Aylott
|
6
|
+
copyright : © 2010 Thomas Aylott
|
7
|
+
license : MIT
|
8
|
+
|
9
|
+
provides : SheetParser.CSS
|
10
|
+
requires : combineRegExp
|
11
|
+
...
|
12
|
+
*/
|
13
|
+
;(function(exports){
|
14
|
+
|
15
|
+
|
16
|
+
/*<depend>*/
|
17
|
+
var UNDEF = {undefined:1}
|
18
|
+
if (!exports.SheetParser) exports.SheetParser = {}
|
19
|
+
|
20
|
+
/*<CommonJS>*/
|
21
|
+
var combineRegExp = UNDEF[typeof require]
|
22
|
+
? exports.combineRegExp
|
23
|
+
: require('./sg-regex-tools').combineRegExp
|
24
|
+
var SheetParser = exports.SheetParser
|
25
|
+
/*</CommonJS>*/
|
26
|
+
|
27
|
+
/*<debug>*/;if (UNDEF[typeof combineRegExp]) throw new Error('Missing required function: "combineRegExp"');/*</debug>*/
|
28
|
+
/*</depend>*/
|
29
|
+
|
30
|
+
|
31
|
+
var CSS = SheetParser.CSS = {version: '1.0.1'}
|
32
|
+
|
33
|
+
CSS.camelCase = function(string){
|
34
|
+
return ('' + string).replace(camelCaseSearch, camelCaseReplace)
|
35
|
+
}
|
36
|
+
var camelCaseSearch = /-\D/g
|
37
|
+
function camelCaseReplace(match){
|
38
|
+
return match.charAt(1).toUpperCase()
|
39
|
+
}
|
40
|
+
|
41
|
+
CSS.parse = function(cssText){
|
42
|
+
var found
|
43
|
+
, rule
|
44
|
+
, rules = {length:0}
|
45
|
+
, keyIndex = -1
|
46
|
+
, regex = this.parser
|
47
|
+
, names = CSS.parser.names
|
48
|
+
, i,r,l
|
49
|
+
, ruleCount
|
50
|
+
|
51
|
+
rules.cssText = cssText = ('' + cssText)
|
52
|
+
|
53
|
+
regex.lastIndex = 0
|
54
|
+
while ((found = regex.exec(cssText))){
|
55
|
+
// avoid an infinite loop on zero-length keys
|
56
|
+
if (regex.lastIndex == found.index) ++ regex.lastIndex
|
57
|
+
|
58
|
+
// key:value
|
59
|
+
if (found[names._key]){
|
60
|
+
rules[rules.length ++] = found[names._key]
|
61
|
+
rules[found[names._key]] = found[names._value]
|
62
|
+
rules[CSS.camelCase(found[names._key])] = found[names._value]
|
63
|
+
continue
|
64
|
+
}
|
65
|
+
|
66
|
+
rules[rules.length++] = rule = {}
|
67
|
+
for (i = -1, l = names.length; i < l; ++i){
|
68
|
+
if (!found[i]) continue
|
69
|
+
rule[names[i-1]] = found[i]
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
for (i = -1, l = rules.length; i < l; ++i){
|
74
|
+
if (!rules[i] || !rules[i].style_cssText) continue
|
75
|
+
|
76
|
+
rules[i].style = CSS.parse(rules[i].style_cssText)
|
77
|
+
|
78
|
+
for (ruleCount = -1, r = -1, rule; rule = rules[i].style[++r];){
|
79
|
+
if (typeof rule == 'string') continue
|
80
|
+
rules[i][r] = (rules[i].cssRules || (rules[i].cssRules = {}))[++ ruleCount] = rule
|
81
|
+
rules[i].cssRules.length = ruleCount + 1
|
82
|
+
rules[i].rules = rules[i].cssRules
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
return rules
|
87
|
+
}
|
88
|
+
|
89
|
+
var x = combineRegExp
|
90
|
+
|
91
|
+
;(CSS.at = x(/\s*(@[-a-zA-Z0-9]+)\s+([^;{]*)/))
|
92
|
+
.names=[ 'kind', 'name']
|
93
|
+
|
94
|
+
CSS.atRule = x([CSS.at, ';'])
|
95
|
+
|
96
|
+
;(CSS.keyValue = x(/\s*([-a-zA-Z0-9]+):\s*(.*?)(?:;|(?=\})|$)/))
|
97
|
+
.names=[ '_key', '_value']
|
98
|
+
|
99
|
+
;(CSS.comment = x(/\/\*\s*((?:[^*]|\*(?!\/))*)\s*\*\//))
|
100
|
+
.names=[ 'comment']
|
101
|
+
|
102
|
+
;(CSS.selector = x(/\s*((\d+%)|[^\{}]+?)\s*/))
|
103
|
+
.names=[ 'selectorText','keyText']
|
104
|
+
|
105
|
+
;(CSS.block = x(/\{\s*((?:[^{}]|\{(?:[^{}]|\{(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\})*\})*)\s*\}/))
|
106
|
+
.names=[ 'style_cssText']
|
107
|
+
|
108
|
+
CSS.selectorBlock = x([CSS.selector, CSS.block])
|
109
|
+
|
110
|
+
CSS.atBlock = x([CSS.at, CSS.block])
|
111
|
+
|
112
|
+
var OR = '|'
|
113
|
+
|
114
|
+
CSS.parser = x([
|
115
|
+
x(CSS.comment)
|
116
|
+
,OR
|
117
|
+
,x(CSS.atBlock)
|
118
|
+
,OR
|
119
|
+
,x(CSS.atRule)
|
120
|
+
,OR
|
121
|
+
,x(CSS.selectorBlock)
|
122
|
+
,OR
|
123
|
+
,x(CSS.keyValue)
|
124
|
+
],'cssText')
|
125
|
+
|
126
|
+
|
127
|
+
})(typeof exports != 'undefined' ? exports : this);
|
@@ -0,0 +1,37 @@
|
|
1
|
+
/*
|
2
|
+
---
|
3
|
+
name : sg-regex-tools
|
4
|
+
description : A few super-handy tools for messing around with RegExp
|
5
|
+
|
6
|
+
authors : Thomas Aylott
|
7
|
+
copyright : © 2010 Thomas Aylott
|
8
|
+
license : MIT
|
9
|
+
|
10
|
+
provides : [combineRegExp]
|
11
|
+
...
|
12
|
+
*/
|
13
|
+
;(function(exports){
|
14
|
+
|
15
|
+
exports.combineRegExp = function(regex, group){
|
16
|
+
if (regex.source) regex = [regex]
|
17
|
+
|
18
|
+
var names = [], i, source = '', this_source
|
19
|
+
|
20
|
+
for (i = 0; i < regex.length; ++i){ if (!regex[i]) continue
|
21
|
+
this_source = regex[i].source || ''+regex[i]
|
22
|
+
if (this_source == '|') source += '|'
|
23
|
+
else {
|
24
|
+
source += (group?'(':'') + this_source.replace(/\s/g,'') + (group?')':'')
|
25
|
+
if (group) names.push(group)
|
26
|
+
}
|
27
|
+
if (regex[i].names) names = names.concat(regex[i].names)
|
28
|
+
}
|
29
|
+
regex = new RegExp(source,'gm')
|
30
|
+
// [key] → 1
|
31
|
+
for (i = -1; i < names.length; ++i) names[names[i]] = i + 1
|
32
|
+
// [1] → key
|
33
|
+
regex.names = names
|
34
|
+
return regex
|
35
|
+
}
|
36
|
+
|
37
|
+
}(typeof exports != 'undefined' ? exports : this))
|
@@ -0,0 +1,56 @@
|
|
1
|
+
{
|
2
|
+
|
3
|
+
"name": "Sheet",
|
4
|
+
"version": "1.0.1",
|
5
|
+
|
6
|
+
"description": "100% DOM-less JavaScript implementation of the styleSheets, cssRule & style APIs \nSupports custom and browser-incompatible CSS syntax like nested rules",
|
7
|
+
"keywords": [
|
8
|
+
"CSS",
|
9
|
+
"CSSOM",
|
10
|
+
"styleSheet",
|
11
|
+
"cssRule",
|
12
|
+
"style",
|
13
|
+
"parse"
|
14
|
+
],
|
15
|
+
|
16
|
+
"authors": ["Thomas Aylott"],
|
17
|
+
"contributors": [
|
18
|
+
{
|
19
|
+
"name": "Thomas Aylott",
|
20
|
+
"email": "thomas@subtlegradient.com",
|
21
|
+
"web": "http://subtlegradient.com"
|
22
|
+
}
|
23
|
+
],
|
24
|
+
|
25
|
+
"copyright": "© 2010 Thomas Aylott",
|
26
|
+
"license": "MIT License",
|
27
|
+
"licenses": [
|
28
|
+
{
|
29
|
+
"type": "MIT",
|
30
|
+
"url": "http://creativecommons.org/licenses/MIT/"
|
31
|
+
}
|
32
|
+
],
|
33
|
+
|
34
|
+
"repositories": [{
|
35
|
+
"type": "git",
|
36
|
+
"url": "http://github.com/subtleGradient/Sheet.js/"
|
37
|
+
}],
|
38
|
+
|
39
|
+
"bugs": {
|
40
|
+
"web": "http://github.com/subtleGradient/Sheet.js/issues"
|
41
|
+
},
|
42
|
+
|
43
|
+
"directories": {
|
44
|
+
"src": "./Source",
|
45
|
+
"lib": "./Source",
|
46
|
+
"doc": ".",
|
47
|
+
"test": "./Test"
|
48
|
+
},
|
49
|
+
|
50
|
+
"sources": [
|
51
|
+
"Source/Sheet.js",
|
52
|
+
"Source/SheetParser.CSS.js"
|
53
|
+
],
|
54
|
+
|
55
|
+
"main":"./Source/Sheet"
|
56
|
+
}
|
@@ -8,32 +8,47 @@ describe Jsus::Package do
|
|
8
8
|
before(:each) { cleanup }
|
9
9
|
after(:all) { cleanup }
|
10
10
|
context "initialization" do
|
11
|
-
let(:input_dir) { "spec/data/OutsideDependencies/app/javascripts/Orwik" }
|
12
|
-
let(:output_dir) { "spec/data/OutsideDependencies/public/javascripts/Orwik" }
|
13
11
|
context "from a directory" do
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
context "with a package.yml" do
|
13
|
+
let(:input_dir) { "spec/data/OutsideDependencies/app/javascripts/Orwik" }
|
14
|
+
let(:output_dir) { "spec/data/OutsideDependencies/public/javascripts/Orwik" }
|
15
|
+
|
16
|
+
it "should load header from package.yml" do
|
17
|
+
subject.name.should == "orwik"
|
18
|
+
subject.filename.should == "orwik.js"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should pass pool in options and register itself in the pool" do
|
22
|
+
pool = Jsus::Pool.new
|
23
|
+
package = Jsus::Package.new(input_dir, :pool => pool)
|
24
|
+
package.pool.should == pool
|
25
|
+
pool.packages.should include(package)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should set provided modules from source files" do
|
29
|
+
subject.provides.should have_exactly(4).items
|
30
|
+
subject.provides_names.should include("Color", "Input", "Input.Color", "Widget")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should set up outside dependencies" do
|
34
|
+
subject.dependencies_names.should == ['core/Class']
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should set directory field" do
|
38
|
+
subject.directory.should == File.expand_path(input_dir)
|
39
|
+
end
|
17
40
|
end
|
18
41
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
package.pool.should == pool
|
23
|
-
pool.packages.should include(package)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should set provided modules from source files" do
|
27
|
-
subject.provides.should have_exactly(4).items
|
28
|
-
subject.provides_names.should include("Color", "Input", "Input.Color", "Widget")
|
29
|
-
end
|
42
|
+
context "with a package.json" do
|
43
|
+
let(:input_dir) { "spec/data/JsonPackage" }
|
44
|
+
let(:output_dir) { "spec/data/JsonPackage" }
|
30
45
|
|
31
|
-
|
32
|
-
|
33
|
-
|
46
|
+
it "should load header from package.json" do
|
47
|
+
subject.name.should == "Sheet"
|
48
|
+
subject.provides_names.should =~ ["Sheet", "SheetParser.CSS"]
|
49
|
+
subject.dependencies_names.should =~ ["combineRegExp"]
|
50
|
+
end
|
34
51
|
|
35
|
-
it "should set directory field" do
|
36
|
-
subject.directory.should == File.expand_path(input_dir)
|
37
52
|
end
|
38
53
|
end
|
39
54
|
end
|
data/spec/lib/jsus/pool_spec.rb
CHANGED
@@ -41,6 +41,11 @@ describe Jsus::Pool do
|
|
41
41
|
pool = Jsus::Pool.new("spec/data/Extensions/app/javascripts")
|
42
42
|
pool.send(:extensions_map).keys.should include(Jsus::Tag["Core/Class"])
|
43
43
|
end
|
44
|
+
|
45
|
+
it "should load package.json packages too" do
|
46
|
+
pool = Jsus::Pool.new("spec/data/JsonPackage")
|
47
|
+
pool.should have_exactly(1).packages
|
48
|
+
end
|
44
49
|
end
|
45
50
|
end
|
46
51
|
|
metadata
CHANGED
@@ -5,8 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
|
8
|
+
- 10
|
9
|
+
- 1
|
10
|
+
version: 0.1.10.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Markiz, idea by Inviz (http://github.com/Inviz)
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-09-11 00:00:00 +04:00
|
18
19
|
default_executable: jsus
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
@@ -147,6 +148,11 @@ files:
|
|
147
148
|
- spec/data/ExternalInternalDependencies/Test/Source/Widget/Input/Input.js
|
148
149
|
- spec/data/ExternalInternalDependencies/Test/Source/Widget/Widget.js
|
149
150
|
- spec/data/ExternalInternalDependencies/Test/package.yml
|
151
|
+
- spec/data/JsonPackage/Source/Sheet.DOM.js
|
152
|
+
- spec/data/JsonPackage/Source/Sheet.js
|
153
|
+
- spec/data/JsonPackage/Source/SheetParser.CSS.js
|
154
|
+
- spec/data/JsonPackage/Source/sg-regex-tools.js
|
155
|
+
- spec/data/JsonPackage/package.json
|
150
156
|
- spec/data/OutsideDependencies/README
|
151
157
|
- spec/data/OutsideDependencies/app/javascripts/Core/Source/Class/Class.Extras.js
|
152
158
|
- spec/data/OutsideDependencies/app/javascripts/Core/Source/Class/Class.js
|