Module: Ronin::Installation
- Defined in:
- lib/ronin/installation.rb
Overview
The Installation module provides methods which help reflect on the installation of Ronin on the system.
Class Method Summary collapse
-
.each_file(pattern) {|file| ... } ⇒ Enumerator
Enumerates over all files within a given directory found in any of the installed Ronin libraries.
-
.each_file_in(directory, ext = nil) {|name| ... } ⇒ Enumerator
Enumerates over every file in a directory.
-
.gems ⇒ Hash{String => Gem::Specification}
Finds the installed Ronin libraries via RubyGems.
-
.libraries ⇒ Array<String>
The names of the additional Ronin libraries installed on the system.
-
.load! ⇒ true
protected
private
Finds the installed Ronin libraries.
-
.load_gems! ⇒ true
protected
private
Finds the installed Ronin gems.
-
.load_gemspecs! ⇒ true
protected
private
Loads the gemspecs of Ronin libraries from the
$LOAD_PATH
. -
.paths ⇒ Set<String>
The paths of the installed Ronin libraries.
Class Method Details
.each_file(pattern) {|file| ... } ⇒ Enumerator
Enumerates over all files within a given directory found in any of the installed Ronin libraries.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/ronin/installation.rb', line 96 def Installation.each_file(pattern) return enum_for(:each_file,pattern) unless block_given? # query the installed gems paths.each do |gem_path| slice_index = gem_path.length + 1 Dir.glob(File.join(gem_path,pattern)) do |path| yield path[slice_index..-1] end end return nil end |
.each_file_in(directory, ext = nil) {|name| ... } ⇒ Enumerator
Enumerates over every file in a directory.
133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/ronin/installation.rb', line 133 def Installation.each_file_in(directory,ext=nil) return enum_for(:each_file_in,directory,ext) unless block_given? pattern = File.join(directory,'**','*') pattern << ".#{ext}" if ext slice_index = directory.length + 1 each_file(pattern) do |path| yield path[slice_index..-1] end end |
.gems ⇒ Hash{String => Gem::Specification}
Finds the installed Ronin libraries via RubyGems.
42 43 44 45 |
# File 'lib/ronin/installation.rb', line 42 def Installation.gems load! if @gems.empty? return @gems end |
.libraries ⇒ Array<String>
The names of the additional Ronin libraries installed on the system.
72 73 74 |
# File 'lib/ronin/installation.rb', line 72 def Installation.libraries gems.keys end |
.load! ⇒ true (protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Finds the installed Ronin libraries.
219 220 221 222 223 224 225 |
# File 'lib/ronin/installation.rb', line 219 def Installation.load! if Gem.loaded_specs.has_key?('ronin') load_gems! else load_gemspecs! end end |
.load_gems! ⇒ true (protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Finds the installed Ronin gems.
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/ronin/installation.rb', line 158 def Installation.load_gems! register_gem = lambda { |gem| @gems[gem.name] = gem @paths << gem.full_gem_path } ronin_gem = Gem.loaded_specs['ronin'] # add the main ronin gem register_gem[ronin_gem] # add any dependent gems ronin_gem.dependent_gems.each do |gems| register_gem[gems[0]] end return true end |
.load_gemspecs! ⇒ true (protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Loads the gemspecs of Ronin libraries from the $LOAD_PATH
.
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/ronin/installation.rb', line 187 def Installation.load_gemspecs! $LOAD_PATH.each do |lib_dir| root_dir = File.(File.join(lib_dir,'..')) gemspec_path = Dir[File.join(root_dir,'ronin*.gemspec')][0] if gemspec_path # switch into the gem directory, before loading the gemspec gem = Dir.chdir(root_dir) do Gem::Specification.load(gemspec_path) end # do not add duplicate ronin gems unless @gems.has_key?(gem.name) @gems[gem.name] = gem @paths << root_dir end end end return true end |
.paths ⇒ Set<String>
The paths of the installed Ronin libraries.
57 58 59 60 |
# File 'lib/ronin/installation.rb', line 57 def Installation.paths load! if @paths.empty? return @paths end |