karl-loris 0.0.6 → 0.0.7

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,21 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "loris"
8
+ gem.summary = %Q{TODO: Automatically run javascript tests}
9
+ gem.description = %Q{TODO: Automatically run javascript tests}
10
+ gem.email = "loris@monket.net"
11
+ gem.homepage = "http://github.com/karl/loris"
12
+ gem.authors = ["Karl O'Keeffe"]
13
+
14
+ gem.add_dependency(%q<visionmedia-bind>, [">= 0.2.6"])
15
+ gem.add_dependency(%q<karl-growl>, [">= 1.0.3"])
16
+
17
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
+ end
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
21
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
Binary file
@@ -20,7 +20,8 @@ require 'extension_filter'
20
20
 
21
21
  require 'outputs/output_collection'
22
22
  require 'outputs/shell_output'
23
- require 'outputs/console_clearing_output'
23
+ require 'outputs/windows_console_clearing_output'
24
+ require 'outputs/unix_console_clearing_output'
24
25
  require 'outputs/growl_output'
25
26
 
26
27
  require 'tasks/list_task'
@@ -28,6 +29,8 @@ require 'tasks/jspec_task'
28
29
  require 'tasks/jspec_runner'
29
30
  require 'tasks/javascript_lint_task'
30
31
  require 'tasks/javascript_lint_runner'
32
+ require 'tasks/js_test_driver_task'
33
+ require 'tasks/js_test_driver_runner'
31
34
 
32
35
 
33
36
  include Config
@@ -65,30 +68,33 @@ module Loris
65
68
 
66
69
  class << self
67
70
  def execute(args)
68
- puts 'Loris is running!'
69
-
71
+
72
+ # Get config variables
70
73
  debug = args.length > 0
71
-
74
+ is_windows = RUBY_PLATFORM =~ /mswin32/
72
75
  dir = Dir.pwd
76
+ sleep_duration = 1
77
+ jstd_jar = File.join(LIBDIR, 'JsTestDriver-1.0b.jar')
73
78
 
74
- w = SleepWaiter.new(1)
79
+ # Create object graph
80
+ w = SleepWaiter.new(sleep_duration)
75
81
  c = AlwaysContinuer.new
76
82
  ff = FileFinder.new(Find, dir)
77
83
  ff.add_filter(FileFilter.new(File))
78
84
  ff.add_filter(ModifiedFilter.new(File))
79
85
 
86
+ cco = is_windows ? WindowsConsoleClearingOutput.new() : UnixConsoleClearingOutput.new()
87
+
80
88
  oc = OutputCollection.new()
81
89
  oc.add(ShellOutput.new($stdout))
82
- oc.add(ConsoleClearingOutput.new())
83
-
84
- if (!debug)
85
- oc.add(GrowlOutput.new(Growl))
86
- end
90
+ oc.add(cco)
91
+ oc.add(GrowlOutput.new(Growl)) unless debug
87
92
 
88
93
  tm = TaskManager.new(oc)
89
94
  tm.add(ListTask.new()) if debug
90
95
  tm.add(JavascriptLintTask.new(JavascriptLintRunner.new(dir), dir))
91
96
  tm.add(JSpecTask.new(JSpecRunner.new(dir)))
97
+ tm.add(JsTestDriverTask.new(JsTestDriverRunner.new(dir, jstd_jar)))
92
98
 
93
99
  a = FileActioner.new(ff, tm)
94
100
 
@@ -0,0 +1,13 @@
1
+ class UnixConsoleClearingOutput
2
+
3
+ def initialize()
4
+ end
5
+
6
+ def start_run()
7
+ system 'clear'
8
+ end
9
+
10
+ def add_result(result)
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ class WindowsConsoleClearingOutput
2
+
3
+ def initialize()
4
+ end
5
+
6
+ def start_run()
7
+ system 'cls'
8
+ end
9
+
10
+ def add_result(result)
11
+ end
12
+
13
+ end
@@ -22,6 +22,7 @@ class JavascriptLintTask
22
22
  state, summary, first = parse_result(detail)
23
23
 
24
24
  # TODO: Tidy!
25
+ # Move to function/class w/ win32 related code
25
26
  if (first[0, @dir.length] == @dir)
26
27
  first = first[(@dir.length + 1)..-1]
27
28
  end
@@ -35,24 +36,25 @@ class JavascriptLintTask
35
36
  }
36
37
  end
37
38
 
39
+ # Move to parse class
38
40
  def parse_result(detail)
39
41
  summary_line = detail.grep( /\d+\s+error.*,\s+\d+\s+warning.*/ )[0]
40
42
 
41
43
  if summary_line.nil?
42
44
  # error
43
- error_info = (detail + "\nUnknown Error!").to_a[0].chomp
45
+ error_info = (detail + "\nUnknown Error!").to_a[0].strip
44
46
  return :error, 'Error', error_info
45
47
  end
46
48
 
47
49
  if summary_line =~ /([1-9]+)\d*\s+error/
