Class: Compass::Commands::CreateProject

Inherits:
StampPattern show all
Defined in:
lib/compass/commands/create_project.rb

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 inherited from StampPattern

#initialize, #perform, #template_directory

Methods included from InstallerCommand

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

Methods inherited from ProjectBase

#execute, #initialize

Methods inherited from Base

#execute, #failed!, #initialize, #perform, register, #successful?

Methods included from Actions

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

Constructor Details

This class inherits a constructor from Compass::Commands::StampPattern

Class Method Details

.description(command) ⇒ Object



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

def description(command)
  if command.to_sym == :create
    "Create a new compass project"
  else
    "Add compass to an existing project"
  end
end

.option_parser(arguments) ⇒ Object



61
62
63
64
65
66
# File 'lib/compass/commands/create_project.rb', line 61

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

.parse!(arguments) ⇒ Object



82
83
84
85
86
87
88
89
90
91
# File 'lib/compass/commands/create_project.rb', line 82

def parse!(arguments)
  parser = option_parser(arguments)
  parse_options!(parser, arguments)
  parse_arguments!(parser, arguments)
  if parser.options[:framework] && parser.options[:bare]
    raise Compass::Error, "A bare project cannot be created when a framework is specified."
  end
  set_default_arguments(parser)
  parser.options
end

.parse_arguments!(parser, arguments) ⇒ Object



109
110
111
112
113
114
115
116
117
# File 'lib/compass/commands/create_project.rb', line 109

def parse_arguments!(parser, arguments)
  if arguments.size == 1
    parser.options[:project_name] = arguments.shift
  elsif arguments.size == 0
    # default to the current directory.
  else
    raise Compass::Error, "Too many arguments were specified."
  end
end

.parse_init!(arguments) ⇒ Object



93
94
95
96
97
98
99
100
101
102
# File 'lib/compass/commands/create_project.rb', line 93

def parse_init!(arguments)
  parser = option_parser(arguments)
  parse_options!(parser, arguments)
  if arguments.size > 0
    parser.options[:project_type] = arguments.shift.to_sym
  end
  parse_arguments!(parser, arguments)
  set_default_arguments(parser)
  parser.options
end

.parse_options!(parser, arguments) ⇒ Object



104
105
106
107
# File 'lib/compass/commands/create_project.rb', line 104

def parse_options!(parser, arguments)
  parser.parse!
  parser
end

.primaryObject



80
# File 'lib/compass/commands/create_project.rb', line 80

def primary; true; end

.set_default_arguments(parser) ⇒ Object



119
120
121
122
# File 'lib/compass/commands/create_project.rb', line 119

def set_default_arguments(parser)
  parser.options[:framework] ||= :compass
  parser.options[:pattern] ||= "project"
end

.usageObject



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

def usage
  option_parser([]).to_s
end

Instance Method Details

#is_project_creation?Boolean

Returns:

  • (Boolean)


125
126
127
# File 'lib/compass/commands/create_project.rb', line 125

def is_project_creation?
  true
end