Module: Gemma::Conventions

Defined in:
lib/gemma/conventions.rb

Overview

Methods to check input against accepted conventions.

For help on extensions:

General objectives for gemma:

  • follow and promote accepted conventions where obvious
  • make the outputs from rdoc, test, etc. work like they do in rubygems
  • avoid load path noise ($: << ...)
  • make it easy to start hacking on an existing gem that uses gemma
    • git clone ...
    • gem install bundle
    • bundle # install both gemma dependencies and the gem's dependencies
    • rake -T # should now work

Class Method Summary collapse

Class Method Details

.gem_name_to_module_name(gem_name) ⇒ String

Convert from underscore-lower-case form to camel-case form; hyphens are also converted to camel case.

Returns:

  • (String)


44
45
46
# File 'lib/gemma/conventions.rb', line 44

def self.gem_name_to_module_name(gem_name)
  gem_name.gsub(/(?:^|_|-)([a-z0-9])/) { Regexp.last_match(1).upcase }
end

.good_gem_name?(gem_name) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/gemma/conventions.rb', line 34

def self.good_gem_name?(gem_name)
  gem_name =~ /^[a-z0-9]+[a-z0-9_-]*$/
end