Class: DRG::Tasks::Updater
- Inherits:
-
Object
- Object
- DRG::Tasks::Updater
- Includes:
- Log
- Defined in:
- lib/drg/tasks/updater.rb
Instance Attribute Summary collapse
-
#gemfile ⇒ Object
readonly
Returns the value of attribute gemfile.
Instance Method Summary collapse
-
#initialize ⇒ Updater
constructor
A new instance of Updater.
-
#perform ⇒ Object
Loads the current version of outdated gems.
Methods included from Log
Constructor Details
Instance Attribute Details
#gemfile ⇒ Object (readonly)
Returns the value of attribute gemfile.
6 7 8 |
# File 'lib/drg/tasks/updater.rb', line 6 def gemfile @gemfile end |
Instance Method Details
#perform ⇒ Object
Note:
‘bundle outdated` returns lines that look like ’slop (newest 4.2.0, installed 3.6.0) in group “default”‘
Loads the current version of outdated gems
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/drg/tasks/updater.rb', line 16 def perform log 'Searching for outdated gems ....' outdated = `bundle outdated`.scan(/\s\*\s(.+)\s/).flatten gems = outdated.map { |item| name = item[/([\-\w0-9]+)\s/, 1] name if gemfile.find_by_name(name) }.compact if gems.any? yield gems else log 'All gems up to date!' end end |