inflections

package module
v0.0.0-...-cb98bfe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2014 License: BSD-3-Clause Imports: 2 Imported by: 19

README

Inflections for Go
------------------

Inflections for Go is a library for the Go language
that is similar in functionality to the Inflections
part of ActiveSupport that comes with the Rails 
project for the Ruby language. I was implementing a
Go interface for a database that is/was/will continue
to be managed by a Rails codebase. In order to do that
I had to make Go code thing like a Rails codebase.

Long term I want to fill out this library and have
close parity with the Rails code so that other 
programmers who also need this functionality will 
be able to use this library to serve a similar need.

Documentation

Overview

Inflections is a set of functions that duplicate the functions in the ActiveSupport::Inflector system from Rails. Some functions are wrappers around go stdlib functions, unless I realize the go stdlib has differing behavior than the ActiveSupport func, in which case the function here will try to mirror the AS version.

Note: Some functions are not mappable to Go functions, the current known functions are: constantize. Also the strange optional arguments available in the Rails functions are not available, if you actually need the optional arguments, please tell me your use case.

Index

Constants

This section is empty.

Variables

View Source
var UserDefinedInflections map[string]string

Functions

func CamelCase

func CamelCase(str string) string

func Camelize

func Camelize(str string) string

func Classify

func Classify(str string) string

func Dasherize

func Dasherize(str string) string

func Demodularize

func Demodularize(str string) string

func ForeignKey

func ForeignKey(thing interface{}) string

func Humanize

func Humanize(str string) string

func Paramterize

func Paramterize(instance interface{}) string

func Pluralize

func Pluralize(str string) string

NounPluralize is based on the algorithm described at www.csse.monash.edu.au/~damian/papers/HTML/Plurals.html It doesn't deal with classical pluralizations at the moment. It could have been based on Rails pluralize implementation, but that code is not clear due to the way it was implemented. It is only implemented for English.

func Singularize

func Singularize(str string) string

func Titlecase

func Titlecase(str string) string

func Titleize

func Titleize(str string) string

func Underscore

func Underscore(str string) string

This function will change a string from a camelcased form to a string with underscores. Will change "::" to "/" to maintain compatibility with Rails's underscore

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL