Class: Cf::Form
Overview
:nodoc: all
Instance Method Summary collapse
Methods included from Config
#config_file, #find_home, #get_api_key, #load_config, #save_config, #set_api_key, #set_target_uri
Instance Method Details
#generate ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/cf/cli/form.rb', line 49 def generate line_destination = Dir.pwd unless File.exist?("#{line_destination}/line.yml") say("The current directory is not a valid line directory.", :red) and return end FileUtils.rm_rf("#{line_destination}/station_#{[:station]}", :verbose => true) if .force? && Dir.exist?("#{line_destination}/station_#{[:station]}") if Dir.exist?("#{line_destination}/station_#{[:station]}") say "Skipping the form generation because the station_#{[:station]} already exists with its custom form.\nUse the -f flag to force it to overwrite or check and delete the station_#{[:station]} folder manually.", :red else say "Generating form for station #{[:station]}", :green Cf::Newform.start([[:station], [:labels], [:fields]]) say "A new custom task form created in station_#{[:station]}." end end |
#preview ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/cf/cli/form.rb', line 67 def preview line_destination = Dir.pwd unless File.exist?("#{line_destination}/line.yml") say("The current directory is not a valid line directory.", :red) and return end if Dir.exist?("#{line_destination}/station_#{[:station]}") and !Dir["#{line_destination}/station_#{[:station]}/*"].empty? say "Generating preview form for station #{[:station]}", :green form_content = File.read("station_#{[:station]}/form.html") Cf::FormPreview.start([[:station], form_content]) else say "No form exists for station #{[:station]}", :red say "Generate the form for station 2 and then preview it.", :red end end |