Class: Loris::CLI::Main

Inherits:
Object
  • Object
show all
Defined in:
lib/loris.rb

Defined Under Namespace

Classes: DummyActioner

Class Method Summary collapse

Class Method Details

.closure_compiler_task(dir) ⇒ Object


225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/loris.rb', line 225

def closure_compiler_task(dir)
  jar = File.join(LIBDIR, 'closure-compiler' , 'closure-compiler.jar')

  return CommandLineTask.new(
    ClosureCompilerRunner.new(
      jar,
      dir,
      ExtensionFilter.new(File, 'js'),
      ClosureCompilerConfig.new(
        dir,
        YAML,
        URI
      )
    ),
    ClosureCompilerParser.new(dir)
  )
end

.coffeescript_task(dir) ⇒ Object


142
143
144
145
146
147
148
149
150
151
152
# File 'lib/loris.rb', line 142

def coffeescript_task(dir)
  return CommandLineTask.new(
    CoffeeScriptRunner.new(
      'coffee',
      dir,
      ExtensionFilter.new(File, 'coffee'),
      DirectoryFinder.new(File, StartsWithFilter.new('coffee-'))
    ),
    CoffeeScriptParser.new(dir)
  )
end

.execute(args) ⇒ Object


95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/loris.rb', line 95

def execute(args)

  # Get config variables
  debug = args.length > 0
  is_windows = RUBY_PLATFORM =~ /mswin32/
  dir = Dir.pwd
  sleep_duration = 1
  browser = is_windows ? 'C:/Program Files/Internet Explorer/iexplore.exe' : 'open'

  # Create object graph
  w = SleepWaiter.new(sleep_duration)
  c = AlwaysContinuer.new
  ff = FileFinder.new(Find, dir)
  ff.add_filter(FileFilter.new(File))
  ff.add_filter(ModifiedFilter.new(File))

  cco = is_windows ? WindowsConsoleClearingOutput.new : UnixConsoleClearingOutput.new

  oc = OutputCollection.new
  oc.add(ShellOutput.new($stdout))
  oc.add(cco) unless debug
  oc.add(GrowlOutput.new(Growl)) unless debug

  tm = TaskManager.new(oc)
  tm.add(ListTask.new) if debug
  tm.add(coffeescript_task(dir))
  tm.add(javascript_lint_task(dir))
  tm.add(google_lint_task(dir))
  tm.add(jasmine_node_task(dir))  # tm.add(jasmine_node_coverage_task(dir))

  tm.add(CommandLineTask.new(JSpecRunner.new(dir, ExtensionFilter.new(File, 'js')), JSpecParser.new)) unless is_windows
  tm.add(jsTestDriverTask(dir))
  tm.add(CommandLineTask.new(RSpecRunner.new(dir, ExtensionFilter.new(File, 'rb'), EndsWithFilter.new('_spec.rb')), RSpecParser.new))
  tm.add(CommandLineTask.new(JasmineCIRunner.new(dir, ExtensionFilter.new(File, 'js')), JasmineCIParser.new))
  tm.add(closure_compiler_task(dir))

  a = FileActioner.new(ff, tm)

  da = DummyActioner.new(a, $stdout)

  p = Poller.new(w, c, debug ? da : a)

  # Start!
  p.start

end

.google_lint_task(dir) ⇒ Object


205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/loris.rb', line 205

def google_lint_task(dir)
  binary = File.join(LIBDIR, 'google-lint' , 'gjslint')
  fix_style_binary = File.join(LIBDIR, 'google-lint' , 'fixjsstyle')

  return CommandLineTask.new(
    GoogleLintRunner.new(
      binary,
      fix_style_binary,
      dir,
      ExtensionFilter.new(File, 'js'),
      GoogleLintConfig.new(
        dir,
        YAML,
        URI
      )
    ),
    GoogleLintParser.new(dir)
  )
end

.jasmine_node_coverage_task(dir) ⇒ Object


170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/loris.rb', line 170

def jasmine_node_coverage_task(dir)
  node = '/usr/local/bin/node'
  spec_dir = File.join(LIBDIR, 'jasmine-node')

  return CommandLineTask.new(
    JasmineNodeCoverageRunner.new(
      JasmineNodeRunner.new(
        node,
        spec_dir,
        dir,
        ExtensionFilter.new(File, 'js'),
        JasmineNodeConfig.new(dir, JSON, File)
      ),
      JsCoverage.new("node-jscoverage"),
      JasmineNodeConfig.new(dir, JSON, File)
    ),
    JasmineNodeParser.new(dir)
  )
end

.jasmine_node_task(dir) ⇒ Object


154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/loris.rb', line 154

def jasmine_node_task(dir)
  node = '/usr/local/bin/node'
  spec_dir = File.join(LIBDIR, 'jasmine-node')

  return CommandLineTask.new(
    JasmineNodeRunner.new(
      node,
      spec_dir,
      dir,
      ExtensionFilter.new(File, 'js'),
      JasmineNodeConfig.new(dir, JSON, File)
    ),
    JasmineNodeParser.new(dir)
  )
end

.javascript_lint_task(dir) ⇒ Object

Refactor into factory


191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/loris.rb', line 191

def javascript_lint_task(dir)
  is_windows = RUBY_PLATFORM =~ /mswin32/
  binary = File.join(LIBDIR, 'javascript-lint' , is_windows ? 'jsl.exe' : 'jsl')

  return CommandLineTask.new(
    JavascriptLintRunner.new(
      binary,
      dir,
      ExtensionFilter.new(File, 'js')
    ),
    JavascriptLintParser.new(dir)
  )
end

.jsTestDriverTask(dir) ⇒ Object

Will need to be refactored into a factory


245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/loris.rb', line 245

def jsTestDriverTask(dir)
  require 'tasks/js_test_driver/js_test_driver_runner'
  require 'tasks/js_test_driver/js_test_driver_parser'
  require 'tasks/js_test_driver/js_test_driver_config'
  require 'tasks/js_test_driver/js_test_driver_server'

  jar = File.join(LIBDIR, 'js-test-driver/JsTestDriver-1.3.2.jar')
  is_windows = RUBY_PLATFORM =~ /mswin32/

  if is_windows
    require 'browser_finder'
    browser = BrowserFinder.new.getDefault
  else
    browser = 'open "%1"'
  end

  sleep_time = 3

  if is_windows
    require 'windows_process'
  else
    require 'unix_process'
  end

  return CommandLineTask.new(
    JsTestDriverRunner.new(
      dir,
      jar,
      ExtensionFilter.new(File, 'js'),
      JsTestDriverServer.new(
        JsTestDriverConfig.new(
          dir,
          YAML,
          URI
        ),
        Pinger.new,
        is_windows ? WindowsProcess.new : UnixProcess.new,
        jar,
        browser,
        sleep_time
      )
    ),
    JsTestDriverParser.new
  )
end