Module: Rise::Util
- Defined in:
- lib/core/util.rb
Class Method Summary collapse
-
.check_for_update! ⇒ Object
Check for a new version of the gem.
-
.is_first_run? ⇒ Boolean
Checks if rise is being run for the first time.
-
.setup ⇒ Object
Creates all of the necessary files and login information.
Class Method Details
.check_for_update! ⇒ Object
Check for a new version of the gem
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/core/util.rb', line 27 def self.check_for_update! begin output = '' temp = Tempfile.new('rise-updater-output') path = temp.path system("gem outdated > #{path}") output << temp.read if output.include? 'rise-cli' Whirly.start(spinner: 'line', status: Paint['New version available, updating...', 'blue']) do system("gem uninstall rise-cli -v #{Rise::Constants::VERSION} > /dev/null") system("gem install rise-cli > /dev/null") puts Paint["Update complete, just run #{Paint['`rise`', '#3498db']} to deploy"] end end rescue Exception => e puts "Unable to check for updates. Error: #{Paint[e.message, 'red']}" exit 1 ensure temp.close temp.unlink end end |
.is_first_run? ⇒ Boolean
Checks if rise is being run for the first time
20 21 22 |
# File 'lib/core/util.rb', line 20 def self.is_first_run? !File.directory?(File.join(Dir.home, '.rise')) end |
.setup ⇒ Object
Creates all of the necessary files and login information
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/core/util.rb', line 52 def self.setup puts Paint['Detected first time setup, creating necessary files...', :blue] FileUtils.mkdir(RISE_DATA_DIR) FileUtils.mkdir(File.join(RISE_DATA_DIR, 'auth')) #TODO Reimplement when the backend server actually works # Get the input from the user #print Paint['1. Log in\n2. Sign up\n > ', :bold] #while (choice = gets.chomp!) # if choice == '1' # login # break # elsif choice == '2' # signup # break # else # puts Paint['Please type `1` or `2`', :red] # next # end #end end |