Skip to content

Instantly share code, notes, and snippets.

@juliancheal
Last active December 17, 2015 06:28
Show Gist options
  • Save juliancheal/5565394 to your computer and use it in GitHub Desktop.
Save juliancheal/5565394 to your computer and use it in GitHub Desktop.
DM-Whisky-Mapper
# cd to dm-mapper's directory
# cd to lib
ruby_classes = []
ObjectSpace.each_object do |o|
ruby_classes << o if o.is_a?(Class)
end
require 'rake'
ruby_files = Rake::FileList.new "**/*.rb"
gem_defined_classes = scan_filelist_for_defined_classes(ruby_files)
files_referring_to_foreign_classes =
ruby_files.each_with_object({}) { |file_path, file_to_foreign_classes|
class_names_from_file = all_class_names_referred_to_in(file_path)
foreign_classes = class_names_from_file - gem_defined_classes
unless foreign_classes.empty?
file_to_foreign_classes[file_path] = foreign_classes
end
}
# NOTE: we need scoped class names to be able to compare against ObjectSpace
def scan_filelist_for_defined_classes
end
# NOTE: we need scoped class names to be able to compare against ObjectSpace
def all_class_names_referred_to_in
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment