Class: Compass::Commands::StampPattern

Inherits:
ProjectBase show all
Includes:
InstallerCommand
Defined in:
lib/compass/commands/stamp_pattern.rb

Direct Known Subclasses

CreateProject

Instance Attribute Summary

Attributes inherited from ProjectBase

#options, #project_name

Attributes inherited from Base

#options, #working_path

Attributes included from Actions

#logger

Class Method Summary collapse

Instance Method Summary collapse

Methods included from InstallerCommand

#app, #configure!, #installer, #installer_args

Methods inherited from ProjectBase

#execute

Methods inherited from Base

#execute, register

Methods included from Actions

#basename, #compile, #copy, #directory, #process_erb, #relativize, #remove, #separate, #strip_trailing_separator, #write_file

Constructor Details

#initialize(working_path, options) ⇒ StampPattern

Returns a new instance of StampPattern.



64
65
66
# File 'lib/compass/commands/stamp_pattern.rb', line 64

def initialize(working_path, options)
  super(working_path, options)
end

Class Method Details

.description(command) ⇒ Object



37
38
39
# File 'lib/compass/commands/stamp_pattern.rb', line 37

def description(command)
  "Install an extension's pattern into your compass project"
end

.option_parser(arguments) ⇒ Object



28
29
30
31
32
33
# File 'lib/compass/commands/stamp_pattern.rb', line 28

def option_parser(arguments)
  parser = Compass::Exec::CommandOptionParser.new(arguments)
  parser.extend(Compass::Exec::GlobalOptionsParser)
  parser.extend(Compass::Exec::ProjectOptionsParser)
  parser.extend(StampPatternOptionsParser)
end

.parse!(arguments) ⇒ Object



40
41
42
43
44
45
# File 'lib/compass/commands/stamp_pattern.rb', line 40

def parse!(arguments)
  parser = option_parser(arguments)
  parser.parse!
  parse_arguments!(parser, arguments)
  parser.options
end

.parse_arguments!(parser, arguments) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/compass/commands/stamp_pattern.rb', line 46

def parse_arguments!(parser, arguments)
  if arguments.size == 0
    raise OptionParser::ParseError, "Please specify a pattern."
  end
  pattern = arguments.shift.split('/', 2)
  parser.options[:framework] = pattern[0]
  parser.options[:pattern] = pattern[1]
  if arguments.size > 0
    parser.options[:project_name] = arguments.shift
  end
  if arguments.size > 0
    raise OptionParser::ParseError, "Unexpected trailing arguments: #{arguments.join(" ")}"
  end
end

.usageObject



34
35
36
# File 'lib/compass/commands/stamp_pattern.rb', line 34

def usage
  option_parser([]).to_s
end

Instance Method Details

#is_project_creation?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/compass/commands/stamp_pattern.rb', line 76

def is_project_creation?
  false
end

#performObject

all commands must implement perform



69
70
71
72
73
74
# File 'lib/compass/commands/stamp_pattern.rb', line 69

def perform
  installer.init
  installer.run(:skip_finalization => true)
  UpdateProject.new(working_path, options).perform if installer.compilation_required?
  installer.finalize(:create => is_project_creation?)
end

#template_directory(pattern) ⇒ Object



80
81
82
# File 'lib/compass/commands/stamp_pattern.rb', line 80

def template_directory(pattern)
  File.join(framework.templates_directory, pattern)
end