i18n-js 2.1.2 → 3.8.3

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.
Files changed (127) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +24 -0
  3. data/.github/FUNDING.yml +3 -0
  4. data/.github/workflows/tests.yaml +100 -0
  5. data/.gitignore +6 -4
  6. data/.npmignore +27 -0
  7. data/Appraisals +44 -0
  8. data/CHANGELOG.md +539 -0
  9. data/Gemfile +1 -1
  10. data/README.md +1086 -0
  11. data/Rakefile +19 -7
  12. data/app/assets/javascripts/i18n.js +1095 -0
  13. data/app/assets/javascripts/i18n/filtered.js.erb +23 -0
  14. data/app/assets/javascripts/i18n/shims.js +240 -0
  15. data/app/assets/javascripts/i18n/translations.js +3 -0
  16. data/gemfiles/i18n_0_6.gemfile +7 -0
  17. data/gemfiles/i18n_0_7.gemfile +7 -0
  18. data/gemfiles/i18n_0_8.gemfile +7 -0
  19. data/gemfiles/i18n_0_9.gemfile +7 -0
  20. data/gemfiles/i18n_1_0.gemfile +7 -0
  21. data/gemfiles/i18n_1_1.gemfile +7 -0
  22. data/gemfiles/i18n_1_2.gemfile +7 -0
  23. data/gemfiles/i18n_1_3.gemfile +7 -0
  24. data/gemfiles/i18n_1_4.gemfile +7 -0
  25. data/gemfiles/i18n_1_5.gemfile +7 -0
  26. data/gemfiles/i18n_1_6.gemfile +7 -0
  27. data/gemfiles/i18n_1_7.gemfile +7 -0
  28. data/gemfiles/i18n_1_8.gemfile +7 -0
  29. data/i18n-js.gemspec +12 -9
  30. data/i18njs.png +0 -0
  31. data/lib/i18n-js.rb +1 -177
  32. data/lib/i18n/js.rb +264 -0
  33. data/lib/i18n/js/dependencies.rb +63 -0
  34. data/lib/i18n/js/engine.rb +87 -0
  35. data/lib/i18n/js/fallback_locales.rb +70 -0
  36. data/lib/i18n/js/formatters/base.rb +25 -0
  37. data/lib/i18n/js/formatters/js.rb +39 -0
  38. data/lib/i18n/js/formatters/json.rb +13 -0
  39. data/lib/{i18n-js → i18n/js}/middleware.rb +32 -9
  40. data/lib/i18n/js/private/config_store.rb +31 -0
  41. data/lib/i18n/js/private/hash_with_symbol_keys.rb +36 -0
  42. data/lib/i18n/js/segment.rb +80 -0
  43. data/lib/i18n/js/utils.rb +78 -0
  44. data/lib/i18n/js/version.rb +7 -0
  45. data/lib/rails/generators/i18n/js/config/config_generator.rb +19 -0
  46. data/{config → lib/rails/generators/i18n/js/config/templates}/i18n-js.yml +11 -6
  47. data/lib/tasks/export.rake +8 -0
  48. data/package.json +25 -0
  49. data/spec/fixtures/custom_path.yml +5 -0
  50. data/spec/fixtures/default.yml +5 -0
  51. data/spec/fixtures/erb.yml +5 -0
  52. data/spec/fixtures/except_condition.yml +7 -0
  53. data/spec/fixtures/js_export_dir_custom.yml +7 -0
  54. data/spec/fixtures/js_export_dir_none.yml +6 -0
  55. data/spec/fixtures/js_extend_parent.yml +6 -0
  56. data/spec/fixtures/js_extend_segment.yml +6 -0
  57. data/spec/fixtures/js_file_per_locale.yml +7 -0
  58. data/spec/fixtures/js_file_per_locale_with_fallbacks_as_default_locale_symbol.yml +4 -0
  59. data/spec/fixtures/js_file_per_locale_with_fallbacks_as_hash.yml +6 -0
  60. data/spec/fixtures/js_file_per_locale_with_fallbacks_as_locale.yml +4 -0
  61. data/spec/fixtures/js_file_per_locale_with_fallbacks_as_locale_without_fallback_translations.yml +4 -0
  62. data/spec/fixtures/js_file_per_locale_with_fallbacks_enabled.yml +4 -0
  63. data/spec/fixtures/js_file_per_locale_without_fallbacks.yml +4 -0
  64. data/spec/fixtures/js_file_with_namespace_prefix_and_pretty_print.yml +9 -0
  65. data/spec/fixtures/js_sort_translation_keys_false.yml +6 -0
  66. data/spec/fixtures/js_sort_translation_keys_true.yml +6 -0
  67. data/spec/fixtures/json_only.yml +18 -0
  68. data/spec/{resources → fixtures}/locales.yml +58 -1
  69. data/spec/fixtures/merge_plurals.yml +6 -0
  70. data/spec/fixtures/merge_plurals_with_no_overrides.yml +4 -0
  71. data/spec/fixtures/merge_plurals_with_partial_overrides.yml +4 -0
  72. data/spec/fixtures/millions.yml +4 -0
  73. data/spec/fixtures/multiple_conditions.yml +7 -0
  74. data/spec/fixtures/multiple_conditions_per_locale.yml +7 -0
  75. data/spec/fixtures/multiple_files.yml +7 -0
  76. data/spec/{resources → fixtures}/no_config.yml +0 -0
  77. data/spec/fixtures/no_scope.yml +4 -0
  78. data/spec/fixtures/simple_scope.yml +5 -0
  79. data/spec/js/currency.spec.js +62 -0
  80. data/spec/js/current_locale.spec.js +19 -0
  81. data/spec/js/dates.spec.js +276 -0
  82. data/spec/js/defaults.spec.js +31 -0
  83. data/spec/js/extend.spec.js +110 -0
  84. data/spec/js/interpolation.spec.js +124 -0
  85. data/spec/js/jasmine/MIT.LICENSE +20 -0
  86. data/spec/js/jasmine/jasmine-html.js +190 -0
  87. data/spec/js/jasmine/jasmine.css +166 -0
  88. data/spec/js/jasmine/jasmine.js +2476 -0
  89. data/spec/js/jasmine/jasmine_favicon.png +0 -0
  90. data/spec/js/json_parsable.spec.js +14 -0
  91. data/spec/js/locales.spec.js +31 -0
  92. data/spec/js/localization.spec.js +78 -0
  93. data/spec/js/numbers.spec.js +174 -0
  94. data/spec/js/placeholder.spec.js +24 -0
  95. data/spec/js/pluralization.spec.js +219 -0
  96. data/spec/js/prepare_options.spec.js +41 -0
  97. data/spec/js/require.js +2083 -0
  98. data/spec/js/specs.html +49 -0
  99. data/spec/js/specs_requirejs.html +72 -0
  100. data/spec/js/translate.spec.js +304 -0
  101. data/spec/js/translations.js +188 -0
  102. data/spec/js/utility_functions.spec.js +20 -0
  103. data/spec/ruby/i18n/js/fallback_locales_spec.rb +84 -0
  104. data/spec/ruby/i18n/js/segment_spec.rb +261 -0
  105. data/spec/ruby/i18n/js/utils_spec.rb +106 -0
  106. data/spec/ruby/i18n/js_spec.rb +748 -0
  107. data/spec/spec_helper.rb +75 -14
  108. data/yarn.lock +131 -0
  109. metadata +223 -98
  110. data/.rspec +0 -1
  111. data/Gemfile.lock +0 -51
  112. data/README.rdoc +0 -305
  113. data/lib/i18n-js/engine.rb +0 -62
  114. data/lib/i18n-js/railtie.rb +0 -13
  115. data/lib/i18n-js/rake.rb +0 -16
  116. data/lib/i18n-js/version.rb +0 -10
  117. data/spec/i18n_spec.js +0 -768
  118. data/spec/i18n_spec.rb +0 -205
  119. data/spec/resources/custom_path.yml +0 -4
  120. data/spec/resources/default.yml +0 -4
  121. data/spec/resources/js_file_per_locale.yml +0 -3
  122. data/spec/resources/multiple_conditions.yml +0 -6
  123. data/spec/resources/multiple_files.yml +0 -6
  124. data/spec/resources/no_scope.yml +0 -3
  125. data/spec/resources/simple_scope.yml +0 -4
  126. data/vendor/assets/javascripts/i18n.js +0 -450
  127. data/vendor/assets/javascripts/i18n/translations.js.erb +0 -7
