Class: Gravityframework::Installer

Inherits:
Object
  • Object
show all
Defined in:
lib/gravityframework.rb

Instance Method Summary collapse

Constructor Details

#initialize(args, libdir) ⇒ Installer

Class for installing creating a new project in the current directory



9
10
11
12
13
14
# File 'lib/gravityframework.rb', line 9

def initialize(args, libdir)
	@project_name = args[0]
	@current = Dir.pwd
	@lib = libdir
	args.index("--scss") ? @scss = true : @scss = false
end

Instance Method Details

#copyFilesObject



28
29
30
31
# File 'lib/gravityframework.rb', line 28

def copyFiles
	FileUtils.cp_r "#{@lib}/gravityframework/src/.", "#{@current}/#{@project_name}/"
	message("New project #{@project_name} successfully created in #{@current}/#{@project_name}/")
end

#createObject



33
34
35
36
37
38
39
40
41
# File 'lib/gravityframework.rb', line 33

def create()
	STDOUT.puts "You selected SCSS option" if @scss
	unless File.directory?(@project_name)
		makeDir(@project_name)
		copyFiles()
	else
		message("That project already exists. Please try another name")
	end
end

#error(string) ⇒ Object



16
17
18
# File 'lib/gravityframework.rb', line 16

def error(string)
	STDERR.puts string
end

#makeDir(name) ⇒ Object



24
25
26
# File 'lib/gravityframework.rb', line 24

def makeDir(name)
	Dir.mkdir(@current + '/' + name)
end

#message(string) ⇒ Object



20
21
22
# File 'lib/gravityframework.rb', line 20

def message(string)
	STDOUT.puts string
end