guillaumegentil-rspactor 0.2.8 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/listener.rb DELETED
@@ -1,55 +0,0 @@
1
- # Some code borrowed from http://rails.aizatto.com/2007/11/28/taming-the-autotest-beast-with-fsevents/
2
-
3
- class Listener
4
-
5
- def initialize(&block)
6
- require 'osx/foundation'
7
- begin
8
- @spec_run_time = Time.now
9
- callback = lambda do |stream, ctx, num_events, paths, marks, event_ids|
10
- changed_files = extract_changed_files_from_paths(split_paths(paths, num_events))
11
- @spec_run_time = Time.now
12
- yield changed_files
13
- end
14
-
15
- OSX.require_framework '/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework'
16
- stream = OSX::FSEventStreamCreate(OSX::KCFAllocatorDefault, callback, nil, [Dir.pwd], OSX::KFSEventStreamEventIdSinceNow, 0.5, 0)
17
- unless stream
18
- puts "Failed to create stream"
19
- exit
20
- end
21
-
22
- OSX::FSEventStreamScheduleWithRunLoop(stream, OSX::CFRunLoopGetCurrent(), OSX::KCFRunLoopDefaultMode)
23
- unless OSX::FSEventStreamStart(stream)
24
- puts "Failed to start stream"
25
- exit
26
- end
27
-
28
- OSX::CFRunLoopRun()
29
- rescue Interrupt
30
- OSX::FSEventStreamStop(stream)
31
- OSX::FSEventStreamInvalidate(stream)
32
- OSX::FSEventStreamRelease(stream)
33
- end
34
- end
35
-
36
- def split_paths(paths, num_events)
37
- paths.regard_as('*')
38
- rpaths = []
39
- num_events.times { |i| rpaths << paths[i] }
40
- rpaths
41
- end
42
-
43
- def extract_changed_files_from_paths(paths)
44
- changed_files = []
45
- paths.each do |path|
46
- Dir.glob(path + "*").each do |file|
47
- next if Inspector.file_is_invalid?(file)
48
- file_time = File.stat(file).mtime
49
- changed_files << file if file_time > @spec_run_time
50
- end
51
- end
52
- changed_files
53
- end
54
-
55
- end
data/lib/resulting.rb DELETED
@@ -1,50 +0,0 @@
1
- class RSpactorFormatter
2
- attr_accessor :example_group, :options, :where
3
- def initialize(options, where)
4
- @options = options
5
- @where = where
6
- end
7
-
8
- def dump_summary(duration, example_count, failure_count, pending_count)
9
- img = (failure_count == 0) ? "rails_ok.png" : "rails_fail.png"
10
- growl "Test Results", "#{example_count} examples, #{failure_count} failures", File.dirname(__FILE__) + "/../asset/#{img}", 0
11
- end
12
-
13
- def start(example_count)
14
- end
15
-
16
- def example_group_started(example_group)
17
- end
18
-
19
- def example_started(example)
20
- end
21
-
22
- def example_passed(example)
23
- end
24
-
25
- def example_failed(example, counter, failure)
26
- end
27
-
28
- def example_pending(example, message, deprecated_pending_location=nil)
29
- end
30
-
31
- def start_dump
32
- end
33
-
34
- def dump_failure(counter, failure)
35
- end
36
-
37
- def dump_summary(duration, example_count, failure_count, pending_count)
38
- end
39
-
40
- def dump_pending
41
- end
42
-
43
- def close
44
- end
45
-
46
- def growl(title, msg, img, pri = 0)
47
- system("growlnotify -w -n rspactor --image #{img} -p #{pri} -m #{msg.inspect} #{title} &")
48
- end
49
- end
50
-
data/lib/runner.rb DELETED
@@ -1,78 +0,0 @@
1
- class Runner
2
-
3
- def self.load(options = {})
4
- @options = options
5
- @inspector = Inspector.new
6
- @interactor = Interactor.new(@options)
7
-
8
- puts "** RSpactor is now watching at '#{Dir.pwd}'#{' and using spec_server' if @options[:drb]}"
9
-
10
- if initial_spec_run_abort
11
- @interactor.start_termination_handler
12
- else
13
- @interactor.start_termination_handler
14
- run_all_specs
15
- end
16
-
17
- Listener.new do |files|
18
- run_specs_for_files(files)
19
- end
20
- end
21
-
22
- def self.run_all_specs
23
- run_spec_command([@inspector.inner_spec_directory(Dir.pwd)])
24
- end
25
-
26
- def self.run_specs_for_files(files)
27
- files_to_spec = []
28
- files.each do |file|
29
- spec_file = @inspector.find_spec_file(file)
30
- files_to_spec << spec_file if spec_file && !files_to_spec.include?(spec_file)
31
- end
32
- unless files_to_spec.empty?
33
- system("clear;") if @options[:clear]
34
- files_to_spec.each { |spec_file| puts spec_file }
35
- run_spec_command(files_to_spec)
36
- end
37
- end
38
-
39
- def self.run_spec_command(locations)
40
- if locations.first
41
- base_spec_root = extract_spec_root(locations.first)
42
- spec_runner_bin = script_runner(locations.first)
43
- locations = locations.join(" ")
44
- cmd = "RAILS_ENV=test; "
45
- cmd << "#{spec_runner_bin} "
46
- cmd << "#{locations} #{spec_opts(base_spec_root)} "
47
- cmd << "--drb " if @options[:drb]
48
- cmd << "-r #{File.dirname(__FILE__)}/../lib/resulting.rb -f RSpactorFormatter:STDOUT"
49
- # puts cmd
50
- system(cmd)
51
- end
52
- end
53
-
54
- def self.extract_spec_root(file)
55
- file[0..file.index("spec") + 4]
56
- end
57
-
58
- def self.spec_opts(base_spec_root)
59
- if File.exist?("#{base_spec_root}spec.opts")
60
- return "-O #{base_spec_root}spec.opts"
61
- else
62
- return "-c -f progress"
63
- end
64
- end
65
-
66
- def self.initial_spec_run_abort
67
- @interactor.wait_for_enter_key("** Hit <enter> to skip initial spec run", 3)
68
- end
69
-
70
- def self.script_runner(file)
71
- # root = file[0..file.index("spec") - 1]
72
- # if File.exist?(root + "script/spec")
73
- # return root + "script/spec"
74
- # else
75
- "spec"
76
- # end
77
- end
78
- end
data/rspactor.gemspec DELETED
@@ -1,36 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{rspactor}
5
- s.version = "0.2.8"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Andreas Wolff"]
9
- s.date = %q{2009-04-20}
10
- s.default_executable = %q{rspactor}
11
- s.description = %q{RSpactor is a little command line tool to automatically run your changed specs (much like autotest).}
12
- s.email = %q{treas@dynamicdudes.com}
13
- s.executables = ["rspactor"]
14
- s.extra_rdoc_files = ["bin/rspactor", "lib/inspector.rb", "lib/interactor.rb", "lib/listener.rb", "lib/resulting.rb", "lib/runner.rb"]
15
- s.files = ["asset/rails_fail.png", "asset/rails_ok.png", "bin/rspactor", "lib/inspector.rb", "lib/interactor.rb", "lib/listener.rb", "lib/resulting.rb", "lib/runner.rb", "Rakefile", "Manifest", "rspactor.gemspec"]
16
- s.has_rdoc = true
17
- s.homepage = %q{http://github.com/guillaumegentil/rspactor/}
18
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Rspactor"]
19
- s.require_paths = ["lib"]
20
- s.rubyforge_project = %q{rspactor}
21
- s.rubygems_version = %q{1.3.2}
22
- s.summary = %q{RSpactor is a little command line tool to automatically run your changed specs (much like autotest).}
23
-
24
- if s.respond_to? :specification_version then
25
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
26
- s.specification_version = 3
27
-
28
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
29
- s.add_runtime_dependency(%q<optiflag>, [">= 0"])
30
- else
31
- s.add_dependency(%q<optiflag>, [">= 0"])
32
- end
33
- else
34
- s.add_dependency(%q<optiflag>, [">= 0"])
35
- end
36
- end