Module: Jenkins::Peace::ThorExtensions
- Included in:
- CLI
- Defined in:
- lib/jenkins/peace/thor_extensions.rb
Instance Method Summary collapse
- #bold(string) ⇒ Object
- #check_conflicts_and_call_method(method, version, check_method = :exists?) {|war_file| ... } ⇒ Object
- #download_it_first! ⇒ Object
- #formated_headers ⇒ Object
- #formated_war_files_list ⇒ Object
- #green(string) ⇒ Object
- #info(message) ⇒ Object
- #red(string) ⇒ Object
- #success_message ⇒ Object
- #warn(message) ⇒ Object
- #yes_no_question(question, &block) ⇒ Object
Instance Method Details
#bold(string) ⇒ Object
25 26 27 |
# File 'lib/jenkins/peace/thor_extensions.rb', line 25 def bold(string) set_color string, :bold end |
#check_conflicts_and_call_method(method, version, check_method = :exists?) {|war_file| ... } ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/jenkins/peace/thor_extensions.rb', line 52 def check_conflicts_and_call_method(method, version, check_method = :exists?, &block) war_file = Jenkins::Peace.build_war_file(version) yield war_file if block_given? = "#{method.capitalize}ing Jenkins war file version : '#{version}'" if war_file.send(check_method) yes_no_question('Overwrite existing file?') do info Jenkins::Peace.send(method, version, true) end else info Jenkins::Peace.send(method, version) end end |
#download_it_first! ⇒ Object
46 47 48 49 |
# File 'lib/jenkins/peace/thor_extensions.rb', line 46 def download_it_first! warn "War file doesn't exist, you should install it first with : jenkins.peace install <version>" warn 'Exiting !' end |
#formated_headers ⇒ Object
80 81 82 |
# File 'lib/jenkins/peace/thor_extensions.rb', line 80 def formated_headers [bold('Version'), bold('Location'), bold('Classpath'), bold('Installed')] end |
#formated_war_files_list ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/jenkins/peace/thor_extensions.rb', line 69 def formated_war_files_list list = [] Jenkins::Peace.list.each do |war_file| installed = war_file.installed? ? green(war_file.installed?) : red(war_file.installed?) version = war_file.latest_version? ? "latest (#{war_file.real_version})" : war_file.version list << [green(version), war_file.location, war_file.classpath, installed] end list end |
#green(string) ⇒ Object
15 16 17 |
# File 'lib/jenkins/peace/thor_extensions.rb', line 15 def green(string) set_color string, :green end |
#info(message) ⇒ Object
10 11 12 |
# File 'lib/jenkins/peace/thor_extensions.rb', line 10 def info() say , :green end |
#red(string) ⇒ Object
20 21 22 |
# File 'lib/jenkins/peace/thor_extensions.rb', line 20 def red(string) set_color string, :red end |
#success_message ⇒ Object
30 31 32 |
# File 'lib/jenkins/peace/thor_extensions.rb', line 30 def info 'Done !' end |
#warn(message) ⇒ Object
5 6 7 |
# File 'lib/jenkins/peace/thor_extensions.rb', line 5 def warn() say , :yellow end |
#yes_no_question(question, &block) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/jenkins/peace/thor_extensions.rb', line 35 def yes_no_question(question, &block) answer = yes? question, :bold if answer yield if block_given? else warn 'Canceled !' end end |