Class: ReleaseProcess

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/release/release_process.rb

Instance Method Summary collapse

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(dry_run, snapshots) ⇒ ReleaseProcess

Returns a new instance of ReleaseProcess.



7
8
9
10
11
# File 'lib/release/release_process.rb', line 7

def initialize(dry_run, snapshots)
  @summary ||=[]
  @dry_run=dry_run
  @snapshots=snapshots
end

Instance Method Details

#set_release_versionsObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/release/release_process.rb', line 52

def set_release_versions
  pom=read_file 'pom.xml'

  @snapshots.each do |snapshot|

    dependency_tag = snapshot[0]
    snapshot_version = snapshot[1]
    release_version = snapshot[2]

    pom=pom.gsub(
        /<#{dependency_tag}>#{snapshot_version}<\/#{dependency_tag}>/,
        "<#{dependency_tag}>#{release_version}</#{dependency_tag}>"
    )
  end

  write_file 'pom.xml',pom
end

#set_snapshot_versionsObject



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/release/release_process.rb', line 70

def set_snapshot_versions
  pom=read_file 'pom.xml'

  @snapshots.each do |snapshot|

    dependency_tag = snapshot[0]
    release_version = snapshot[2]
    next_snapshot_version = snapshot[3]

    pom=pom.gsub(
        /<#{dependency_tag}>#{release_version}<\/#{dependency_tag}>/,
        "<#{dependency_tag}>#{next_snapshot_version}</#{dependency_tag}>"
    )
  end

  write_file 'pom.xml',pom
end

#show_summaryObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/release/release_process.rb', line 13

def show_summary

  if @summary.size==0
    return
  end

  help_info "\nSummary"

  @summary.each_with_index do |step, index|
    help_info "\n#{index}. #{step}"
  end

end

#step(info, commands) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/release/release_process.rb', line 27

def step(info, commands)
  echo_with_color "#{info}", 'green'
  puts "\n#{commands.join("\n")}"

  log_commands ||=[]
  commands.each do |command|

    internal_call_match = /^\$\$(.+)$/.match(command)
    if internal_call_match
      internal_method_call = internal_call_match.captures[0]
      log_commands << internal_method_call
      eval("#{internal_method_call}")
    else
      log_commands << command
      unless @dry_run
        system(command)
      end
    end

  end

  @summary << "#{info}: \n\t#{log_commands.join("\n\t")}"
  self
end