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

.coffeescript_task(dir) ⇒ Object


126
127
128
129
130
131
132
133
134
135
136
# File 'lib/loris.rb', line 126

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


83
84
85
86
87
88
89
90
91
92
93
94
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
# File 'lib/loris.rb', line 83

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(jasmine_node_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))

  a = FileActioner.new(ff, tm)    
  
  da = DummyActioner.new(a, $stdout)
        
  p = Poller.new(w, c, debug ? da : a)
  
  # Start!
  p.start

end

.jasmine_node_task(dir) ⇒ Object


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

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')
    ),
    JasmineNodeParser.new(dir)
  )
end

.javascript_lint_task(dir) ⇒ Object

Refactor into factory


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

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


169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/loris.rb', line 169

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.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