Class: Cellophane::Main

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = nil) ⇒ Main

Returns a new instance of Main.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cellophane/main.rb', line 13

def initialize(args = nil)
	args ||= ARGV
	@project_options_file = Cellophane::PROJECT_OPTIONS_FILE
	@options = Cellophane::Options.parse(args)
	
	@message = 'Invalid regular expression provided.' and return if @options[:regexp] && @options[:pattern].nil?
	
	parser = Cellophane::Parser.new(@options)
	@features = parser.features
	
	@message = 'No features matching PATTERN were found.' and return unless @features
	
	@tags = parser.tags
	
	@command = generate_command
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



11
12
13
# File 'lib/cellophane/main.rb', line 11

def command
  @command
end

#messageObject (readonly)

Returns the value of attribute message.



11
12
13
# File 'lib/cellophane/main.rb', line 11

def message
  @message
end

#project_options_fileObject (readonly)

Returns the value of attribute project_options_file.



11
12
13
# File 'lib/cellophane/main.rb', line 11

def project_options_file
  @project_options_file
end

Instance Method Details

#runObject



30
31
32
33
# File 'lib/cellophane/main.rb', line 30

def run
	puts @message and return if @message
	@options[:print] || @options[:version] ? puts(@command) : system("#{@command}\n\n")
end