Created
October 31, 2012 09:15
-
-
Save burtlo/3986007 to your computer and use it in GitHub Desktop.
Looking at ways to provide auto-reloading to an application outside of the Rails space.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A | |
def hello ; puts "hello" ; end | |
def goodbye ; puts "goodbye" ; end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A | |
def silence ; puts "silence" ; end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_support' | |
require 'active_support/dependencies' | |
require 'open3' | |
include ActiveSupport::Dependencies | |
hook! | |
watcher = WatchStack.new | |
watcher.watch_namespaces([ Object ]) | |
require './a_test' | |
watcher.new_constants.each do |constant| | |
puts "Marking clas: #{constant} unloadable" | |
unloadable constant | |
end | |
output, status = Open3.capture2e("ruby b_test.rb") | |
valid_code = (status == 0) | |
puts "Success? #{status}" | |
# We only wnat to clear and load the code if the code is valid ruby code | |
if valid_code | |
clear | |
require_or_load('./b_test') | |
else | |
puts "*" * 80 | |
puts "There was an error in your code:" | |
puts output | |
puts "*" * 80 | |
end | |
[ :hello, :goodbye, :silence ].each do |method| | |
puts "A##{method} #{A.instance_methods.include?(method)}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment