Class: Rubyfox::Server::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/rubyfox/server/cli.rb

Defined Under Namespace

Classes: WrongVersionError

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



13
14
15
# File 'lib/rubyfox/server/cli.rb', line 13

def self.source_root
  Rubyfox::Server.data_dir
end

Instance Method Details

#configure(target_dir, template_dir) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rubyfox/server/cli.rb', line 29

def configure(target_dir, template_dir)
  template_dir = File.expand_path(template_dir, Dir.pwd)
  target_dir = File.expand_path(target_dir, Dir.pwd)

  verify_version(template_dir)

  Dir["#{template_dir}/**/*"].each do |file|
    if File.file?(file)
      part = file.partition(template_dir).last
      target_file = "#{target_dir}/#{part}"
      if file_plain?(file)
        template file, target_file
      else
        copy_file file, target_file
      end
    end
  end
rescue WrongVersionError => e
  STDERR.puts e.message
end

#install(target_dir) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/rubyfox/server/cli.rb', line 19

def install(target_dir)
  if File.exist?(target_dir)
    abort "Directory #{target_dir} already exists!"
  end

  directory self.class.source_root, target_dir
end

#start(target_dir) ⇒ Object



54
55
56
57
58
# File 'lib/rubyfox/server/cli.rb', line 54

def start(target_dir)
  inside(target_dir) do
    system "sh ./sfs2x.sh"
  end
end

#versionObject



62
63
64
# File 'lib/rubyfox/server/cli.rb', line 62

def version
  puts Rubyfox::Server::VERSION
end