ninjs-framework 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/.DS_Store +0 -0
  2. data/.bundle/config +2 -0
  3. data/.travis.yml +2 -0
  4. data/Gemfile +10 -0
  5. data/Gemfile.lock +47 -0
  6. data/LICENSE.txt +20 -0
  7. data/README.md +4 -0
  8. data/Rakefile +76 -0
  9. data/VERSION +1 -0
  10. data/lib/.DS_Store +0 -0
  11. data/lib/ninjs-framework.rb +164 -0
  12. data/lib/ninjs-framework/assets/jasmine/jasmine-html.js +190 -0
  13. data/lib/ninjs-framework/assets/jasmine/jasmine.css +166 -0
  14. data/lib/ninjs-framework/assets/jasmine/jasmine.js +2476 -0
  15. data/lib/ninjs-framework/assets/jasmine/jasmine_favicon.png +0 -0
  16. data/lib/ninjs-framework/core/.core.pdoc.yaml +0 -0
  17. data/lib/ninjs-framework/core/.existence.pdoc.yaml +12 -0
  18. data/lib/ninjs-framework/core/.extend.pdoc.yaml +0 -0
  19. data/lib/ninjs-framework/core/.nin.pdoc.yaml +0 -0
  20. data/lib/ninjs-framework/core/application.js +17 -0
  21. data/lib/ninjs-framework/core/dom.js +164 -0
  22. data/lib/ninjs-framework/core/existence.js +60 -0
  23. data/lib/ninjs-framework/core/extend.js +14 -0
  24. data/lib/ninjs-framework/core/module.js +66 -0
  25. data/lib/ninjs-framework/core/nin.js +5 -0
  26. data/lib/ninjs-framework/extensions/jquery.elements.js +60 -0
  27. data/lib/ninjs-framework/templates/application.js.erb +3 -0
  28. data/lib/ninjs-framework/templates/autoload.js.erb +3 -0
  29. data/lib/ninjs-framework/templates/core.js.erb +3 -0
  30. data/lib/ninjs-framework/templates/dependency.js.erb +3 -0
  31. data/lib/ninjs-framework/templates/jasmine.yml.erb +75 -0
  32. data/lib/ninjs-framework/templates/test-index.html.erb +51 -0
  33. data/lib/ninjs-framework/utilities/all.js +5 -0
  34. data/lib/ninjs-framework/utilities/array.js +29 -0
  35. data/lib/ninjs-framework/utilities/cookie.js +59 -0
  36. data/lib/ninjs-framework/utilities/css.js +51 -0
  37. data/lib/ninjs-framework/utilities/number.js +11 -0
  38. data/lib/ninjs-framework/utilities/string.js +61 -0
  39. data/spec/fixtures/myapp.js +530 -0
  40. data/spec/fixtures/nin.js +297 -0
  41. data/spec/fixtures/ninjs.conf +9 -0
  42. data/spec/fixtures/test.elements.js +3 -0
  43. data/spec/fixtures/test.js +14 -0
  44. data/spec/fixtures/test.model.js +3 -0
  45. data/spec/fixtures/test.module.js +10 -0
  46. data/spec/fixtures/utilities.js +211 -0
  47. data/spec/javascripts/application_spec.js +22 -0
  48. data/spec/javascripts/array_utility_spec.js +49 -0
  49. data/spec/javascripts/existence_spec.js +71 -0
  50. data/spec/javascripts/extension_spec.js +22 -0
  51. data/spec/javascripts/helpers/SpecHelper.js +3 -0
  52. data/spec/javascripts/module_spec.js +30 -0
  53. data/spec/javascripts/string_utility_spec.js +85 -0
  54. data/spec/javascripts/support/jasmine.yml +75 -0
  55. data/spec/javascripts/support/jasmine_config.rb +23 -0
  56. data/spec/javascripts/support/jasmine_runner.rb +32 -0
  57. data/spec/ninjs_framework_spec.rb +121 -0
  58. data/spec/spec_helper.rb +41 -0
  59. data/spec/tmp/Rakefile +76 -0
  60. data/spec/tmp/application/myapp.js +530 -0
  61. data/spec/tmp/application/test.js +14 -0
  62. data/spec/tmp/elements/test.elements.js +3 -0
  63. data/spec/tmp/lib/nin.js +297 -0
  64. data/spec/tmp/lib/utilities.js +211 -0
  65. data/spec/tmp/models/test.model.js +3 -0
  66. data/spec/tmp/modules/test.module.js +10 -0
  67. data/spec/tmp/ninjs.conf +9 -0
  68. data/spec/tmp/spec/index.html +51 -0
  69. data/spec/tmp/spec/javascripts/application_spec.js +22 -0
  70. data/spec/tmp/spec/javascripts/array_utility_spec.js +49 -0
  71. data/spec/tmp/spec/javascripts/existence_spec.js +71 -0
  72. data/spec/tmp/spec/javascripts/extension_spec.js +22 -0
  73. data/spec/tmp/spec/javascripts/module_spec.js +30 -0
  74. data/spec/tmp/spec/javascripts/string_utility_spec.js +85 -0
  75. data/spec/tmp/spec/javascripts/support/jasmine-html.js +190 -0
  76. data/spec/tmp/spec/javascripts/support/jasmine.css +166 -0
  77. data/spec/tmp/spec/javascripts/support/jasmine.js +2476 -0
  78. data/spec/tmp/spec/javascripts/support/jasmine.yml.erb +75 -0
  79. data/spec/tmp/spec/javascripts/support/jasmine_config.rb +23 -0
  80. data/spec/tmp/spec/javascripts/support/jasmine_favicon.png +0 -0
  81. data/spec/tmp/spec/javascripts/support/jasmine_runner.rb +32 -0
  82. metadata +285 -0
