Class: Bundler::AutoUpdate::GemUpdater
- Inherits:
-
Object
- Object
- Bundler::AutoUpdate::GemUpdater
- Defined in:
- lib/bundler_auto_update.rb
Instance Attribute Summary collapse
-
#gem ⇒ Object
readonly
Returns the value of attribute gem.
-
#gemfile ⇒ Object
readonly
Returns the value of attribute gemfile.
-
#test_command ⇒ Object
readonly
Returns the value of attribute test_command.
Instance Method Summary collapse
-
#auto_update ⇒ Object
Attempt to update to patch, then to minor then to major versions.
-
#initialize(gem, gemfile, test_command) ⇒ GemUpdater
constructor
A new instance of GemUpdater.
-
#updatable? ⇒ Boolean
True when the gem has a fixed version.
-
#update(version_type) ⇒ Boolean
Update current gem to latest :version_type:, run test suite and commit new Gemfile if successful.
Constructor Details
#initialize(gem, gemfile, test_command) ⇒ GemUpdater
Returns a new instance of GemUpdater.
47 48 49 |
# File 'lib/bundler_auto_update.rb', line 47 def initialize(gem, gemfile, test_command) @gem, @gemfile, @test_command = gem, gemfile, test_command end |
Instance Attribute Details
#gem ⇒ Object (readonly)
Returns the value of attribute gem.
45 46 47 |
# File 'lib/bundler_auto_update.rb', line 45 def gem @gem end |
#gemfile ⇒ Object (readonly)
Returns the value of attribute gemfile.
45 46 47 |
# File 'lib/bundler_auto_update.rb', line 45 def gemfile @gemfile end |
#test_command ⇒ Object (readonly)
Returns the value of attribute test_command.
45 46 47 |
# File 'lib/bundler_auto_update.rb', line 45 def test_command @test_command end |
Instance Method Details
#auto_update ⇒ Object
Attempt to update to patch, then to minor then to major versions.
52 53 54 55 56 57 58 59 |
# File 'lib/bundler_auto_update.rb', line 52 def auto_update if updatable? Logger.log "Updating #{gem.name}" update(:patch) and update(:minor) and update(:major) else Logger.log "#{gem.name} is not auto-updatable, passing it." end end |
#updatable? ⇒ Boolean
Returns true when the gem has a fixed version.
88 89 90 |
# File 'lib/bundler_auto_update.rb', line 88 def updatable? !!(gem.version =~ /^~?>? ?\d+\.\d+(\.\d+)?$/) end |
#update(version_type) ⇒ Boolean
Update current gem to latest :version_type:, run test suite and commit new Gemfile if successful.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/bundler_auto_update.rb', line 66 def update(version_type) new_version = gem.last_version(version_type) if new_version == gem.version Logger.log_indent "Current gem already at latest #{version_type} version. Passing this update." return true end Logger.log_indent "Updating to #{version_type} version #{new_version}" gem.version = new_version if update_gemfile and run_test_suite and commit_new_version true else revert_to_previous_version false end end |