Class: SafeUpdate::OutdatedGem
- Inherits:
-
Object
- Object
- SafeUpdate::OutdatedGem
- Defined in:
- lib/safe_update/outdated_gem.rb
Instance Attribute Summary collapse
-
#installed ⇒ Object
readonly
Returns the value of attribute installed.
-
#newest ⇒ Object
readonly
Returns the value of attribute newest.
-
#requested ⇒ Object
readonly
Returns the value of attribute requested.
Instance Method Summary collapse
- #attempt_update(test_command = nil) ⇒ Object
-
#initialize(line, git_repo = nil) ⇒ OutdatedGem
constructor
line is a line from bundle outdated –parseable eg.
- #name ⇒ Object
Constructor Details
#initialize(line, git_repo = nil) ⇒ OutdatedGem
line is a line from bundle outdated –parseable eg. react-rails (newest 1.6.0, installed 1.5.0, requested ~> 1.0) or. react-rails (newest 1.6.0, installed 1.5.0)
8 9 10 11 12 13 14 |
# File 'lib/safe_update/outdated_gem.rb', line 8 def initialize(line, git_repo = nil) @line = line @git_repo = git_repo || GitRepo.new if name.to_s.empty? fail "Unexpected output from `bundle outdated --parseable`: #{@line}" end end |
Instance Attribute Details
#installed ⇒ Object (readonly)
Returns the value of attribute installed.
3 4 5 |
# File 'lib/safe_update/outdated_gem.rb', line 3 def installed @installed end |
#newest ⇒ Object (readonly)
Returns the value of attribute newest.
3 4 5 |
# File 'lib/safe_update/outdated_gem.rb', line 3 def newest @newest end |
#requested ⇒ Object (readonly)
Returns the value of attribute requested.
3 4 5 |
# File 'lib/safe_update/outdated_gem.rb', line 3 def requested @requested end |
Instance Method Details
#attempt_update(test_command = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/safe_update/outdated_gem.rb', line 16 def attempt_update(test_command = nil) puts '-------------' puts "OUTDATED GEM: #{name}" puts " Newest: #{newest}. " puts "Installed: #{installed}." puts "Running `bundle update #{name}`..." `bundle update #{name}` # sometimes the gem may be outdated, but it's matching the # version required by the gemfile, so bundle update does nothing # in which case, don't waste time on tests etc. if false return end if test_command puts "Running tests with: #{test_command}" result = system(test_command) if result != true puts "tests failed - this gem won't be updated (test result: #{$?.to_i})" @git_repo.discard_local_changes return end end puts "committing changes (message: '#{commit_message}')..." @git_repo.commit_gemfile_lock() end |
#name ⇒ Object
46 47 48 |
# File 'lib/safe_update/outdated_gem.rb', line 46 def name string_between(@line, '', ' (newest') end |