Sha256: 955b8dff8b0704c9e9b8f8538db550900e23f37dd76236e71453c6280e85dd9e
Contents?: true
Size: 1.3 KB
Versions: 11
Compression:
Stored size: 1.3 KB
Contents
#!/usr/bin/env ruby require "bundler/setup" require "martyr" require "chinook_database" ChinookDatabase.connect require_relative "../spec/models/spec_models" ActiveRecord::Base.logger = Logger.new(STDOUT) module Martyr def self.reload! Reloader.new(self).reload end class Reloader def initialize(top) @top = top end def reload cleanup load_all end private def all_project_objects_lookup @_all_project_objects_lookup ||= Hash[all_project_objects.map{|x| [x, true]}] end def all_project_objects(current = @top) return [] unless current.is_a?(Module) and current.to_s.split('::').first == @top.to_s [current] + current.constants.flat_map{|x| all_project_objects(current.const_get(x))} end def cleanup(parent = Object, current = @top) return unless all_project_objects_lookup[current] current.constants.each {|const| cleanup current, current.const_get(const)} parent.send(:remove_const, current.to_s.split('::').last.to_sym) end def loaded_files $LOADED_FEATURES.select{|x| x.starts_with?(File.expand_path('../../lib/martyr'))} end def load_all loaded_files.each{|x| load x} true end end end def reload! Martyr.reload! end require "pry" Pry.start # require "irb" # IRB.start
Version data entries
11 entries across 11 versions & 1 rubygems