karl-loris 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +12 -0
- data/.gitignore +1 -0
- data/TODO +21 -0
- data/VERSION +1 -0
- data/autotest/discover.rb +3 -0
- data/cucumber.yml +1 -0
- data/examples/self_test/jsl.conf +0 -0
- data/examples/self_test/spec/spec.rhino.js +6 -0
- data/features/run.feature +37 -0
- data/features/step_definitons/all.rb +61 -0
- data/features/support/env.rb +145 -0
- data/lib/always_continuer.rb +7 -0
- data/lib/extension_filter.rb +20 -0
- data/lib/file_actioner.rb +16 -0
- data/lib/file_filter.rb +14 -0
- data/lib/file_finder.rb +31 -0
- data/lib/icons/error.png +0 -0
- data/lib/icons/failure.png +0 -0
- data/lib/icons/info.png +0 -0
- data/lib/icons/success.png +0 -0
- data/lib/icons/warning.png +0 -0
- data/lib/loris.rb +108 -0
- data/lib/modified_filter.rb +21 -0
- data/lib/outputs/console_clearing_output.rb +14 -0
- data/lib/outputs/growl_output.rb +26 -0
- data/lib/outputs/output_collection.rb +23 -0
- data/lib/outputs/shell_output.rb +17 -0
- data/lib/poller.rb +16 -0
- data/lib/sleep_waiter.rb +11 -0
- data/lib/task_manager.rb +27 -0
- data/lib/tasks/javascript_lint_runner.rb +15 -0
- data/lib/tasks/javascript_lint_task.rb +63 -0
- data/lib/tasks/jspec_runner.rb +15 -0
- data/lib/tasks/jspec_task.rb +53 -0
- data/lib/tasks/list_task.rb +34 -0
- data/loris.tmproj +202 -0
- data/spec/file_actioner_spec.rb +41 -0
- data/spec/file_filter_spec.rb +28 -0
- data/spec/file_finder_spec.rb +73 -0
- data/spec/growl_output_spec.rb +33 -0
- data/spec/jspec_task_spec.rb +47 -0
- data/spec/list_task_spec.rb +58 -0
- data/spec/modified_filter_spec.rb +47 -0
- data/spec/poller_spec.rb +28 -0
- data/spec/shell_output_spec.rb +25 -0
- data/spec/task_manager_spec.rb +64 -0
- metadata +70 -19
- data/loris.gemspec +0 -33
@@ -0,0 +1,21 @@
|
|
1
|
+
class ModifiedFilter
|
2
|
+
|
3
|
+
def initialize(file_class, last_modified = nil)
|
4
|
+
@file_class = file_class
|
5
|
+
@last_modified = last_modified
|
6
|
+
@modifieds = []
|
7
|
+
end
|
8
|
+
|
9
|
+
def filter(path)
|
10
|
+
modified = @file_class.mtime(path)
|
11
|
+
@modifieds << modified
|
12
|
+
|
13
|
+
return @last_modified.nil? || modified > @last_modified
|
14
|
+
end
|
15
|
+
|
16
|
+
def complete()
|
17
|
+
@last_modified = @modifieds.max
|
18
|
+
@modifieds = []
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class GrowlOutput
|
2
|
+
|
3
|
+
def initialize(growler)
|
4
|
+
@growler = growler
|
5
|
+
end
|
6
|
+
|
7
|
+
def start_run()
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_result(result)
|
11
|
+
icon = get_icon(result[:state])
|
12
|
+
|
13
|
+
if @growler.installed?
|
14
|
+
@growler.notify {
|
15
|
+
self.title = result[:title] + (result[:summary].nil? ? '' : ' - ' + result[:summary])
|
16
|
+
self.message = result[:first]
|
17
|
+
self.image = icon
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_icon(state)
|
23
|
+
return File.join(File.expand_path(File.dirname(__FILE__)), '..', 'icons', "#{state.to_s}.png")
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class OutputCollection
|
2
|
+
|
3
|
+
def initialize()
|
4
|
+
@outputs = []
|
5
|
+
end
|
6
|
+
|
7
|
+
def start_run()
|
8
|
+
@outputs.each do |output|
|
9
|
+
output.start_run()
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def add(output)
|
14
|
+
@outputs << output
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_result(result)
|
18
|
+
@outputs.each do |output|
|
19
|
+
output.add_result(result)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class ShellOutput
|
2
|
+
|
3
|
+
def initialize(output)
|
4
|
+
@output = output
|
5
|
+
end
|
6
|
+
|
7
|
+
def start_run()
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_result(result)
|
11
|
+
@output.puts result[:title]
|
12
|
+
@output.puts result[:state]
|
13
|
+
@output.puts result[:summary]
|
14
|
+
@output.puts result[:detail]
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
data/lib/poller.rb
ADDED
data/lib/sleep_waiter.rb
ADDED
data/lib/task_manager.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
class TaskManager
|
2
|
+
|
3
|
+
def initialize(output)
|
4
|
+
@output = output
|
5
|
+
@tasks = []
|
6
|
+
end
|
7
|
+
|
8
|
+
def add(task)
|
9
|
+
@tasks << task
|
10
|
+
end
|
11
|
+
|
12
|
+
def run(files)
|
13
|
+
@output.start_run();
|
14
|
+
|
15
|
+
@tasks.each do |task|
|
16
|
+
|
17
|
+
result = task.run(files)
|
18
|
+
if !result.nil?
|
19
|
+
@output.add_result(result)
|
20
|
+
break if [:error, :failure].include? result[:state]
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class JavascriptLintRunner
|
2
|
+
|
3
|
+
def initialize(dir)
|
4
|
+
@dir = dir
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute()
|
8
|
+
return `jsl -conf "jsl.conf" -nologo -nofilelisting 2>&1`
|
9
|
+
end
|
10
|
+
|
11
|
+
def is_configured?(all_files)
|
12
|
+
return all_files.include?(@dir + '/jsl.conf')
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
class JavascriptLintTask
|
2
|
+
|
3
|
+
def initialize(javascript_lint, dir)
|
4
|
+
@javascript_lint = javascript_lint
|
5
|
+
@dir = dir
|
6
|
+
|
7
|
+
# TODO: Tidy!
|
8
|
+
if (RUBY_PLATFORM =~ /mswin32/)
|
9
|
+
@dir = @dir.gsub('/', '\\')
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
def run(files)
|
15
|
+
all_files = files[:all]
|
16
|
+
mofified_files = files[:filtered]
|
17
|
+
|
18
|
+
return nil if (!@javascript_lint.is_configured? all_files)
|
19
|
+
|
20
|
+
detail = @javascript_lint.execute()
|
21
|
+
|
22
|
+
state, summary, first = parse_result(detail)
|
23
|
+
|
24
|
+
# TODO: Tidy!
|
25
|
+
if (first[0, @dir.length] == @dir)
|
26
|
+
first = first[(@dir.length + 1)..-1]
|
27
|
+
end
|
28
|
+
|
29
|
+
return {
|
30
|
+
:state => state,
|
31
|
+
:title => 'Javascript Lint',
|
32
|
+
:summary => summary,
|
33
|
+
:first => first,
|
34
|
+
:detail => detail
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
def parse_result(detail)
|
39
|
+
summary_line = detail.grep( /\d+\s+error.*,\s+\d+\s+warning.*/ )[0]
|
40
|
+
|
41
|
+
if summary_line.nil?
|
42
|
+
# error
|
43
|
+
error_info = (detail + "\nUnknown Error!").to_a[0].chomp
|
44
|
+
return :error, 'Error', error_info
|
45
|
+
end
|
46
|
+
|
47
|
+
if summary_line =~ /([1-9]+)\d*\s+error/
|
48
|
+
num_failures = $1
|
49
|
+
error_info = detail.grep(/\([0-9]+\):([^:]*)Error:/)[0].chomp
|
50
|
+
return :failure, num_failures + ' Errors', error_info
|
51
|
+
end
|
52
|
+
|
53
|
+
if summary_line =~ /([1-9]+)\d*\s+warning/
|
54
|
+
num_failures = $1
|
55
|
+
error_info = detail.grep(/\([0-9]+\)/)[0].chomp
|
56
|
+
return :warning, num_failures + ' Warnings', error_info
|
57
|
+
end
|
58
|
+
|
59
|
+
return :success, 'All files are clean', ''
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
class JSpecTask
|
2
|
+
|
3
|
+
def initialize(jspec)
|
4
|
+
@jspec = jspec
|
5
|
+
end
|
6
|
+
|
7
|
+
def run(files)
|
8
|
+
all_files = files[:all]
|
9
|
+
mofified_files = files[:filtered]
|
10
|
+
|
11
|
+
return nil if (!@jspec.is_configured? all_files)
|
12
|
+
|
13
|
+
detail = @jspec.execute
|
14
|
+
|
15
|
+
state, summary, first = parse_results(detail)
|
16
|
+
|
17
|
+
return {
|
18
|
+
:state => state,
|
19
|
+
:title => 'JSpec',
|
20
|
+
:summary => summary,
|
21
|
+
:first => first,
|
22
|
+
:detail => detail
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def parse_results(detail)
|
27
|
+
summary_line = detail.grep( /Passes:/ )[0]
|
28
|
+
|
29
|
+
if summary_line.nil?
|
30
|
+
# error
|
31
|
+
error_info = (detail + "\nUnknown Error!").to_a[0]
|
32
|
+
return :error, 'Error', error_info
|
33
|
+
end
|
34
|
+
|
35
|
+
# remove console colour information and trim start and end white space
|
36
|
+
summary_line = remove_colour(summary_line).strip
|
37
|
+
|
38
|
+
if summary_line =~ /Failures:\s+([1-9]+)\d*/
|
39
|
+
num_failures = $1
|
40
|
+
error_line = detail.grep(/\[31m/)[1] || ''
|
41
|
+
error_info = remove_colour(error_line).strip
|
42
|
+
return :failure, num_failures + ' Failures', error_info
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
return :success, 'All Passed', summary_line
|
47
|
+
end
|
48
|
+
|
49
|
+
def remove_colour(string)
|
50
|
+
return string.gsub(/\e\[[0-9]+m?/, '')
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class ListTask
|
2
|
+
|
3
|
+
def initialize(format_string = "%s")
|
4
|
+
@format_string = format_string
|
5
|
+
end
|
6
|
+
|
7
|
+
def run(files)
|
8
|
+
all_files = files[:all]
|
9
|
+
mofified_files = files[:filtered]
|
10
|
+
|
11
|
+
return {
|
12
|
+
:state => :success,
|
13
|
+
:title => 'List',
|
14
|
+
:first => mofified_files.length == 1 ? mofified_files[0] : '%s files.' % mofified_files.length,
|
15
|
+
:detail => get_detail(mofified_files)
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_detail(paths)
|
20
|
+
detail = ""
|
21
|
+
limit = [paths.length - 1, 14].min
|
22
|
+
(0..limit).each do |i|
|
23
|
+
path = paths[i]
|
24
|
+
detail += (@format_string % path)
|
25
|
+
detail += "\n"
|
26
|
+
end
|
27
|
+
if limit < paths.length - 1
|
28
|
+
detail += " - Plus #{(paths.length - 1) - limit} more files."
|
29
|
+
end
|
30
|
+
|
31
|
+
return detail
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/loris.tmproj
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>currentDocument</key>
|
6
|
+
<string>lib/tasks/jspec_task.rb</string>
|
7
|
+
<key>documents</key>
|
8
|
+
<array>
|
9
|
+
<dict>
|
10
|
+
<key>expanded</key>
|
11
|
+
<true/>
|
12
|
+
<key>name</key>
|
13
|
+
<string>loris</string>
|
14
|
+
<key>regexFolderFilter</key>
|
15
|
+
<string>!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
|
16
|
+
<key>selected</key>
|
17
|
+
<true/>
|
18
|
+
<key>sourceDirectory</key>
|
19
|
+
<string></string>
|
20
|
+
</dict>
|
21
|
+
</array>
|
22
|
+
<key>fileHierarchyDrawerWidth</key>
|
23
|
+
<integer>200</integer>
|
24
|
+
<key>metaData</key>
|
25
|
+
<dict>
|
26
|
+
<key>TODO</key>
|
27
|
+
<dict>
|
28
|
+
<key>caret</key>
|
29
|
+
<dict>
|
30
|
+
<key>column</key>
|
31
|
+
<integer>5</integer>
|
32
|
+
<key>line</key>
|
33
|
+
<integer>2</integer>
|
34
|
+
</dict>
|
35
|
+
<key>firstVisibleColumn</key>
|
36
|
+
<integer>0</integer>
|
37
|
+
<key>firstVisibleLine</key>
|
38
|
+
<integer>0</integer>
|
39
|
+
</dict>
|
40
|
+
<key>lib/file_actioner.rb</key>
|
41
|
+
<dict>
|
42
|
+
<key>caret</key>
|
43
|
+
<dict>
|
44
|
+
<key>column</key>
|
45
|
+
<integer>7</integer>
|
46
|
+
<key>line</key>
|
47
|
+
<integer>12</integer>
|
48
|
+
</dict>
|
49
|
+
<key>firstVisibleColumn</key>
|
50
|
+
<integer>0</integer>
|
51
|
+
<key>firstVisibleLine</key>
|
52
|
+
<integer>0</integer>
|
53
|
+
</dict>
|
54
|
+
<key>lib/file_filter.rb</key>
|
55
|
+
<dict>
|
56
|
+
<key>caret</key>
|
57
|
+
<dict>
|
58
|
+
<key>column</key>
|
59
|
+
<integer>33</integer>
|
60
|
+
<key>line</key>
|
61
|
+
<integer>7</integer>
|
62
|
+
</dict>
|
63
|
+
<key>firstVisibleColumn</key>
|
64
|
+
<integer>0</integer>
|
65
|
+
<key>firstVisibleLine</key>
|
66
|
+
<integer>0</integer>
|
67
|
+
</dict>
|
68
|
+
<key>lib/loris.rb</key>
|
69
|
+
<dict>
|
70
|
+
<key>caret</key>
|
71
|
+
<dict>
|
72
|
+
<key>column</key>
|
73
|
+
<integer>50</integer>
|
74
|
+
<key>line</key>
|
75
|
+
<integer>83</integer>
|
76
|
+
</dict>
|
77
|
+
<key>firstVisibleColumn</key>
|
78
|
+
<integer>0</integer>
|
79
|
+
<key>firstVisibleLine</key>
|
80
|
+
<integer>54</integer>
|
81
|
+
</dict>
|
82
|
+
<key>lib/sleep_waiter.rb</key>
|
83
|
+
<dict>
|
84
|
+
<key>caret</key>
|
85
|
+
<dict>
|
86
|
+
<key>column</key>
|
87
|
+
<integer>4</integer>
|
88
|
+
<key>line</key>
|
89
|
+
<integer>9</integer>
|
90
|
+
</dict>
|
91
|
+
<key>firstVisibleColumn</key>
|
92
|
+
<integer>0</integer>
|
93
|
+
<key>firstVisibleLine</key>
|
94
|
+
<integer>0</integer>
|
95
|
+
</dict>
|
96
|
+
<key>lib/tasks/javascript_lint_runner.rb</key>
|
97
|
+
<dict>
|
98
|
+
<key>caret</key>
|
99
|
+
<dict>
|
100
|
+
<key>column</key>
|
101
|
+
<integer>0</integer>
|
102
|
+
<key>line</key>
|
103
|
+
<integer>5</integer>
|
104
|
+
</dict>
|
105
|
+
<key>columnSelection</key>
|
106
|
+
<false/>
|
107
|
+
<key>firstVisibleColumn</key>
|
108
|
+
<integer>0</integer>
|
109
|
+
<key>firstVisibleLine</key>
|
110
|
+
<integer>0</integer>
|
111
|
+
<key>selectFrom</key>
|
112
|
+
<dict>
|
113
|
+
<key>column</key>
|
114
|
+
<integer>0</integer>
|
115
|
+
<key>line</key>
|
116
|
+
<integer>2</integer>
|
117
|
+
</dict>
|
118
|
+
<key>selectTo</key>
|
119
|
+
<dict>
|
120
|
+
<key>column</key>
|
121
|
+
<integer>0</integer>
|
122
|
+
<key>line</key>
|
123
|
+
<integer>5</integer>
|
124
|
+
</dict>
|
125
|
+
</dict>
|
126
|
+
<key>lib/tasks/javascript_lint_task.rb</key>
|
127
|
+
<dict>
|
128
|
+
<key>caret</key>
|
129
|
+
<dict>
|
130
|
+
<key>column</key>
|
131
|
+
<integer>0</integer>
|
132
|
+
<key>line</key>
|
133
|
+
<integer>11</integer>
|
134
|
+
</dict>
|
135
|
+
<key>columnSelection</key>
|
136
|
+
<false/>
|
137
|
+
<key>firstVisibleColumn</key>
|
138
|
+
<integer>0</integer>
|
139
|
+
<key>firstVisibleLine</key>
|
140
|
+
<integer>0</integer>
|
141
|
+
<key>selectFrom</key>
|
142
|
+
<dict>
|
143
|
+
<key>column</key>
|
144
|
+
<integer>0</integer>
|
145
|
+
<key>line</key>
|
146
|
+
<integer>7</integer>
|
147
|
+
</dict>
|
148
|
+
<key>selectTo</key>
|
149
|
+
<dict>
|
150
|
+
<key>column</key>
|
151
|
+
<integer>0</integer>
|
152
|
+
<key>line</key>
|
153
|
+
<integer>11</integer>
|
154
|
+
</dict>
|
155
|
+
</dict>
|
156
|
+
<key>lib/tasks/jspec_runner.rb</key>
|
157
|
+
<dict>
|
158
|
+
<key>caret</key>
|
159
|
+
<dict>
|
160
|
+
<key>column</key>
|
161
|
+
<integer>0</integer>
|
162
|
+
<key>line</key>
|
163
|
+
<integer>5</integer>
|
164
|
+
</dict>
|
165
|
+
<key>firstVisibleColumn</key>
|
166
|
+
<integer>0</integer>
|
167
|
+
<key>firstVisibleLine</key>
|
168
|
+
<integer>0</integer>
|
169
|
+
</dict>
|
170
|
+
<key>lib/tasks/jspec_task.rb</key>
|
171
|
+
<dict>
|
172
|
+
<key>caret</key>
|
173
|
+
<dict>
|
174
|
+
<key>column</key>
|
175
|
+
<integer>26</integer>
|
176
|
+
<key>line</key>
|
177
|
+
<integer>10</integer>
|
178
|
+
</dict>
|
179
|
+
<key>firstVisibleColumn</key>
|
180
|
+
<integer>0</integer>
|
181
|
+
<key>firstVisibleLine</key>
|
182
|
+
<integer>0</integer>
|
183
|
+
</dict>
|
184
|
+
</dict>
|
185
|
+
<key>openDocuments</key>
|
186
|
+
<array>
|
187
|
+
<string>TODO</string>
|
188
|
+
<string>lib/tasks/javascript_lint_runner.rb</string>
|
189
|
+
<string>lib/loris.rb</string>
|
190
|
+
<string>lib/sleep_waiter.rb</string>
|
191
|
+
<string>lib/file_actioner.rb</string>
|
192
|
+
<string>lib/file_filter.rb</string>
|
193
|
+
<string>lib/tasks/javascript_lint_task.rb</string>
|
194
|
+
<string>lib/tasks/jspec_runner.rb</string>
|
195
|
+
<string>lib/tasks/jspec_task.rb</string>
|
196
|
+
</array>
|
197
|
+
<key>showFileHierarchyDrawer</key>
|
198
|
+
<false/>
|
199
|
+
<key>windowFrame</key>
|
200
|
+
<string>{{0, 0}, {1436, 878}}</string>
|
201
|
+
</dict>
|
202
|
+
</plist>
|