Class: Show::Gem::Junk::GemFile
- Inherits:
-
Object
- Object
- Show::Gem::Junk::GemFile
- Defined in:
- lib/show/gem/junk/gemfile.rb
Overview
GemFile is a file that belongs to a rubygem
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
-
#stat ⇒ Object
Returns the value of attribute stat.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(path) ⇒ GemFile
constructor
A new instance of GemFile.
- #junk? ⇒ Boolean
- #pretty_path ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(path) ⇒ GemFile
Returns a new instance of GemFile.
9 10 11 12 |
# File 'lib/show/gem/junk/gemfile.rb', line 9 def initialize(path) @path = path @stat = File.stat(path) end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
7 8 9 |
# File 'lib/show/gem/junk/gemfile.rb', line 7 def path @path end |
#stat ⇒ Object
Returns the value of attribute stat.
7 8 9 |
# File 'lib/show/gem/junk/gemfile.rb', line 7 def stat @stat end |
Instance Method Details
#<=>(other) ⇒ Object
22 23 24 |
# File 'lib/show/gem/junk/gemfile.rb', line 22 def <=>(other) size <=> other.size end |
#junk? ⇒ Boolean
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/show/gem/junk/gemfile.rb', line 26 def junk? return false if File.directory?(path) basename = File.basename(path) # Files return true if basename.end_with?('.gemspec') return true if basename == '.gitignore' return true if basename == '.travis.yml' return true if basename == '.appveyor.yml' # Loose path matching return true if path.include?('concourse') # Specs parts = Pathname.new(pretty_path).each_filename.to_a return false if parts.size < 2 return true if parts[1] == 'test' return true if parts[1] == 'spec' return true if parts[1] == 'features' false end |
#pretty_path ⇒ Object
18 19 20 |
# File 'lib/show/gem/junk/gemfile.rb', line 18 def pretty_path path.gsub(GEMS_DIR, '') end |
#size ⇒ Object
14 15 16 |
# File 'lib/show/gem/junk/gemfile.rb', line 14 def size stat.size end |