xpcomcore-rubygem 0.3.2 → 0.5.0
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/README.markdown +14 -0
- data/Rakefile +13 -11
- data/VERSION +1 -1
- data/bin/xpcomcore +7 -0
- data/lib/xpcomcore-rubygem.rb +9 -0
- data/lib/xpcomcore-rubygem/commands.rb +54 -0
- data/lib/xpcomcore-rubygem/commands/generate.rb +23 -0
- data/lib/xpcomcore-rubygem/commands/generate/application.rb +63 -0
- data/lib/xpcomcore-rubygem/commands/generate/jeweler_builder_command.rb +108 -0
- data/lib/xpcomcore-rubygem/commands/generate/library.rb +25 -0
- data/lib/xpcomcore-rubygem/commands/generate/template_helpers.rb +78 -0
- data/lib/xpcomcore-rubygem/commands/launch.rb +129 -0
- data/templates/application/application.ini.erb +12 -0
- data/templates/application/chrome/chrome.manifest.erb +1 -0
- data/templates/application/chrome/content/xul/main_window.xul.erb +6 -0
- data/{extension → templates/application}/components/bootstrapper.js +1 -1
- data/templates/application/defaults/preferences/prefs.js.erb +7 -0
- data/templates/shared/jsdoc_doc_task.erb +7 -0
- data/templates/shared/xultestrunner_test_task.erb +7 -0
- data/xpcomcore-rubygem.gemspec +48 -136
- data/xpcomcore/Rakefile +42 -19
- data/xpcomcore/bootstrapper.js +1 -3
- data/xpcomcore/{VERSION.yml → build_properties.yml} +3 -0
- data/xpcomcore/components/XPCOMCore.js +0 -2
- data/xpcomcore/doc/files.html +10 -10
- data/xpcomcore/doc/index.html +17 -17
- data/xpcomcore/doc/symbols/_global_.html +10 -9
- data/xpcomcore/doc/symbols/{Error.html → error.html} +10 -9
- data/xpcomcore/doc/symbols/{File.html → file.html} +13 -12
- data/xpcomcore/doc/symbols/{File.NoSuchFileError.html → file.nosuchfileerror.html} +13 -12
- data/xpcomcore/doc/symbols/{Kernel.html → kernel.html} +48 -47
- data/xpcomcore/doc/symbols/{LoadError.html → loaderror.html} +13 -12
- data/xpcomcore/doc/symbols/{SelfConceptError.html → selfconcepterror.html} +13 -12
- data/xpcomcore/doc/symbols/{Sys.html → sys.html} +12 -11
- data/xpcomcore/doc/symbols/{XPCBuiltins.html → xpcbuiltins.html} +11 -10
- metadata +61 -135
- data/README.rdoc +0 -18
- data/bin/xpcomcore-firefox +0 -4
- data/bin/xpcomcore-rubygem-install +0 -205
- data/extension/README.txt +0 -1
- data/extension/install.rdf +0 -16
- data/xpcomcore/etc/jsdoc-toolkit/README.txt +0 -186
- data/xpcomcore/etc/jsdoc-toolkit/app/frame.js +0 -33
- data/xpcomcore/etc/jsdoc-toolkit/app/frame/Chain.js +0 -102
- data/xpcomcore/etc/jsdoc-toolkit/app/frame/Dumper.js +0 -144
- data/xpcomcore/etc/jsdoc-toolkit/app/frame/Hash.js +0 -84
- data/xpcomcore/etc/jsdoc-toolkit/app/frame/Link.js +0 -153
- data/xpcomcore/etc/jsdoc-toolkit/app/frame/Namespace.js +0 -10
- data/xpcomcore/etc/jsdoc-toolkit/app/frame/Opt.js +0 -134
- data/xpcomcore/etc/jsdoc-toolkit/app/frame/Reflection.js +0 -26
- data/xpcomcore/etc/jsdoc-toolkit/app/frame/String.js +0 -93
- data/xpcomcore/etc/jsdoc-toolkit/app/frame/Testrun.js +0 -129
- data/xpcomcore/etc/jsdoc-toolkit/app/handlers/FOODOC.js +0 -26
- data/xpcomcore/etc/jsdoc-toolkit/app/handlers/XMLDOC.js +0 -26
- data/xpcomcore/etc/jsdoc-toolkit/app/handlers/XMLDOC/DomReader.js +0 -159
- data/xpcomcore/etc/jsdoc-toolkit/app/handlers/XMLDOC/XMLDoc.js +0 -16
- data/xpcomcore/etc/jsdoc-toolkit/app/handlers/XMLDOC/XMLParse.js +0 -292
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC.js +0 -104
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/DocComment.js +0 -200
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/DocTag.js +0 -294
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/JsDoc.js +0 -126
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/JsPlate.js +0 -109
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Lang.js +0 -144
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Parser.js +0 -145
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/PluginManager.js +0 -33
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Symbol.js +0 -645
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/SymbolSet.js +0 -241
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/TextStream.js +0 -41
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Token.js +0 -18
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/TokenReader.js +0 -332
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/TokenStream.js +0 -133
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Util.js +0 -32
- data/xpcomcore/etc/jsdoc-toolkit/app/lib/JSDOC/Walker.js +0 -474
- data/xpcomcore/etc/jsdoc-toolkit/app/main.js +0 -111
- data/xpcomcore/etc/jsdoc-toolkit/app/plugins/commentSrcJson.js +0 -20
- data/xpcomcore/etc/jsdoc-toolkit/app/plugins/frameworkPrototype.js +0 -16
- data/xpcomcore/etc/jsdoc-toolkit/app/plugins/functionCall.js +0 -10
- data/xpcomcore/etc/jsdoc-toolkit/app/plugins/publishSrcHilite.js +0 -62
- data/xpcomcore/etc/jsdoc-toolkit/app/plugins/symbolLink.js +0 -10
- data/xpcomcore/etc/jsdoc-toolkit/app/plugins/tagParamConfig.js +0 -31
- data/xpcomcore/etc/jsdoc-toolkit/app/plugins/tagSynonyms.js +0 -43
- data/xpcomcore/etc/jsdoc-toolkit/app/run.js +0 -348
- data/xpcomcore/etc/jsdoc-toolkit/app/t/TestDoc.js +0 -144
- data/xpcomcore/etc/jsdoc-toolkit/app/t/runner.js +0 -13
- data/xpcomcore/etc/jsdoc-toolkit/app/test.js +0 -325
- data/xpcomcore/etc/jsdoc-toolkit/app/test/addon.js +0 -24
- data/xpcomcore/etc/jsdoc-toolkit/app/test/anon_inner.js +0 -14
- data/xpcomcore/etc/jsdoc-toolkit/app/test/augments.js +0 -31
- data/xpcomcore/etc/jsdoc-toolkit/app/test/augments2.js +0 -26
- data/xpcomcore/etc/jsdoc-toolkit/app/test/borrows.js +0 -46
- data/xpcomcore/etc/jsdoc-toolkit/app/test/borrows2.js +0 -23
- data/xpcomcore/etc/jsdoc-toolkit/app/test/config.js +0 -22
- data/xpcomcore/etc/jsdoc-toolkit/app/test/constructs.js +0 -18
- data/xpcomcore/etc/jsdoc-toolkit/app/test/encoding.js +0 -10
- data/xpcomcore/etc/jsdoc-toolkit/app/test/encoding_other.js +0 -12
- data/xpcomcore/etc/jsdoc-toolkit/app/test/event.js +0 -54
- data/xpcomcore/etc/jsdoc-toolkit/app/test/exports.js +0 -14
- data/xpcomcore/etc/jsdoc-toolkit/app/test/functions_anon.js +0 -39
- data/xpcomcore/etc/jsdoc-toolkit/app/test/functions_nested.js +0 -33
- data/xpcomcore/etc/jsdoc-toolkit/app/test/global.js +0 -13
- data/xpcomcore/etc/jsdoc-toolkit/app/test/globals.js +0 -25
- data/xpcomcore/etc/jsdoc-toolkit/app/test/ignore.js +0 -10
- data/xpcomcore/etc/jsdoc-toolkit/app/test/inner.js +0 -16
- data/xpcomcore/etc/jsdoc-toolkit/app/test/jsdoc_test.js +0 -477
- data/xpcomcore/etc/jsdoc-toolkit/app/test/lend.js +0 -33
- data/xpcomcore/etc/jsdoc-toolkit/app/test/memberof.js +0 -19
- data/xpcomcore/etc/jsdoc-toolkit/app/test/memberof_constructor.js +0 -17
- data/xpcomcore/etc/jsdoc-toolkit/app/test/module.js +0 -17
- data/xpcomcore/etc/jsdoc-toolkit/app/test/name.js +0 -19
- data/xpcomcore/etc/jsdoc-toolkit/app/test/namespace_nested.js +0 -23
- data/xpcomcore/etc/jsdoc-toolkit/app/test/nocode.js +0 -13
- data/xpcomcore/etc/jsdoc-toolkit/app/test/oblit_anon.js +0 -20
- data/xpcomcore/etc/jsdoc-toolkit/app/test/overview.js +0 -20
- data/xpcomcore/etc/jsdoc-toolkit/app/test/param_inline.js +0 -37
- data/xpcomcore/etc/jsdoc-toolkit/app/test/params_optional.js +0 -8
- data/xpcomcore/etc/jsdoc-toolkit/app/test/prototype.js +0 -17
- data/xpcomcore/etc/jsdoc-toolkit/app/test/prototype_nested.js +0 -9
- data/xpcomcore/etc/jsdoc-toolkit/app/test/prototype_oblit.js +0 -13
- data/xpcomcore/etc/jsdoc-toolkit/app/test/prototype_oblit_constructor.js +0 -24
- data/xpcomcore/etc/jsdoc-toolkit/app/test/public.js +0 -10
- data/xpcomcore/etc/jsdoc-toolkit/app/test/scripts/code.js +0 -5
- data/xpcomcore/etc/jsdoc-toolkit/app/test/scripts/notcode.txt +0 -5
- data/xpcomcore/etc/jsdoc-toolkit/app/test/shared.js +0 -42
- data/xpcomcore/etc/jsdoc-toolkit/app/test/shared2.js +0 -2
- data/xpcomcore/etc/jsdoc-toolkit/app/test/shortcuts.js +0 -22
- data/xpcomcore/etc/jsdoc-toolkit/app/test/static_this.js +0 -13
- data/xpcomcore/etc/jsdoc-toolkit/app/test/synonyms.js +0 -31
- data/xpcomcore/etc/jsdoc-toolkit/app/test/tosource.js +0 -23
- data/xpcomcore/etc/jsdoc-toolkit/app/test/variable_redefine.js +0 -14
- data/xpcomcore/etc/jsdoc-toolkit/changes.txt +0 -96
- data/xpcomcore/etc/jsdoc-toolkit/conf/sample.conf +0 -31
- data/xpcomcore/etc/jsdoc-toolkit/java/build.xml +0 -36
- data/xpcomcore/etc/jsdoc-toolkit/java/build_1.4.xml +0 -36
- data/xpcomcore/etc/jsdoc-toolkit/java/classes/js.jar +0 -0
- data/xpcomcore/etc/jsdoc-toolkit/java/src/JsDebugRun.java +0 -21
- data/xpcomcore/etc/jsdoc-toolkit/java/src/JsRun.java +0 -21
- data/xpcomcore/etc/jsdoc-toolkit/jsdebug.jar +0 -0
- data/xpcomcore/etc/jsdoc-toolkit/jsrun.jar +0 -0
- data/xpcomcore/etc/jsdoc-toolkit/jsrun.sh +0 -52
- data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/allclasses.tmpl +0 -17
- data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/allfiles.tmpl +0 -56
- data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/class.tmpl +0 -646
- data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/index.tmpl +0 -39
- data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/publish.js +0 -200
- data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/static/default.css +0 -162
- data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/static/header.html +0 -2
- data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/static/index.html +0 -19
- data/xpcomcore/etc/jsdoc-toolkit/templates/jsdoc/symbol.tmpl +0 -35
data/README.markdown
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
xpcomcore-rubygem
|
|
2
|
+
=================
|
|
3
|
+
|
|
4
|
+
This is the XPCOMCore JS library wrapped up in a RubyGem with a handy executable for doing things like
|
|
5
|
+
launching XPCOMCore based apps installed as RubyGems and generating new applications and extensions that
|
|
6
|
+
take advantage of XPCOMCore. See `xpcomcore help` once you have the gem installed for details on available
|
|
7
|
+
commands.
|
|
8
|
+
|
|
9
|
+
License
|
|
10
|
+
=================
|
|
11
|
+
|
|
12
|
+
See LICENSE for details.
|
|
13
|
+
|
|
14
|
+
Copyright (c) 2009 ggironda. See LICENSE for details.
|
data/Rakefile
CHANGED
|
@@ -7,26 +7,28 @@ begin
|
|
|
7
7
|
|
|
8
8
|
Jeweler::Tasks.new do |gem|
|
|
9
9
|
gem.name = "xpcomcore-rubygem"
|
|
10
|
-
gem.executables = %w[xpcomcore
|
|
10
|
+
gem.executables = %w[xpcomcore]
|
|
11
11
|
gem.summary = %Q{Gem to allow for using XPCOMCore via RubyGems}
|
|
12
12
|
gem.description = %Q{Gem to allow for using XPCOMCore via RubyGems}
|
|
13
13
|
gem.email = "gabriel.gironda@gmail.com"
|
|
14
14
|
gem.homepage = "http://github.com/gabrielg/xpcomcore-rubygem"
|
|
15
15
|
gem.authors = ["ggironda"]
|
|
16
16
|
gem.files = (gem.files + FileList["xpcomcore/**/*"]).uniq
|
|
17
|
-
gem.post_install_message =
|
|
17
|
+
gem.post_install_message = %Q[
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
EOF
|
|
19
|
+
STEP 1. OBTAIN A PIG. THIS ONE WILL DO:
|
|
20
|
+
|
|
21
|
+
_____
|
|
22
|
+
^..^ \\9
|
|
23
|
+
(oo)_____/
|
|
24
|
+
WW WW Pig
|
|
25
|
+
|
|
26
|
+
].split("\n").collect { |l| l.ljust(80) }.join("\n").red_on_blue.bold
|
|
28
27
|
|
|
29
28
|
gem.add_dependency "sys-uname"
|
|
29
|
+
gem.add_dependency "cmdparse"
|
|
30
|
+
gem.add_dependency "uuidtools", ">=2.0.0"
|
|
31
|
+
gem.add_dependency "jeweler", "=1.2.1"
|
|
30
32
|
gem.add_development_dependency "colored"
|
|
31
33
|
end
|
|
32
34
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.5.0
|
data/bin/xpcomcore
ADDED
data/lib/xpcomcore-rubygem.rb
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
require 'pathname'
|
|
2
|
+
|
|
3
|
+
module XPCOMCore
|
|
4
|
+
GemRoot = Pathname(__FILE__).parent.parent
|
|
5
|
+
Version = (GemRoot + "VERSION").read.strip
|
|
6
|
+
BootstrapperLocation = (GemRoot + "xpcomcore/bootstrapper.js").expand_path
|
|
7
|
+
BuildProperties = YAML.load_file((GemRoot + "xpcomcore/build_properties.yml").to_s)
|
|
8
|
+
|
|
9
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require 'cmdparse'
|
|
2
|
+
require 'xpcomcore-rubygem'
|
|
3
|
+
require 'pathname'
|
|
4
|
+
|
|
5
|
+
module XPCOMCore
|
|
6
|
+
class CommandParser
|
|
7
|
+
class << self
|
|
8
|
+
attr_accessor :quiet
|
|
9
|
+
end
|
|
10
|
+
self.quiet = false
|
|
11
|
+
|
|
12
|
+
@@commands = [CmdParse::HelpCommand, CmdParse::VersionCommand]
|
|
13
|
+
|
|
14
|
+
def initialize
|
|
15
|
+
@cmd = CmdParse::CommandParser.new(true, # handle exceptions gracefully
|
|
16
|
+
true) # use partial command matching)
|
|
17
|
+
@cmd.program_version = XPCOMCore::Version
|
|
18
|
+
@cmd.options = CmdParse::OptionParserWrapper.new do |opt|
|
|
19
|
+
opt.separator "Global options:"
|
|
20
|
+
opt.on("-q", "--quiet", "Be quiet about what's happening", self.class.method(:quiet=))
|
|
21
|
+
end
|
|
22
|
+
add_commands
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def parse
|
|
26
|
+
@cmd.parse
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.load_commands
|
|
30
|
+
(XPCOMCore::GemRoot + "lib/xpcomcore-rubygem/commands").each_entry do |entry|
|
|
31
|
+
next unless entry.extname == ".rb"
|
|
32
|
+
require "xpcomcore-rubygem/commands/#{entry.basename}"
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.add_command(cmd_class)
|
|
37
|
+
@@commands.push(cmd_class)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.log(msg)
|
|
41
|
+
return nil if quiet
|
|
42
|
+
puts msg
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
def add_commands
|
|
48
|
+
@@commands.each { |cmd_class| @cmd.add_command(cmd_class.new) }
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end # CommandParser
|
|
52
|
+
end # XPCOMCore
|
|
53
|
+
|
|
54
|
+
XPCOMCore::CommandParser.load_commands
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'xpcomcore-rubygem/commands'
|
|
2
|
+
|
|
3
|
+
module XPCOMCore
|
|
4
|
+
class CommandParser
|
|
5
|
+
class GenerateCommand < CmdParse::Command
|
|
6
|
+
class GenerationError < CmdParse::ParseError
|
|
7
|
+
reason "An error occured trying to generate your application"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def initialize
|
|
11
|
+
super('generate', true, # Takes subcommands
|
|
12
|
+
true) # Uses partial command matching
|
|
13
|
+
self.short_desc = "Generates an XPCOMCore based XUL application or library packaged in a RubyGem."
|
|
14
|
+
[ApplicationCommand, LibraryCommand].each { |k| add_command(k.new) }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end # GenerateCommand
|
|
18
|
+
end # CommandParser
|
|
19
|
+
end # XPCOMCore
|
|
20
|
+
|
|
21
|
+
XPCOMCore::CommandParser.add_command(XPCOMCore::CommandParser::GenerateCommand)
|
|
22
|
+
require "xpcomcore-rubygem/commands/generate/application"
|
|
23
|
+
require "xpcomcore-rubygem/commands/generate/library"
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require "xpcomcore-rubygem/commands/generate/jeweler_builder_command"
|
|
2
|
+
require 'uuidtools'
|
|
3
|
+
|
|
4
|
+
module XPCOMCore
|
|
5
|
+
class CommandParser
|
|
6
|
+
class GenerateCommand
|
|
7
|
+
|
|
8
|
+
class ApplicationCommand < JewelerBuilderCommand
|
|
9
|
+
|
|
10
|
+
def initialize
|
|
11
|
+
super('application', false) # Doesn't take subcommands
|
|
12
|
+
self.short_desc = "Generates an application"
|
|
13
|
+
self.options = CmdParse::OptionParserWrapper.new { |opt_parse| add_jeweler_opts(opt_parse) }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def setup_project(gem_name, project_path)
|
|
19
|
+
with_rakefile_in(project_path) do |rakefile|
|
|
20
|
+
add_jsdoc_toolkit_doc_task(rakefile, :task_name => "doc:app", :doc_dir => "xpcomcore/app/doc", :doc_paths => %w[xpcomcore/app/chrome xpcomcore/app/components])
|
|
21
|
+
add_xultestrunner_test_task(rakefile, :task_name => "test:app", :test_libs => %w[xpcomcore/app/chrome], :test_pattern => "xpcomcore/app/test/**/*_test.js")
|
|
22
|
+
end
|
|
23
|
+
copy_template_application(gem_name, project_path)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def copy_template_application(gem_name, project_path)
|
|
27
|
+
template_vars = {'application.ini' => default_application_ini_values(gem_name),
|
|
28
|
+
'chrome.manifest' => default_chrome_manifest_values(gem_name),
|
|
29
|
+
'main_window.xul' => default_main_window_xul_values(gem_name),
|
|
30
|
+
'prefs.js' => default_prefs_js_values(gem_name)}
|
|
31
|
+
|
|
32
|
+
copy_template_directory("application", project_path + "xpcomcore/app", template_vars)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def default_application_ini_values(gem_name)
|
|
36
|
+
build_properties_version = XPCOMCore::BuildProperties['version']
|
|
37
|
+
min_xpcomcore_version = build_properties_version.values_at('major', 'minor', 'patch').join('.')
|
|
38
|
+
{:app_name => gem_name.capitalize,
|
|
39
|
+
:app_version => "0.0.0",
|
|
40
|
+
:build_id => UUIDTools::UUID.random_create.to_s,
|
|
41
|
+
:app_id => "#{gem_name.capitalize}@CHANGEME.example.com",
|
|
42
|
+
:app_vendor => ENV['USER'],
|
|
43
|
+
:min_gecko_version => XPCOMCore::BuildProperties['gecko']['min_version'],
|
|
44
|
+
:min_xpcomcore_version => min_xpcomcore_version}
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def default_chrome_manifest_values(gem_name)
|
|
48
|
+
{:default_chrome_id => gem_name}
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def default_prefs_js_values(gem_name)
|
|
52
|
+
{:default_chrome_id => gem_name}
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def default_main_window_xul_values(gem_name)
|
|
56
|
+
{:app_name => gem_name.capitalize}
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end # ApplicationCommand
|
|
60
|
+
|
|
61
|
+
end # GenerateCommand
|
|
62
|
+
end # CommandParser
|
|
63
|
+
end # XPCOMCore
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
require "xpcomcore-rubygem/commands/generate/template_helpers"
|
|
2
|
+
require "english"
|
|
3
|
+
require "shell"
|
|
4
|
+
require "stringio"
|
|
5
|
+
|
|
6
|
+
module XPCOMCore
|
|
7
|
+
class CommandParser
|
|
8
|
+
class GenerateCommand
|
|
9
|
+
|
|
10
|
+
class JewelerBuilderCommand < CmdParse::Command
|
|
11
|
+
include TemplateHelpers
|
|
12
|
+
|
|
13
|
+
JewelerSuccess = /Jeweler has prepared your gem in (.*)/
|
|
14
|
+
DefaultJewelerOpts = %w[--testunit]
|
|
15
|
+
ApplicableJewelerOpts = {
|
|
16
|
+
"--create-repo" => "create the repository on GitHub",
|
|
17
|
+
"--gemcutter" => "setup project for gemcutter",
|
|
18
|
+
"--summary [SUMMARY]" => "specify the summary of the project",
|
|
19
|
+
"--description [DESCRIPTION]" => "specify a description of the project",
|
|
20
|
+
"--directory [DIRECTORY]" => "specify the directory to generate into"
|
|
21
|
+
}
|
|
22
|
+
DefaultGemDependencies = {'xpcomcore-rubygem' => ">=#{XPCOMCore::Version}",
|
|
23
|
+
'riot-js' => ">0.0.0"}
|
|
24
|
+
RakefileGemDepFormat = " gem.add_dependency %s, %s"
|
|
25
|
+
RakefileGemSpecLine = /# gem is a Gem::Specification/
|
|
26
|
+
|
|
27
|
+
def initialize(*args)
|
|
28
|
+
super(*args)
|
|
29
|
+
@jeweler_opts = {}
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def execute(args)
|
|
33
|
+
gem_name = args.shift || raise(CmdParse::InvalidArgumentError, "A name must be given")
|
|
34
|
+
project_path = Pathname(Dir.pwd) + make_jeweler_project(gem_name)
|
|
35
|
+
with_rakefile_in(project_path) { |rakefile| add_gem_dependencies(rakefile) }
|
|
36
|
+
rewrite_stub_ruby_file(gem_name, project_path)
|
|
37
|
+
setup_project(gem_name, project_path)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def setup_project(gem_name, project_path)
|
|
43
|
+
raise NotImplementedError
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def rewrite_stub_ruby_file(gem_name, project_path)
|
|
47
|
+
(project_path + "lib" + "#{gem_name}.rb").open('w') do |f|
|
|
48
|
+
f << "warn('This is a stub file generated by xpcomcore-rubygem. There may in fact be no Ruby code to speak of in this gem.')"
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def add_gem_dependencies(rakefile)
|
|
53
|
+
new_rakefile = rakefile.readlines.inject([]) do |new_rake,line|
|
|
54
|
+
if line =~ RakefileGemSpecLine
|
|
55
|
+
new_rake.concat(DefaultGemDependencies.collect { |dep,ver| RakefileGemDepFormat % [dep.inspect, ver.inspect] })
|
|
56
|
+
end
|
|
57
|
+
new_rake << line.chomp
|
|
58
|
+
end
|
|
59
|
+
rakefile.rewind && rakefile.write(new_rakefile.join($RS))
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def with_rakefile_in(project_path)
|
|
63
|
+
(project_path + "Rakefile").open("r+") { |f| yield(f) }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def make_jeweler_project(gem_name)
|
|
67
|
+
# FIXME - ugh. jeweler doesn't return non-zero exit on failure.
|
|
68
|
+
captured, sh, jeweler_args = StringIO.new, Shell.new, make_jeweler_args
|
|
69
|
+
sh.out(captured) { sh.system("jeweler", gem_name, *jeweler_args) }
|
|
70
|
+
captured = captured.rewind && captured.read
|
|
71
|
+
(captured =~ JewelerSuccess) ? (return($1)) : raise(GenerationError, "Failed to generate your project using Jeweler.")
|
|
72
|
+
ensure
|
|
73
|
+
puts captured
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def add_jeweler_opts(opt_parse)
|
|
77
|
+
ApplicableJewelerOpts.each do |switch,desc|
|
|
78
|
+
switch_name = switch.split(" ", 2)[0]
|
|
79
|
+
opt_parse.on(switch, desc) {|val| @jeweler_opts[switch_name] = val }
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def make_jeweler_args
|
|
84
|
+
@jeweler_opts.inject(DefaultJewelerOpts.dup) do |args,(opt_switch,opt_val)|
|
|
85
|
+
opt_val == true ? args.push(opt_switch) : args.push(opt_switch, opt_val)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def add_jsdoc_toolkit_doc_task(rakefile, options)
|
|
90
|
+
append_to(rakefile, eval_template("shared/jsdoc_doc_task.erb", options))
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def add_xultestrunner_test_task(rakefile, options)
|
|
94
|
+
append_to(rakefile, eval_template("shared/xultestrunner_test_task.erb", options))
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def append_to(io, str, add_newlines = true)
|
|
98
|
+
io.seek(0, IO::SEEK_END)
|
|
99
|
+
io << $RS * 2 if add_newlines
|
|
100
|
+
io << str
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
end # JewelerBuilderCommand
|
|
104
|
+
|
|
105
|
+
end # GenerateCommand
|
|
106
|
+
end # CommandParser
|
|
107
|
+
end # XPCOMCore
|
|
108
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require "xpcomcore-rubygem/commands/generate/jeweler_builder_command"
|
|
2
|
+
|
|
3
|
+
module XPCOMCore
|
|
4
|
+
class CommandParser
|
|
5
|
+
class GenerateCommand
|
|
6
|
+
|
|
7
|
+
class LibraryCommand < JewelerBuilderCommand
|
|
8
|
+
|
|
9
|
+
def initialize
|
|
10
|
+
super('library', false) # Doesn't take subcommands
|
|
11
|
+
self.short_desc = "Generates a library"
|
|
12
|
+
self.options = CmdParse::OptionParserWrapper.new { |opt_parse| add_jeweler_opts(opt_parse) }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def setup_project(gem_name, project_path)
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end # LibraryCommand
|
|
22
|
+
|
|
23
|
+
end # GenerateCommand
|
|
24
|
+
end # CommandParser
|
|
25
|
+
end # XPCOMCore
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
require 'erb'
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
|
|
4
|
+
# FIXME - clean this ugly guy up
|
|
5
|
+
module XPCOMCore
|
|
6
|
+
class CommandParser
|
|
7
|
+
class GenerateCommand
|
|
8
|
+
|
|
9
|
+
module TemplateHelpers
|
|
10
|
+
TemplateDir = XPCOMCore::GemRoot + "templates"
|
|
11
|
+
class EvalContext
|
|
12
|
+
def initialize(ivars)
|
|
13
|
+
ivars.each {|k,v| instance_variable_set("@#{k}", v)}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def get_binding
|
|
17
|
+
binding
|
|
18
|
+
end
|
|
19
|
+
end # EvalContext
|
|
20
|
+
|
|
21
|
+
def eval_template(path, vars)
|
|
22
|
+
context = EvalContext.new(vars)
|
|
23
|
+
template = ERB.new((TemplateDir + path).read)
|
|
24
|
+
template.result(context.get_binding)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def copy_template_directory(dir_name, dest, template_vars)
|
|
28
|
+
template_dir = (TemplateDir + dir_name).expand_path
|
|
29
|
+
dest.mkpath
|
|
30
|
+
Pathname.glob("#{template_dir}/**/*").each do |dir_entry|
|
|
31
|
+
handle_entry_creation(template_dir, dir_entry, dest, template_vars)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def handle_entry_creation(template_dir, dir_entry, dest_dir, template_vars)
|
|
36
|
+
relative_path = dir_entry.relative_path_from(template_dir)
|
|
37
|
+
if dir_entry.directory?
|
|
38
|
+
mkpath(dest_dir + relative_path)
|
|
39
|
+
else
|
|
40
|
+
handle_file(dir_entry, (dest_dir + relative_path), template_vars)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def handle_file(entry, dest, template_vars)
|
|
45
|
+
if entry.extname == ".erb"
|
|
46
|
+
copy_template(entry, dest, template_vars)
|
|
47
|
+
else
|
|
48
|
+
copy_file(entry, dest)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def mkpath(path)
|
|
53
|
+
puts "Creating #{path}"
|
|
54
|
+
path.mkpath
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def copy_template(entry, dest, template_vars)
|
|
58
|
+
real_dest = Pathname(dest.expand_path.to_s.sub(/#{dest.extname}$/, ""))
|
|
59
|
+
puts "Creating #{real_dest}"
|
|
60
|
+
vars = determine_template_vars(real_dest, template_vars)
|
|
61
|
+
real_dest.open('w') { |f| f << eval_template(entry, vars) }
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def copy_file(entry, dest)
|
|
65
|
+
puts "Creating #{dest.expand_path}"
|
|
66
|
+
FileUtils.cp(entry.expand_path.to_s, dest.expand_path.to_s)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def determine_template_vars(dest, template_vars)
|
|
70
|
+
template_vars.detect do |path,values|
|
|
71
|
+
dest.to_s =~ /#{Regexp.escape(path)}$/
|
|
72
|
+
end.last
|
|
73
|
+
end
|
|
74
|
+
end # TemplateHelpers
|
|
75
|
+
|
|
76
|
+
end # GenerateCommand
|
|
77
|
+
end # CommandParser
|
|
78
|
+
end # XPCOMCore
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'xpcomcore-rubygem/commands'
|
|
3
|
+
require 'sys/uname'
|
|
4
|
+
require 'pathname'
|
|
5
|
+
|
|
6
|
+
module XPCOMCore
|
|
7
|
+
class CommandParser
|
|
8
|
+
class LaunchCommand < CmdParse::Command
|
|
9
|
+
attr_accessor :use_xulrunner
|
|
10
|
+
|
|
11
|
+
class ApplicationNotFoundError < CmdParse::InvalidArgumentError
|
|
12
|
+
reason 'Application not found'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class XULRunnerNotFoundError < CmdParse::ParseError
|
|
16
|
+
reason 'XULRunner not found'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
GemAppRelativePath = "xpcomcore/app/application.ini"
|
|
20
|
+
CurrentPlatform = Sys::Uname.sysname.downcase.to_sym
|
|
21
|
+
|
|
22
|
+
# FIXME - clean up this xulrunnerlocator crap that takes up like half the class
|
|
23
|
+
XULRunnerLocators = {:firefox => {}, :xulrunner => {}}
|
|
24
|
+
XULRunnerLocators[:firefox][:unix] = [lambda { `which firefox-bin`}, lambda { `which firefox`}]
|
|
25
|
+
XULRunnerLocators[:xulrunner][:unix] = [lambda { `which xulrunner-bin`}, lambda { `which xulrunner`}]
|
|
26
|
+
|
|
27
|
+
# Linux uses the default UNIX locators
|
|
28
|
+
XULRunnerLocators[:firefox][:linux] = XULRunnerLocators[:firefox][:unix]
|
|
29
|
+
XULRunnerLocators[:xulrunner][:linux] = XULRunnerLocators[:xulrunner][:unix]
|
|
30
|
+
|
|
31
|
+
# Darwin does some extra magic
|
|
32
|
+
XULRunnerLocators[:firefox][:darwin] = XULRunnerLocators[:firefox][:unix] + [
|
|
33
|
+
lambda do
|
|
34
|
+
applications = `osascript -e 'POSIX path of (path to applications folder)'`.strip
|
|
35
|
+
firefox_bin = Pathname(applications) + "Firefox.app/Contents/MacOS/firefox-bin"
|
|
36
|
+
firefox_bin.exist? ? firefox_bin.expand_path.to_s : ''
|
|
37
|
+
end
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
XULRunnerLocators[:xulrunner][:darwin] = XULRunnerLocators[:xulrunner][:unix] + [
|
|
41
|
+
lambda do
|
|
42
|
+
library = `osascript -e 'POSIX path of (path to library folder)'`.strip
|
|
43
|
+
xulrunner_bin = Pathname(library) + "Frameworks/XUL.framework/xulrunner-bin"
|
|
44
|
+
xulrunner_bin.exist? ? xulrunner_bin.expand_path.to_s : ''
|
|
45
|
+
end
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def initialize
|
|
50
|
+
super('launch', false, # Doesn't take subcommands
|
|
51
|
+
true) # Uses partial command matching
|
|
52
|
+
self.short_desc = "Launches an XPCOMCore based XUL application either from RubyGems or a given path"
|
|
53
|
+
self.options = CmdParse::OptionParserWrapper.new do |opt|
|
|
54
|
+
opt.on('-x', '--use-xulrunner', 'Tries to use XULRunner to launch the given application rather than the default of Firefox', method(:use_xulrunner=))
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def execute(args)
|
|
59
|
+
app_name_or_path = args.shift || '.'
|
|
60
|
+
application = find_app(app_name_or_path)
|
|
61
|
+
unless application
|
|
62
|
+
raise(ApplicationNotFoundError, "The application '#{app_name_or_path}' could not be found in the given path or in your RubyGems install")
|
|
63
|
+
end
|
|
64
|
+
launch_app(application, args)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def use_xulrunner?
|
|
68
|
+
!!use_xulrunner
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def runner_type
|
|
72
|
+
use_xulrunner ? :xulrunner : :firefox
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
private
|
|
76
|
+
|
|
77
|
+
def launch_app(application_ini_path, args)
|
|
78
|
+
xulrunner_path = find_xulrunner
|
|
79
|
+
if xulrunner_path
|
|
80
|
+
XPCOMCore::CommandParser.log("Launching XUL application using '#{xulrunner_path}' from '#{application_ini_path}'")
|
|
81
|
+
set_env_and_launch(xulrunner_path, application_ini_path, args)
|
|
82
|
+
else
|
|
83
|
+
raise(XULRunnerNotFoundError, "A valid XULRunner executable could not be found.")
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def set_env_and_launch(xulrunner_bin, application_ini, args)
|
|
88
|
+
ENV['XPCOMCORE'] = ENV['XPCOMCORE'] || XPCOMCore::BootstrapperLocation.to_s
|
|
89
|
+
XPCOMCore::CommandParser.log("Using XPCOMCore bootstrapper at '#{ENV['XPCOMCORE']}'")
|
|
90
|
+
exec(xulrunner_bin, *["-app", application_ini, *args])
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def find_xulrunner
|
|
94
|
+
XULRunnerLocators[runner_type][CurrentPlatform].any? do |locator|
|
|
95
|
+
location = locator.call.strip
|
|
96
|
+
location.empty? ? nil : (break(location))
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def find_app(app_path)
|
|
101
|
+
fs_path = Pathname(Dir.pwd) + app_path + "application.ini"
|
|
102
|
+
if fs_path.exist?
|
|
103
|
+
return fs_path
|
|
104
|
+
else
|
|
105
|
+
return search_gems(app_path)
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def search_gems(app_name)
|
|
110
|
+
gems = Gem.source_index.find_name(app_name)
|
|
111
|
+
return nil if gems.empty?
|
|
112
|
+
latest_gem_spec = gems.last
|
|
113
|
+
get_application_path_from_gem_spec(latest_gem_spec)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def get_application_path_from_gem_spec(gem_spec)
|
|
117
|
+
ini_path = Pathname(gem_spec.full_gem_path) + GemAppRelativePath
|
|
118
|
+
if ini_path.exist?
|
|
119
|
+
return ini_path
|
|
120
|
+
else
|
|
121
|
+
return nil
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
end # LaunchCommand
|
|
126
|
+
end # CommandParser
|
|
127
|
+
end # XPCOMCore
|
|
128
|
+
|
|
129
|
+
XPCOMCore::CommandParser.add_command(XPCOMCore::CommandParser::LaunchCommand)
|