loris 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -14,6 +14,7 @@ begin
14
14
  gem.homepage = "http://github.com/karl/loris"
15
15
  gem.authors = ["Karl O'Keeffe"]
16
16
 
17
+ gem.add_dependency('json', [">= 1.4.3"])
17
18
  gem.add_dependency('bind', [">= 0.2.6"])
18
19
  gem.add_dependency('karl-growl', [">= 1.0.6"])
19
20
  gem.add_dependency('extensions', [">= 0.6.0"])
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.3.0
Binary file
data/lib/file_actioner.rb CHANGED
@@ -9,6 +9,7 @@ class FileActioner
9
9
 
10
10
  def run
11
11
  begin
12
+ num_tasks_run = 0
12
13
  files = @file_finder.find
13
14
 
14
15
  # Refactor this to the file_finder class
@@ -16,13 +17,15 @@ class FileActioner
16
17
  files[:filtered] = files[:filtered] | changes
17
18
 
18
19
  if (files[:filtered] != [])
19
- @task_manager.run(files)
20
+ num_tasks_run = @task_manager.run(files)
20
21
  end
21
22
 
22
23
  @prev_all_files = files[:all]
23
24
  rescue Exception => e
24
25
  @task_manager.output_exception(e);
25
26
  end
27
+
28
+ num_tasks_run > 0
26
29
  end
27
30
 
28
31
  end
@@ -4,13 +4,20 @@ class ModifiedFilter
4
4
  @file_class = file_class
5
5
  @last_modified = last_modified
6
6
  @modifieds = []
7
+ @prev_file_sizes = {}
7
8
  end
8
9
 
9
10
  def filter(path)
10
11
  modified = @file_class.mtime(path)
11
12
  @modifieds << modified
12
13
 
13
- return @last_modified.nil? || modified > @last_modified
14
+ file_size = @file_class.size(path)
15
+ prev_file_size = @prev_file_sizes[path]
16
+ modified = @last_modified.nil? || modified > @last_modified || prev_file_size.nil? || file_size != prev_file_size
17
+
18
+ @prev_file_sizes[path] = file_size
19
+
20
+ return modified
14
21
  end
15
22
 
16
23
  def complete
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/python
2
+ # EASY-INSTALL-ENTRY-SCRIPT: 'closure-linter==2.2.5','console_scripts','fixjsstyle'
3
+ __requires__ = 'closure-linter==2.2.5'
4
+ import sys
5
+ from pkg_resources import load_entry_point
6
+
7
+ sys.exit(
8
+ load_entry_point('closure-linter==2.2.5', 'console_scripts', 'fixjsstyle')()
9
+ )
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/python
2
+ # EASY-INSTALL-ENTRY-SCRIPT: 'closure-linter==2.2.5','console_scripts','gjslint'
3
+ __requires__ = 'closure-linter==2.2.5'
4
+ import sys
5
+ from pkg_resources import load_entry_point
6
+
7
+ sys.exit(
8
+ load_entry_point('closure-linter==2.2.5', 'console_scripts', 'gjslint')()
9
+ )
@@ -29,7 +29,7 @@ jasmine.executeSpecsInFolder = function(folder, done, isVerbose, showColors){
29
29
  yellow: '\033[33m',
30
30
  none: '\033[0m'
31
31
  };