data/.DS_Store ADDED
Binary file
data/.bundle/config ADDED
@@ -0,0 +1,2 @@
1
+ --- {}
2
+
data/.travis.yml ADDED
@@ -0,0 +1,2 @@
1
+ rvm: 1.9.2
2
+ before_script: sh -e /etc/init.d/xvfb start
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ group :development do
4
+ gem "rake"
5
+ gem "jasmine"
6
+ gem "rspec", "~> 2.3.0"
7
+ gem "bundler", "~> 1.0.0"
8
+ gem "jeweler", "~> 1.5.2"
9
+ gem "rcov", ">= 0"
10
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,47 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ childprocess (0.2.2)
5
+ ffi (~> 1.0.6)
6
+ diff-lcs (1.1.3)
7
+ ffi (1.0.10)
8
+ git (1.2.5)
9
+ jasmine (1.1.2)
10
+ jasmine-core (>= 1.1.0)
11
+ rack (>= 1.1)
12
+ rspec (>= 1.3.1)
13
+ selenium-webdriver (>= 0.1.3)
14
+ jasmine-core (1.1.0)
15
+ jeweler (1.5.2)
16
+ bundler (~> 1.0.0)
17
+ git (>= 1.2.5)
18
+ rake
19
+ json_pure (1.6.1)
20
+ rack (1.3.5)
21
+ rake (0.9.2.2)
22
+ rcov (0.9.11)
23
+ rspec (2.3.0)
24
+ rspec-core (~> 2.3.0)
25
+ rspec-expectations (~> 2.3.0)
26
+ rspec-mocks (~> 2.3.0)
27
+ rspec-core (2.3.1)
28
+ rspec-expectations (2.3.0)
29
+ diff-lcs (~> 1.1.2)
30
+ rspec-mocks (2.3.0)
31
+ rubyzip (0.9.4)
32
+ selenium-webdriver (2.12.1)
33
+ childprocess (>= 0.2.1)
34
+ ffi (~> 1.0.9)
35
+ json_pure
36
+ rubyzip
37
+
38
+ PLATFORMS
39
+ ruby
40
+
41
+ DEPENDENCIES
42
+ bundler (~> 1.0.0)
43
+ jasmine
44
+ jeweler (~> 1.5.2)
45
+ rake
46
+ rcov
47
+ rspec (~> 2.3.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Dayton Nolan
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.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ Read Me
2
+ =======
3
+
4
+ The Ninjs framework is a small good-parts JavaScript library that provides a basic application structure to build sophisticated JavaScript applications.
data/Rakefile ADDED
@@ -0,0 +1,76 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "ninjs-framework"
16
+ gem.homepage = "http://github.com/daytonn/ninjs-framework"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{ninjs-framework is a small JavaScript framework for building modular javascript applications}
19
+ gem.description = %Q{ninjs-framework is the JavaScript framework component of the ninjs development framework. ninjs-framework is focus on helping you build extensible modular javascript applications, without using a classical inheritance pattern.}
20
+ gem.email = "daytonn@gmail.com"
21
+ gem.authors = ["Dayton Nolan"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ gem.add_development_dependency 'rake'
27
+ gem.add_development_dependency 'jasmine'
28
+ gem.add_development_dependency 'rake'
29
+ gem.add_development_dependency "rspec", "~> 2.3.0"
30
+ gem.add_development_dependency "bundler", "~> 1.0.0"
31
+ gem.add_development_dependency "jeweler", "~> 1.5.2"
32
+ gem.add_development_dependency "rcov", ">= 0"
33
+ end
34
+ Jeweler::RubygemsDotOrgTasks.new
35
+
36
+ require 'rspec/core'
37
+ require 'rspec/core/rake_task'
38
+ RSpec::Core::RakeTask.new(:spec) do |spec|
39
+ spec.pattern = FileList['spec/**/*_spec.rb']
40
+ end
41
+
42
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
43
+ spec.pattern = 'spec/**/*_spec.rb'
44
+ spec.rcov = true
45
+ end
46
+
47
+ task :default => :spec
48
+
49
+ require 'rdoc/task'
50
+ RDoc::Task.new do |rdoc|
51
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
52
+
53
+ rdoc.rdoc_dir = 'rdoc'
54
+ rdoc.title = "ninjs-ninjs-framework #{version}"
55
+ rdoc.rdoc_files.include('README*')
56
+ rdoc.rdoc_files.include('lib/**/*.rb')
57
+ end
58
+
59
+ begin
60
+ require 'jasmine'
61
+ load 'jasmine/tasks/jasmine.rake'
62
+ rescue LoadError
63
+ task :jasmine do
64
+ abort "Jasmine is not available. In order to run jasmine, you must: (sudo) gem install jasmine"
65
+ end
66
+ end
67
+
68
+ task :travis do
69
+ ["rake jasmine:ci"].each do |cmd|
70
+ puts "Starting to run #{cmd}..."
71
+ system("export DISPLAY=:99.0 && bundle exec #{cmd}")
72
+ raise "#{cmd} failed!" unless $?.exitstatus == 0
73
+ end
74
+ end
75
+
76
+ task :default => 'travis'
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/lib/.DS_Store ADDED
Binary file
@@ -0,0 +1,164 @@
1
+ class NinjsFramework < Ninjs::Framework
2
+
3
+ attr_accessor :template_dir
4
+
5
+ def initialize
6
+ @fw_root = File.expand_path('../', File.dirname(__FILE__))
7
+ @lib_dir = File.expand_path('lib', @fw_root)
8
+ @template_dir = File.expand_path('ninjs-framework/templates', @lib_dir)
9
+ super({
10
+ name: 'ninjs',
11
+ manifest: [
12
+ 'application',
13
+ 'elements',
14
+ 'lib',
15
+ 'models',
16
+ 'modules',
17
+ 'plugins',
18
+ 'spec',
19
+ 'spec/javascripts',
20
+ 'spec/javascripts/support'
21
+ ],
22
+ defaults: {
23
+ name: 'application',
24
+ framework: 'ninjs',
25
+ src_dir: 'modules',
26
+ dest_dir: 'application',
27
+ asset_root: '../',
28
+ output: 'expanded',
29
+ dependencies: ['<jquery/latest>'],
30
+ autoload: ['../lib/utilities'],
31
+ module_alias: 'm'
32
+ }
33
+ })
34
+ end
35
+
36
+ def create(root, config)
37
+ @root = root
38
+ @config = config
39
+ create_ninjs_lib_file
40
+ create_utility_lib_file
41
+ create_ninjs_application_file
42
+ import_rakefile
43
+ import_spec_files
44
+ end
45
+
46
+ def update(root, config)
47
+ @root = root
48
+ @config = config
49
+ update_application_file
50
+ end
51
+
52
+ def create_ninjs_lib_file
53
+ operation = File.exists?("#{@root}/lib/nin.js") ? 'updated' : 'created'
54
+ ninjs_lib_secretary = Sprockets::Secretary.new(
55
+ :root => "#{@lib_dir}/ninjs-framework",
56
+ :load_path => ["core", "extensions", "utilities"],
57
+ source_files: ["core/nin.js"]
58
+ )
59
+
60
+ ninjs_lib_secretary.concatenation.save_to "#{@root}/lib/nin.js"
61
+
62
+ puts Ninjs::Notification.added "lib/nin.js #{operation}"
63
+ end
64
+
65
+ def create_utility_lib_file
66
+ utility_lib_secretary = Sprockets::Secretary.new(
67
+ root: "#{@lib_dir}/ninjs-framework",
68
+ load_path: ["core", "extensions", "utilities"],
69
+ source_files: ["utilities/all.js"]
70
+ )
71
+
72
+ utility_lib_secretary.concatenation.save_to "#{@root}/lib/utilities.js"
73
+
74
+ puts Ninjs::Notification.added "lib/utilities.js created"
75
+ end
76
+
77
+ def create_ninjs_application_file
78
+ ninjs_lib = File.read("#{@root}/lib/nin.js")
79
+ template = ERB.new(File.read(File.expand_path("#{@template_dir}/application.js.erb")))
80
+
81
+ File.open("#{@root}/application/#{@config[:name].downcase}.js", "w+") do |file|
82
+ file << template.result(binding)
83
+ end
84
+ end
85
+
86
+ def import_rakefile
87
+ FileUtils.cp "#{@fw_root}/Rakefile", "#{@root}/Rakefile"
88
+ end
89
+
90
+ def import_spec_files
91
+ {
92
+ "spec/javascripts/application_spec.js" => 'spec/javascripts/',
93
+ "spec/javascripts/array_utility_spec.js" => 'spec/javascripts/',
94
+ "spec/javascripts/existence_spec.js" => 'spec/javascripts/',
95
+ "spec/javascripts/extension_spec.js" => 'spec/javascripts/',
96
+ "spec/javascripts/module_spec.js" => 'spec/javascripts/',
97
+ "spec/javascripts/string_utility_spec.js" => 'spec/javascripts/',
98
+ "spec/javascripts/support/jasmine_config.rb" => 'spec/javascripts/support',
99
+ "spec/javascripts/support/jasmine_runner.rb" => 'spec/javascripts/support',
100
+ "lib/ninjs-framework/templates/test-index.html.erb" => 'spec/index.html',
101
+ "lib/ninjs-framework/templates/jasmine.yml.erb" => 'spec/javascripts/support/',
102
+ "lib/ninjs-framework/assets/jasmine/jasmine-html.js" => 'spec/javascripts/support/',
103
+ "lib/ninjs-framework/assets/jasmine/jasmine.css" => 'spec/javascripts/support/',
104
+ "lib/ninjs-framework/assets/jasmine/jasmine.js" => 'spec/javascripts/support/',
105
+ "lib/ninjs-framework/assets/jasmine/jasmine_favicon.png" => 'spec/javascripts/support/'
106
+ }.each { |src, dest| import_spec_file src, dest }
107
+ end
108
+
109
+ def import_spec_file(src, dest)
110
+ FileUtils.cp "#{@fw_root}/#{src}", "#{@root}/#{dest}"
111
+ end
112
+
113
+ def update_application_file
114
+ application_file = "#{@root}/#{@config[:dest_dir]}/#{@config[:name].downcase}.js"
115
+
116
+ File.open(application_file, "w+") do |file|
117
+ write_dependencies(file)
118
+ write_core(file)
119
+ write_autoload(file)
120
+ end
121
+
122
+ compile_application_file application_file
123
+ end
124
+
125
+ def write_dependencies(file)
126
+ template = ERB.new(File.read(File.expand_path("#{@template_dir}/dependency.js.erb")))
127
+ @config[:dependencies].each do |dependency|
128
+ is_repo = dependency.match(/^\<.+\>$/)
129
+ file << template.result(binding)
130
+ end
131
+ end
132
+
133
+ def write_core(file)
134
+ template = ERB.new(File.read(File.expand_path("#{@template_dir}/core.js.erb")))
135
+ file << template.result(binding)
136
+ end
137
+
138
+ def write_autoload(file)
139
+ template = ERB.new(File.read(File.expand_path("#{@template_dir}/autoload.js.erb")))
140
+ @config[:autoload].each do |auto_file|
141
+ is_repo = auto_file.match(/^\<.+\>$/)
142
+ file << template.result(binding)
143
+ end
144
+ end
145
+
146
+ def compile_application_file(file)
147
+ begin
148
+ ninjs_lib_secretary = Sprockets::Secretary.new(
149
+ :root => Ninjs::BASE_DIR,
150
+ :asset_root => @config[:asset_root],
151
+ :load_path => ["repository"],
152
+ source_files: ["#{file}"]
153
+ )
154
+
155
+ application_file = ninjs_lib_secretary.concatenation
156
+ ninjs_lib_secretary.install_assets
157
+ application_file.save_to "#{file}"
158
+ rescue Exception => error
159
+ @errors = true
160
+ puts Ninjs::Notification.error "Sprockets error: #{error.message}"
161
+ end
162
+ end
163
+
164
+ end
@@ -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
+ };