Class: Command

Inherits:
Object
  • Object
show all
Includes:
PathCommon
Defined in:
lib/command.rb

Constant Summary

Constants included from PathCommon

PathCommon::CONFIG_FILE, PathCommon::PROJECT_DIR

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PathCommon

#absolute_path, #get_path, #join, #parse_string, #require_p

Constructor Details

#initialize(params) ⇒ Command

Returns a new instance of Command.



10
11
12
13
14
15
16
# File 'lib/command.rb', line 10

def initialize(params)
	@params = params
	get_template_dir
	get_target_dir
	get_classes
	get_operations
end

Instance Attribute Details

#base_nameObject

Returns the value of attribute base_name.



8
9
10
# File 'lib/command.rb', line 8

def base_name
  @base_name
end

#classesObject

Returns the value of attribute classes.



8
9
10
# File 'lib/command.rb', line 8

def classes
  @classes
end

#operationsObject

Returns the value of attribute operations.



8
9
10
# File 'lib/command.rb', line 8

def operations
  @operations
end

#target_dirObject

Returns the value of attribute target_dir.



8
9
10
# File 'lib/command.rb', line 8

def target_dir
  @target_dir
end

#template_dirObject

Returns the value of attribute template_dir.



8
9
10
# File 'lib/command.rb', line 8

def template_dir
  @template_dir
end

Instance Method Details

#get_classesObject



26
27
28
29
30
31
32
33
34
# File 'lib/command.rb', line 26

def get_classes
	classes = get_param("-c")
	if classes
	  @classes = parse_string( classes )
	else
	  @base_name = @params[1]
	  @classes = nil
	end
end

#get_operationsObject



35
36
37
# File 'lib/command.rb', line 35

def get_operations
	@operations = parse_string( operations = get_param("-op") || " " )
end

#get_target_dirObject



23
24
25
# File 'lib/command.rb', line 23

def get_target_dir
	@target_dir = absolute_path(get_param("-d") || ".")
end

#get_template_dirObject



17
18
19
20
21
22
# File 'lib/command.rb', line 17

def get_template_dir
	template = get_param("-t") || @params[0]
	get_templates(template).each do |dir|
	  @template_dir = dir if File.directory?(dir) 
	end
end