Module: Horatio::Detector::JSONWriter

Included in:
Docker
Defined in:
lib/horatio/detector/json_writer.rb

Instance Method Summary collapse

Instance Method Details

#increment(releaser) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/horatio/detector/json_writer.rb', line 6

def increment(releaser)
  increment_version
  if ENV['DRY_RUN']
    color { Log.info "dry run: would've saved updated #{output}" }
    return
  end
  color { Log.info "saving updated #{output}" }
  File.open(output, 'w') { |f| f.write(JSON.pretty_generate(info)) } unless ENV['DRY_RUN']
  releaser.vcs.commit(output)
end

#increment_versionObject



17
18
19
20
21
22
23
# File 'lib/horatio/detector/json_writer.rb', line 17

def increment_version
  parts = info['version'].split('.')
  parts[-1] = parts[-1].to_i + 1
  version = parts.join('.')
  color { Log.info "incrementing version from #{info['version']} to #{version}"}
  info['version'] = version
end