@@ -0,0 +1,31 @@
1
+ var I18n = require("../../app/assets/javascripts/i18n");
2
+
3
+ describe("Defaults", function(){
4
+ beforeEach(function(){
5
+ I18n.reset();
6
+ });
7
+
8
+ it("sets the default locale", function(){
9
+ expect(I18n.defaultLocale).toEqual("en");
10
+ });
11
+
12
+ it("sets current locale", function(){
13
+ expect(I18n.locale).toEqual("en");
14
+ });
15
+
16
+ it("sets default separator", function(){
17
+ expect(I18n.defaultSeparator).toEqual(".");
18
+ });
19
+
20
+ it("sets fallback", function(){
21
+ expect(I18n.fallbacks).toEqual(false);
22
+ });
23
+
24
+ it("set empty translation prefix", function(){
25
+ expect(I18n.missingTranslationPrefix).toEqual('');
26
+ });
27
+
28
+ it("sets default missingBehaviour", function(){
29
+ expect(I18n.missingBehaviour).toEqual('message');
30
+ });
31
+ });
@@ -0,0 +1,110 @@
1
+ var I18n = require("../../app/assets/javascripts/i18n")
2
+ , Translations = require("./translations")
3
+ ;
4
+
5
+ describe("Extend", function () {
6
+ it("should return an object", function () {
7
+ expect(typeof I18n.extend()).toBe('object');
8
+ });
9
+
10
+ it("should merge 2 objects into 1", function () {
11
+ var obj1 = {
12
+ test1: "abc"
13
+ }
14
+ , obj2 = {
15
+ test2: "xyz"
16
+ }
17
+ , expected = {
18
+ test1: "abc"
19
+ , test2: "xyz"
20
+ };
21
+
22
+ expect(I18n.extend(obj1,obj2)).toEqual(expected);
23
+ });
24
+ it("should overwrite a property from obj1 with the same property of obj2", function () {
25
+ var obj1 = {
26
+ test1: "abc"
27
+ , test3: "def"
28
+ }
29
+ , obj2 = {
30
+ test2: "xyz"
31
+ , test3: "uvw"
32
+ }
33
+ , expected = {
34
+ test1: "abc"
35
+ , test2: "xyz"
36
+ , test3: "uvw"
37
+ };
38
+
39
+ expect(I18n.extend(obj1,obj2)).toEqual(expected);
40
+ });
41
+
42
+ it("should merge deeply from obj1 with the same key of obj2", function() {
43
+ var obj1 = {
44
+ test1: {
45
+ test2: "abc"
46
+ }
47
+ }
48
+ , obj2 = {
49
+ test1: {
50
+ test3: "xyz"
51
+ }
52
+ }
53
+ , expected = {
54
+ test1: {
55
+ test2: "abc"
56
+ , test3: "xyz"
57
+ }
58
+ }
59
+
60
+ expect(I18n.extend(obj1, obj2)).toEqual(expected);
61
+ });
62
+
63
+ it("should correctly merge string, numberic, boolean, and null values", function() {
64
+ var obj1 = {
65
+ test1: {
66
+ test2: false
67
+ }
68
+ }
69
+ , obj2 = {
70
+ test1: {
71
+ test3: 23,
72
+ test4: 'abc',
73
+ test5: null
74
+ }
75
+ }
76
+ , expected = {
77
+ test1: {
78
+ test2: false
79
+ , test3: 23
80
+ , test4: 'abc'
81
+ , test5: null
82
+ }
83
+ }
84
+
85
+ expect(I18n.extend(obj1, obj2)).toEqual(expected);
86
+ });
87
+
88
+ it("should merge array values", function() {
89
+ var obj1 = {
90
+ array1: [1, 2]
91
+ },
92
+ obj2 = {
93
+ array2: [1, 2],
94
+ obj3: {
95
+ array3: [1, 2],
96
+ array4: [{obj4: 1}, 2]
97
+ }
98
+ },
99
+ expected = {
100
+ array1: [1, 2],
101
+ array2: [1, 2],
102
+ obj3: {
103
+ array3: [1, 2],
104
+ array4: [{obj4: 1}, 2]
105
+ }
106
+ }
107
+
108
+ expect(JSON.stringify(I18n.extend(obj1, obj2))).toEqual(JSON.stringify(expected));
109
+ });
110
+ });
@@ -0,0 +1,124 @@
1
+ var I18n = require("../../app/assets/javascripts/i18n")
2
+ , Translations = require("./translations")
3
+ ;
4
+
5
+ describe("Interpolation", function(){
6
+ var actual, expected;
7
+
8
+ beforeEach(function(){
9
+ I18n.reset();
10
+ I18n.translations = Translations();
11
+ });
12
+
13
+ it("performs single interpolation", function(){
14
+ actual = I18n.t("greetings.name", {name: "John Doe"});
15
+ expect(actual).toEqual("Hello John Doe!");
16
+ });
17
+
18
+ it("performs multiple interpolations", function(){
19
+ actual = I18n.t("profile.details", {name: "John Doe", age: 27});
20
+ expect(actual).toEqual("John Doe is 27-years old");
21
+ });
22
+
23
+ describe("Pluralization", function() {
24
+ var translation_key;
25
+
26
+ describe("when count is passed in", function() {
27
+ describe("and translation key does contain pluralization", function() {
28
+ beforeEach(function() {
29
+ translation_key = "inbox";
30
+ });
31
+
32
+ it("return translated and pluralized string", function() {
33
+ expect(I18n.t(translation_key, {count: 0})).toEqual("You have no messages");
34
+ expect(I18n.t(translation_key, {count: 1})).toEqual("You have 1 message");
35
+ expect(I18n.t(translation_key, {count: 5})).toEqual("You have 5 messages");
36
+ });
37
+ });
38
+ describe("and translation key does NOT contain pluralization", function() {
39
+ beforeEach(function() {
40
+ translation_key = "hello";
41
+ });
42
+
43
+ it("return translated string ONLY", function() {
44
+ expect(I18n.t(translation_key, {count: 0})).toEqual("Hello World!");
45
+ expect(I18n.t(translation_key, {count: 1})).toEqual("Hello World!");
46
+ expect(I18n.t(translation_key, {count: 5})).toEqual("Hello World!");
47
+ });
48
+ });
49
+ describe("and translation key does contain pluralization with null content", function() {
50
+ beforeEach(function() {
51
+ translation_key = "sent";
52
+ });
53
+
54
+ it("return empty string", function() {
55
+ expect(I18n.t(translation_key, {count: 0})).toEqual('[missing "en.sent.zero" translation]');
56
+ expect(I18n.t(translation_key, {count: 1})).toEqual('[missing "en.sent.one" translation]');
57
+ expect(I18n.t(translation_key, {count: 5})).toEqual('[missing "en.sent.other" translation]');
58
+ });
59
+ });
60
+ });
61
+
62
+ describe("when count is NOT passed in", function() {
63
+ describe("and translation key does contain pluralization", function() {
64
+ beforeEach(function() {
65
+ translation_key = "inbox";
66
+ });
67
+
68
+ var expected_translation_object = {
69
+ one : 'You have {{count}} message',
70
+ other : 'You have {{count}} messages',
71
+ zero : 'You have no messages'
72
+ }
73
+
74
+ it("return translated and pluralized string", function() {
75
+ expect(I18n.t(translation_key, {not_count: 0})).toEqual(expected_translation_object);
76
+ expect(I18n.t(translation_key, {not_count: 1})).toEqual(expected_translation_object);
77
+ expect(I18n.t(translation_key, {not_count: 5})).toEqual(expected_translation_object);
78
+ });
79
+ });
80
+ describe("and translation key does NOT contain pluralization", function() {
81
+ beforeEach(function() {
82
+ translation_key = "hello";
83
+ });
84
+
85
+ it("return translated string ONLY", function() {
86
+ expect(I18n.t(translation_key, {not_count: 0})).toEqual("Hello World!");
87
+ expect(I18n.t(translation_key, {not_count: 1})).toEqual("Hello World!");
88
+ expect(I18n.t(translation_key, {not_count: 5})).toEqual("Hello World!");
89
+ });
90
+ });
91
+ });
92
+ });
93
+
94
+ it("outputs missing placeholder message if interpolation value is missing", function(){
95
+ actual = I18n.t("greetings.name");
96
+ expect(actual).toEqual("Hello [missing {{name}} value]!");
97
+ });
98
+
99
+ it("outputs missing placeholder message if interpolation value is null", function(){
100
+ actual = I18n.t("greetings.name", {name: null});
101
+ expect(actual).toEqual("Hello [missing {{name}} value]!");
102
+ });
103
+
104
+ it("allows overriding the null placeholder message", function(){
105
+ var orig = I18n.nullPlaceholder;
106
+ I18n.nullPlaceholder = function() {return "";}
107
+ actual = I18n.t("greetings.name", {name: null});
108
+ expect(actual).toEqual("Hello !");
109
+ I18n.nullPlaceholder = orig;
110
+ });
111
+
112
+ it("provides missingPlaceholder with the placeholder, message, and options object", function(){
113
+ var orig = I18n.missingPlaceholder;
114
+ I18n.missingPlaceholder = function(placeholder, message, options) {
115
+ expect(placeholder).toEqual('{{name}}');
116
+ expect(message).toEqual('Hello {{name}}!');
117
+ expect(options.debugScope).toEqual('landing-page');
118
+ return '[missing-placeholder-debug]';
119
+ };
120
+ actual = I18n.t("greetings.name", {debugScope: 'landing-page'});
121
+ expect(actual).toEqual("Hello [missing-placeholder-debug]!");
122
+ I18n.missingPlaceholder = orig;
123
+ });
124
+ });
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008-2011 Pivotal Labs
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,190 @@
1
+ jasmine.TrivialReporter = function(doc) {
2
+ this.document = doc || document;
3
+ this.suiteDivs = {};
4
+ this.logRunningSpecs = false;
5
+ };
6
+
7
+ jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
8
+ var el = document.createElement(type);
9
+
10
+ for (var i = 2; i < arguments.length; i++) {
11
+ var child = arguments[i];
12
+
13
+ if (typeof child === 'string') {
14
+ el.appendChild(document.createTextNode(child));
15
+ } else {
16
+ if (child) { el.appendChild(child); }
17
+ }
18
+ }
19
+
20
+ for (var attr in attrs) {
21
+ if (attr == "className") {
22
+ el[attr] = attrs[attr];
23
+ } else {
24
+ el.setAttribute(attr, attrs[attr]);
25
+ }
26
+ }
27
+
28
+ return el;
29
+ };
30
+
31
+ jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
32
+ var showPassed, showSkipped;
33
+
34
+ this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
35
+ this.createDom('div', { className: 'banner' },
36
+ this.createDom('div', { className: 'logo' },
37
+ this.createDom('span', { className: 'title' }, "Jasmine"),
38
+ this.createDom('span', { className: 'version' }, runner.env.versionString())),
39
+ this.createDom('div', { className: 'options' },
40
+ "Show ",
41
+ showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
42
+ this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
43
+ showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
44
+ this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
45
+ )
46
+ ),
47
+
48
+ this.runnerDiv = this.createDom('div', { className: 'runner running' },
49
+ this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
50
+ this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
51
+ this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
52
+ );
53
+
54
+ this.document.body.appendChild(this.outerDiv);
55
+
56
+ var suites = runner.suites();
57
+ for (var i = 0; i < suites.length; i++) {
58
+ var suite = suites[i];
59
+ var suiteDiv = this.createDom('div', { className: 'suite' },
60
+ this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
61
+ this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
62
+ this.suiteDivs[suite.id] = suiteDiv;
63
+ var parentDiv = this.outerDiv;
64
+ if (suite.parentSuite) {
65
+ parentDiv = this.suiteDivs[suite.parentSuite.id];
66
+ }
67
+ parentDiv.appendChild(suiteDiv);
68
+ }
69
+
70
+ this.startedAt = new Date();
71
+
72
+ var self = this;
73
+ showPassed.onclick = function(evt) {
74
+ if (showPassed.checked) {
75
+ self.outerDiv.className += ' show-passed';
76
+ } else {
77
+ self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
78
+ }
79
+ };
80
+
81
+ showSkipped.onclick = function(evt) {
82
+ if (showSkipped.checked) {
83
+ self.outerDiv.className += ' show-skipped';
84
+ } else {
85
+ self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
86
+ }
87
+ };
88
+ };
89
+
90
+ jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
91
+ var results = runner.results();
92
+ var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
93
+ this.runnerDiv.setAttribute("class", className);
94
+ //do it twice for IE
95
+ this.runnerDiv.setAttribute("className", className);
96
+ var specs = runner.specs();
97
+ var specCount = 0;
98
+ for (var i = 0; i < specs.length; i++) {
99
+ if (this.specFilter(specs[i])) {
100
+ specCount++;
101
+ }
102
+ }
103
+ var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
104
+ message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
105
+ this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
106
+
107
+ this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
108
+ };
109
+
110
+ jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
111
+ var results = suite.results();
112
+ var status = results.passed() ? 'passed' : 'failed';
113
+ if (results.totalCount === 0) { // todo: change this to check results.skipped
114
+ status = 'skipped';
115
+ }
116
+ this.suiteDivs[suite.id].className += " " + status;
117
+ };
118
+
119
+ jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
120
+ if (this.logRunningSpecs) {
121
+ this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
122
+ }
123
+ };
124
+
125
+ jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
126
+ var results = spec.results();
127
+ var status = results.passed() ? 'passed' : 'failed';
128
+ if (results.skipped) {
129
+ status = 'skipped';
130
+ }
131
+ var specDiv = this.createDom('div', { className: 'spec ' + status },
132
+ this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
133
+ this.createDom('a', {
134
+ className: 'description',
135
+ href: '?spec=' + encodeURIComponent(spec.getFullName()),
136
+ title: spec.getFullName()
137
+ }, spec.description));
138
+
139
+
140
+ var resultItems = results.getItems();
141
+ var messagesDiv = this.createDom('div', { className: 'messages' });
142
+ for (var i = 0; i < resultItems.length; i++) {
143
+ var result = resultItems[i];
144
+
145
+ if (result.type == 'log') {
146
+ messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
147
+ } else if (result.type == 'expect' && result.passed && !result.passed()) {
148
+ messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
149
+
150
+ if (result.trace.stack) {
151
+ messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
152
+ }
153
+ }
154
+ }
155
+
156
+ if (messagesDiv.childNodes.length > 0) {
157
+ specDiv.appendChild(messagesDiv);
158
+ }
159
+
160
+ this.suiteDivs[spec.suite.id].appendChild(specDiv);
161
+ };
162
+
163
+ jasmine.TrivialReporter.prototype.log = function() {
164
+ var console = jasmine.getGlobal().console;
165
+ if (console && console.log) {
166
+ if (console.log.apply) {
167
+ console.log.apply(console, arguments);
168
+ } else {
169
+ console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
170
+ }
171
+ }
172
+ };
173
+
174
+ jasmine.TrivialReporter.prototype.getLocation = function() {
175
+ return this.document.location;
176
+ };
177
+
178
+ jasmine.TrivialReporter.prototype.specFilter = function(spec) {
179
+ var paramMap = {};
180
+ var params = this.getLocation().search.substring(1).split('&');
181
+ for (var i = 0; i < params.length; i++) {
182
+ var p = params[i].split('=');
183
+ paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
184
+ }
185
+
186
+ if (!paramMap.spec) {
187
+ return true;
188
+ }
189
+ return spec.getFullName().indexOf(paramMap.spec) === 0;
190
+ };