Sha256: 5303e48b728f60a41bcda320b715352547a6ba75d9c15efc578738f47d410419

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

module Vedeu

  module Generator

    module Helpers

      # @return [String]
      def app_name
        @app_name ||= File.read('./config/app_name')
      end

      # @param name [String]
      # @return [String]
      def app_name_as_snake_case(name = app_name)
        name.gsub!(/::/, '/')
        name.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
        name.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
        name.tr!('-', '_')
        name.downcase!
        name
      end

      # @param source [String]
      # @param destination [String]
      # @return [void]
      def make_file(source, destination)
        File.write(destination, parse(source))
      end

      # @return [String]
      def name
        @_name ||= @name.downcase
      end

      # @return [String]
      def name_as_class
        name.downcase.split(/_|-/).map(&:capitalize).join
      end

      # @param source [String]
      # @return [String]
      def parse(source)
        Vedeu::Template.parse(self, source)
      end

      # @return [String]
      def source
        File.dirname(__FILE__) + '/templates/application/.'
      end

    end # Helpers

  end # Generator

end # Vedeu

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.4.36 lib/vedeu/generator/helpers.rb