Module: Negroku::Modes::App
Instance Method Summary collapse
- #ask_features ⇒ Object
-
#ask_name ⇒ Object
Ask the application name.
- #build_capfile ⇒ Object
- #check_all_versions ⇒ Object
- #check_capfile_version ⇒ Object
- #check_version ⇒ Object
-
#custom_capify(data = {}, config = nil) ⇒ Object
This code was exatracted from capistrano to be used with our own templates github.com/capistrano/capistrano/blob/68e7632c5f16823a09c324d556a208e096abee62/lib/capistrano/tasks/install.rake.
- #install ⇒ Object
- #install_binstubs ⇒ Object
-
#select_repo ⇒ Object
Get git remotes from current git and ask to select one.
- #update ⇒ Object
Instance Method Details
#ask_features ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/negroku/modes/app.rb', line 79 def ask_features optional_features = Negroku::Config::attributes.select{|k,v| !v.required?} default_features = optional_features.map{|k,v| v.enabled?} features_names = optional_features.map{|k,v| v.name} question = I18n.t :application_features, scope: :negroku selected = Ask.checkbox question, features_names, default: default_features optional_features.each.with_index do |(idx, feat), index| Negroku::Config[feat.name].enabled = selected[index] end end |
#ask_name ⇒ Object
Ask the application name
74 75 76 77 |
# File 'lib/negroku/modes/app.rb', line 74 def ask_name question = I18n.t :application_name, scope: :negroku Ask.input question, default: File.basename(Dir.getwd) end |
#build_capfile ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/negroku/modes/app.rb', line 65 def build_capfile # Default Config config ||= Negroku::Config capfile = AppDirectory.root.join('Capfile') build_template('templates/Capfile.erb', capfile, binding) end |
#check_all_versions ⇒ Object
162 163 164 165 166 167 168 |
# File 'lib/negroku/modes/app.rb', line 162 def check_all_versions continue = self.check_version unless(continue) self.check_capfile_version end end |
#check_capfile_version ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/negroku/modes/app.rb', line 136 def check_capfile_version updated = Negroku.check_capfile_version if(updated) puts I18n.t(:capfile_up_to_date, scope: :negroku).colorize(:green) else puts I18n.t(:capfile_new_version, scope: :negroku).colorize(:red) puts I18n.t(:gem_current_version, scope: :negroku, version: Negroku.version.colorize(:green)) puts I18n.t(:capfile_current_version, scope: :negroku, version: Negroku.capfile_version.colorize(:red)) puts "\n" capfile_str = "Capfile".colorize(mode: :bold) cmd_str = "negroku app update".colorize(mode: :bold) puts I18n.t(:capfile_update_instructions, scope: :negroku, capfile: capfile_str, cmd: cmd_str) puts "\n" question = I18n.t(:continue_without_update, scope: :negroku) continue = ::Ask.confirm(question, default: false) exit 0 unless(continue) end end |
#check_version ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/negroku/modes/app.rb', line 107 def check_version updated = Negroku.check_version if(updated) puts I18n.t(:gem_up_to_date, scope: :negroku).colorize(:green) else puts I18n.t(:gem_new_version, scope: :negroku).colorize(:yellow) puts I18n.t(:gem_latest_version, scope: :negroku, version: Negroku.latest.colorize(:green)) puts I18n.t(:gem_current_version, scope: :negroku, version: Negroku.version.colorize(:yellow)) puts "\n" gemfile_str = "Gemfile".colorize(mode: :bold) cmd_str = "bundle install".colorize(mode: :bold) puts I18n.t(:gem_update_instructions, scope: :negroku, gemfile: gemfile_str, cmd: cmd_str) puts "\n" question = I18n.t(:continue_without_update, scope: :negroku) continue = ::Ask.confirm(question, default: true) exit 0 unless(continue) return continue end end |
#custom_capify(data = {}, config = nil) ⇒ Object
This code was exatracted from capistrano to be used with our own templates github.com/capistrano/capistrano/blob/68e7632c5f16823a09c324d556a208e096abee62/lib/capistrano/tasks/install.rake
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/negroku/modes/app.rb', line 47 def custom_capify(data={}, config=nil) # defaults data[:server_url] = "" data[:branch] = "master" FileUtils.mkdir_p AppDirectory.deploy build_capfile deploy_rb = AppDirectory.config.join('deploy.rb') build_template("templates/deploy.rb.erb", deploy_rb, binding) FileUtils.mkdir_p AppDirectory.tasks puts I18n.t :capified, scope: :negroku end |
#install ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/negroku/modes/app.rb', line 7 def install check_version data = {} data[:application_name] = ask_name data[:repo_url] = select_repo ask_features custom_capify data install_binstubs end |
#install_binstubs ⇒ Object
41 42 43 |
# File 'lib/negroku/modes/app.rb', line 41 def install_binstubs `bundle binstub capistrano negroku` end |
#select_repo ⇒ Object
Get git remotes from current git and ask to select one
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/negroku/modes/app.rb', line 93 def select_repo remote_urls = %x(git remote -v 2> /dev/null | awk '{print $2}' | uniq).split("\n") remote_urls << (I18n.t :other, scope: :negroku) question = I18n.t :choose_repo_url, scope: :negroku selected_idx = Ask.list question, remote_urls if selected_idx == remote_urls.length - 1 question = I18n.t :type_repo_url, scope: :negroku Ask.input question else remote_urls[selected_idx] end end |
#update ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/negroku/modes/app.rb', line 22 def update puts I18n.t :updating_capfile, scope: :negroku capfilePath = AppDirectory.root.join('Capfile') capfile = File.read(capfilePath) build_capfile capfile_new = File.read(capfilePath) if capfile_new != capfile puts I18n.t :updated_capfile, scope: :negroku else puts I18n.t :no_change_capfile, scope: :negroku end end |