jsus 0.2.0 → 0.2.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 +5 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +12 -2
- data/VERSION +1 -1
- data/autotest/discover.rb +1 -0
- data/bin/jsus +86 -90
- data/cucumber.yml +1 -0
- data/features/command-line/basic_dependency_resolution.feature +99 -0
- data/features/command-line/extensions.feature +70 -0
- data/features/command-line/external_dependency_resolution.feature +120 -0
- data/features/command-line/json_package.feature +50 -0
- data/features/command-line/structure_json.feature +56 -0
- data/features/data/Basic/Source/Library/Color.js +16 -0
- data/features/data/Basic/Source/Widget/Input/Input.Color.js +19 -0
- data/features/data/Basic/package.yml +9 -0
- data/features/data/BasicWrongOrder/Source/Library/Color.js +16 -0
- data/features/data/BasicWrongOrder/Source/Widget/Input/Input.Color.js +19 -0
- data/features/data/BasicWrongOrder/package.yml +9 -0
- data/features/data/Extensions/Mootools/Source/Core.js +16 -0
- data/features/data/Extensions/Mootools/package.yml +8 -0
- data/features/data/Extensions/Source/Extensions/MootoolsCore.js +16 -0
- data/features/data/Extensions/Source/Library/Color.js +19 -0
- data/features/data/Extensions/package.yml +9 -0
- data/features/data/ExternalDependency/Mootools/Source/Core.js +16 -0
- data/features/data/ExternalDependency/Mootools/package.yml +8 -0
- data/features/data/ExternalDependency/Source/Library/Color.js +19 -0
- data/features/data/ExternalDependency/Source/Widget/Input/Input.Color.js +19 -0
- data/features/data/ExternalDependency/package.yml +9 -0
- data/features/data/ExternalDependencyWithExternalDependency/Leonardo/Source/Core.js +19 -0
- data/features/data/ExternalDependencyWithExternalDependency/Leonardo/package.yml +8 -0
- data/features/data/ExternalDependencyWithExternalDependency/Mootools/Source/Core.js +16 -0
- data/features/data/ExternalDependencyWithExternalDependency/Mootools/package.yml +8 -0
- data/features/data/ExternalDependencyWithExternalDependency/Source/Library/Color.js +19 -0
- data/features/data/ExternalDependencyWithExternalDependency/Source/Widget/Input/Input.Color.js +19 -0
- data/features/data/ExternalDependencyWithExternalDependency/package.yml +9 -0
- data/features/data/JsonPackage/Source/Library/Color.js +16 -0
- data/features/data/JsonPackage/Source/Widget/Input/Input.Color.js +19 -0
- data/features/data/JsonPackage/package.json +12 -0
- data/features/data/tmp2/package.js +35 -0
- data/features/data/tmp2/scripts.json +13 -0
- data/features/data/tmp2/tree.json +26 -0
- data/features/step_definitions/cli_steps.rb +53 -0
- data/features/support/env.rb +9 -0
- data/jsus.gemspec +42 -5
- metadata +45 -8
data/CHANGELOG
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
= Jsus Changelog
|
2
|
+
== Version 0.2.1
|
3
|
+
* Started adding cucumber features for command-line utility. Look into /features
|
4
|
+
directory for reference
|
5
|
+
* Removed choice gem from list of dependency. Using stdlib's optparse instead
|
6
|
+
|
2
7
|
== Version 0.2.0
|
3
8
|
* Support for mooforge validator (checks if every file has authors && license),
|
4
9
|
more validators at request
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,14 +2,23 @@ GEM
|
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
4
|
activesupport (3.0.3)
|
5
|
-
|
5
|
+
builder (3.0.0)
|
6
|
+
cucumber (0.10.0)
|
7
|
+
builder (>= 2.1.2)
|
8
|
+
diff-lcs (~> 1.1.2)
|
9
|
+
gherkin (~> 2.3.2)
|
10
|
+
json (~> 1.4.6)
|
11
|
+
term-ansicolor (~> 1.0.5)
|
6
12
|
diff-lcs (1.1.2)
|
13
|
+
gherkin (2.3.3)
|
14
|
+
json (~> 1.4.6)
|
7
15
|
git (1.2.5)
|
8
16
|
haml (3.0.25)
|
9
17
|
jeweler (1.5.2)
|
10
18
|
bundler (~> 1.0.0)
|
11
19
|
git (>= 1.2.5)
|
12
20
|
rake
|
21
|
+
json (1.4.6)
|
13
22
|
json_pure (1.4.6)
|
14
23
|
murdoc (0.1.5)
|
15
24
|
haml (~> 3.0.0)
|
@@ -30,6 +39,7 @@ GEM
|
|
30
39
|
diff-lcs (~> 1.1.2)
|
31
40
|
rspec-mocks (2.4.0)
|
32
41
|
stream (0.5)
|
42
|
+
term-ansicolor (1.0.5)
|
33
43
|
|
34
44
|
PLATFORMS
|
35
45
|
ruby
|
@@ -37,7 +47,7 @@ PLATFORMS
|
|
37
47
|
DEPENDENCIES
|
38
48
|
activesupport
|
39
49
|
bundler
|
40
|
-
|
50
|
+
cucumber
|
41
51
|
jeweler
|
42
52
|
json_pure
|
43
53
|
murdoc
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/autotest/discover.rb
CHANGED
data/bin/jsus
CHANGED
@@ -1,120 +1,115 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'rubygems'
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
|
4
|
+
if File.exists?('./lib/jsus.rb') # override with local version of jsus
|
5
|
+
$:.unshift File.expand_path(Dir.pwd) + "/lib"
|
6
|
+
elsif File.exists?(File.expand_path(File.dirname(__FILE__)) + "/../lib/jsus.rb")
|
7
|
+
$:.unshift File.expand_path(File.dirname(__FILE__)) + "/../lib"
|
8
8
|
end
|
9
|
+
require 'jsus'
|
9
10
|
|
10
11
|
require "fileutils"
|
11
|
-
require
|
12
|
+
require "optparse"
|
13
|
+
|
12
14
|
start_time = Time.now
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
+
options = {}
|
17
|
+
cli = OptionParser.new do |opts|
|
18
|
+
opts.banner = "jsus #{Jsus.version}. Usage: jsus [options] <input_dir> <output_dir>"
|
16
19
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
desc "Path to directory containing your package to compile."
|
20
|
+
opts.on('-i', '--input-directory [DIR]', '[DEPRECATED] path to input directory ') do |dir|
|
21
|
+
$stderr.puts "DEPRECATION NOTICE: please do not use -i command-line argument"
|
22
|
+
options[:input_dir] = dir
|
21
23
|
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
|
25
|
+
opts.on('-o', '--input-directory [DIR]', '[DEPRECATED] path to output directory ') do |dir|
|
26
|
+
$stderr.puts "DEPRECATION NOTICE: please do not use -o command-line argument"
|
27
|
+
options[:output_dir] = dir
|
28
|
+
end
|
29
|
+
|
30
|
+
opts.on('-d', '--with-dependencies [DEPS]', 'path to directory containing dependency packages') do |dir|
|
31
|
+
options[:deps_dir] = dir
|
27
32
|
end
|
28
33
|
|
29
|
-
|
30
|
-
|
31
|
-
long "--with-dependencies=DIRECTORY"
|
32
|
-
desc "Path to directory containing packages this package relies on. " <<
|
33
|
-
"If set, all the packages will be compiled into a single file."
|
34
|
+
opts.on('-g', '--generate-includes', 'generates includes.js file that you may use for ad-hoc requiring of dependencies') do
|
35
|
+
options[:generate_includes] = true
|
34
36
|
end
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
|
38
|
+
opts.on('--generate-docs [*CLASSES]', Array, "generate docs for some of the sources. When given empty array, defaults to /**/*") do |docs|
|
39
|
+
if !docs
|
40
|
+
options[:documented_classes] = ["/**/*"]
|
41
|
+
else
|
42
|
+
options[:documented_classes] = docs
|
43
|
+
end
|
40
44
|
end
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
desc "When this flag is set, jsus doesn't generate tree.json file" <<
|
45
|
-
"with tree structure of your package."
|
45
|
+
|
46
|
+
opts.on('--no-syntax-highlight', 'if you turned on docs generation, it will use syntax highlighting by default. This option prevents it') do
|
47
|
+
options[:no_syntax_highlight] = true
|
46
48
|
end
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
long "--generate-includes=[ROOT]"
|
51
|
-
desc "Generates includes.js file that you may use for ad-hoc requiring" <<
|
52
|
-
"of the needed javascripts. Defaults to output_directory."
|
49
|
+
|
50
|
+
opts.on('--validate-with [*VALIDATORS]', Array, 'performs a check against some of the validators. Available validators: mooforge') do |validators|
|
51
|
+
options[:validators] = (validators || []).map {|v| v.downcase }
|
53
52
|
end
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
short "-b"
|
58
|
-
desc "Performs a benchmark, indicating how much time you needed to" <<
|
59
|
-
"compile the package"
|
53
|
+
|
54
|
+
opts.on_tail('-v', '--verbose', 'verbose mode, shows various debug messages') do
|
55
|
+
options[:verbose] = true
|
60
56
|
end
|
61
57
|
|
62
|
-
|
63
|
-
|
64
|
-
long "--generate-docs *CLASSES"
|
65
|
-
desc "Generate documentation for classes via murdoc. You need to use FULL PATHS, e.g.: " <<
|
66
|
-
"/mootools/*, /LSD/*, /**/*"
|
67
|
-
|
58
|
+
opts.on_tail('-b', '--benchmark', 'shows time spent on various stages') do
|
59
|
+
options[:benchmark] = true
|
68
60
|
end
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
long "--no-syntax-highlight"
|
73
|
-
desc "Disable syntax highlighting in murdoc. Greatly increases docs generation speed. " <<
|
74
|
-
"Note: This option won't have any effect unless you have Pygments installed."
|
61
|
+
|
62
|
+
opts.on_tail('--without-scripts-info', 'do not generate scripts.json') do
|
63
|
+
options[:without_scripts_info] = true
|
75
64
|
end
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
short "-v"
|
80
|
-
long "--verbose"
|
81
|
-
desc "When verbose mode is enabled, some debug information is displayed. Defaults to false."
|
65
|
+
|
66
|
+
opts.on_tail('--without-tree-info', 'do not generate tree.json') do
|
67
|
+
options[:without_tree_info] = true
|
82
68
|
end
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
opts.on_tail('-h', '--help', 'Show this message') do
|
73
|
+
puts opts
|
74
|
+
exit
|
89
75
|
end
|
90
76
|
end
|
77
|
+
cli.parse!
|
91
78
|
|
92
|
-
|
79
|
+
options[:input_dir] ||= ARGV[0]
|
80
|
+
options[:output_dir] ||= ARGV[1]
|
93
81
|
|
94
|
-
|
82
|
+
if !(options[:input_dir] && options[:output_dir])
|
83
|
+
puts cli
|
84
|
+
exit
|
85
|
+
end
|
95
86
|
|
87
|
+
compile_start_time = Time.now
|
88
|
+
|
89
|
+
Jsus.verbose = options[:verbose]
|
90
|
+
|
96
91
|
pool_load_start_time = Time.now
|
97
|
-
pool = if
|
98
|
-
Jsus::Pool.new(
|
92
|
+
pool = if options[:deps_dir]
|
93
|
+
Jsus::Pool.new(options[:deps_dir])
|
99
94
|
else
|
100
95
|
Jsus::Pool.new
|
101
96
|
end
|
102
97
|
pool_load_finish_time = Time.now
|
103
98
|
|
104
|
-
package = Jsus::Package.new(
|
105
|
-
package.include_dependencies!
|
106
|
-
|
107
|
-
package.compile(
|
108
|
-
package.generate_scripts_info(
|
109
|
-
package.generate_tree(
|
99
|
+
package = Jsus::Package.new(options[:input_dir], :pool => pool)
|
100
|
+
package.include_dependencies!
|
101
|
+
output_dir = options[:output_dir]
|
102
|
+
package.compile(output_dir)
|
103
|
+
package.generate_scripts_info(output_dir) unless options[:without_scripts_info]
|
104
|
+
package.generate_tree(output_dir) unless options[:without_tree_info]
|
110
105
|
|
111
106
|
# Validations
|
112
107
|
validators_map = {"mooforge" => Jsus::Validator::Mooforge}
|
113
|
-
|
114
|
-
if validator = validators_map[validator_name
|
108
|
+
(options[:validators] || []).each do |validator_name|
|
109
|
+
if validator = validators_map[validator_name]
|
115
110
|
errors = validator.new(pool.sources.to_a & package.source_files.to_a).validation_errors
|
116
111
|
unless errors.empty?
|
117
|
-
puts "Validator found errors: "
|
112
|
+
puts "Validator #{validator_name} found errors: "
|
118
113
|
errors.each {|e| puts " * #{e}"}
|
119
114
|
end
|
120
115
|
else
|
@@ -123,35 +118,36 @@ Choice.choices[:validate_with].each do |validator_name|
|
|
123
118
|
end
|
124
119
|
|
125
120
|
# Hack, hack, hack :[
|
126
|
-
if
|
127
|
-
|
128
|
-
File.open(File.join(Choice.choices[:output_directory], "includes.js"), "w") do |f|
|
121
|
+
if options[:generate_includes]
|
122
|
+
File.open(File.join(output_dir, "includes.js"), "w") do |f|
|
129
123
|
c = Jsus::Container.new(*(package.source_files.to_a + package.linked_external_dependencies.to_a))
|
130
124
|
script = %{(function(prefix) {
|
131
125
|
var sources = %sources%;
|
132
126
|
for (var i = 0, j = sources.length; i < j; i++) document.write('<scr' + 'ipt src="' + (prefix || '') + sources[i] + '"></script>');
|
133
|
-
})(window.prefix);}.sub("%sources%", JSON.pretty_generate(c.required_files(
|
127
|
+
})(window.prefix);}.sub("%sources%", JSON.pretty_generate(c.required_files(output_dir)))
|
134
128
|
f.puts script
|
135
129
|
end
|
136
130
|
end
|
137
131
|
|
132
|
+
docs_start_time = Time.now
|
138
133
|
# Generate documentation
|
139
|
-
|
140
|
-
documenter = Jsus::Documenter.new(:highlight_source => !
|
134
|
+
if options[:documented_classes] && !options[:documented_classes].empty?
|
135
|
+
documenter = Jsus::Documenter.new(:highlight_source => !options[:no_syntax_highlight])
|
141
136
|
package.source_files.each {|source| documenter << source }
|
142
137
|
pool.sources.each {|source| documenter << source } if pool
|
143
|
-
documenter.only(
|
138
|
+
documenter.only(options[:documented_classes]).generate(output_dir + "/docs")
|
144
139
|
end
|
145
|
-
|
140
|
+
docs_finish_time = Time.now
|
146
141
|
|
147
142
|
finish_time = Time.now
|
148
143
|
|
149
144
|
|
150
|
-
if
|
145
|
+
if options[:benchmark]
|
151
146
|
puts "Benchmarking results:"
|
152
147
|
puts "Total execution time: #{format("%.3f" ,finish_time - start_time)}s"
|
153
148
|
puts ""
|
154
149
|
puts "Of them:"
|
155
150
|
puts "Pool preloading time: #{format("%.3f", pool_load_finish_time - pool_load_start_time)}s"
|
151
|
+
puts "Docs generation time: #{format("%.3f", docs_finish_time - docs_start_time)}s" if options[:documented_classes]
|
156
152
|
puts "Total compilation time: #{format("%.3f", finish_time - compile_start_time - (pool_load_finish_time - pool_load_start_time))}s"
|
157
153
|
end
|
data/cucumber.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
default: --format pretty --color
|
@@ -0,0 +1,99 @@
|
|
1
|
+
Feature: resolve dependencies
|
2
|
+
In order to resolve dependencies, jsus should use topological sort on the
|
3
|
+
dependency list.
|
4
|
+
|
5
|
+
Scenario: internal dependencies in correct order
|
6
|
+
When I run "jsus -i Basic -o tmp"
|
7
|
+
Then the following files should exist:
|
8
|
+
| tmp/package.js |
|
9
|
+
And file "tmp/package.js" should contain
|
10
|
+
"""
|
11
|
+
/*
|
12
|
+
---
|
13
|
+
|
14
|
+
script: Color.js
|
15
|
+
|
16
|
+
description: A library to work with colors
|
17
|
+
|
18
|
+
license: MIT-style license
|
19
|
+
|
20
|
+
authors:
|
21
|
+
- Valerio Proietti
|
22
|
+
|
23
|
+
provides: [Color]
|
24
|
+
|
25
|
+
...
|
26
|
+
*/
|
27
|
+
"""
|
28
|
+
And file "tmp/package.js" should contain
|
29
|
+
"""
|
30
|
+
/*
|
31
|
+
---
|
32
|
+
|
33
|
+
script: Input.Color.js
|
34
|
+
|
35
|
+
description: Cool colorpicker for everyone to enjoy
|
36
|
+
|
37
|
+
license: MIT-style license
|
38
|
+
|
39
|
+
authors:
|
40
|
+
- Yaroslaff Fedin
|
41
|
+
|
42
|
+
requires:
|
43
|
+
- Color
|
44
|
+
|
45
|
+
provides: [Input.Color]
|
46
|
+
|
47
|
+
...
|
48
|
+
*/
|
49
|
+
"""
|
50
|
+
And file "tmp/package.js" should have "script: Color.js" before "script: Input.Color.js"
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
Scenario: internal dependencies in wrong order
|
55
|
+
When I run "jsus -i BasicWrongOrder -o tmp"
|
56
|
+
Then the following files should exist:
|
57
|
+
| tmp/package.js |
|
58
|
+
And file "tmp/package.js" should contain
|
59
|
+
"""
|
60
|
+
/*
|
61
|
+
---
|
62
|
+
|
63
|
+
script: Color.js
|
64
|
+
|
65
|
+
description: A library to work with colors
|
66
|
+
|
67
|
+
license: MIT-style license
|
68
|
+
|
69
|
+
authors:
|
70
|
+
- Valerio Proietti
|
71
|
+
|
72
|
+
provides: [Color]
|
73
|
+
|
74
|
+
...
|
75
|
+
*/
|
76
|
+
"""
|
77
|
+
And file "tmp/package.js" should contain
|
78
|
+
"""
|
79
|
+
/*
|
80
|
+
---
|
81
|
+
|
82
|
+
script: Input.Color.js
|
83
|
+
|
84
|
+
description: Cool colorpicker for everyone to enjoy
|
85
|
+
|
86
|
+
license: MIT-style license
|
87
|
+
|
88
|
+
authors:
|
89
|
+
- Yaroslaff Fedin
|
90
|
+
|
91
|
+
requires:
|
92
|
+
- Color
|
93
|
+
|
94
|
+
provides: [Input.Color]
|
95
|
+
|
96
|
+
...
|
97
|
+
*/
|
98
|
+
"""
|
99
|
+
And file "tmp/package.js" should have "script: Color.js" before "script: Input.Color.js"
|
@@ -0,0 +1,70 @@
|
|
1
|
+
Feature: extensions
|
2
|
+
In order to monkeypatch other libraries, I should be able to cook some
|
3
|
+
extensions.
|
4
|
+
|
5
|
+
Scenario: monkeypatch for external dependency
|
6
|
+
When I run "jsus -i Extensions -o tmp -d Extensions/Mootools"
|
7
|
+
Then the following files should exist:
|
8
|
+
| tmp/package.js |
|
9
|
+
And file "tmp/package.js" should contain
|
10
|
+
"""
|
11
|
+
/*
|
12
|
+
---
|
13
|
+
|
14
|
+
script: Core.js
|
15
|
+
|
16
|
+
description: Mootools fake core
|
17
|
+
|
18
|
+
license: MIT-style license
|
19
|
+
|
20
|
+
authors:
|
21
|
+
- Valerio Proietti
|
22
|
+
|
23
|
+
provides: [Core]
|
24
|
+
|
25
|
+
...
|
26
|
+
*/
|
27
|
+
"""
|
28
|
+
And file "tmp/package.js" should contain
|
29
|
+
"""
|
30
|
+
/*
|
31
|
+
---
|
32
|
+
|
33
|
+
script: MootooolsCore.js
|
34
|
+
|
35
|
+
description: Extension for mootools core
|
36
|
+
|
37
|
+
license: MIT-style license
|
38
|
+
|
39
|
+
authors:
|
40
|
+
- Mark Abramov
|
41
|
+
|
42
|
+
extends: Mootools/Core
|
43
|
+
|
44
|
+
...
|
45
|
+
*/
|
46
|
+
"""
|
47
|
+
And file "tmp/package.js" should contain
|
48
|
+
"""
|
49
|
+
/*
|
50
|
+
---
|
51
|
+
|
52
|
+
script: Color.js
|
53
|
+
|
54
|
+
description: A library to work with colors
|
55
|
+
|
56
|
+
license: MIT-style license
|
57
|
+
|
58
|
+
authors:
|
59
|
+
- Valerio Proietti
|
60
|
+
|
61
|
+
requires:
|
62
|
+
- Mootools/Core
|
63
|
+
|
64
|
+
provides: [Color]
|
65
|
+
|
66
|
+
...
|
67
|
+
*/
|
68
|
+
"""
|
69
|
+
And file "tmp/package.js" should have "MootooolsCore.js" after "script: Core.js"
|
70
|
+
And file "tmp/package.js" should have "MootooolsCore.js" before "script: Color.js"
|