Module: EasyStart

Defined in:
lib/easy_start.rb,
lib/easy_start/version.rb

Constant Summary collapse

VERSION =
"0.1.2"

Class Method Summary collapse

Class Method Details

.add(project) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/easy_start.rb', line 5

def self.add(project)
	base_data = {'project_name' => '', 'project_path' => ''}		
	base_data.each do |key,value|	
		loop do 
			base_data[key] = project[key]
			unless base_data[key].present?
				puts "Enter #{key}"
				input = gets.chomp
				base_data[key] = input					
			end
			break if base_data[key].present?
		end
	end
	create_script base_data
end

.create_directory_if_not_foundObject



28
29
30
31
32
33
# File 'lib/easy_start.rb', line 28

def self.create_directory_if_not_found
	directory_path = File.join(File.dirname(__FILE__), "../scripts")
	unless File.directory?(directory_path)
		Dir.mkdir directory_path
	end
end

.create_script(base_data) ⇒ Object



21
22
23
24
25
26
# File 'lib/easy_start.rb', line 21

def self.create_script base_data
	create_directory_if_not_found	
	file_path = File.join(File.dirname(__FILE__), "../scripts/#{base_data['project_name']}.sh")
	File.open(file_path, 'w') {|f| f.write("ROOT_PATH=\"#{base_data['project_path']}\"\n" + ) }
	system "chmod 755 #{file_path}"
end

.launch(name, branch = '') ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/easy_start.rb', line 35

def self.launch(name,branch='')		
	begin
		file_path = File.join(File.dirname(__FILE__), "../scripts/#{name}.sh")
		a = system "#{file_path}",(branch || '') 
	rescue SystemExit, Interrupt
		exit 0
	rescue Exception => e
	  puts e
	end	
end

.meta_dataObject



46
47
48
# File 'lib/easy_start.rb', line 46

def self.
	['cd "$ROOT_PATH"','if [ -n "$1" ]; then','git checkout $1','git pull','fi','rails s'].join("\n")
end