Module: SinatraToTheMoon::Project
- Defined in:
- lib/sinatra_to_the_moon/project.rb
Constant Summary collapse
- NAME_PATTERN =
/\A[a-z][a-z0-9_-]*\z/- PROFILES =
%w[web minimal api graphql].freeze
Class Method Summary collapse
Class Method Details
.constant_name(name) ⇒ Object
24 25 26 |
# File 'lib/sinatra_to_the_moon/project.rb', line 24 def constant_name(name) name.split(/[-_]/).map(&:capitalize).join end |
.validate_name!(name) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/sinatra_to_the_moon/project.rb', line 10 def validate_name!(name) return name if NAME_PATTERN.match?(name) raise InvalidProjectNameError, "Project name must start with a lowercase letter and contain only " \ "lowercase letters, numbers, dashes, or underscores" end |
.validate_profile!(profile) ⇒ Object
18 19 20 21 22 |
# File 'lib/sinatra_to_the_moon/project.rb', line 18 def validate_profile!(profile) return profile if PROFILES.include?(profile) raise UnknownProfileError, "Unknown profile #{profile.inspect}. Choose: #{PROFILES.join(', ')}" end |