Class: ReleaseModel
- Inherits:
-
Object
- Object
- ReleaseModel
- Includes:
- Utilities
- Defined in:
- lib/release/release_model.rb
Instance Attribute Summary collapse
-
#dry_run ⇒ Object
readonly
Returns the value of attribute dry_run.
-
#next_version ⇒ Object
readonly
Returns the value of attribute next_version.
-
#release_branch ⇒ Object
readonly
Returns the value of attribute release_branch.
-
#release_version ⇒ Object
readonly
Returns the value of attribute release_version.
-
#snapshots ⇒ Object
readonly
Returns the value of attribute snapshots.
Instance Method Summary collapse
- #column(value) ⇒ Object
-
#initialize ⇒ ReleaseModel
constructor
A new instance of ReleaseModel.
- #prepare_new_iteration_deps ⇒ Object
- #read_release_version ⇒ Object
- #read_snapshot_versions ⇒ Object
Methods included from Utilities
#ask, #echo_with_color, #help_info, #next_snapshot, #read_file, #right_padding, #terminate, #verify_pattern, #verify_pattern_terminate, #wait_or_do, #write_file
Constructor Details
#initialize ⇒ ReleaseModel
Returns a new instance of ReleaseModel.
12 13 14 15 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 45 46 |
# File 'lib/release/release_model.rb', line 12 def initialize @dry_run = (ask 'Dry run?','n') == 'y' @release_version = ask 'What should the release version be?', read_release_version verify_pattern_terminate @release_version, $version @next_version = ask 'What should the next SNAPSHOT version be?', (next_snapshot @release_version) verify_pattern_terminate @next_version, $snapshot_version @release_branch = "release/#{@release_version}" @snapshots = File.open('pom.xml').read.scan($snapshot_dependency) read_snapshot_versions prepare_new_iteration_deps echo_with_color "\n\n====================Release information========================================================",'green' puts "\nDry run: #{@dry_run}" if @dry_run help_info "---> IMPORTANT: Dry run will still change the snapshot dependencies versions (if any), don't forget to revert those changes\n" end help_info "\n1. Release version: "; puts release_version help_info "\n2. Next snapshot version: ";puts next_version help_info "\n3. Snapshot dependencies found:\n" unless @snapshots.size==0 help_info "#{column 'Dependency'} : #{column 'Current version'} -> #{column 'Release version'} -> #{column 'New iteration version'}\n" @snapshots.each do |snapshot| puts "#{column snapshot[0]} : #{column snapshot[1]} -> #{column snapshot[2]} -> #{column snapshot[3]}" end end echo_with_color "\n=================================================================================================",'green' end |
Instance Attribute Details
#dry_run ⇒ Object (readonly)
Returns the value of attribute dry_run.
52 53 54 |
# File 'lib/release/release_model.rb', line 52 def dry_run @dry_run end |
#next_version ⇒ Object (readonly)
Returns the value of attribute next_version.
52 53 54 |
# File 'lib/release/release_model.rb', line 52 def next_version @next_version end |
#release_branch ⇒ Object (readonly)
Returns the value of attribute release_branch.
52 53 54 |
# File 'lib/release/release_model.rb', line 52 def release_branch @release_branch end |
#release_version ⇒ Object (readonly)
Returns the value of attribute release_version.
52 53 54 |
# File 'lib/release/release_model.rb', line 52 def release_version @release_version end |
#snapshots ⇒ Object (readonly)
Returns the value of attribute snapshots.
52 53 54 |
# File 'lib/release/release_model.rb', line 52 def snapshots @snapshots end |
Instance Method Details
#column(value) ⇒ Object
48 49 50 |
# File 'lib/release/release_model.rb', line 48 def column(value) right_padding value,30; end |
#prepare_new_iteration_deps ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/release/release_model.rb', line 73 def prepare_new_iteration_deps unless @snapshots return end help_info "\n\nSet SNAPSHOT versions for dependencies for the next iteration" @snapshots.each do |snapshot| default_version = next_snapshot snapshot[2] snap_version=self.ask "For the next iteration, what snapshot version to use for ==> #{snapshot[0]}?", default_version snapshot << (snap_version == 'y' ? default_version : snap_version) end end |
#read_release_version ⇒ Object
54 55 56 57 58 |
# File 'lib/release/release_model.rb', line 54 def read_release_version artifact_version = REXML::Document.new(File.new('pom.xml')).elements['/project/version'].text verify_pattern_terminate artifact_version, $snapshot_version $snapshot_version.match(artifact_version).captures[0] end |
#read_snapshot_versions ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/release/release_model.rb', line 60 def read_snapshot_versions unless @snapshots return end help_info "\n\nFound dependencies with SNAPSHOT versions:" @snapshots.each do |snapshot| default_version=$snapshot_version.match(snapshot[1]).captures[0] release_version=self.ask "What release version to use for ==> #{snapshot[0]}?", default_version snapshot << (release_version == 'y' ? default_version : release_version) end end |