Skip to content

Commit

Permalink
Add missing requires
Browse files Browse the repository at this point in the history
  • Loading branch information
jstorimer committed Jun 19, 2012
1 parent 0519b9e commit b1c775f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion bin/spin
Original file line number Original file line Diff line number Diff line change
@@ -1,17 +1,25 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby


require 'spin/watcher'
require 'spin/preloader'
require 'spin/socket' require 'spin/socket'


# requires # requires
# parse options (preload an extra path(s), add path(s) to watch) # parse options (preload an extra path(s), add path(s) to watch)
at_exit { File.delete(Spin::Socket.filepath) }
trap("SIGINT") { exit }

# signal handlers # signal handlers
# #
# spawn file watcher w/ pipe # spawn file watcher w/ pipe
reader = Spin::Watcher.spawn reader = Spin::Watcher.spawn


at_exit { File.delete(Spin::Socket.filepath) }
push_socket = Spin::Socket.open

# preload rails # preload rails
Spin::Preloader.require_files Spin::Preloader.require_files

# IO.select pipe + unix socket # IO.select pipe + unix socket
# add files to be processed to the next test run obj # add files to be processed to the next test run obj
# include the recved io if applicable # include the recved io if applicable
Expand Down
5 changes: 5 additions & 0 deletions lib/spin/socket.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


require 'tempfile' # for Dir::tmpdir require 'tempfile' # for Dir::tmpdir
require 'digest/md5' require 'digest/md5'
require 'socket'


module Spin module Spin
class Socket class Socket
Expand All @@ -11,6 +12,10 @@ def self.filepath
slug = Digest::MD5.hexdigest ['spin', Dir.pwd].join('-') slug = Digest::MD5.hexdigest ['spin', Dir.pwd].join('-')
[Dir::tmpdir, slug].join('/') [Dir::tmpdir, slug].join('/')
end end

def self.open
UNIXServer.open(filepath)
end
end end
end end


5 changes: 4 additions & 1 deletion lib/spin/watcher.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'listen'

module Spin module Spin
module Watcher module Watcher
extend self extend self
Expand All @@ -11,7 +13,8 @@ def spawn
fork { fork {
rd.close rd.close


Listen.to(AppDirectories + TestDirectories, :filter => /\.rb$/, :latency => 0.1) do |modified, added, removed| dirs = AppDirectories + TestDirectories
Listen.to(*dirs, :filter => /\.rb$/, :latency => 0.1) do |modified, added, removed|
changed_files = [modified + added + removed].uniq changed_files = [modified + added + removed].uniq


files_to_queue = changed_files.map { |file| files_to_queue = changed_files.map { |file|
Expand Down

0 comments on commit b1c775f

Please sign in to comment.