Sha256: 9c38e6ded5e38d6e8f4046aa96fd581a9bd1f6eb78d0cf1c227c8e1112f7c5ef

Contents?: true

Size: 709 Bytes

Versions: 7

Compression:

Stored size: 709 Bytes

Contents

require 'fileutils'
require 'ggem/template'

module GGem
  class Gem

    attr_reader :root_path, :name

    def initialize(path, name)
      @root_path = path
      self.name = name
    end

    def name=(name)
      @name = name.gsub(/([A-Z])([a-z])/, '-\1\2').sub(/^-/, '').downcase
    end

    def module_name
      @module_name ||= transform_name {|part| part.capitalize }
    end
    def ruby_name
      @ruby_name ||= transform_name('_') {|part| part.downcase }
    end

    def save
      Template.new(self).save
    end

    private

    def transform_name(glue = nil, &block)
      self.name.split(/[_-]/).collect do |part|
        yield part if block_given?
      end.join(glue)
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ggem-1.1.4 lib/ggem/gem.rb
ggem-1.1.3 lib/ggem/gem.rb
ggem-1.1.2 lib/ggem/gem.rb
ggem-1.1.1 lib/ggem/gem.rb
ggem-1.1.0 lib/ggem/gem.rb
ggem-1.0.1 lib/ggem/gem.rb
ggem-1.0.0 lib/ggem/gem.rb