Class: Pitman
- Inherits:
-
Object
- Object
- Pitman
- Defined in:
- lib/pitman.rb
Constant Summary collapse
- DEFAULT_GEMS =
%w(bigdecimal io-console json minitest psych rake rdoc test-unit)
Class Method Summary collapse
Class Method Details
.collect(root) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/pitman.rb', line 30 def self.collect(root) used = used_gems(root) all = gems_list all - (used + DEFAULT_GEMS) end |
.gems_list ⇒ Object
5 6 7 |
# File 'lib/pitman.rb', line 5 def self.gems_list `gem list`.split("\n").collect { |str| str.split(" (").first.strip } end |
.parse(file) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/pitman.rb', line 9 def self.parse(file) File.read(file) .split("\n") .select { |str| str =~ /\(.+\)/ } .collect { |str| str.split(" ").first } .uniq end |
.used_gems(root) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pitman.rb', line 17 def self.used_gems(root) dirs = root.children.select { |c| c.directory? } gems = dirs.collect do |dir| Dir.chdir(dir) do next unless File.exist?('Gemfile.lock') parse('Gemfile.lock') end end gems.flatten end |