class Inits::CLI

Public Instance Methods

help() click to toggle source
# File lib/inits/cli.rb, line 17
    def help
      puts <<-HELP
      Manual:
        Commands:
          bundle exec exe/inits on

        Options:
          -v: verbose
          -brew_path: brew's local path, default is `#{options[:brew_path]}`
          -rbenv_path: rbenv's local path, default is `#{options[:rbenv_path]}`
          -rbenv_installed: rbenv's local installed ruby versions, default is `true`
          -rbenv_listing: rbenv's all ruby versions, default is `false`
      HELP
    end
on() click to toggle source
# File lib/inits/cli.rb, line 35
def on
  p options if options[:verbose]
  brew
  rbenv
end

Private Instance Methods

brew() click to toggle source
# File lib/inits/cli.rb, line 50
def brew
  execute('brew') { system "#{options[:brew_path]} update" }
end
execute(label) { || ... } click to toggle source
# File lib/inits/cli.rb, line 43
def execute(label)
  return if options["#{label}_path".to_sym].empty?
  puts "[#{label}] update start..."
  yield if block_given?
  puts "[#{label}] update end...\n\n"
end
rbenv() click to toggle source
# File lib/inits/cli.rb, line 54
def rbenv
  pullmaster = ->(*paths) { paths.map { |path| system "cd #{path} && git pull origin master" } }
  execute('rbenv') do
    pullmaster.call options[:rbenv_path], "#{options[:rbenv_path]}/plugins/ruby-build"
    system 'rbenv versions && ruby -v' if options[:rbenv_installed]
    system 'rbenv install --list' if options[:rbenv_listing]
  end
end