32
-
32
+
33
33
  for (var i = 0, len = specs.length; i < len; ++i){
34
34
  var filename = specs[i];
35
35
  require(filename.replace(/\.js$/, ""));
@@ -2,6 +2,7 @@ require.paths.push(__dirname + "/lib");
2
2
  require.paths.push("./");
3
3
 
4
4
  var sys = require('sys');
5
+ var fs = require('fs');
5
6
  var jasmine = require('jasmine');
6
7
 
7
8
  for(var key in jasmine) {
@@ -10,18 +11,175 @@ for(var key in jasmine) {
10
11
 
11
12
  var isVerbose = false;
12
13
  var showColors = true;
13
- var dir = __dirname;
14
+ var config = null;
15
+ var sourceDirectory;
16
+ var prev = null;
14
17
  process.argv.forEach(function(arg){
15
18
  switch(arg) {
16
- case '--color': showColors = true; break;
17
- case '--noColor': showColors = false; break;
18
- case '--verbose': isVerbose = true; break;
19
- default: dir = arg; break;
19
+ case '--color': showColors = true; break;
20
+ case '--noColor': showColors = false; break;
21
+ case '--verbose': isVerbose = true; break;
22
+ default:
23
+ if (prev === '--source-directory') {
24
+ sourceDirectory = arg;
25
+ } else {
26
+ config_path = arg;
27
+ }
28
+ break;
20
29
  }
30
+ prev = arg;
21
31
  });
22
32
 
33
+ var dir = config_path.substring(0, config_path.lastIndexOf('/'));
23
34
 
24
- jasmine.executeSpecsInFolder(dir + '/spec', function(runner, log) {
35
+ // read in config
36
+ var config = fs.readFileSync(config_path);
37
+ config = JSON.parse(config + "");
38
+
39
+ // get the spec directory (or use the default)
40
+
41
+
42
+ // add source dir to requires path (or given source dir argument)
43
+ require.paths.unshift(sourceDirectory || config.sourceDirectory);
44
+
45
+ // require all the requires files
46
+ for (var i = 0, len = config.requires.length; i < len; ++i){
47
+ require(config.requires[i]);
48
+ }
49
+
50
+
51
+ jasmine.executeSpecsInFolder.call(this, config.specDirectory || dir + '/spec', function(runner, log) {
52
+
53
+ if (typeof _$jscoverage === 'object') {
54
+ reportCoverage(_$jscoverage);
55
+ }
56
+
25
57
  // Cannot call process.exit, standard out and standard error do not get flushed
26
58
  // process.exit(runner.results().failedCount);
27
59
  }, isVerbose, showColors);
60
+
61
+ function reportCoverage(cov) {
62
+ populateCoverage(cov);
63
+ // Stats
64
+ sys.print('\n [bold]{Test Coverage}\n');
65
+ var sep = ' +------------------------------------------+----------+------+------+--------+',
66
+ lastSep = ' +----------+------+------+--------+';
67
+ sys.puts(sep);
68
+ sys.puts(' | filename | coverage | LOC | SLOC | missed |');
69
+ sys.puts(sep);
70
+ for (var name in cov) {
71
+ var file = cov[name];
72
+ if (file instanceof Array) {
73
+ sys.print(' | ' + rpad(name, 40));
74
+ sys.print(' | ' + lpad(file.coverage.toFixed(2), 8));
75
+ sys.print(' | ' + lpad(file.LOC, 4));
76
+ sys.print(' | ' + lpad(file.SLOC, 4));
77
+ sys.print(' | ' + lpad(file.totalMisses, 6));
78
+ sys.print(' |\n');
79
+ }
80
+ }
81
+ sys.puts(sep);
82
+ sys.print(' ' + rpad('', 40));
83
+ sys.print(' | ' + lpad(cov.coverage.toFixed(2), 8));
84
+ sys.print(' | ' + lpad(cov.LOC, 4));
85
+ sys.print(' | ' + lpad(cov.SLOC, 4));
86
+ sys.print(' | ' + lpad(cov.totalMisses, 6));
87
+ sys.print(' |\n');
88
+ sys.puts(lastSep);
89
+ // // Source
90
+ // for (var name in cov) {
91
+ // if (name.match(/\.js$/)) {
92
+ // var file = cov[name];
93
+ // sys.print('\n [bold]{' + name + '}:');
94
+ // sys.print(file.source);
95
+ // sys.print('\n');
96
+ // }
97
+ // }
98
+ }
99
+
100
+ /**
101
+ * Populate code coverage data.
102
+ *
103
+ * @param {Object} cov
104
+ * @api private
105
+ */
106
+
107
+ function populateCoverage(cov) {
108
+ cov.LOC =
109
+ cov.SLOC =
110
+ cov.totalFiles =
111
+ cov.totalHits =
112
+ cov.totalMisses =
113
+ cov.coverage = 0;
114
+ for (var name in cov) {
115
+ var file = cov[name];
116
+ if (file instanceof Array) {
117
+ // Stats
118
+ ++cov.totalFiles;
119
+ cov.totalHits += file.totalHits = coverage(file, true);
120
+ cov.totalMisses += file.totalMisses = coverage(file, false);
121
+ file.totalLines = file.totalHits + file.totalMisses;
122
+ cov.SLOC += file.SLOC = file.totalLines;
123
+ cov.LOC += file.LOC = file.source.length;
124
+ file.coverage = (file.totalHits / file.totalLines) * 100;
125
+ // Source
126
+ var width = file.source.length.toString().length;
127
+ file.source = file.source.map(function(line, i){
128
+ ++i;
129
+ var hits = file[i] === 0 ? 0 : (file[i] || ' ');
130
+ return '\n ' + lpad(i, width) + ' | ' + hits + ' | ' + line;
131
+ }).join('');
132
+ }
133
+ }
134
+ cov.coverage = (cov.totalHits / cov.SLOC) * 100;
135
+ }
136
+
137
+ /**
138
+ * Total coverage for the given file data.
139
+ *
140
+ * @param {Array} data
141
+ * @return {Type}
142
+ * @api private
143
+ */
144
+
145
+ function coverage(data, val) {
146
+ var n = 0;
147
+ for (var i = 0, len = data.length; i < len; ++i) {
148
+ if (data[i] !== undefined && data[i] == val) ++n;
149
+ }
150
+ return n;
151
+ }
152
+
153
+ /**
154
+ * Pad the given string to the maximum width provided.
155
+ *
156
+ * @param {String} str
157
+ * @param {Number} width
158
+ * @return {String}
159
+ * @api private
160
+ */
161
+
162
+ function lpad(str, width) {
163
+ str = String(str);
164
+ var n = width - str.length;
165
+ if (n < 1) return str;
166
+ while (n--) str = ' ' + str;
167
+ return str;
168
+ }
169
+
170
+ /**
171
+ * Pad the given string to the maximum width provided.
172
+ *
173
+ * @param {String} str
174
+ * @param {Number} width
175
+ * @return {String}
176
+ * @api private
177
+ */
178
+
179
+ function rpad(str, width) {
180
+ str = String(str);
181
+ var n = width - str.length;
182
+ if (n < 1) return str;
183
+ while (n--) str = str + ' ';
184
+ return str;
185
+ }
data/lib/loris.rb CHANGED
@@ -7,6 +7,7 @@ require 'rbconfig'
7
7
  require 'find'
8
8
  require 'Growl'
9
9
  require 'yaml'
10
+ require 'json'
10
11
  require 'uri'
11
12
 
12
13
 
@@ -40,10 +41,19 @@ require 'tasks/coffeescript/coffeescript_runner'
40
41
  require 'tasks/coffeescript/coffeescript_parser'
41
42
  require 'tasks/javascript_lint/javascript_lint_runner'
42
43
  require 'tasks/javascript_lint/javascript_lint_parser'
44
+ require 'tasks/google_lint/google_lint_runner'
45
+ require 'tasks/google_lint/google_lint_config'
46
+ require 'tasks/google_lint/google_lint_parser'
47
+ require 'tasks/jasmine_node/jasmine_node_config'
43
48
  require 'tasks/jasmine_node/jasmine_node_runner'
44
49
  require 'tasks/jasmine_node/jasmine_node_parser'
50
+ require 'tasks/jasmine_node_coverage/jasmine_node_coverage_runner'
51
+ require 'tasks/jasmine_node_coverage/js_coverage'
45
52
  require 'tasks/rspec/rspec_runner'
46
53
  require 'tasks/rspec/rspec_parser'
54
+ require 'tasks/closure_compiler/closure_compiler_config'
55
+ require 'tasks/closure_compiler/closure_compiler_runner'
56
+ require 'tasks/closure_compiler/closure_compiler_parser'
47
57
 
48
58
 
49
59
  include Config
@@ -107,10 +117,13 @@ module Loris
107
117
  tm.add(ListTask.new) if debug
108
118
  tm.add(coffeescript_task(dir))
109
119
  tm.add(javascript_lint_task(dir))
120
+ tm.add(google_lint_task(dir))
110
121
  tm.add(jasmine_node_task(dir))
122
+ tm.add(jasmine_node_coverage_task(dir))
111
123
  tm.add(CommandLineTask.new(JSpecRunner.new(dir, ExtensionFilter.new(File, 'js')), JSpecParser.new)) unless is_windows
112
124
  tm.add(jsTestDriverTask(dir))
113
125
  tm.add(CommandLineTask.new(RSpecRunner.new(dir, ExtensionFilter.new(File, 'rb'), EndsWithFilter.new('_spec.rb')), RSpecParser.new))
126
+ tm.add(closure_compiler_task(dir))
114
127
 
115
128
  a = FileActioner.new(ff, tm)
116
129
 
@@ -144,7 +157,28 @@ module Loris
144
157
  node,
145
158
  spec_dir,
146
159
  dir,
147
- ExtensionFilter.new(File, 'js')
160
+ ExtensionFilter.new(File, 'js'),
161
+ JasmineNodeConfig.new(dir, JSON, File)
162
+ ),
163
+ JasmineNodeParser.new(dir)
164
+ )
165
+ end
166
+
167
+ def jasmine_node_coverage_task(dir)
168
+ node = '/usr/local/bin/node'
169
+ spec_dir = File.join(LIBDIR, 'jasmine-node')
170
+
171
+ return CommandLineTask.new(
172
+ JasmineNodeCoverageRunner.new(
173
+ JasmineNodeRunner.new(
174
+ node,
175
+ spec_dir,
176
+ dir,
177
+ ExtensionFilter.new(File, 'js'),
178
+ JasmineNodeConfig.new(dir, JSON, File)
179
+ ),
180
+ JsCoverage.new("node-jscoverage"),
181
+ JasmineNodeConfig.new(dir, JSON, File)
148
182
  ),
149
183
  JasmineNodeParser.new(dir)
150
184
  )
@@ -165,6 +199,45 @@ module Loris
165
199
  )
166
200
  end
167
201
 
202
+ def google_lint_task(dir)
203
+ binary = File.join(LIBDIR, 'google-lint' , 'gjslint')
204
+ fix_style_binary = File.join(LIBDIR, 'google-lint' , 'fixjsstyle')
205
+
206
+ return CommandLineTask.new(
207
+ GoogleLintRunner.new(
208
+ binary,
209
+ fix_style_binary,
210
+ dir,
211
+ ExtensionFilter.new(File, 'js'),
212
+ GoogleLintConfig.new(
213
+ dir,
214
+ YAML,
215
+ URI
216
+ )
217
+ ),
218
+ GoogleLintParser.new(dir)
219
+ )
220
+ end
221
+
222
+ def closure_compiler_task(dir)
223
+ jar = File.join(LIBDIR, 'closure-compiler' , 'compiler.jar')
224
+
225
+ return CommandLineTask.new(
226
+ ClosureCompilerRunner.new(
227
+ jar,
228
+ dir,
229
+ ExtensionFilter.new(File, 'js'),
230
+ ClosureCompilerConfig.new(
231
+ dir,
232
+ YAML,
233
+ URI
234
+ )
235
+ ),
236
+ ClosureCompilerParser.new(dir)
237
+ )
238
+ end
239
+
240
+
168
241
  # Will need to be refactored into a factory
169
242
  def jsTestDriverTask(dir)
170
243
  require 'tasks/js_test_driver/js_test_driver_runner'
data/lib/poller.rb CHANGED
@@ -7,9 +7,10 @@ class Poller
7
7
  end
8
8
 
9
9
  def start
10
+ ran = false
10
11
  while @continuer.continue?
11
- @waiter.wait
12
- @action.run
12
+ @waiter.wait unless ran
13
+ ran = @action.run
13
14
  end
14
15
  end
15
16
 
data/lib/task_manager.rb CHANGED
@@ -48,6 +48,7 @@ class TaskManager
48
48
 
49
49
  end
50
50
 
51
+ @num_tasks_run
51
52
  end
52
53
 
53
54
  def run_task(files, task)
@@ -73,7 +74,7 @@ class TaskManager
73
74
  :title => 'Task',
74
75
  :summary => 'Exception',
75
76
  :first => ex.message,
76
- :detail => ex.backtrace
77
+ :detail => ex.message + "\n" + ex.backtrace.join("\n")
77
78
  }
78
79
  end
79
80
 
@@ -0,0 +1,17 @@
1
+ class ClosureCompilerConfig
2
+
3
+ def initialize(dir, yaml, uri)
4
+ @config_file = dir + '/closure-compiler.yml'
5
+ @yaml = yaml
6
+ @uri = uri
7
+ end
8
+
9
+ def reload
10
+ @conf = @yaml.load_file(@config_file)
11
+ end
12
+
13
+ def conf
14
+ return @conf
15
+ end
16
+
17
+ end
@@ -0,0 +1,46 @@
1
+ class ClosureCompilerParser
2
+
3
+ def initialize(dir)
4
+ @dir = dir
5
+
6
+ # TODO: Tidy!
7
+ if (RUBY_PLATFORM =~ /mswin32/)
8
+ @dir = @dir.gsub('/', '\\')
9
+ end
10
+ end
11
+
12
+ def parse_result(detail)
13
+ summary_line = detail.grep( /\d+\s+error.*,\s+\d+\s+warning.*/ )[0]
14
+
15
+ if summary_line.nil?
16
+ # error
17
+ error_info = (detail + "\nUnknown Error!").to_a[0].strip
18
+ return :error, 'Error', error_info
19
+ end
20
+
21
+ if summary_line =~ /([1-9]+)\d*\s+error/
22
+ num_failures = $1
23
+ error_info = detail.grep(/ ERROR - /)[0].strip
24
+ return :failure, num_failures + ' Errors', strip_dir(error_info)
25
+ end
26
+
27
+ if summary_line =~ /([1-9]+)\d*\s+warning/
28
+ num_failures = $1
29
+ error_info = detail.grep(/ WARNING - /)[0].strip
30
+ return :warning, num_failures + ' Warnings', strip_dir(error_info)
31
+ end
32
+
33
+ return :success, 'All files compiled successfully', ''
34
+ end
35
+
36
+ def strip_dir(text)
37
+
38
+ # Move to function/class w/ win32 related code
39
+ if (text[0, @dir.length] == @dir)
40
+ text = text[(@dir.length + 1)..-1]
41
+ end
42
+
43
+ text
44
+ end
45
+
46
+ end
@@ -0,0 +1,47 @@
1
+ class ClosureCompilerRunner
2
+
3
+ def initialize(jar, dir, filter, config)
4
+ @jar = jar
5
+ @config_file = dir + '/closure-compiler.yml'
6
+ @dir = dir
7
+ @filter = filter
8
+ @config = config
9
+ end
10
+
11
+ def name
12
+ return 'Closure Compiler'
13
+ end
14
+
15
+ def execute
16
+ @config.reload
17
+ conf = @config.conf
18
+
19
+ input_params = ''
20
+
21
+ conf.each do |param, value|
22
+
23
+ if value.kind_of? Array
24
+
25
+ value.each do |inner_value|
26
+ input_params += " --#{param} \"#{inner_value}\""
27
+ end
28
+
29
+ elsif value.kind_of? Integer
30
+ input_params += " --#{param} #{value}"
31
+ else
32
+ input_params += " --#{param} \"#{value}\""
33
+ end
34
+ end
35
+
36
+ return `java -Xmx1024m -jar "#{@jar}" #{input_params} 2>&1`
37
+ end
38
+
39
+ def is_configured?(all_files)
40
+ return all_files.include?(@config_file)
41
+ end
42
+
43
+ def should_run?(modified_files)
44
+ return !(modified_files.detect { |file| @filter.filter(file) && file != @output }).nil? || modified_files.include?(@config_file)
45
+ end
46
+
47
+ end
@@ -0,0 +1,17 @@
1
+ class GoogleLintConfig
2
+
3
+ def initialize(dir, yaml, uri)
4
+ @config_file = dir + '/gjslint.yml'
5
+ @yaml = yaml
6
+ @uri = uri
7
+ end
8
+
9
+ def reload
10
+ @conf = @yaml.load_file(@config_file)
11
+ end
12
+
13
+ def conf
14
+ return @conf
15
+ end
16
+
17
+ end
@@ -0,0 +1,41 @@
1
+ class GoogleLintParser
2
+
3
+ def initialize(dir)
4
+ @dir = dir
5
+
6
+ # TODO: Tidy!
7
+ if (RUBY_PLATFORM =~ /mswin32/)
8
+ @dir = @dir.gsub('/', '\\')
9
+ end
10
+ end
11
+
12
+ def parse_result(detail)
13
+ summary_line = detail.grep( /Found \d+\s+error*/ )[0]
14
+
15
+ if not detail.grep( /no errors found./ )[0].nil?
16
+ return :success, 'All files are clean', ''
17
+ end
18
+
19
+ if summary_line =~ /([1-9]+)\d*\s+error/
20
+ num_failures = $1
21
+ error_info = detail.grep(/FILE/)[0].strip
22
+ file_name = /:(.+) -----/.match error_info.strip
23
+ return :failure, num_failures + ' Errors', strip_dir(file_name)
24
+ end
25
+
26
+ # error
27
+ error_info = (detail + "\nUnknown Error!").to_a[0].strip
28
+ return :error, 'Error', error_info
29
+ end
30
+
31
+ def strip_dir(text)
32
+
33
+ # Move to function/class w/ win32 related code
34
+ if (text[0, @dir.length] == @dir)
35
+ text = text[(@dir.length + 1)..-1]
36
+ end
37
+
38
+ text
39
+ end
40
+
41
+ end
@@ -0,0 +1,62 @@
1
+ class GoogleLintRunner
2
+
3
+ def initialize(binary, fix_style_binary, dir, filter, config)
4
+ @binary = binary
5
+ @fix_style_binary = fix_style_binary
6
+ @config_file = dir + '/gjslint.yml'
7
+ @dir = dir
8
+ @filter = filter
9
+ @config = config
10
+ end
11
+
12
+ def name
13
+ return 'Google Lint'
14
+ end
15
+
16
+ def execute
17
+ @config.reload
18
+ conf = @config.conf
19
+
20
+ input_params = ''
21
+ run_fix_style = false
22
+
23
+ conf.each do |param, value|
24
+
25
+ if param == 'strict'
26
+ input_params += " --#{param}"
27
+ next
28
+ end
29
+
30
+ if param == 'run-fix-style'
31
+ run_fix_style = true
32
+ next
33
+ end
34
+
35
+ if value.kind_of? Array
36
+
37
+ value.each do |inner_value|
38
+ input_params += " --#{param} \"#{inner_value}\""
39
+ end
40
+
41
+ elsif value.kind_of? Integer
42
+ input_params += " --#{param} #{value}"
43
+ else
44
+ input_params += " --#{param} \"#{value}\""
45
+ end
46
+ end
47
+
48
+ result = ''
49
+ result += `#{@fix_style_binary} #{input_params} . 2>&1` if run_fix_style
50
+
51
+ return result + `#{@binary} #{input_params} . 2>&1`
52
+ end
53
+
54
+ def is_configured?(all_files)
55
+ return all_files.include?(@config_file)
56
+ end
57
+
58
+ def should_run?(modified_files)
59
+ return !(modified_files.detect { |file| @filter.filter(file) }).nil? || modified_files.include?(@config_file)
60
+ end
61
+
62
+ end
@@ -0,0 +1,30 @@
1
+ class JasmineNodeConfig
2
+
3
+ def initialize(dir, json, file)
4
+ @config_path = dir + '/jasmine.conf'
5
+ @json = json
6
+ @file = file
7
+ end
8
+
9
+ def config_path
10
+ return @config_path
11
+ end
12
+
13
+ def reload
14
+ contents = File.open(@config_path, 'r') { |f| f.read }
15
+ @config = @json.parse contents
16
+ end
17
+
18
+ def source_dir
19
+ return @config["sourceDirectory"]
20
+ end
21
+
22
+ def spec_dir
23
+ return @config["specDirectory"]
24
+ end
25
+
26
+ def requires
27
+ return @config["requires"]
28
+ end
29
+
30
+ end
@@ -9,7 +9,7 @@ class JasmineNodeParser
9
9
 
10
10
  if summary_line.nil?
11
11
  # error
12
- error_info = detail.grep(/Error: /)[0] || ["Unknown Error!"]
12
+ error_info = detail.grep(/Error: /)[0] || "Unknown Error!"
13
13
  return :error, 'Error', error_info.strip
14
14
  end
15
15
 
@@ -1,10 +1,12 @@
1
1
  class JasmineNodeRunner
2
2
 
3
- def initialize(node, spec_dir, dir, filter)
3
+ def initialize(node, spec_dir, dir, filter, config)
4
4
  @node = node
5
5
  @spec_dir = spec_dir
6
6
  @dir = dir
7
7
  @filter = filter
8
+ @config = config
9
+ @source_args = "";
8
10
  end
9
11
 
10
12
  def name
@@ -12,17 +14,19 @@ class JasmineNodeRunner
12
14
  end
13
15
 
14
16
  def execute
15
- return `"#{@node}" "#{@spec_dir}/specs.js" --noColor "#{@dir}" 2>&1`
17
+ return `"#{@node}" "#{@spec_dir}/specs.js" --noColor #{@source_args} "#{@config.config_path}" 2>&1`
16
18
  end
17
19
 
18
- # TODO: Only return true if we can find the node binary
19
20
  def is_configured?(all_files)
20
- spec_filter = StartsWithFilter.new(@dir + '/spec/')
21
- return !(all_files.detect { |file| spec_filter.filter(file) }).nil?
21
+ return all_files.include?(@config.config_path)
22
22
  end
23
23
 
24
24
  def should_run?(modified_files)
25
- return !(modified_files.detect { |file| @filter.filter(file) }).nil?
25
+ return !(modified_files.detect { |file| @filter.filter(file) }).nil? || modified_files.include?(@config.config_path)
26
+ end
27
+
28
+ def source_dir(source_dir)
29
+ @source_args = source_dir.nil? ? "" : "--source-directory \"#{source_dir}\""
26
30
  end
27
31
 
28
32
  end
@@ -0,0 +1,36 @@
1
+ require 'FileUtils'
2
+
3
+ class JasmineNodeCoverageRunner
4
+
5
+ def initialize(jasmine_runner, coverage, config)
6
+ @jasmine_runner = jasmine_runner
7
+ @coverage = coverage
8
+ @config = config
9
+ end
10
+
11
+ def name
12
+ return 'Coverage'
13
+ end
14
+
15
+ def execute
16
+ @config.reload
17
+
18
+ source_dir = @config.source_dir
19
+ coverage_dir = source_dir + "-cov"
20
+
21
+ FileUtils.rm_rf coverage_dir
22
+
23
+ output = @coverage.run source_dir, coverage_dir
24
+ @jasmine_runner.source_dir coverage_dir
25
+ return output + "\n\n" + @jasmine_runner.execute
26
+ end
27
+
28
+ def is_configured?(all_files)
29
+ return @jasmine_runner.is_configured? all_files
30
+ end
31
+
32
+ def should_run?(modified_files)
33
+ return @jasmine_runner.should_run? modified_files
34
+ end
35
+
36
+ end
@@ -0,0 +1,11 @@
1
+ class JsCoverage
2
+
3
+ def initialize(jscoverage)
4
+ @jscoverage = jscoverage
5
+ end
6
+
7
+ def run(source_dir, coverage_dir)
8
+ return `"#{@jscoverage}" "#{source_dir}" "#{coverage_dir}" 2>&1`
9
+ end
10
+
11
+ end
data/loris.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{loris}
8
- s.version = "0.2.3"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Karl O'Keeffe"]
12
- s.date = %q{2010-07-12}
12
+ s.date = %q{2010-10-01}
13
13
  s.default_executable = %q{loris}
14
14
  s.description = %q{Automatically run javascript unit tests}
15
15
  s.email = %q{loris@monket.net}
@@ -34,6 +34,7 @@ Gem::Specification.new do |s|
34
34
  "features/support/env.rb",
35
35
  "lib/always_continuer.rb",
36
36
  "lib/browser_finder.rb",
37
+ "lib/closure-compiler/compiler.jar",
37
38
  "lib/directory_finder.rb",
38
39
  "lib/file_actioner.rb",
39
40
  "lib/file_finder.rb",
@@ -42,6 +43,8 @@ Gem::Specification.new do |s|
42
43
  "lib/filters/file_filter.rb",
43
44
  "lib/filters/modified_filter.rb",
44
45
  "lib/filters/starts_with_filter.rb",
46
+ "lib/google-lint/fixjsstyle",
47
+ "lib/google-lint/gjslint",
45
48
  "lib/icons/error.png",
46
49
  "lib/icons/failure.png",
47
50
  "lib/icons/info.png",
@@ -65,11 +68,20 @@ Gem::Specification.new do |s|
65
68
  "lib/poller.rb",
66
69
  "lib/sleep_waiter.rb",
67
70
  "lib/task_manager.rb",
71
+ "lib/tasks/closure_compiler/closure_compiler_config.rb",
72
+ "lib/tasks/closure_compiler/closure_compiler_parser.rb",
73
+ "lib/tasks/closure_compiler/closure_compiler_runner.rb",
68
74
  "lib/tasks/coffeescript/coffeescript_parser.rb",
69
75
  "lib/tasks/coffeescript/coffeescript_runner.rb",
70
76
  "lib/tasks/command_line_task.rb",
77
+ "lib/tasks/google_lint/google_lint_config.rb",
78
+ "lib/tasks/google_lint/google_lint_parser.rb",
79
+ "lib/tasks/google_lint/google_lint_runner.rb",
80
+ "lib/tasks/jasmine_node/jasmine_node_config.rb",
71
81
  "lib/tasks/jasmine_node/jasmine_node_parser.rb",
72
82
  "lib/tasks/jasmine_node/jasmine_node_runner.rb",
83
+ "lib/tasks/jasmine_node_coverage/jasmine_node_coverage_runner.rb",
84
+ "lib/tasks/jasmine_node_coverage/js_coverage.rb",
73
85
  "lib/tasks/javascript_lint/javascript_lint_parser.rb",
74
86
  "lib/tasks/javascript_lint/javascript_lint_runner.rb",
75
87
  "lib/tasks/js_test_driver/js_test_driver_config.rb",
@@ -103,7 +115,7 @@ Gem::Specification.new do |s|
103
115
  s.homepage = %q{http://github.com/karl/loris}
104
116
  s.rdoc_options = ["--charset=UTF-8"]
105
117
  s.require_paths = ["lib"]
106
- s.rubygems_version = %q{1.3.5}
118
+ s.rubygems_version = %q{1.3.7}
107
119
  s.summary = %q{Automatically run javascript unit tests}
108
120
  s.test_files = [
109
121
  "spec/file_actioner_spec.rb",
@@ -126,16 +138,19 @@ Gem::Specification.new do |s|
126
138
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
127
139
  s.specification_version = 3
128
140
 
129
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
141
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
142
+ s.add_runtime_dependency(%q<json>, [">= 1.4.3"])
130
143
  s.add_runtime_dependency(%q<bind>, [">= 0.2.6"])
131
144
  s.add_runtime_dependency(%q<karl-growl>, [">= 1.0.6"])
132
145
  s.add_runtime_dependency(%q<extensions>, [">= 0.6.0"])
133
146
  else
147
+ s.add_dependency(%q<json>, [">= 1.4.3"])
134
148
  s.add_dependency(%q<bind>, [">= 0.2.6"])
135
149
  s.add_dependency(%q<karl-growl>, [">= 1.0.6"])
136
150
  s.add_dependency(%q<extensions>, [">= 0.6.0"])
137
151
  end
138
152
  else
153
+ s.add_dependency(%q<json>, [">= 1.4.3"])
139
154
  s.add_dependency(%q<bind>, [">= 0.2.6"])
140
155
  s.add_dependency(%q<karl-growl>, [">= 1.0.6"])
141
156
  s.add_dependency(%q<extensions>, [">= 0.6.0"])
data/loris.tmproj CHANGED
@@ -3,7 +3,7 @@
3
3
  <plist version="1.0">
4
4
  <dict>
5
5
  <key>currentDocument</key>
6
- <string>lib/directory_finder.rb</string>
6
+ <string>lib/filters/modified_filter.rb</string>
7
7
  <key>documents</key>
8
8
  <array>
9
9
  <dict>
@@ -49,6 +49,20 @@
49
49
  <key>firstVisibleLine</key>
50
50
  <integer>0</integer>
51
51
  </dict>
52
+ <key>lib/file_actioner.rb</key>
53
+ <dict>
54
+ <key>caret</key>
55
+ <dict>
56
+ <key>column</key>
57
+ <integer>0</integer>
58
+ <key>line</key>
59
+ <integer>27</integer>
60
+ </dict>
61
+ <key>firstVisibleColumn</key>
62
+ <integer>0</integer>
63
+ <key>firstVisibleLine</key>
64
+ <integer>0</integer>
65
+ </dict>
52
66
  <key>lib/file_finder.rb</key>
53
67
  <dict>
54
68
  <key>caret</key>
@@ -93,6 +107,34 @@
93
107
  <integer>16</integer>
94
108
  </dict>
95
109
  </dict>
110
+ <key>lib/filters/file_filter.rb</key>
111
+ <dict>
112
+ <key>caret</key>
113
+ <dict>
114
+ <key>column</key>
115
+ <integer>0</integer>
116
+ <key>line</key>
117
+ <integer>0</integer>
118
+ </dict>
119
+ <key>firstVisibleColumn</key>
120
+ <integer>0</integer>
121
+ <key>firstVisibleLine</key>
122
+ <integer>0</integer>
123
+ </dict>
124
+ <key>lib/filters/modified_filter.rb</key>
125
+ <dict>
126
+ <key>caret</key>
127
+ <dict>
128
+ <key>column</key>
129
+ <integer>20</integer>
130
+ <key>line</key>
131
+ <integer>17</integer>
132
+ </dict>
133
+ <key>firstVisibleColumn</key>
134
+ <integer>0</integer>
135
+ <key>firstVisibleLine</key>
136
+ <integer>0</integer>
137
+ </dict>
96
138
  <key>lib/jasmine-node/specs.js</key>
97
139
  <dict>
98
140
  <key>caret</key>
@@ -112,14 +154,14 @@
112
154
  <key>caret</key>
113
155
  <dict>
114
156
  <key>column</key>
115
- <integer>26</integer>
157
+ <integer>28</integer>
116
158
  <key>line</key>
117
- <integer>20</integer>
159
+ <integer>97</integer>
118
160
  </dict>
119
161
  <key>firstVisibleColumn</key>
120
162
  <integer>0</integer>
121
163
  <key>firstVisibleLine</key>
122
- <integer>0</integer>
164
+ <integer>82</integer>
123
165
  </dict>
124
166
  <key>lib/outputs/growl_output.rb</key>
125
167
  <dict>
@@ -149,6 +191,106 @@
149
191
  <key>firstVisibleLine</key>
150
192
  <integer>0</integer>
151
193
  </dict>
194
+ <key>lib/poller.rb</key>
195
+ <dict>
196
+ <key>caret</key>
197
+ <dict>
198
+ <key>column</key>
199
+ <integer>0</integer>
200
+ <key>line</key>
201
+ <integer>13</integer>
202
+ </dict>
203
+ <key>firstVisibleColumn</key>
204
+ <integer>0</integer>
205
+ <key>firstVisibleLine</key>
206
+ <integer>0</integer>
207
+ </dict>
208
+ <key>lib/sleep_waiter.rb</key>
209
+ <dict>
210
+ <key>caret</key>
211
+ <dict>
212
+ <key>column</key>
213
+ <integer>30</integer>
214
+ <key>line</key>
215
+ <integer>2</integer>
216
+ </dict>
217
+ <key>columnSelection</key>
218
+ <false/>
219
+ <key>firstVisibleColumn</key>
220
+ <integer>0</integer>
221
+ <key>firstVisibleLine</key>
222
+ <integer>0</integer>
223
+ <key>selectFrom</key>
224
+ <dict>
225
+ <key>column</key>
226
+ <integer>31</integer>
227
+ <key>line</key>
228
+ <integer>2</integer>
229
+ </dict>
230
+ <key>selectTo</key>
231
+ <dict>
232
+ <key>column</key>
233
+ <integer>30</integer>
234
+ <key>line</key>
235
+ <integer>2</integer>
236
+ </dict>
237
+ </dict>
238
+ <key>lib/task_manager.rb</key>
239
+ <dict>
240
+ <key>caret</key>
241
+ <dict>
242
+ <key>column</key>
243
+ <integer>18</integer>
244
+ <key>line</key>
245
+ <integer>50</integer>
246
+ </dict>
247
+ <key>firstVisibleColumn</key>
248
+ <integer>0</integer>
249
+ <key>firstVisibleLine</key>
250
+ <integer>3</integer>
251
+ </dict>
252
+ <key>lib/tasks/closure_compiler/closure_compiler_config.rb</key>
253
+ <dict>
254
+ <key>caret</key>
255
+ <dict>
256
+ <key>column</key>
257
+ <integer>13</integer>
258
+ <key>line</key>
259
+ <integer>0</integer>
260
+ </dict>
261
+ <key>firstVisibleColumn</key>
262
+ <integer>0</integer>
263
+ <key>firstVisibleLine</key>
264
+ <integer>0</integer>
265
+ </dict>
266
+ <key>lib/tasks/closure_compiler/closure_compiler_parser.rb</key>
267
+ <dict>
268
+ <key>caret</key>
269
+ <dict>
270
+ <key>column</key>
271
+ <integer>0</integer>
272
+ <key>line</key>
273
+ <integer>29</integer>
274
+ </dict>
275
+ <key>firstVisibleColumn</key>
276
+ <integer>0</integer>
277
+ <key>firstVisibleLine</key>
278
+ <integer>0</integer>
279
+ </dict>
280
+ <key>lib/tasks/closure_compiler/closure_compiler_runner.rb</key>
281
+ <dict>
282
+ <key>caret</key>
283
+ <dict>
284
+ <key>column</key>
285
+ <integer>0</integer>
286
+ <key>line</key>
287
+ <integer>44</integer>
288
+ </dict>
289
+ <key>firstVisibleColumn</key>
290
+ <integer>0</integer>
291
+ <key>firstVisibleLine</key>
292
+ <integer>0</integer>
293
+ </dict>
152
294
  <key>lib/tasks/coffeescript/coffeescript_runner.rb</key>
153
295
  <dict>
154
296
  <key>caret</key>
@@ -163,6 +305,34 @@
163
305
  <key>firstVisibleLine</key>
164
306
  <integer>0</integer>
165
307
  </dict>
308
+ <key>lib/tasks/google_lint/google_lint_parser.rb</key>
309
+ <dict>
310
+ <key>caret</key>
311
+ <dict>
312
+ <key>column</key>
313
+ <integer>12</integer>
314
+ <key>line</key>
315
+ <integer>0</integer>
316
+ </dict>
317
+ <key>firstVisibleColumn</key>
318
+ <integer>0</integer>
319
+ <key>firstVisibleLine</key>
320
+ <integer>0</integer>
321
+ </dict>
322
+ <key>lib/tasks/google_lint/google_lint_runner.rb</key>
323
+ <dict>
324
+ <key>caret</key>
325
+ <dict>
326
+ <key>column</key>
327
+ <integer>31</integer>
328
+ <key>line</key>
329
+ <integer>14</integer>
330
+ </dict>
331
+ <key>firstVisibleColumn</key>
332
+ <integer>0</integer>
333
+ <key>firstVisibleLine</key>
334
+ <integer>0</integer>
335
+ </dict>
166
336
  <key>lib/tasks/jasmine_node/jasmine_node_runner.rb</key>
167
337
  <dict>
168
338
  <key>caret</key>
@@ -177,6 +347,20 @@
177
347
  <key>firstVisibleLine</key>
178
348
  <integer>0</integer>
179
349
  </dict>
350
+ <key>lib/tasks/js_test_driver/js_test_driver_config.rb</key>
351
+ <dict>
352
+ <key>caret</key>
353
+ <dict>
354
+ <key>column</key>
355
+ <integer>2</integer>
356
+ <key>line</key>
357
+ <integer>12</integer>
358
+ </dict>
359
+ <key>firstVisibleColumn</key>
360
+ <integer>0</integer>
361
+ <key>firstVisibleLine</key>
362
+ <integer>0</integer>
363
+ </dict>
180
364
  <key>lib/tasks/list_task.rb</key>
181
365
  <dict>
182
366
  <key>caret</key>
@@ -210,9 +394,21 @@
210
394
  <array>
211
395
  <string>TODO</string>
212
396
  <string>lib/loris.rb</string>
397
+ <string>lib/filters/file_filter.rb</string>
398
+ <string>lib/tasks/closure_compiler/closure_compiler_parser.rb</string>
399
+ <string>lib/tasks/closure_compiler/closure_compiler_runner.rb</string>
400
+ <string>lib/task_manager.rb</string>
401
+ <string>lib/file_actioner.rb</string>
402
+ <string>lib/poller.rb</string>
403
+ <string>lib/sleep_waiter.rb</string>
404
+ <string>lib/tasks/js_test_driver/js_test_driver_config.rb</string>
405
+ <string>lib/tasks/closure_compiler/closure_compiler_config.rb</string>
406
+ <string>lib/tasks/google_lint/google_lint_parser.rb</string>
407
+ <string>lib/tasks/google_lint/google_lint_runner.rb</string>
213
408
  <string>lib/filters/ends_with_filter.rb</string>
214
409
  <string>lib/directory_finder.rb</string>
215
410
  <string>lib/file_finder.rb</string>
411
+ <string>lib/filters/modified_filter.rb</string>
216
412
  <string>lib/tasks/coffeescript/coffeescript_runner.rb</string>
217
413
  <string>lib/tasks/jasmine_node/jasmine_node_runner.rb</string>
218
414
  <string>lib/jasmine-node/specs.js</string>
@@ -220,6 +416,6 @@
220
416
  <key>showFileHierarchyDrawer</key>
221
417
  <false/>
222
418
  <key>windowFrame</key>
223
- <string>{{0, 0}, {1436, 878}}</string>
419
+ <string>{{0, 0}, {1920, 1178}}</string>
224
420
  </dict>
225
421
  </plist>
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ hash: 19
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Karl O'Keeffe
@@ -9,39 +15,73 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-07-12 00:00:00 +01:00
18
+ date: 2010-10-01 00:00:00 +01:00
13
19
  default_executable: loris
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
- name: bind
22
+ name: json
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 1
30
+ segments:
31
+ - 1
32
+ - 4
33
+ - 3
34
+ version: 1.4.3
17
35
  type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: bind
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
20
42
  requirements:
21
43
  - - ">="
22
44
  - !ruby/object:Gem::Version
45
+ hash: 27
46
+ segments:
47
+ - 0
48
+ - 2
49
+ - 6
23
50
  version: 0.2.6
24
- version:
51
+ type: :runtime
52
+ version_requirements: *id002
25
53
  - !ruby/object:Gem::Dependency
26
54
  name: karl-growl
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
30
58
  requirements:
31
59
  - - ">="
32
60
  - !ruby/object:Gem::Version
61
+ hash: 27
62
+ segments:
63
+ - 1
64
+ - 0
65
+ - 6
33
66
  version: 1.0.6
34
- version:
67
+ type: :runtime
68
+ version_requirements: *id003
35
69
  - !ruby/object:Gem::Dependency
36
70
  name: extensions
37
- type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
40
74
  requirements:
41
75
  - - ">="
42
76
  - !ruby/object:Gem::Version
77
+ hash: 7
78
+ segments:
79
+ - 0
80
+ - 6
81
+ - 0
43
82
  version: 0.6.0
44
- version:
83
+ type: :runtime
84
+ version_requirements: *id004
45
85
  description: Automatically run javascript unit tests
46
86
  email: loris@monket.net
47
87
  executables:
@@ -67,6 +107,7 @@ files:
67
107
  - features/support/env.rb
68
108
  - lib/always_continuer.rb
69
109
  - lib/browser_finder.rb
110
+ - lib/closure-compiler/compiler.jar
70
111
  - lib/directory_finder.rb
71
112
  - lib/file_actioner.rb
72
113
  - lib/file_finder.rb
@@ -75,6 +116,8 @@ files:
75
116
  - lib/filters/file_filter.rb
76
117
  - lib/filters/modified_filter.rb
77
118
  - lib/filters/starts_with_filter.rb
119
+ - lib/google-lint/fixjsstyle
120
+ - lib/google-lint/gjslint
78
121
  - lib/icons/error.png
79
122
  - lib/icons/failure.png
80
123
  - lib/icons/info.png
@@ -98,11 +141,20 @@ files:
98
141
  - lib/poller.rb
99
142
  - lib/sleep_waiter.rb
100
143
  - lib/task_manager.rb
144
+ - lib/tasks/closure_compiler/closure_compiler_config.rb
145
+ - lib/tasks/closure_compiler/closure_compiler_parser.rb
146
+ - lib/tasks/closure_compiler/closure_compiler_runner.rb
101
147
  - lib/tasks/coffeescript/coffeescript_parser.rb
102
148
  - lib/tasks/coffeescript/coffeescript_runner.rb
103
149
  - lib/tasks/command_line_task.rb
150
+ - lib/tasks/google_lint/google_lint_config.rb
151
+ - lib/tasks/google_lint/google_lint_parser.rb
152
+ - lib/tasks/google_lint/google_lint_runner.rb
153
+ - lib/tasks/jasmine_node/jasmine_node_config.rb
104
154
  - lib/tasks/jasmine_node/jasmine_node_parser.rb
105
155
  - lib/tasks/jasmine_node/jasmine_node_runner.rb
156
+ - lib/tasks/jasmine_node_coverage/jasmine_node_coverage_runner.rb
157
+ - lib/tasks/jasmine_node_coverage/js_coverage.rb
106
158
  - lib/tasks/javascript_lint/javascript_lint_parser.rb
107
159
  - lib/tasks/javascript_lint/javascript_lint_runner.rb
108
160
  - lib/tasks/js_test_driver/js_test_driver_config.rb
@@ -142,21 +194,27 @@ rdoc_options:
142
194
  require_paths:
143
195
  - lib
144
196
  required_ruby_version: !ruby/object:Gem::Requirement
197
+ none: false
145
198
  requirements:
146
199
  - - ">="
147
200
  - !ruby/object:Gem::Version
201
+ hash: 3
202
+ segments:
203
+ - 0
148
204
  version: "0"
149
- version:
150
205
  required_rubygems_version: !ruby/object:Gem::Requirement
206
+ none: false
151
207
  requirements:
152
208
  - - ">="
153
209
  - !ruby/object:Gem::Version
210
+ hash: 3
211
+ segments:
212
+ - 0
154
213
  version: "0"
155
- version:
156
214
  requirements: []
157
215
 
158
216
  rubyforge_project:
159
- rubygems_version: 1.3.5
217
+ rubygems_version: 1.3.7
160
218
  signing_key:
161
219
  specification_version: 3
162
220
  summary: Automatically run javascript unit tests