Sha256: a2dc2e0b1cef12f48235ab87a72c025889532b69a12177d43aa232a50fdbe1c9
Contents?: true
Size: 1.92 KB
Versions: 9
Compression:
Stored size: 1.92 KB
Contents
module Flydata module Command class Base def initialize @api_client = ApiClient.instance end def flydata; @api_client end def retrieve_data_entries data_entries = flydata.get('/data_entries') unless flydata.response.code == 200 raise "Failed to retrieve data_entries" end data_entries end def register_crontab data_entries = retrieve_data_entries if data_entries.any?{|e| e['log_deletion']} Flydata::Command::Crontab.new.run end end # print console def newline; puts end def separator(str="=") puts str * 64 end def ask_yes_no(message, default_yes=true) suffix = default_yes ? "(Y/n)" : "(y/n)" loop do ans = ask("#{message} #{suffix}: ") return true if default_yes and ans == '' if ans.size > 0 case ans[0].downcase when 'y'; return true when 'n'; return false end end say(" ! Please answer y[es] or n[o]") newline end end def choose_one(message, prompt, menu_list, value_list=[]) choice = nil value_list = menu_list unless menu_list.size == value_list.size say(message) if message choose do |menu| menu.index = :number menu.index_suffix = ") " menu.select_by = :index menu.prompt = prompt ? prompt : ">> " menu.choices(*menu_list) {|item| choice = value_list[menu_list.index(item)]} end choice end def ask_input_table_name input = nil loop do say("Input a table name.") say(">> ") input = gets.strip if input =~ /^[a-zA-Z0-9_]+$/ break else puts "Please enter a valid table name." end end input end end end end
Version data entries
9 entries across 9 versions & 1 rubygems