xpcomcore-rubygem 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.5.2
@@ -8,6 +8,8 @@ var XPCOMCoreBootstrapper = function() {
8
8
 
9
9
  XPCOMCoreBootstrapper.prototype = {
10
10
  bootstrapped: false,
11
+ xpcomcoreEnvVar: 'XPCOMCORE',
12
+
11
13
  classDescription: "XPCOMCore Bootstrapper Component",
12
14
  contractID: "@conflagrationjs.org/xpcomcore/bootstrapper;1",
13
15
  classID: Components.ID("{5412c380-b3b2-11de-8a39-0800200c9a66}"),
@@ -16,38 +18,51 @@ XPCOMCoreBootstrapper.prototype = {
16
18
 
17
19
  observe: function(subject, topic, data) {
18
20
  if (topic != "xpcom-startup") { return false; }
19
- if (this.bootstrapped) {
20
- dump("\n\nXPCOMCore already bootstrapped.\n\n");
21
- } else {
22
- var env = Components.classes["@mozilla.org/process/environment;1"].getService(Components.interfaces.nsIEnvironment);
23
- var xpcomcoreBootstrapper = env.exists('XPCOMCORE') && env.get('XPCOMCORE');
24
- if (xpcomcoreBootstrapper) {
25
- try {
26
- var iniFile = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("XCurProcD", Components.interfaces.nsIFile);
27
- iniFile.append("application.ini");
28
- iniFile.QueryInterface(Components.interfaces.nsILocalFile);
29
-
30
- var iniParser = Components.classes["@mozilla.org/xpcom/ini-parser-factory;1"].getService(Components.interfaces.nsIINIParserFactory).createINIParser(iniFile);
31
- var xpcomCoreMinVersion = iniParser.getString('XPCOMCore', 'MinVersion');
32
-
33
- dump("\n\nLoading XPCOMCore Bootstrapper from " + xpcomcoreBootstrapper + ".\n\n");
34
- Components.utils.import("file://" + xpcomcoreBootstrapper);
35
- var versionComparator = Components.classes["@mozilla.org/xpcom/version-comparator;1"].createInstance(Components.interfaces.nsIVersionComparator);
36
-
37
- if (versionComparator.compare(XPCOMCoreConfig.getProperty('version'), xpcomCoreMinVersion) < 0) {
38
- throw("XPCOMCore version " + xpcomCoreMinVersion + " is required but we were bootstrapped with " + XPCOMCoreConfig.getProperty('version') + ".");
39
- }
21
+ if (this.bootstrapped) { this.puts("XPCOMCore already bootstrapped."); return true; }
22
+ try {
23
+ var xpcomcoreBootstrapper = this.getBootstrapper();
24
+ if (!xpcomcoreBootstrapper) { throw("No bootstrapper was found. Are you sure " + this.xpcomcoreEnvVar + " is set in your environment?"); }
40
25
 
41
- dump("\n\nXPCOMCore bootstrapped with version " + XPCOMCoreConfig.getProperty('version') + ".\n\n");
42
- } catch (e) {
43
- dump("\nException caught. Quitting.\n" + e + "\n");
44
- var appStartup = Components.classes['@mozilla.org/toolkit/app-startup;1'].getService(Components.interfaces.nsIAppStartup);
45
- appStartup.quit(Components.interfaces.nsIAppStartup.eForceQuit);
46
- }
47
- } else {
48
- dump("\n\nNot loading XPCOMCore Bootstrapper.\n\n");
49
- }
26
+ this.puts("Loading XPCOMCore Bootstrapper from " + xpcomcoreBootstrapper);
27
+ Components.utils.import("file://" + xpcomcoreBootstrapper);
28
+ this.checkVersion();
29
+ this.puts("XPCOMCore bootstrapped with version " + XPCOMCoreConfig.getProperty('version'));
30
+ } catch (e) {
31
+ this.puts("Exception caught. Quitting.\n" + e);
32
+ this.forceQuit();
33
+ }
34
+ },
35
+
36
+ getBootstrapper: function() {
37
+ var env = Components.classes["@mozilla.org/process/environment;1"].getService(Components.interfaces.nsIEnvironment);
38
+ return env.exists(this.xpcomcoreEnvVar) && env.get(this.xpcomcoreEnvVar);
39
+ },
40
+
41
+ getMinXPCOMCoreVersion: function() {
42
+ var iniFile = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("XCurProcD", Components.interfaces.nsIFile);
43
+ iniFile.append("application.ini");
44
+ iniFile.QueryInterface(Components.interfaces.nsILocalFile);
45
+
46
+ var iniParser = Components.classes["@mozilla.org/xpcom/ini-parser-factory;1"].getService(Components.interfaces.nsIINIParserFactory).createINIParser(iniFile);
47
+ return iniParser.getString('XPCOMCore', 'MinVersion');
48
+ },
49
+
50
+ checkVersion: function() {
51
+ var xpcomCoreMinVersion = this.getMinXPCOMCoreVersion();
52
+ var versionComparator = Components.classes["@mozilla.org/xpcom/version-comparator;1"].createInstance(Components.interfaces.nsIVersionComparator);
53
+
54
+ if (versionComparator.compare(XPCOMCoreConfig.getProperty('version'), xpcomCoreMinVersion) < 0) {
55
+ throw("XPCOMCore version " + xpcomCoreMinVersion + " is required but we were bootstrapped with " + XPCOMCoreConfig.getProperty('version') + ".");
50
56
  }
57
+ },
58
+
59
+ forceQuit: function() {
60
+ var appStartup = Components.classes['@mozilla.org/toolkit/app-startup;1'].getService(Components.interfaces.nsIAppStartup);
61
+ appStartup.quit(Components.interfaces.nsIAppStartup.eForceQuit);
62
+ },
63
+
64
+ puts: function(str) {
65
+ dump(str + "\n");
51
66
  }
52
67
 
53
68
  };
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{xpcomcore-rubygem}
8
- s.version = "0.5.1"
8
+ s.version = "0.5.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["ggironda"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xpcomcore-rubygem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ggironda