Class: Rrm::GemfileLock
- Inherits:
-
Object
- Object
- Rrm::GemfileLock
- Defined in:
- lib/rrm/filehandlers/gemfile_lock.rb
Constant Summary collapse
- GEMFILE =
'Gemfile'
- FILENAME =
'Gemfile.lock'
- TIMEOUT_SECONDS =
240
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#git ⇒ Object
Returns the value of attribute git.
-
#new_version ⇒ Object
Returns the value of attribute new_version.
-
#update_gems ⇒ Object
Returns the value of attribute update_gems.
Instance Method Summary collapse
-
#initialize(git, update_gems) ⇒ GemfileLock
constructor
A new instance of GemfileLock.
- #update!(new_version) ⇒ Object
Constructor Details
#initialize(git, update_gems) ⇒ GemfileLock
Returns a new instance of GemfileLock.
11 12 13 14 15 16 17 |
# File 'lib/rrm/filehandlers/gemfile_lock.rb', line 11 def initialize(git, update_gems) @content = File.read("#{git.dir.path}/#{FILENAME}") @git = git @update_gems = update_gems rescue @content = nil end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
9 10 11 |
# File 'lib/rrm/filehandlers/gemfile_lock.rb', line 9 def content @content end |
#git ⇒ Object
Returns the value of attribute git.
9 10 11 |
# File 'lib/rrm/filehandlers/gemfile_lock.rb', line 9 def git @git end |
#new_version ⇒ Object
Returns the value of attribute new_version.
9 10 11 |
# File 'lib/rrm/filehandlers/gemfile_lock.rb', line 9 def new_version @new_version end |
#update_gems ⇒ Object
Returns the value of attribute update_gems.
9 10 11 |
# File 'lib/rrm/filehandlers/gemfile_lock.rb', line 9 def update_gems @update_gems end |
Instance Method Details
#update!(new_version) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rrm/filehandlers/gemfile_lock.rb', line 19 def update!(new_version) image = Docker::Image.create('fromImage' => "ruby:#{new_version}") container = Docker::Container.create('Cmd' => 'bundle', 'Image' => "ruby:#{new_version}", 'Env' => ) container.store_file("/#{GEMFILE}", File.read("#{git.dir.path}/#{GEMFILE}")) container.store_file("/#{FILENAME}", File.read("#{git.dir.path}/#{FILENAME}")) unless update_gems container.start Rrm.logger.debug "Running 'bundle' inside Docker, please wait. Timeout is #{TIMEOUT_SECONDS} seconds" container.wait(TIMEOUT_SECONDS) new_content = container.read_file("/#{FILENAME}") container.stop file = File.open("#{git.dir.path}/#{FILENAME}", 'w') file.puts new_content file.close git.commit_all((new_version)) end |