Class: Pendaxes::CommandLine::Oneshot
- Inherits:
-
Object
- Object
- Pendaxes::CommandLine::Oneshot
- Defined in:
- lib/pendaxes/command_line.rb
Instance Method Summary collapse
-
#initialize(*args) ⇒ Oneshot
constructor
A new instance of Oneshot.
- #run ⇒ Object
- #usage ⇒ Object
Constructor Details
#initialize(*args) ⇒ Oneshot
Returns a new instance of Oneshot.
193 194 195 |
# File 'lib/pendaxes/command_line.rb', line 193 def initialize(*args) @args = args end |
Instance Method Details
#run ⇒ Object
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/pendaxes/command_line.rb', line 197 def run quiet = false path = Dir.pwd reporter = :text OptionParser.new do |opts| opts.on('-q', '--quiet', 'Turn off progress output.') do quiet = true end opts.on('-d DIR', '--repo DIR', 'Specify path to working copy of git.') do |dir| path = dir end opts.on('-r REPORTER', '--reporter REPORTER', 'Specify reporter') do |name| reporter = name.to_sym end opts.on_tail('--help', 'Show this help') do return usage end end.parse!(@args) files = @args.map { |pattern| Dir[pattern].map do |file_or_directory| if FileTest.file?(file_or_directory) file_or_directory elsif FileTest.directory?(file_or_directory) Dir[File.join(file_or_directory, '**', '*_spec.rb')] else abort "#{$0}: #{file_or_directory}: No such file or directory" end end }.flatten workspace = Workspace.new(path: path) $stderr.puts '=> Detecting...' unless quiet pendings = Detector.find(:rspec).new(workspace, out: quiet ? nil : $stderr).detect $stderr.puts '=> Total Result:' unless quiet notificator = Notificator.find(:terminal).new( out: $stdout, reporter: {use: reporter} ) notificator.add pendings notificator.notify 0 end |
#usage ⇒ Object
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/pendaxes/command_line.rb', line 247 def usage $stderr.puts "Usage: pendaxes-oneshot [--help] [-q|--quiet] [-d DIR|--repo=DIR] [-r REPORTER|--reporter REPORTER] file_or_directory [file_or_directory ...]" $stderr.puts "" $stderr.puts "file_or_directory:" $stderr.puts " File name, pattern or directory name to detect pendings." $stderr.puts " if directory name given, will use *_spec.rb files in that directory (recursive)." $stderr.puts "" $stderr.puts " NOTE: Files should be managed by git." $stderr.puts "" $stderr.puts "--help: Show this help and quit." $stderr.puts "--quiet, -q: Turn off progress output." $stderr.puts "--repo, -d: Specify path to working copy of git repository. (default: current directory)" $stderr.puts "--reporter, -r: Specify reporter. (Default: text)" 0 end |