48
50
  num_failures = $1
49
- error_info = detail.grep(/\([0-9]+\):([^:]*)Error:/)[0].chomp
51
+ error_info = detail.grep(/\([0-9]+\):([^:]*)Error:/)[0].strip
50
52
  return :failure, num_failures + ' Errors', error_info
51
53
  end
52
54
 
53
55
  if summary_line =~ /([1-9]+)\d*\s+warning/
54
56
  num_failures = $1
55
- error_info = detail.grep(/\([0-9]+\)/)[0].chomp
57
+ error_info = detail.grep(/\([0-9]+\)/)[0].strip
56
58
  return :warning, num_failures + ' Warnings', error_info
57
59
  end
58
60
 
@@ -0,0 +1,16 @@
1
+ class JsTestDriverRunner
2
+
3
+ def initialize(dir, jar)
4
+ @dir = dir
5
+ @jar = jar
6
+ end
7
+
8
+ def execute()
9
+ return `java -jar "#{@jar}" --config "jsTestDriver.conf" --tests all --verbose 2>&1`
10
+ end
11
+
12
+ def is_configured?(all_files)
13
+ return all_files.include?(@dir + '/jsTestDriver.conf')
14
+ end
15
+
16
+ end
@@ -0,0 +1,52 @@
1
+ class JsTestDriverTask
2
+
3
+ def initialize(js_test_driver)
4
+ @js_test_driver = js_test_driver
5
+ end
6
+
7
+ def run(files)
8
+ all_files = files[:all]
9
+ mofified_files = files[:filtered]
10
+
11
+ return nil if (!@js_test_driver.is_configured? all_files)
12
+
13
+ detail = @js_test_driver.execute()
14
+
15
+ state, summary, first = parse_result(detail)
16
+
17
+ return {
18
+ :state => state,
19
+ :title => 'JS Test Driver',
20
+ :summary => summary,
21
+ :first => first,
22
+ :detail => detail
23
+ }
24
+ end
25
+
26
+ # Move to parse class
27
+ def parse_result(detail)
28
+ summary_line = detail.grep( /Total \d+ tests/ )[0]
29
+
30
+ if summary_line.nil?
31
+ # error
32
+ error_info = (detail + "\nUnknown Error!").to_a[0].strip
33
+ return :error, 'Error', error_info
34
+ end
35
+
36
+ if summary_line =~ /Errors: ([1-9]+)/
37
+ num_errors = $1
38
+ error_info = detail.grep(/error \([0-9]+.[0-9]+ ms\)/)[0].strip
39
+ return :failure, num_errors + ' Errors', error_info
40
+ end
41
+
42
+ if summary_line =~ /Fails: ([1-9]+)/
43
+ num_failures = $1
44
+ error_info = detail.grep(/failed \([0-9]+.[0-9]+ ms\)/)[0].strip
45
+ return :failure, num_failures + ' Failures', error_info
46
+ end
47
+
48
+ return :success, 'All tests pass', ''
49
+
50
+ end
51
+
52
+ end
@@ -0,0 +1,109 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{loris}
8
+ s.version = "0.0.7"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Karl O'Keeffe"]
12
+ s.date = %q{2009-09-17}
13
+ s.default_executable = %q{loris}
14
+ s.description = %q{TODO: Automatically run javascript tests}
15
+ s.email = %q{loris@monket.net}
16
+ s.executables = ["loris"]
17
+ s.extra_rdoc_files = [
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".autotest",
22
+ ".gitignore",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "TODO",
26
+ "VERSION",
27
+ "autotest/discover.rb",
28
+ "bin/loris",
29
+ "cucumber.yml",
30
+ "examples/self_test/jsl.conf",
31
+ "examples/self_test/spec/spec.rhino.js",
32
+ "features/run.feature",
33
+ "features/step_definitons/all.rb",
34
+ "features/support/env.rb",
35
+ "lib/JsTestDriver-1.0b.jar",
36
+ "lib/always_continuer.rb",
37
+ "lib/extension_filter.rb",
38
+ "lib/file_actioner.rb",
39
+ "lib/file_filter.rb",
40
+ "lib/file_finder.rb",
41
+ "lib/icons/error.png",
42
+ "lib/icons/failure.png",
43
+ "lib/icons/info.png",
44
+ "lib/icons/success.png",
45
+ "lib/icons/warning.png",
46
+ "lib/loris.rb",
47
+ "lib/modified_filter.rb",
48
+ "lib/outputs/growl_output.rb",
49
+ "lib/outputs/output_collection.rb",
50
+ "lib/outputs/shell_output.rb",
51
+ "lib/outputs/unix_console_clearing_output.rb",
52
+ "lib/outputs/windows_console_clearing_output.rb",
53
+ "lib/poller.rb",
54
+ "lib/sleep_waiter.rb",
55
+ "lib/task_manager.rb",
56
+ "lib/tasks/javascript_lint_runner.rb",
57
+ "lib/tasks/javascript_lint_task.rb",
58
+ "lib/tasks/js_test_driver_runner.rb",
59
+ "lib/tasks/js_test_driver_task.rb",
60
+ "lib/tasks/jspec_runner.rb",
61
+ "lib/tasks/jspec_task.rb",
62
+ "lib/tasks/list_task.rb",
63
+ "loris.gemspec",
64
+ "loris.tmproj",
65
+ "spec/file_actioner_spec.rb",
66
+ "spec/file_filter_spec.rb",
67
+ "spec/file_finder_spec.rb",
68
+ "spec/growl_output_spec.rb",
69
+ "spec/jspec_task_spec.rb",
70
+ "spec/list_task_spec.rb",
71
+ "spec/modified_filter_spec.rb",
72
+ "spec/poller_spec.rb",
73
+ "spec/shell_output_spec.rb",
74
+ "spec/task_manager_spec.rb"
75
+ ]
76
+ s.homepage = %q{http://github.com/karl/loris}
77
+ s.rdoc_options = ["--charset=UTF-8"]
78
+ s.require_paths = ["lib"]
79
+ s.rubygems_version = %q{1.3.5}
80
+ s.summary = %q{TODO: Automatically run javascript tests}
81
+ s.test_files = [
82
+ "spec/file_actioner_spec.rb",
83
+ "spec/file_filter_spec.rb",
84
+ "spec/file_finder_spec.rb",
85
+ "spec/growl_output_spec.rb",
86
+ "spec/jspec_task_spec.rb",
87
+ "spec/list_task_spec.rb",
88
+ "spec/modified_filter_spec.rb",
89
+ "spec/poller_spec.rb",
90
+ "spec/shell_output_spec.rb",
91
+ "spec/task_manager_spec.rb"
92
+ ]
93
+
94
+ if s.respond_to? :specification_version then
95
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
96
+ s.specification_version = 3
97
+
98
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
99
+ s.add_runtime_dependency(%q<visionmedia-bind>, [">= 0.2.6"])
100
+ s.add_runtime_dependency(%q<karl-growl>, [">= 1.0.3"])
101
+ else
102
+ s.add_dependency(%q<visionmedia-bind>, [">= 0.2.6"])
103
+ s.add_dependency(%q<karl-growl>, [">= 1.0.3"])
104
+ end
105
+ else
106
+ s.add_dependency(%q<visionmedia-bind>, [">= 0.2.6"])
107
+ s.add_dependency(%q<karl-growl>, [">= 1.0.3"])
108
+ end
109
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: karl-loris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl O'Keeffe
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-16 00:00:00 -07:00
12
+ date: 2009-09-17 00:00:00 -07:00
13
13
  default_executable: loris
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -44,6 +44,7 @@ files:
44
44
  - .autotest
45
45
  - .gitignore
46
46
  - README.rdoc
47
+ - Rakefile
47
48
  - TODO
48
49
  - VERSION
49
50
  - autotest/discover.rb
@@ -54,6 +55,7 @@ files:
54
55
  - features/run.feature
55
56
  - features/step_definitons/all.rb
56
57
  - features/support/env.rb
58
+ - lib/JsTestDriver-1.0b.jar
57
59
  - lib/always_continuer.rb
58
60
  - lib/extension_filter.rb
59
61
  - lib/file_actioner.rb
@@ -66,18 +68,22 @@ files:
66
68
  - lib/icons/warning.png
67
69
  - lib/loris.rb
68
70
  - lib/modified_filter.rb
69
- - lib/outputs/console_clearing_output.rb
70
71
  - lib/outputs/growl_output.rb
71
72
  - lib/outputs/output_collection.rb
72
73
  - lib/outputs/shell_output.rb
74
+ - lib/outputs/unix_console_clearing_output.rb
75
+ - lib/outputs/windows_console_clearing_output.rb
73
76
  - lib/poller.rb
74
77
  - lib/sleep_waiter.rb
75
78
  - lib/task_manager.rb
76
79
  - lib/tasks/javascript_lint_runner.rb
77
80
  - lib/tasks/javascript_lint_task.rb
81
+ - lib/tasks/js_test_driver_runner.rb
82
+ - lib/tasks/js_test_driver_task.rb
78
83
  - lib/tasks/jspec_runner.rb
79
84
  - lib/tasks/jspec_task.rb
80
85
  - lib/tasks/list_task.rb
86
+ - loris.gemspec
81
87
  - loris.tmproj
82
88
  - spec/file_actioner_spec.rb
83
89
  - spec/file_filter_spec.rb
@@ -1,14 +0,0 @@
1
- class ConsoleClearingOutput
2
-
3
- def initialize()
4
- end
5
-
6
- def start_run()
7
- clear = RUBY_PLATFORM =~ /mswin32/ ? 'cls' : 'clear'
8
- system clear
9
- end
10
-
11
- def add_result(result)
12
- end
13
-
14
- end