Class: Show::Gem::Junk::RubyGem
- Inherits:
-
Object
- Object
- Show::Gem::Junk::RubyGem
- Defined in:
- lib/show/gem/junk/rubygem.rb
Overview
RubyGem is an unpacked gem on disk
Instance Attribute Summary collapse
-
#files ⇒ Object
Returns the value of attribute files.
-
#name ⇒ Object
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(path) ⇒ RubyGem
constructor
A new instance of RubyGem.
- #junk_files ⇒ Object
- #junk_size ⇒ Object
- #percent_junk ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(path) ⇒ RubyGem
Returns a new instance of RubyGem.
7 8 9 10 11 12 13 |
# File 'lib/show/gem/junk/rubygem.rb', line 7 def initialize(path) @path = File.(path) @name, _, @version = path.gsub(GEMS_DIR, '').rpartition('-') @files = Dir.glob("#{GEMS_DIR}#{name}-#{version}/**/*", File::FNM_DOTMATCH).map do |f| Show::Gem::Junk::GemFile.new(f) end end |
Instance Attribute Details
#files ⇒ Object
Returns the value of attribute files.
5 6 7 |
# File 'lib/show/gem/junk/rubygem.rb', line 5 def files @files end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/show/gem/junk/rubygem.rb', line 5 def name @name end |
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/show/gem/junk/rubygem.rb', line 5 def path @path end |
#version ⇒ Object
Returns the value of attribute version.
5 6 7 |
# File 'lib/show/gem/junk/rubygem.rb', line 5 def version @version end |
Instance Method Details
#<=>(other) ⇒ Object
33 34 35 |
# File 'lib/show/gem/junk/rubygem.rb', line 33 def <=>(other) percent_junk <=> other.percent_junk end |
#junk_files ⇒ Object
15 16 17 |
# File 'lib/show/gem/junk/rubygem.rb', line 15 def junk_files files.select(&:junk?) end |
#junk_size ⇒ Object
23 24 25 |
# File 'lib/show/gem/junk/rubygem.rb', line 23 def junk_size junk_files.map(&:size).sum end |
#percent_junk ⇒ Object
27 28 29 30 31 |
# File 'lib/show/gem/junk/rubygem.rb', line 27 def percent_junk return 0.0 if size.zero? (junk_size.to_f / size) * 100 end |
#size ⇒ Object
19 20 21 |
# File 'lib/show/gem/junk/rubygem.rb', line 19 def size files.map(&:size).sum end |