Sha256: c662a815452bb243b7e71172d3f74057db89957021b50e821d4d00f55e2fd685

Contents?: true

Size: 1.97 KB

Versions: 8

Compression:

Stored size: 1.97 KB

Contents

#!/usr/bin/env ruby

require 'fileutils'

TARGET_DIR = File.join( FileUtils.pwd, "Frank" )
SOURCE_DIR = File.join( File.dirname(__FILE__), '..', 'frank-skeleton' )

command = ARGV[0]

unless ["update-server",nil].include? command
  puts "unrecognized command #{command}"
  puts "the only valid command at the moment is update-server"
  exit 10
end

update_mode = ARGV[0] == 'update-server'

def create_skeleton_dir
  puts "I'm about to create a subdirectory called Frank which will contain the Frank server files and also your Cucumber tests. Please hit return to confirm that's what you want."
  exit 3 unless STDIN.gets.chomp == ''

  FileUtils.mkdir_p( TARGET_DIR )
  FileUtils.cp_r( Dir.glob( SOURCE_DIR+"/*" ), TARGET_DIR )

  puts <<-EOS
  Frank subdirectory created.
  Your next step is to create a Frankified target for your app, and add the libFrank.a and frank_static_resources.bundle files inside the Frank directory to that target.
  After that, you can build the target and try executing 'cucumber' from the Frank directory to see how your initial cucumber test runs.
  EOS
end

def update_server_files
  source_files = %w{libFrank.a frank_static_resources.bundle}.map{ |x| File.join( SOURCE_DIR, x ) }
  FileUtils.cp_r( source_files, TARGET_DIR )
  puts "All done. I've updated libFrank.a and frank_static_resources.bundle inside #{TARGET_DIR}"
end

frank_dir_already_exists = File.exists?( TARGET_DIR ) 

if frank_dir_already_exists && !update_mode
  puts "A Frank subdirectory already exists. I don't want to mess with that. \n\nIf you want me to update the frank server code in that directory then run `frank-skeleton update-server`"
  exit 1
elsif !frank_dir_already_exists && update_mode
  puts "There isn't a Frank subdirectory here for me to update.\n\nIf you want to create a new Frank subdirectory containing the Frank server code and an initial Cucumber setup then you should run `frank-skeleton` with no arguments"
  exit 2
end

if update_mode
  update_server_files
else
  create_skeleton_dir
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
frank-cucumber-0.8.5 bin/frank-skeleton
frank-cucumber-0.8.4 bin/frank-skeleton
frank-cucumber-0.8.3 bin/frank-skeleton
frank-cucumber-0.8.2 bin/frank-skeleton
frank-cucumber-0.8.1 bin/frank-skeleton
frank-cucumber-0.8.0 bin/frank-skeleton
frank-cucumber-0.7.8 bin/frank-skeleton
frank-cucumber-0.7.7 bin/frank-skeleton