Sha256: 5843a67043720367db79c426ce4b69bdfaf96355e36f382a880a69480e0f4ded
Contents?: true
Size: 1.9 KB
Versions: 1
Compression:
Stored size: 1.9 KB
Contents
#!/usr/bin/env ruby require 'rubygems' require 'sinatra-s3' if ARGV.any? { |arg| %w(--version -v).any? { |flag| arg == flag } } puts "Sinatra-S3 #{S3::VERSION}" exit 0 end if ARGV.any? { |arg| %w(--help -h).any? { |flag| arg == flag } } puts "sinatra-s3 [options] install_dir\n\n" puts " --version -v Get version string" puts " --help -h this" puts " --include-wiki installs sinatra-s3 with wiki support" exit 0 end $APP_PATH = ARGV.last def check_install(file,data) file_path = File.join($APP_PATH, file) if File.exists?(file_path) if Digest::MD5.hexdigest(data) == Digest::MD5.hexdigest(File.read(file_path)) install_msg("identical",file) else if ['y','a',''].include?(verify_overwrite(file).downcase) File.open(file_path,"w") { |f| f.write(data) } install_msg("force",file) else install_msg("skip",file) end end else install_msg("create", file) File.open(file_path,"w") { |f| f.write(data) } end end def install_msg(status, msg) print status.rjust(10) + " #{msg}\n" end def verify_overwrite(file) return 'a' if $SKIP_INSTALL_VERIFY print "overwrite #{file} [Yna] " resp = STDIN.gets.chomp $SKIP_INSTALL_VERIFY = true if resp.downcase == "a" resp = verify_overwrite(file) unless ['y','n','a',''].include?(resp.downcase) resp end FileUtils.mkdir_p($APP_PATH) FileUtils.mkdir_p(File.join($APP_PATH, "public")) config_ru = "require 'rubygems'\nrequire 'sinatra-s3'" if ARGV.any? { |arg| %w(--include-wiki --wiki).any? { |flag| arg == flag } } check_install("wiki.rb", File.read(File.join(S3::ROOT_DIR,"examples","wiki.rb"))) config_ru += "\nrequire 'wiki'" end config_ru += "\n\nuse S3::Tracker if defined?(RubyTorrent)\nuse S3::Admin\nrun S3::Application" check_install("config.ru", config_ru) check_install("Rakefile", "require 'sinatra-s3/tasks'") check_install("s3.yml", File.read(File.join(S3::ROOT_DIR,"s3.yml.example")))
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sinatra-s3-0.99 | bin/sinatra-s3 |