class Configurator
Public Class Methods
new()
click to toggle source
# File lib/menu.rb, line 186 def initialize File.new(File.join(Dir.home, "printsly.json"), "w+") unless File.exists?(File.join(Dir.home, "printsly.json")) puts #format puts "Let's configure " + "Printsly".yellow + "." work_dir_text batchy_text auto_text end
Public Instance Methods
actions(move, cur_conf)
click to toggle source
# File lib/menu.rb, line 163 def actions move, cur_conf case when move == "1" begin work_dir_text puts #format puts "The working directory is currently: " + cur_conf[:work_dir].green cur_conf[:work_dir] = choose_file puts #format puts "You have chosen " + cur_conf[:work_dir].yellow + " Is this correct?" yes_no end while not (@yes_no == "yes") when move == "2" cur_conf[:batchy] = batch_mode(cur_conf[:batchy]) when move == "3" cur_conf[:auto_mater] = provision_mode(cur_conf[:auto_mater]) when move == "4" puts #format puts "Returning to main menu." end cur_conf end
batch_mode(batchy)
click to toggle source
Set and save Printsly defaults
# File lib/menu.rb, line 125 def batch_mode batchy batchy_text puts #format puts "Batch mode is currently turned " + batchy.green + "." puts #format case when batchy == "Off" puts "Turn batch mode on?" @yes_no = yes_no batchy = "On" if @yes_no == "yes" when batchy == "On" puts "Turn batch mode off?" @yes_no = yes_no puts @yes_no batchy = "Off" if @yes_no == "yes" end puts batchy batchy end
choices(cur_conf)
click to toggle source
# File lib/menu.rb, line 145 def choices(cur_conf) move = 0 until move == "4" bar_both c = Choice.new "What would you like to configure?", { "1" => "Set Working Directory | Current: " + cur_conf[:work_dir].green, "2" => "Batch Mode | Current: " + cur_conf[:batchy].green, "3" => "Auto Provision? | Current: " + cur_conf[:auto_mater].green, "4" => "Return To Main Menu." } move = c.prompt cur_conf = actions(move, cur_conf) end save_config(cur_conf) return cur_conf end
provision_mode(auto_mater)
click to toggle source
# File lib/menu.rb, line 195 def provision_mode auto_mater auto_text puts #format puts "Auto provision is currently turned " + auto_mater.green + "." puts #format case when auto_mater == "Off" puts "Turn auto provision on?" @yes_no = yes_no auto_mater = "On" if @yes_no == "yes" when auto_mater == "On" puts "Turn auto provision off?" @yes_no = yes_no auto_mater = "Off" if @yes_no == "yes" end end