lib/ronin/installation.rb in ronin-1.5.0.rc2 vs lib/ronin/installation.rb in ronin-1.5.0

- old
+ new

@@ -37,11 +37,11 @@ # # @since 1.0.0 # # @api semipublic # - def Installation.gems + def self.gems load! if @gems.empty? return @gems end # @@ -52,11 +52,11 @@ # # @since 1.0.1 # # @api semipublic # - def Installation.paths + def self.paths load! if @paths.empty? return @paths end # @@ -67,11 +67,11 @@ # # @since 1.0.0 # # @api semipublic # - def Installation.libraries + def self.libraries gems.keys end # # Enumerates over all files within a given directory found in any @@ -91,12 +91,12 @@ # # @since 1.0.0 # # @api semipublic # - def Installation.each_file(pattern) - return enum_for(:each_file,pattern) unless block_given? + def self.each_file(pattern) + return enum_for(__method__,pattern) unless block_given? # query the installed gems paths.each do |gem_path| slice_index = gem_path.length + 1 @@ -128,20 +128,20 @@ # # @since 1.0.0 # # @api semipublic # - def Installation.each_file_in(directory,ext=nil) - return enum_for(:each_file_in,directory,ext) unless block_given? + def self.each_file_in(directory,ext=nil) + return enum_for(__method__,directory,ext) unless block_given? + directory = File.join(directory,File::SEPARATOR) + pattern = File.join(directory,'**','*') pattern << ".#{ext}" if ext - slice_index = directory.length + 1 - each_file(pattern) do |path| - yield path[slice_index..-1] + yield path.sub(directory,'') end end protected @@ -153,11 +153,11 @@ # # @since 1.0.1 # # @api private # - def Installation.load_gems! + def self.load_gems! register_gem = lambda { |gem| @gems[gem.name] = gem @paths << gem.full_gem_path } @@ -182,11 +182,11 @@ # # @since 1.0.0 # # @api private # - def Installation.load_gemspecs! + def self.load_gemspecs! $LOAD_PATH.each do |lib_dir| root_dir = File.expand_path(File.join(lib_dir,'..')) gemspec_path = Dir[File.join(root_dir,'ronin*.gemspec')][0] if gemspec_path @@ -214,10 +214,10 @@ # # @since 1.0.1 # # @api private # - def Installation.load! + def self.load! if Gem.loaded_specs.has_key?('ronin') load_gems! else load_gemspecs! end