Module: Gem::Prune::Util
- Included in:
- Commands::KeepCommand, Commands::PruneCommand
- Defined in:
- lib/gem/prune/util.rb
Instance Method Summary collapse
- #gems_to_keep ⇒ Object
- #load_configuration ⇒ Object
- #save_configuration ⇒ Object
- #settings_filename ⇒ Object
Instance Method Details
#gems_to_keep ⇒ Object
7 8 9 |
# File 'lib/gem/prune/util.rb', line 7 def gems_to_keep @configuration end |
#load_configuration ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/gem/prune/util.rb', line 11 def load_configuration @configuration ||= File.read(settings_filename).split("\n").map do |line| gem, versions = line.split(' ', 2) versions = versions.to_s.gsub(/[\(\)]/, '').split(', ') [gem, versions] end end |
#save_configuration ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gem/prune/util.rb', line 19 def save_configuration File.open(settings_filename, "w") do |file| formatted = @configuration.map do |gem, versions| version_string = versions.length.zero? ? "" : " (%s)" % versions.join(", ") "#{gem}#{version_string}" end.join("\n") file.puts formatted end end |
#settings_filename ⇒ Object
3 4 5 |
# File 'lib/gem/prune/util.rb', line 3 def settings_filename File.('~/.gem-prune') end |