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, #failed!, register, #successful?

Methods included from Actions

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

Constructor Details

#initialize(working_path, options) ⇒ StampPattern

Returns a new instance of StampPattern.



68
69
70
# File 'lib/compass/commands/stamp_pattern.rb', line 68

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

Class Method Details

.description(command) ⇒ Object



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

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

.option_parser(arguments) ⇒ Object



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

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



44
45
46
47
48
49
# File 'lib/compass/commands/stamp_pattern.rb', line 44

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

.parse_arguments!(parser, arguments) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/compass/commands/stamp_pattern.rb', line 50

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



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

def usage
  option_parser([]).to_s
end

Instance Method Details

#is_project_creation?Boolean

Returns:

  • (Boolean)


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

def is_project_creation?
  false
end

#performObject

all commands must implement perform



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

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

#template_directory(pattern) ⇒ Object



84
85
86
# File 'lib/compass/commands/stamp_pattern.rb', line 84

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