Class: Lion::Installer

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

Instance Method Summary collapse

Constructor Details

#initialize(args, libdir) ⇒ Installer

Class for installing creating a new project in the current directory



7
8
9
10
11
12
# File 'lib/lion/installer.rb', line 7

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



26
27
28
29
# File 'lib/lion/installer.rb', line 26

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

#createObject



31
32
33
34
35
36
37
38
39
# File 'lib/lion/installer.rb', line 31

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



14
15
16
# File 'lib/lion/installer.rb', line 14

def error(string)
	STDERR.puts string
end

#makeDir(name) ⇒ Object



22
23
24
# File 'lib/lion/installer.rb', line 22

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

#message(string) ⇒ Object



18
19
20
# File 'lib/lion/installer.rb', line 18

def message(string)
	STDOUT.puts string
end