multi_js 0.0.1 → 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a095fa22e642ab2986f9d5f0e353943d93bd5218
4
+ data.tar.gz: 7390d53407e38b04799040d4b3c849f1cd60c5ca
5
+ SHA512:
6
+ metadata.gz: ac76b72c49e63ad2a42e5befdec3dffab2e04a8c54a7b96b37b77f3a0c636f6f4b1da0dadf0b24e1ae3d031eeaf47f8383d218868ae1ee169bd9d2f162b0968d
7
+ data.tar.gz: e124c6a913c9439d398210758d579d9738e41dd93ea97c3384db3434a2b965bbe964ec2992f28c38571d8f723e2a1031095c03dc3970110911105f451debc47f
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ report/report.html
@@ -1,10 +1,10 @@
1
- language: ruby
2
- rvm:
3
- - rbx-18mode
4
- - rbx-19mode
5
- - jruby-18mode
6
- - jruby-19mode
7
- - 1.8.7
8
- - 1.9.2
9
- - 1.9.3
10
- - ruby-head
1
+ language: ruby
2
+ rvm:
3
+ - rbx-18mode
4
+ - rbx-19mode
5
+ - jruby-18mode
6
+ - jruby-19mode
7
+ - 1.8.7
8
+ - 1.9.2
9
+ - 1.9.3
10
+ - ruby-head
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'closure-compiler', :require => nil
4
- # gem 'yui-compressor', :require => nil
5
- gem 'uglifier', :require => nil
6
-
7
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'closure-compiler', :require => nil
4
+ # gem 'yui-compressor', :require => nil
5
+ gem 'uglifier', :require => nil
6
+
7
+ gemspec
data/README.md CHANGED
@@ -26,10 +26,11 @@ If no other library is available, MultiJs falls back to [uglifier](https://githu
26
26
 
27
27
  ## TODO
28
28
 
29
+ - Implement report:publish rake task
30
+ - Add desciption and some design to report. Put it all in separate folder
29
31
  - benchmark against most popular JS frameworks (speed, size)
30
32
  - generate benchmark report (html or md)
31
33
  - write test suite
32
- - generate comparison table (html or md) with the help of test suite
33
34
 
34
35
  ## Contributing
35
36
 
data/Rakefile CHANGED
@@ -1,20 +1,46 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
3
-
4
- require 'rspec/core/rake_task'
5
- desc "Run all examples"
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- task :default => :spec
9
- task :test => :spec
10
-
11
- namespace :doc do
12
- require 'rdoc/task'
13
- require File.expand_path('../lib/multi_js/version', __FILE__)
14
- RDoc::Task.new do |rdoc|
15
- rdoc.rdoc_dir = 'rdoc'
16
- rdoc.title = "multi_js #{MultiJs::VERSION}"
17
- rdoc.main = 'README.md'
18
- rdoc.rdoc_files.include('README.md', 'LICENSE.md', 'lib/**/*.rb')
19
- end
20
- end
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ desc "Run all examples"
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
9
+ task :test => :spec
10
+
11
+ namespace :doc do
12
+ require 'rdoc/task'
13
+ require File.expand_path('../lib/multi_js/version', __FILE__)
14
+ RDoc::Task.new do |rdoc|
15
+ rdoc.rdoc_dir = 'rdoc'
16
+ rdoc.title = "multi_js #{MultiJs::VERSION}"
17
+ rdoc.main = 'README.md'
18
+ rdoc.rdoc_files.include('README.md', 'LICENSE.md', 'lib/**/*.rb')
19
+ end
20
+ end
21
+
22
+ desc "generate report"
23
+ RSpec::Core::RakeTask.new(:report) do |task|
24
+ task.pattern = 'report/*_spec.rb'
25
+ task.fail_on_error = false
26
+ task.rspec_opts = "--format ReportFormatter --require #{File.expand_path('../report/report_formatter', __FILE__)} --out report/report.html"
27
+ end
28
+
29
+ desc "publish report"
30
+ task "report:publish" => :report do
31
+ fail "Not implemented yet"
32
+ # TODO fail if something not commited
33
+ sh 'git status'
34
+ # TODO get latest commit message and SHA
35
+ sh 'git log'
36
+ message = nil
37
+ sha = nil
38
+ # TODO copy report files to temp directory
39
+ sh 'git checkout --orphan gh-pages'
40
+ sh 'git rm -rf .'
41
+ # TODO copy report files from temp directory
42
+ sh 'git add .'
43
+ sh "git commit -a -m 'report: #{message} #{sha}'"
44
+ sh 'git push origin gh-pages'
45
+ sh 'git checkout master'
46
+ end
@@ -92,16 +92,11 @@ module MultiJs
92
92
  string = string.read if string.respond_to?(:read)
93
93
 
94
94
  adapter = current_adapter(options)
95
- if defined?(adapter::ParseError)
96
- begin
97
- adapter.compile(string, options)
98
- rescue adapter::ParseError => exception
99
- raise ::MultiJs::ParseError.new(exception.message, exception.backtrace)
100
- end
101
- else
95
+ begin
102
96
  adapter.compile(string, options)
97
+ rescue adapter::ParseError => exception
98
+ raise ::MultiJs::ParseError.new(exception.message, exception.backtrace)
103
99
  end
104
100
  end
105
-
106
101
  end
107
102
  end
@@ -1,14 +1,15 @@
1
- require 'closure-compiler' unless defined?(::Closure)
2
-
3
- module MultiJs
4
- module Adapters
5
- class Closure
6
- ParseError = ::Closure::Error
7
-
8
- def self.compile(text, options={}) #:nodoc:
9
- compressor = ::Closure::Compiler.new options
10
- compressor.compile text
11
- end
12
- end
13
- end
14
- end
1
+ require 'closure-compiler' unless defined?(::Closure)
2
+
3
+ module MultiJs
4
+ module Adapters
5
+ class Closure
6
+ ParseError = ::Closure::Error
7
+
8
+ def self.compile(text, options={}) #:nodoc:
9
+ options.delete(:output)
10
+ compressor = ::Closure::Compiler.new options
11
+ compressor.compile(text).chomp
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,14 +1,14 @@
1
- require 'uglifier' unless defined?(::Uglifier)
2
-
3
- module MultiJs
4
- module Adapters
5
- class Uglifier
6
- ParseError = ::Uglifier::Error
7
-
8
- def self.compile(text, options={}) #:nodoc:
9
- compressor = ::Uglifier.new options
10
- compressor.compile text
11
- end
12
- end
13
- end
14
- end
1
+ require 'uglifier' unless defined?(::Uglifier)
2
+
3
+ module MultiJs
4
+ module Adapters
5
+ class Uglifier
6
+ ParseError = ::Uglifier::Error
7
+
8
+ def self.compile(text, options={}) #:nodoc:
9
+ compressor = ::Uglifier.new options
10
+ compressor.compile text
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,14 +1,15 @@
1
- require 'yui/compressor' unless defined?(::YUI::JavaScriptCompressor)
2
-
3
- module MultiJs
4
- module Adapters
5
- class YuiCompressor
6
- ParseError = ::YUI::Compressor::RuntimeError
7
-
8
- def self.compile(text, options={}) #:nodoc:
9
- compressor = ::YUI::JavaScriptCompressor.new options
10
- compressor.compress text
11
- end
12
- end
13
- end
14
- end
1
+ require 'yui/compressor' unless defined?(::YUI::JavaScriptCompressor)
2
+
3
+ module MultiJs
4
+ module Adapters
5
+ class YuiCompressor
6
+ ParseError = ::YUI::Compressor::RuntimeError
7
+
8
+ def self.compile(text, options={}) #:nodoc:
9
+ options.delete(:output)
10
+ compressor = ::YUI::JavaScriptCompressor.new options
11
+ compressor.compress text
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module MultiJs
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.require_paths = ["lib"]
20
20
 
21
- gem.add_dependency 'uglifier'
21
+ gem.add_dependency 'uglifier', '~> 2'
22
22
 
23
23
  gem.add_development_dependency 'rake'
24
24
  gem.add_development_dependency 'rdoc'
@@ -0,0 +1,364 @@
1
+ /*!
2
+ * Bootstrap v2.2.1
3
+ *
4
+ * Copyright 2012 Twitter, Inc
5
+ * Licensed under the Apache License v2.0
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ *
8
+ * Designed and built with all the love in the world @twitter by @mdo and @fat.
9
+ */
10
+ .clearfix {
11
+ *zoom: 1;
12
+ }
13
+ .clearfix:before,
14
+ .clearfix:after {
15
+ display: table;
16
+ content: "";
17
+ line-height: 0;
18
+ }
19
+ .clearfix:after {
20
+ clear: both;
21
+ }
22
+ .hide-text {
23
+ font: 0/0 a;
24
+ color: transparent;
25
+ text-shadow: none;
26
+ background-color: transparent;
27
+ border: 0;
28
+ }
29
+ .input-block-level {
30
+ display: block;
31
+ width: 100%;
32
+ min-height: 30px;
33
+ -webkit-box-sizing: border-box;
34
+ -moz-box-sizing: border-box;
35
+ box-sizing: border-box;
36
+ }
37
+ article,
38
+ aside,
39
+ details,
40
+ figcaption,
41
+ figure,
42
+ footer,
43
+ header,
44
+ hgroup,
45
+ nav,
46
+ section {
47
+ display: block;
48
+ }
49
+ audio,
50
+ canvas,
51
+ video {
52
+ display: inline-block;
53
+ *display: inline;
54
+ *zoom: 1;
55
+ }
56
+ audio:not([controls]) {
57
+ display: none;
58
+ }
59
+ html {
60
+ font-size: 100%;
61
+ -webkit-text-size-adjust: 100%;
62
+ -ms-text-size-adjust: 100%;
63
+ }
64
+ a:focus {
65
+ outline: thin dotted #333;
66
+ outline: 5px auto -webkit-focus-ring-color;
67
+ outline-offset: -2px;
68
+ }
69
+ a:hover,
70
+ a:active {
71
+ outline: 0;
72
+ }
73
+ sub,
74
+ sup {
75
+ position: relative;
76
+ font-size: 75%;
77
+ line-height: 0;
78
+ vertical-align: baseline;
79
+ }
80
+ sup {
81
+ top: -0.5em;
82
+ }
83
+ sub {
84
+ bottom: -0.25em;
85
+ }
86
+ img {
87
+ /* Responsive images (ensure images don't scale beyond their parents) */
88
+
89
+ max-width: 100%;
90
+ /* Part 1: Set a maxium relative to the parent */
91
+
92
+ width: auto\9;
93
+ /* IE7-8 need help adjusting responsive images */
94
+
95
+ height: auto;
96
+ /* Part 2: Scale the height according to the width, otherwise you get stretching */
97
+
98
+ vertical-align: middle;
99
+ border: 0;
100
+ -ms-interpolation-mode: bicubic;
101
+ }
102
+ #map_canvas img,
103
+ .google-maps img {
104
+ max-width: none;
105
+ }
106
+ button,
107
+ input,
108
+ select,
109
+ textarea {
110
+ margin: 0;
111
+ font-size: 100%;
112
+ vertical-align: middle;
113
+ }
114
+ button,
115
+ input {
116
+ *overflow: visible;
117
+ line-height: normal;
118
+ }
119
+ button::-moz-focus-inner,
120
+ input::-moz-focus-inner {
121
+ padding: 0;
122
+ border: 0;
123
+ }
124
+ button,
125
+ html input[type="button"],
126
+ input[type="reset"],
127
+ input[type="submit"] {
128
+ -webkit-appearance: button;
129
+ cursor: pointer;
130
+ }
131
+ input[type="search"] {
132
+ -webkit-box-sizing: content-box;
133
+ -moz-box-sizing: content-box;
134
+ box-sizing: content-box;
135
+ -webkit-appearance: textfield;
136
+ }
137
+ input[type="search"]::-webkit-search-decoration,
138
+ input[type="search"]::-webkit-search-cancel-button {
139
+ -webkit-appearance: none;
140
+ }
141
+ textarea {
142
+ overflow: auto;
143
+ vertical-align: top;
144
+ }
145
+ table {
146
+ max-width: 100%;
147
+ background-color: transparent;
148
+ border-collapse: collapse;
149
+ border-spacing: 0;
150
+ }
151
+ .table {
152
+ width: 100%;
153
+ margin-bottom: 20px;
154
+ }
155
+ .table th,
156
+ .table td {
157
+ padding: 8px;
158
+ line-height: 20px;
159
+ text-align: left;
160
+ vertical-align: top;
161
+ border-top: 1px solid #dddddd;
162
+ }
163
+ .table th {
164
+ font-weight: bold;
165
+ }
166
+ .table thead th {
167
+ vertical-align: bottom;
168
+ }
169
+ .table caption + thead tr:first-child th,
170
+ .table caption + thead tr:first-child td,
171
+ .table colgroup + thead tr:first-child th,
172
+ .table colgroup + thead tr:first-child td,
173
+ .table thead:first-child tr:first-child th,
174
+ .table thead:first-child tr:first-child td {
175
+ border-top: 0;
176
+ }
177
+ .table tbody + tbody {
178
+ border-top: 2px solid #dddddd;
179
+ }
180
+ .table-condensed th,
181
+ .table-condensed td {
182
+ padding: 4px 5px;
183
+ }
184
+ .table-bordered {
185
+ border: 1px solid #dddddd;
186
+ border-collapse: separate;
187
+ *border-collapse: collapse;
188
+ border-left: 0;
189
+ -webkit-border-radius: 4px;
190
+ -moz-border-radius: 4px;
191
+ border-radius: 4px;
192
+ }
193
+ .table-bordered th,
194
+ .table-bordered td {
195
+ border-left: 1px solid #dddddd;
196
+ }
197
+ .table-bordered caption + thead tr:first-child th,
198
+ .table-bordered caption + tbody tr:first-child th,
199
+ .table-bordered caption + tbody tr:first-child td,
200
+ .table-bordered colgroup + thead tr:first-child th,
201
+ .table-bordered colgroup + tbody tr:first-child th,
202
+ .table-bordered colgroup + tbody tr:first-child td,
203
+ .table-bordered thead:first-child tr:first-child th,
204
+ .table-bordered tbody:first-child tr:first-child th,
205
+ .table-bordered tbody:first-child tr:first-child td {
206
+ border-top: 0;
207
+ }
208
+ .table-bordered thead:first-child tr:first-child th:first-child,
209
+ .table-bordered tbody:first-child tr:first-child td:first-child {
210
+ -webkit-border-top-left-radius: 4px;
211
+ border-top-left-radius: 4px;
212
+ -moz-border-radius-topleft: 4px;
213
+ }
214
+ .table-bordered thead:first-child tr:first-child th:last-child,
215
+ .table-bordered tbody:first-child tr:first-child td:last-child {
216
+ -webkit-border-top-right-radius: 4px;
217
+ border-top-right-radius: 4px;
218
+ -moz-border-radius-topright: 4px;
219
+ }
220
+ .table-bordered thead:last-child tr:last-child th:first-child,
221
+ .table-bordered tbody:last-child tr:last-child td:first-child,
222
+ .table-bordered tfoot:last-child tr:last-child td:first-child {
223
+ -webkit-border-radius: 0 0 0 4px;
224
+ -moz-border-radius: 0 0 0 4px;
225
+ border-radius: 0 0 0 4px;
226
+ -webkit-border-bottom-left-radius: 4px;
227
+ border-bottom-left-radius: 4px;
228
+ -moz-border-radius-bottomleft: 4px;
229
+ }
230
+ .table-bordered thead:last-child tr:last-child th:last-child,
231
+ .table-bordered tbody:last-child tr:last-child td:last-child,
232
+ .table-bordered tfoot:last-child tr:last-child td:last-child {
233
+ -webkit-border-bottom-right-radius: 4px;
234
+ border-bottom-right-radius: 4px;
235
+ -moz-border-radius-bottomright: 4px;
236
+ }
237
+ .table-bordered caption + thead tr:first-child th:first-child,
238
+ .table-bordered caption + tbody tr:first-child td:first-child,
239
+ .table-bordered colgroup + thead tr:first-child th:first-child,
240
+ .table-bordered colgroup + tbody tr:first-child td:first-child {
241
+ -webkit-border-top-left-radius: 4px;
242
+ border-top-left-radius: 4px;
243
+ -moz-border-radius-topleft: 4px;
244
+ }
245
+ .table-bordered caption + thead tr:first-child th:last-child,
246
+ .table-bordered caption + tbody tr:first-child td:last-child,
247
+ .table-bordered colgroup + thead tr:first-child th:last-child,
248
+ .table-bordered colgroup + tbody tr:first-child td:last-child {
249
+ -webkit-border-top-right-radius: 4px;
250
+ border-top-right-radius: 4px;
251
+ -moz-border-radius-topright: 4px;
252
+ }
253
+ .table-striped tbody tr:nth-child(odd) td,
254
+ .table-striped tbody tr:nth-child(odd) th {
255
+ background-color: #f9f9f9;
256
+ }
257
+ .table-hover tbody tr:hover td,
258
+ .table-hover tbody tr:hover th {
259
+ background-color: #f5f5f5;
260
+ }
261
+ table td[class*="span"],
262
+ table th[class*="span"],
263
+ .row-fluid table td[class*="span"],
264
+ .row-fluid table th[class*="span"] {
265
+ display: table-cell;
266
+ float: none;
267
+ margin-left: 0;
268
+ }
269
+ .table td.span1,
270
+ .table th.span1 {
271
+ float: none;
272
+ width: 44px;
273
+ margin-left: 0;
274
+ }
275
+ .table td.span2,
276
+ .table th.span2 {
277
+ float: none;
278
+ width: 124px;
279
+ margin-left: 0;
280
+ }
281
+ .table td.span3,
282
+ .table th.span3 {
283
+ float: none;
284
+ width: 204px;
285
+ margin-left: 0;
286
+ }
287
+ .table td.span4,
288
+ .table th.span4 {
289
+ float: none;
290
+ width: 284px;
291
+ margin-left: 0;
292
+ }
293
+ .table td.span5,
294
+ .table th.span5 {
295
+ float: none;
296
+ width: 364px;
297
+ margin-left: 0;
298
+ }
299
+ .table td.span6,
300
+ .table th.span6 {
301
+ float: none;
302
+ width: 444px;
303
+ margin-left: 0;
304
+ }
305
+ .table td.span7,
306
+ .table th.span7 {
307
+ float: none;
308
+ width: 524px;
309
+ margin-left: 0;
310
+ }
311
+ .table td.span8,
312
+ .table th.span8 {
313
+ float: none;
314
+ width: 604px;
315
+ margin-left: 0;
316
+ }
317
+ .table td.span9,
318
+ .table th.span9 {
319
+ float: none;
320
+ width: 684px;
321
+ margin-left: 0;
322
+ }
323
+ .table td.span10,
324
+ .table th.span10 {
325
+ float: none;
326
+ width: 764px;
327
+ margin-left: 0;
328
+ }
329
+ .table td.span11,
330
+ .table th.span11 {
331
+ float: none;
332
+ width: 844px;
333
+ margin-left: 0;
334
+ }
335
+ .table td.span12,
336
+ .table th.span12 {
337
+ float: none;
338
+ width: 924px;
339
+ margin-left: 0;
340
+ }
341
+ .table tbody tr.success td {
342
+ background-color: #dff0d8;
343
+ }
344
+ .table tbody tr.error td {
345
+ background-color: #f2dede;
346
+ }
347
+ .table tbody tr.warning td {
348
+ background-color: #fcf8e3;
349
+ }
350
+ .table tbody tr.info td {
351
+ background-color: #d9edf7;
352
+ }
353
+ .table-hover tbody tr.success:hover td {
354
+ background-color: #d0e9c6;
355
+ }
356
+ .table-hover tbody tr.error:hover td {
357
+ background-color: #ebcccc;
358
+ }
359
+ .table-hover tbody tr.warning:hover td {
360
+ background-color: #faf2cc;
361
+ }
362
+ .table-hover tbody tr.info:hover td {
363
+ background-color: #c4e3f3;
364
+ }
@@ -0,0 +1,77 @@
1
+ require 'erb'
2
+
3
+ class HtmlPrinter
4
+ include ERB::Util # for the #h method
5
+ def initialize(output)
6
+ @output = output
7
+ end
8
+
9
+ def print_html_start
10
+ @output.puts HTML_HEADER
11
+ # @output.puts REPORT_HEADER
12
+ end
13
+
14
+ def print_summary( was_dry_run, duration, example_count, failure_count, pending_count )
15
+ # TODO - kill dry_run?
16
+ # if was_dry_run
17
+ # totals = "This was a dry-run"
18
+ # else
19
+ # totals = "#{example_count} example#{'s' unless example_count == 1}, "
20
+ # totals << "#{failure_count} failure#{'s' unless failure_count == 1}"
21
+ # totals << ", #{pending_count} pending" if pending_count > 0
22
+ # end
23
+
24
+ # formatted_duration = sprintf("%.5f", duration)
25
+
26
+ # @output.puts "<script>document.getElementById('duration').innerHTML = \"Finished in <strong>#{formatted_duration} seconds</strong>\";</script>"
27
+ # @output.puts "<script>document.getElementById('totals').innerHTML = \"#{totals}\";</script>"
28
+ @output.puts "</body></html>"
29
+ end
30
+
31
+ def print_table(table, table_header)
32
+ @output.puts '<table class="table table-striped"><thead><tr><th>&nbsp;</th>'
33
+ table_header.keys.each do |name|
34
+ @output.puts "<th>#{h(name)}</th>"
35
+ end
36
+ @output.puts "</tr></thead><tbody>"
37
+ table.each do |name, examples|
38
+ @output.puts "<tr><td>#{h(name)}</td>"
39
+ examples.each do |name, value|
40
+ @output.puts "<td>#{h(value.to_s)}</td>"
41
+ end
42
+ @output.puts "</tr>"
43
+ end
44
+ @output.puts "</tbody></table>"
45
+ end
46
+
47
+ def flush
48
+ @output.flush
49
+ end
50
+
51
+ private
52
+
53
+ # REPORT_HEADER = <<-EOF
54
+ # <div id="summary">
55
+ # <p id="totals">&nbsp;</p>
56
+ # <p id="duration">&nbsp;</p>
57
+ # </div>
58
+ # EOF
59
+
60
+ HTML_HEADER = <<-EOF
61
+ <!DOCTYPE html>
62
+ <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
63
+ <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
64
+ <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
65
+ <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
66
+ <head>
67
+ <meta charset="utf-8">
68
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
69
+ <title>Report</title>
70
+ <meta name="description" content="">
71
+ <meta name="viewport" content="width=device-width">
72
+ <link rel="stylesheet" href="bootstrap.css">
73
+ </head>
74
+ <body>
75
+ EOF
76
+
77
+ end
@@ -0,0 +1,76 @@
1
+ require 'rspec/core/formatters/base_text_formatter'
2
+ require File.expand_path('../html_printer', __FILE__)
3
+
4
+ class ReportFormatter < RSpec::Core::Formatters::BaseTextFormatter
5
+
6
+ def initialize(output)
7
+ super(output)
8
+ @printer = HtmlPrinter.new(output)
9
+
10
+ # @output = output
11
+ @adapter = nil
12
+ @table = {}
13
+ @table_header = {}
14
+ end
15
+
16
+ private
17
+ def method_missing(m, *a, &b)
18
+ # no-op
19
+ end
20
+
21
+ public
22
+ def message(message)
23
+ end
24
+
25
+ def start(example_count)
26
+ super(example_count)
27
+ @printer.print_html_start
28
+ end
29
+
30
+ def example_group_started(example_group)
31
+ super(example_group)
32
+ if example_group.parent_groups.size == 2
33
+ @adapter = example_group.description
34
+ end
35
+ end
36
+
37
+ def example_add(example, val)
38
+ @table[example.description] ||= {}
39
+ @table[example.description][@adapter] = val
40
+ @table_header[@adapter] = true
41
+ end
42
+
43
+ def example_passed(example)
44
+ example_add(example, true)
45
+ end
46
+
47
+ def example_failed(example)
48
+ super(example)
49
+
50
+ example_add(example, false)
51
+
52
+ # exception = example.metadata[:execution_result][:exception]
53
+ # exception_details = if exception
54
+ # {
55
+ # :message => exception.message,
56
+ # :backtrace => format_backtrace(exception.backtrace, example).join("\n")
57
+ # }
58
+ # else
59
+ # false
60
+ # end
61
+ end
62
+
63
+ def dump_summary(duration, example_count, failure_count, pending_count)
64
+ @printer.print_table(@table, @table_header)
65
+
66
+ @printer.print_summary(
67
+ dry_run?,
68
+ duration,
69
+ example_count,
70
+ failure_count,
71
+ pending_count
72
+ )
73
+
74
+ @printer.flush
75
+ end
76
+ end
@@ -0,0 +1,10 @@
1
+ require File.expand_path('../../spec/helper', __FILE__)
2
+ require File.expand_path('../../spec/adapter_shared_example', __FILE__)
3
+
4
+ describe 'MultiJs' do
5
+ %w(closure uglifier).each do |adapter|
6
+ context adapter do
7
+ it_behaves_like "an adapter", adapter
8
+ end
9
+ end
10
+ end
@@ -1,21 +1,26 @@
1
- shared_examples_for "an adapter" do |adapter|
2
-
3
- before do
4
- begin
5
- MultiJs.use adapter
6
- rescue LoadError
7
- pending "Adapter #{adapter} couldn't be loaded (not installed?)"
8
- end
9
- end
10
-
11
- describe '.compile' do
12
- it 'minify' do
13
- js = "(function(){var long_name=1}())"
14
- MultiJs.compile(js).length.should be < js.length
15
- end
16
-
17
- it 'throws exception if parse error occurred' do
18
- lambda { MultiJs.compile('error statement') }.should raise_error MultiJs::ParseError
19
- end
20
- end
21
- end
1
+ shared_examples_for "an adapter" do |adapter|
2
+
3
+ before do
4
+ begin
5
+ MultiJs.use adapter
6
+ rescue LoadError
7
+ pending "Adapter #{adapter} couldn't be loaded (not installed?)"
8
+ end
9
+ end
10
+
11
+ describe '.compile' do
12
+ it 'minify' do
13
+ js = "(function(){var long_name=1}())"
14
+ MultiJs.compile(js).length.should be < js.length
15
+ end
16
+
17
+ it 'throws exception if parse error occurred' do
18
+ lambda { MultiJs.compile('error statement') }.should raise_error MultiJs::ParseError
19
+ end
20
+
21
+ it 'support :inline_script option' do
22
+ js = 'var a="<\/script>";'
23
+ MultiJs.compile(js, :output => {:inline_script => true}).should eq js
24
+ end
25
+ end
26
+ end
@@ -1,23 +1,23 @@
1
- def jruby?
2
- defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
3
- end
4
-
5
- def macruby?
6
- defined?(RUBY_ENGINE) && RUBY_ENGINE == 'macruby'
7
- end
8
-
9
- unless ENV['CI'] || macruby?
10
- require 'simplecov'
11
- SimpleCov.start do
12
- add_filter 'spec'
13
- end
14
- end
15
-
16
- require 'multi_js'
17
- require 'rspec'
18
-
19
- class MockDecoder
20
- def self.compile(string, options={})
21
- 'js code'
22
- end
23
- end
1
+ def jruby?
2
+ defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
3
+ end
4
+
5
+ def macruby?
6
+ defined?(RUBY_ENGINE) && RUBY_ENGINE == 'macruby'
7
+ end
8
+
9
+ unless ENV['CI'] || macruby?
10
+ require 'simplecov'
11
+ SimpleCov.start do
12
+ add_filter 'spec'
13
+ end
14
+ end
15
+
16
+ require 'multi_js'
17
+ require 'rspec'
18
+
19
+ class MockDecoder
20
+ def self.compile(string, options={})
21
+ 'js code'
22
+ end
23
+ end
@@ -1,67 +1,67 @@
1
- require 'helper'
2
- require 'adapter_shared_example'
3
- require 'stringio'
4
-
5
- describe 'MultiJs' do
6
- context 'adapters' do
7
- before do
8
- MultiJs.use nil
9
- end
10
- context 'when no other implementations are available' do
11
-
12
- CONSTS = [:Closure, :YUI, :Uglifier]
13
-
14
- before do
15
- @old_map = MultiJs::REQUIREMENT_MAP
16
- @old_consts = {}
17
- CONSTS.each do |c|
18
- @old_consts[c] = Object.const_get c if Object.const_defined?(c)
19
- end
20
-
21
- MultiJs::REQUIREMENT_MAP.each_with_index do |(library, adapter), index|
22
- MultiJs::REQUIREMENT_MAP[index] = ["foo/#{library}", adapter]
23
- end
24
-
25
- CONSTS.each do |c|
26
- Object.send :remove_const, c if @old_consts[c]
27
- end
28
- end
29
-
30
- after do
31
- @old_map.each_with_index do |(library, adapter), index|
32
- MultiJs::REQUIREMENT_MAP[index] = [library, adapter]
33
- end
34
-
35
- CONSTS.each do |c|
36
- Object.const_set c, @old_consts[c] if @old_consts[c]
37
- end
38
- end
39
-
40
- it 'defaults to vendored implemention if no other implementions are available' do
41
- MultiJs.default_adapter.should eq :uglifier
42
- end
43
- end
44
-
45
- it 'defaults to the best not vendored lib if any other lib available' do
46
- require 'closure-compiler'
47
- MultiJs.adapter.name.should eq 'MultiJs::Adapters::Closure'
48
- end
49
-
50
- it 'is settable via a symbol' do
51
- MultiJs.use :closure
52
- MultiJs.adapter.name.should eq 'MultiJs::Adapters::Closure'
53
- end
54
-
55
- it 'is settable via a class' do
56
- MultiJs.use MockDecoder
57
- MultiJs.adapter.name.should eq 'MockDecoder'
58
- end
59
- end
60
-
61
- %w(closure uglifier).each do |adapter|
62
- context adapter do
63
- it_behaves_like "an adapter", adapter
64
- end
65
- end
66
- end
67
-
1
+ require 'helper'
2
+ require 'adapter_shared_example'
3
+ require 'stringio'
4
+
5
+ describe 'MultiJs' do
6
+ context 'adapters' do
7
+ before do
8
+ MultiJs.use nil
9
+ end
10
+ context 'when no other implementations are available' do
11
+
12
+ CONSTS = [:Closure, :YUI, :Uglifier]
13
+
14
+ before do
15
+ @old_map = MultiJs::REQUIREMENT_MAP
16
+ @old_consts = {}
17
+ CONSTS.each do |c|
18
+ @old_consts[c] = Object.const_get c if Object.const_defined?(c)
19
+ end
20
+
21
+ MultiJs::REQUIREMENT_MAP.each_with_index do |(library, adapter), index|
22
+ MultiJs::REQUIREMENT_MAP[index] = ["foo/#{library}", adapter]
23
+ end
24
+
25
+ CONSTS.each do |c|
26
+ Object.send :remove_const, c if @old_consts[c]
27
+ end
28
+ end
29
+
30
+ after do
31
+ @old_map.each_with_index do |(library, adapter), index|
32
+ MultiJs::REQUIREMENT_MAP[index] = [library, adapter]
33
+ end
34
+
35
+ CONSTS.each do |c|
36
+ Object.const_set c, @old_consts[c] if @old_consts[c]
37
+ end
38
+ end
39
+
40
+ it 'defaults to vendored implemention if no other implementions are available' do
41
+ MultiJs.default_adapter.should eq :uglifier
42
+ end
43
+ end
44
+
45
+ it 'defaults to the best not vendored lib if any other lib available' do
46
+ require 'closure-compiler'
47
+ MultiJs.adapter.name.should eq 'MultiJs::Adapters::Closure'
48
+ end
49
+
50
+ it 'is settable via a symbol' do
51
+ MultiJs.use :closure
52
+ MultiJs.adapter.name.should eq 'MultiJs::Adapters::Closure'
53
+ end
54
+
55
+ it 'is settable via a class' do
56
+ MultiJs.use MockDecoder
57
+ MultiJs.adapter.name.should eq 'MockDecoder'
58
+ end
59
+ end
60
+
61
+ %w(closure uglifier).each do |adapter|
62
+ context adapter do
63
+ it_behaves_like "an adapter", adapter
64
+ end
65
+ end
66
+ end
67
+
metadata CHANGED
@@ -1,94 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi_js
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - sterebooster
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-11-28 00:00:00.000000000 Z
11
+ date: 2013-06-04 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: uglifier
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: '2'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: '0'
26
+ version: '2'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rdoc
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: simplecov
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  description: A generic swappable back-end for JS minifiers
@@ -110,33 +99,36 @@ files:
110
99
  - lib/multi_js/adapters/yui_compressor.rb
111
100
  - lib/multi_js/version.rb
112
101
  - multi_js.gemspec
102
+ - report/bootstrap.css
103
+ - report/html_printer.rb
104
+ - report/report_formatter.rb
105
+ - report/report_spec.rb
113
106
  - spec/adapter_shared_example.rb
114
107
  - spec/helper.rb
115
108
  - spec/multi_js_spec.rb
116
109
  homepage: https://github.com/stereobooster/multi_js
117
110
  licenses:
118
111
  - MIT
112
+ metadata: {}
119
113
  post_install_message:
120
114
  rdoc_options: []
121
115
  require_paths:
122
116
  - lib
123
117
  required_ruby_version: !ruby/object:Gem::Requirement
124
- none: false
125
118
  requirements:
126
- - - ! '>='
119
+ - - '>='
127
120
  - !ruby/object:Gem::Version
128
121
  version: '0'
129
122
  required_rubygems_version: !ruby/object:Gem::Requirement
130
- none: false
131
123
  requirements:
132
- - - ! '>='
124
+ - - '>='
133
125
  - !ruby/object:Gem::Version
134
126
  version: '0'
135
127
  requirements: []
136
128
  rubyforge_project:
137
- rubygems_version: 1.8.24
129
+ rubygems_version: 2.0.3
138
130
  signing_key:
139
- specification_version: 3
131
+ specification_version: 4
140
132
  summary: A generic swappable back-end for JS minifiers
141
133
  test_files:
142
134
  - spec/adapter_shared_example.rb