Module: Ronin::Repos::ClassDir::ClassMethods
- Defined in:
- lib/ronin/repos/class_dir.rb
Overview
Class-methods.
Instance Method Summary collapse
-
#list_files ⇒ Array<String>
List the module names within the
class_dir
and within #repo_class_dir across all installed repositories. -
#path_for(name) ⇒ String?
Finds a module within
class_dir
or withinrepo_class_dir
in one of the installed repositories. -
#repo_class_dir(new_dir = nil) ⇒ String
Gets or sets the repository module directory name.
Instance Method Details
#list_files ⇒ Array<String>
List the module names within the class_dir
and within
#repo_class_dir across all installed repositories.
124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/ronin/repos/class_dir.rb', line 124 def list_files paths = Set.new(super) pattern = File.join(repo_class_dir,"{**/}*.rb") # the String#slice range to remove the repo_class_dir/ and .rb ext slice_range = (repo_class_dir.length + 1)...-3 Repos.list_files(pattern).each do |path| # NOTE: String#slice is faster than .delete_prefix + delete.suffix paths << path.slice(slice_range) end return paths.to_a end |
#path_for(name) ⇒ String?
Finds a module within class_dir
or within repo_class_dir
in one of the installed repositories.
150 151 152 153 |
# File 'lib/ronin/repos/class_dir.rb', line 150 def path_for(name) super(name) || Repos.find_file(File.join(repo_class_dir,"#{name}.rb")) end |
#repo_class_dir(new_dir = nil) ⇒ String
Gets or sets the repository module directory name.
110 111 112 113 114 115 116 |
# File 'lib/ronin/repos/class_dir.rb', line 110 def repo_class_dir(new_dir=nil) if new_dir @repo_class_dir = new_dir else @repo_class_dir || raise(NotImplementedError,"#{self} did not define a repo_class_dir") end end |