Class: Gemfiler::Filer

Inherits:
Object
  • Object
show all
Defined in:
lib/Gemfiler/filer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cabinet) ⇒ Filer

Returns a new instance of Filer.



5
6
7
8
9
# File 'lib/Gemfiler/filer.rb', line 5

def initialize(cabinet)
  @cabinet       = cabinet
  @groups        = {}
  @uncategorized = []
end

Instance Attribute Details

#cabinetObject

Returns the value of attribute cabinet.



3
4
5
# File 'lib/Gemfiler/filer.rb', line 3

def cabinet
  @cabinet
end

#groupsObject

Returns the value of attribute groups.



3
4
5
# File 'lib/Gemfiler/filer.rb', line 3

def groups
  @groups
end

#uncategorizedObject

Returns the value of attribute uncategorized.



3
4
5
# File 'lib/Gemfiler/filer.rb', line 3

def uncategorized
  @uncategorized
end

Instance Method Details

#alphabetizeObject



23
24
25
26
27
28
29
# File 'lib/Gemfiler/filer.rb', line 23

def alphabetize
  self.uncategorized = alphabetize_from_array(self.uncategorized)
  self.groups = self.groups.inject({}) do |hash, (groups, gems)|
    hash[groups] = alphabetize_from_array(gems)
    hash
  end
end

#groupObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/Gemfiler/filer.rb', line 11

def group
  cabinet.gems.each do |gem|
    if gem[:groups]
      gem_groups           = gem.delete(:groups).sort
      groups[gem_groups] ||= []
      groups[gem_groups] << gem
    else
      uncategorized << gem
    end
  end
end

#shimObject

Delegate shim



32
33
34
# File 'lib/Gemfiler/filer.rb', line 32

def shim
  cabinet.shim
end