Coder Social home page Coder Social logo

flect's Introduction

Buffalo Documentation

gobuffalo.io

This is the repository for https://www.gobuffalo.io, the official website of the Buffalo ecosystem.

This documentation contains:

Contributing

Contributing to this documentation site is a great, and easy, way to help make Buffalo better!

Note that this repository is only about Buffalo ecosystem documentation. If you want to contribute to the ecosystem itself, please refer to the concerned repository:

See the contribution guide for more info about how to contribute.

flect's People

Contributors

atomicnibble avatar breml avatar brycahta avatar divan avatar dmuriel avatar duckbrain avatar grdryn avatar jh125486 avatar lukasschlueter avatar markbates avatar mclark4386 avatar mschneider82 avatar paganotoni avatar pgier avatar renathoaz avatar sio4 avatar stanislas-m avatar stephenbrown2 avatar timorunge avatar tsmith1024 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flect's Issues

Tableize: underscore before pluralize

Due to the complexity of the English language, it seems that Pluralize may sometimes not preserve the capital cases in a name (as shown by this issue: #20).

Due to this fact, it would be safer for Tableize to perform Underscore() before Pluralize() (affected line of code here).

For example, if I have a struct named "BigPerson", I would expect that tableized name to be "big_people". Currently, Tableize("BigPerson") -> "bigpeople", because the Pluralize step does not preserve the capital P. Underscoring first would produce the expected "big_people" result.

Pluralization and capitalization issues

Pluralize() should in theory pluralize a name while maintaining the cases. For example, FooBar -> FooBars.

However, there are a few cases where the pluralization produces unintentional lowercasing.

  1. Half -> halves
    It seems that when the whole word matches an item in the singularToPlural map, the entire word gets converted in lowercase. On the contrary, this seems to behave correctly when a singular word is attached to another one, such as the case of LemonHalf -> LemonHalves.

  2. SmartPerson -> Smartpeople
    It seems that when the suffix matches one of the pluralRules, the entire matched portion remains lowercase.

  3. SuperbOx -> Superboxes
    It seems that camel-casing is not respected for breaking up words. In fact, the pluralRules seem to be applied first (box -> boxes) before the singularToPlural rules (ox -> oxen). In fact, it seems that when ox is attached to another word, it will never be changed to oxen (example: big_ox -> big_oxes).

Overall, having consistent behavior here is important as this package is used by gobuffalo/pop for auto-generating table names from camel-case structs. Happy to help discuss potential solutions!

Remove envy dependency

Bringing over markbates/inflect#12. See the previous conversation from @bep.

Is this package intended to be used by the wider Go community? I appreciate that Buffalo likely wants the existing auto-env-loading functionality, but this feature and dependency are unnecessary side-effects for non-Buffalo projects.

Resource generation with wrong name

Description

When generating a human resource, it generate all as humans, except for the .fizz files which keeps generating humens

If this is a feature request, explain why it should be added. Specific use-cases are best.

For bug reports, please provide as much relevant info as possible.

Steps to Reproduce the Problem

Please describe in painful detail what you did (so others can play along with you) to get to this point. This includes things like the exact command(s) you used, or the curl command you used, that sort of thing.

  1. Go into a buffalo project
  2. Run buffalo generate resource human name

Expected Behavior

Generate all of the resource as humans instead of humens in .fizz files

What did you what to happen? Tell us a story. We love to read.

Actual Behavior

Generate the plural of human as humens in .fizz files

Info

Buffalo Version

v0.13.2

App Information

Pwd=/tmp/inflect
Root=/tmp/inflect
GoPath=/home/ricardoseriani/dev/go
Name=inflect
Bin=bin/inflect
PackagePkg=github.com/markbates/inflect
ActionsPkg=github.com/markbates/inflect/actions
ModelsPkg=github.com/markbates/inflect/models
GriftsPkg=github.com/markbates/inflect/grifts
VCS=git
WithPop=false
WithSQLite=false
WithDep=false
WithWebpack=false
WithYarn=false
WithDocker=false
WithGrifts=false
WithModules=true

Go Version

go version go1.11.1 linux/amd64

Go Env

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ricardoseriani/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/ricardoseriani/dev/go"
GOPROXY=""
GORACE=""
GOROOT="/home/ricardoseriani/bin/go"
GOTMPDIR=""
GOTOOLDIR="/home/ricardoseriani/bin/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/inflect/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build763771968=/tmp/go-build -gno-record-gcc-switches"

Node Version

v8.12.0

NPM Version

6.4.1

Yarn Version

1.10.1

PostgreSQL Version

PostgreSQL Not Found

MySQL Version

MySQL Not Found

SQLite Version

3.11.0 2016-02-15 17:29:24 3d862f207e3adc00f78066799ac5a8c282430a5f

Dep Version

could not find a Gopkg.toml file

Dep Status

could not find a Gopkg.toml file

go.mod

module github.com/markbates/inflect

require (
github.com/gobuffalo/envy v1.6.5
github.com/stretchr/testify v1.2.2
)

bug: Singular form of "invoices" is "invoice"

Description

Description

The singular form of "invoices" is "invoice". Similar words are "voices" -> "voice" and "choices" -> "choice". Flect.Singularize() does not return the correct singular form of these words. As a side note, flect.Pluralize() does return the proper plural form of the singular form of these words.

Expected Behavior

flect.Singularize("invoices") == "invoice"
flect.Singularize("voices") == "voice"
flect.Singularize("choices") == "choice"

Actual Behavior

flect.Singularize("invoices") == "invoex"
flect.Singularize("voices") == "voex"
flect.Singularize("choices") == "choex"

To Reproduce

No response

Additional Context

No response

Folder produces inconsistent results

Description

v0.14.0-beta.2

When using an underscore in the name of a resource the generator creates a wrong directory structure inside of templates/.

Steps to Reproduce the Problem character

  1. buffalo generate resource electronic_store name web

Expected Behavior

├── electronic_stores
│       ├── edit.html
│       ├── _form.html
│       ├── index.html
│       ├── new.html
│       └── show.html

Actual Behavior

├── electronic
│   └── stores
│       ├── edit.html
│       ├── _form.html
│       ├── index.html
│       ├── new.html
│       └── show.html

Info

### Buffalo Version
v0.14.0-beta.2

### App Information
Pwd=/home/tobante/go/src/github.com/tobiashienzsch/shoppinger_data_manager
Root=/home/tobante/go/src/github.com/tobiashienzsch/shoppinger_data_manager
GoPath=/home/tobante/go
PackagePkg=github.com/tobiashienzsch/shoppinger_data_manager
ActionsPkg=github.com/tobiashienzsch/shoppinger_data_manager/actions
ModelsPkg=github.com/tobiashienzsch/shoppinger_data_manager/models
GriftsPkg=github.com/tobiashienzsch/shoppinger_data_manager/grifts
WithModules=true
Name=shoppinger-data-manager
Bin=bin/shoppinger-data-manager
VCS=git
WithPop=true
WithSQLite=false
WithDep=false
WithWebpack=true
WithNodeJs=false
WithYarn=true
WithDocker=false
WithGrifts=false
AsWeb=true
AsAPI=false

### Go Version
go version go1.11.4 linux/amd64

### Go Env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/tobante/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/tobante/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/tobante/go/src/github.com/tobiashienzsch/shoppinger_data_manager/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build032577947=/tmp/go-build -gno-record-gcc-switches"

### Node Version
v10.15.0

### NPM Version
6.4.1

### Yarn Version
1.12.3

### PostgreSQL Version
PostgreSQL Not Found

### MySQL Version
MySQL Not Found

### SQLite Version
3.22.0 2018-01-22 18:45:57 0c55d179733b46d8d0ba4d88e01a25e10677046ee3da1d5b1581e86726f2alt1

### Dep Version
could not find a Gopkg.toml file

### Dep Status
could not find a Gopkg.toml file

### go.mod
module github.com/tobiashienzsch/shoppinger_data_manager

require (
        github.com/codegangsta/negroni v1.0.0 // indirect
        github.com/gobuffalo/buffalo v0.14.0-beta.2
        github.com/gobuffalo/buffalo-pop v1.4.0
        github.com/gobuffalo/envy v1.6.11
        github.com/gobuffalo/makr v1.1.5 // indirect
        github.com/gobuffalo/mw-csrf v0.0.0-20180802151833-446ff26e108b
        github.com/gobuffalo/mw-forcessl v0.0.0-20180802152810-73921ae7a130
        github.com/gobuffalo/mw-i18n v0.0.0-20181027200759-09e0c99be4d3
        github.com/gobuffalo/mw-paramlogger v0.0.0-20181005191442-d6ee392ec72e
        github.com/gobuffalo/packr v1.21.9
        github.com/gobuffalo/packr/v2 v2.0.0-rc.14
        github.com/gobuffalo/pop v4.9.4+incompatible
        github.com/gobuffalo/suite v2.6.0+incompatible
        github.com/gobuffalo/uuid v2.0.5+incompatible
        github.com/gobuffalo/validate v2.0.3+incompatible
        github.com/jackc/pgx v3.3.0+incompatible // indirect
        github.com/jmoiron/sqlx v1.2.0 // indirect
        github.com/markbates/grift v1.0.5
        github.com/pkg/errors v0.8.1
        github.com/unrolled/secure v0.0.0-20190103195806-76e6d4e9b90c
)

feature: Support verb inflection

Description

It would be nice if this package also supported singlular/plural verb inflection. For example "There is/are".

BTW, this Perl package is a great reference implementation for all forms of inflection - https://metacpan.org/dist/Lingua-EN-Inflexion

It not only handles verb plurals, but also tenses and adjectives.

Additional Information

No response

Humanize capitalization inconsistency

Humanize() is working differently than in github.com/markbates/inflect:

package main

import (
	"fmt"
	"github.com/gobuffalo/flect"
	"github.com/markbates/inflect"
)

func main() {
	fmt.Println("github.com/markbates/inflect: ", inflect.Humanize("MyCamel"))
	fmt.Println("github.com/gobuffalo/flect: ", flect.Humanize("MyCamel"))
}

yields:

github.com/markbates/inflect:  My camel
github.com/gobuffalo/flect:  My Camel

This isn't conforming to the documented behavior, which says

Humanize returns first letter of sentence capitalized employee_salary = Employee salary employee_id = employee ID employee_mobile_number = Employee mobile number"

Replace an existing rule

AddPlural doesn't replace an existing rule but append it to the list.

let's say I want replace suffix: "o" to "os".

When call pluralize it won't achieve this new rule, 'cause it is in the end of the list,
so pluralize will do the default one {"o", "oes"} first and return.

is there any possibility to change it ? when add new rule if it exists replace it.

Resource Named Param and Routes change after upgrade

Description

Resource Named Routes and Named Parameters change after upgrade from 0.14 to 0.16.8. also reproducible on brand new app generated from scratch
probably matches a list of reserved names but it would nice to know that list

on new initialized app it's not really a problem but on existing app (I have a nested resource under Devices)

  1. it needs a lot of refactoring and
  2. pop "BelongsTo" call seems to ignore the customized "fk_id" tag. and looks for "devex_id" instead of "device_id" for the nested resource, I guess that would be more a bug for pop than buffalo. the only work around is either hardcode a where query or a Eager query.

here a very plain simple out-of-the-box simulation showing/reproducing the problem, I'm happy to post more in comments later to avoid confusion

Steps to Reproduce the Problem

  1. create new app buffalo new whatever --db-type sqlite3
  2. create resource devices buffalo g resource devices
  3. migrations buffalo pop migrate up
  4. check routes: buffalo routes

Expected Behavior

METHOD | PATH                      | ALIASES | NAME           | HANDLER
------ | ----                      | ------- | ----           | -------
GET    | /                         |         | rootPath       | whatever/actions.HomeHandler
GET    | /devices/                 |         | devicesPath    | whatever/actions.DevicesResource.List
POST   | /devices/                 |         | devicesPath    | whatever/actions.DevicesResource.Create
GET    | /devices/new/             |         | newDevicesPath | whatever/actions.DevicesResource.New
GET    | /devices/{device_id}/      |         | devicePath      | whatever/actions.DevicesResource.Show
PUT    | /devices/{device_id}/      |         | devicePath      | whatever/actions.DevicesResource.Update
DELETE | /devices/{device_id}/      |         | devicePath      | whatever/actions.DevicesResource.Destroy
GET    | /devices/{device_id}/edit/ |         | editDevicePath  | whatever/actions.DevicesResource.Edit

Actual Behavior

METHOD | PATH                      | ALIASES | NAME           | HANDLER
------ | ----                      | ------- | ----           | -------
GET    | /                         |         | rootPath       | whatever/actions.HomeHandler
GET    | /devices/                 |         | devicesPath    | whatever/actions.DevicesResource.List
POST   | /devices/                 |         | devicesPath    | whatever/actions.DevicesResource.Create
GET    | /devices/new/             |         | newDevicesPath | whatever/actions.DevicesResource.New
GET    | /devices/{devex_id}/      |         | devexPath      | whatever/actions.DevicesResource.Show
PUT    | /devices/{devex_id}/      |         | devexPath      | whatever/actions.DevicesResource.Update
DELETE | /devices/{devex_id}/      |         | devexPath      | whatever/actions.DevicesResource.Destroy
GET    | /devices/{devex_id}/edit/ |         | editDevexPath  | whatever/actions.DevicesResource.Edit

Info

Please run buffalo info and paste the information below where it says "PASTE_HERE".

-> Go: Checking installation
✓ The `go` executable was found on your system at: /home/toby/bin/go

-> Go: Checking minimum version requirements
✓ Your version of Go, 1.14.2, meets the minimum requirements.

-> Go: Checking Package Management
✓ You are using Go Modules (`go`) for package management.

-> Go: Checking PATH
✘ Your PATH (/home/mitico/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin) does not contain /home/toby/go/bin.

Without /home/mitico/go/bin in your `PATH` any Go executables can not be run globally.

For help setting up your Go environment please follow the instructions for you platform at:

https://www.gopherguides.com/courses/preparing-your-environment-for-go-development

-> Node: Checking installation
✓ The `node` executable was found on your system at: /home/mitico/bin/node

-> Node: Checking minimum version requirements
✓ Your version of Node, v13.10.1, meets the minimum requirements.

-> NPM: Checking installation
✓ The `npm` executable was found on your system at: /home/mitico/bin/npm

-> NPM: Checking minimum version requirements
✓ Your version of NPM, 6.14.2, meets the minimum requirements.

-> Yarn: Checking installation
✓ The `yarnpkg` executable was found on your system at: /home/mitico/bin/yarnpkg

-> Yarn: Checking minimum version requirements
✓ Your version of Yarn, 1.22.4, meets the minimum requirements.

-> PostgreSQL: Checking installation
✘ The `postgres` executable could not be found on your system.
For help setting up your Postgres environment please follow the instructions for you platform at:

https://www.postgresql.org/download/

-> MySQL: Checking installation
✘ The `mysql` executable could not be found on your system.
For help setting up your MySQL environment please follow the instructions for you platform at:

https://www.mysql.com/downloads/

-> SQLite3: Checking installation
✓ The `sqlite3` executable was found on your system at: /usr/bin/sqlite3

-> SQLite3: Checking minimum version requirements
✓ Your version of SQLite3, 3.29.0, meets the minimum requirements.

-> Cockroach: Checking installation
✘ The `cockroach` executable could not be found on your system.
For help setting up your Cockroach environment please follow the instructions for you platform at:

https://www.cockroachlabs.com/docs/stable/

-> Buffalo (CLI): Checking installation
✓ The `buffalo` executable was found on your system at: /home/toby/bin/buffalo

-> Buffalo (CLI): Checking minimum version requirements
✓ Your version of Buffalo (CLI), v0.16.8, meets the minimum requirements.

-> Buffalo: Application Details
Pwd         /home/mitico/whatever
Root        /home/mitico/whatever
GoPath      /home/mitico/go
PackagePkg  whatever
ActionsPkg  whatever/actions
ModelsPkg   whatever/models
GriftsPkg   whatever/grifts
WithModules true
Name        whatever
Bin         bin/whatever
VCS         git
WithPop     true
WithSQLite  true
WithDep     false
WithWebpack true
WithNodeJs  true
WithYarn    true
WithDocker  true
WithGrifts  true
AsWeb       true
AsAPI       false
InApp       true
PackageJSON {map[build:webpack -p --progress dev:webpack --watch]}

-> Buffalo: config/buffalo-app.toml
name = "whatever"
bin = "bin/whatever"
vcs = "git"
with_pop = true
with_sqlite = true
with_dep = false
with_webpack = true
with_nodejs = true
with_yarn = true
with_docker = true
with_grifts = true
as_web = true
as_api = false

-> Buffalo: config/buffalo-plugins.toml
[[plugin]]
  binary = "buffalo-pop"
  go_get = "github.com/gobuffalo/buffalo-pop/v2"
  tags = ["sqlite"]

-> Buffalo: go.mod
module whatever

go 1.14

require (
        github.com/gobuffalo/buffalo v0.15.5
        github.com/gobuffalo/buffalo-pop/v2 v2.0.6
        github.com/gobuffalo/envy v1.9.0
        github.com/gobuffalo/mw-csrf v0.0.0-20190129204204-25460a055517
        github.com/gobuffalo/mw-forcessl v0.0.0-20180802152810-73921ae7a130
        github.com/gobuffalo/mw-i18n v0.0.0-20190129204410-552713a3ebb4
        github.com/gobuffalo/mw-paramlogger v0.0.0-20190129202837-395da1998525
        github.com/gobuffalo/packr/v2 v2.8.0
        github.com/gobuffalo/pop/v5 v5.1.1
        github.com/gobuffalo/validate/v3 v3.1.0
        github.com/gobuffalo/x v0.0.0-20190224155809-6bb134105960
        github.com/gofrs/uuid v3.2.0+incompatible
        github.com/markbates/grift v1.5.0
        github.com/unrolled/secure v0.0.0-20190103195806-76e6d4e9b90c
)

Generating a "pepsi" resource doesn't produce the desired outcome

Description

When I try to generate a "pepsi" resource in a new buffalo app, the generator sometimes generates the proper names "pepsi/pepsis", and sometimes it generates "pepse/pepses".

METHOD PATH NAME HANDLER
GET / rootPath coke/actions.HomeHandler
GET /pepsis/ pepsisPath coke/actions.PepsisResource.List
POST /pepsis/ pepsisPath coke/actions.PepsisResource.Create
GET /pepsis/new/ newPepsisPath coke/actions.PepsisResource.New
GET /pepsis/{pepse_id}/ pepsePath coke/actions.PepsisResource.Show
PUT /pepsis/{pepse_id}/ pepsePath coke/actions.PepsisResource.Update
DELETE /pepsis/{pepse_id}/ pepsePath coke/actions.PepsisResource.Destroy
GET /pepsis/{pepse_id}/edit/ editPepsePath coke/actions.PepsisResource.Edit

These inconsistencies are also present in the code of the generated actions, for example:

// List gets all Pepsis. This function is mapped to the path
// GET /pepsis
func (v PepsisResource) List(c buffalo.Context) error {
  // Get the DB connection from the context
  tx, ok := c.Value("tx").(*pop.Connection)
  if !ok {
    return fmt.Errorf("no transaction found")
  }

  pepses := &models.Pepsis{}

Steps to Reproduce the Problem

  1. Generate a new buffalo app with buffalo new dummyapp, and set it up
  2. Inside your new app's folder run buffalo generate resource pepsi
  3. Check the generated code, or start your app in development mode, and try to create a new pepsi entry

Expected Behaviour

"Pepsi" is a weird word, but pluralizing it does make sense, in my opinion, probably as "pepsis", but in any case, I would expect the generator to produce consistent naming and functional codde.

Actual Behaviour

The naming is inconsistent and some routes are broken.

Info

Please run buffalo info and paste the information below where it says "PASTE_HERE".

-> Go: Checking installation
✓ The `go` executable was found on your system at: /snap/bin/go

-> Go: Checking minimum version requirements
✓ Your version of Go, 1.13.4, meets the minimum requirements.

-> Go: Checking GOPATH
✓ You are using Go Modules, so no need to worry about the GOPATH.

-> Go: Checking Package Management
✓ You are using Go Modules (`go`) for package management.

-> Go: Checking PATH
✓ Your PATH contains /home/mladen/go/bin.

-> Node: Checking installation
✓ The `node` executable was found on your system at: /home/mladen/.nvm/versions/node/v13.5.0/bin/node

-> Node: Checking minimum version requirements
✓ Your version of Node, v13.5.0, meets the minimum requirements.

-> NPM: Checking installation
✓ The `npm` executable was found on your system at: /home/mladen/.nvm/versions/node/v13.5.0/bin/npm

-> NPM: Checking minimum version requirements
✓ Your version of NPM, 6.13.7, meets the minimum requirements.

-> Yarn: Checking installation
✓ The `yarnpkg` executable was found on your system at: /home/mladen/.nvm/versions/node/v13.5.0/bin/yarnpkg

-> Yarn: Checking minimum version requirements
✓ Your version of Yarn, 1.21.1, meets the minimum requirements.

-> PostgreSQL: Checking installation
✘ The `postgres` executable could not be found on your system.
For help setting up your Postgres environment please follow the instructions for you platform at:

https://www.postgresql.org/download/

-> MySQL: Checking installation
✓ The `mysql` executable was found on your system at: /usr/bin/mysql

-> MySQL: Checking minimum version requirements
✓ Your version of MySQL, 14.14, meets the minimum requirements.

-> SQLite3: Checking installation
✓ The `sqlite3` executable was found on your system at: /usr/bin/sqlite3

-> SQLite3: Checking minimum version requirements
✓ Your version of SQLite3, 3.22.0, meets the minimum requirements.

-> Cockroach: Checking installation
✘ The `cockroach` executable could not be found on your system.
For help setting up your Cockroach environment please follow the instructions for you platform at:

https://www.cockroachlabs.com/docs/stable/

-> Buffalo (CLI): Checking installation
✓ The `buffalo` executable was found on your system at: /usr/local/bin/buffalo

-> Buffalo (CLI): Checking minimum version requirements
✓ Your version of Buffalo (CLI), v0.15.3, meets the minimum requirements.

-> Buffalo: Application Details
Pwd         /home/mladen/Projects/BuffaloTest/coke
Root        /home/mladen/Projects/BuffaloTest/coke
GoPath      /home/mladen/go
PackagePkg  coke
ActionsPkg  coke/actions
ModelsPkg   coke/models
GriftsPkg   coke/grifts
WithModules true
Name        coke
Bin         bin/coke
VCS         git
WithPop     true
WithSQLite  false
WithDep     false
WithWebpack true
WithNodeJs  true
WithYarn    true
WithDocker  true
WithGrifts  true
AsWeb       true
AsAPI       false
InApp       true
PackageJSON {map[build:webpack -p --progress dev:webpack --watch]}

-> Buffalo: config/buffalo-app.toml
name = "coke"
bin = "bin/coke"
vcs = "git"
with_pop = true
with_sqlite = false
with_dep = false
with_webpack = true
with_nodejs = true
with_yarn = true
with_docker = true
with_grifts = true
as_web = true
as_api = false

-> Buffalo: config/buffalo-plugins.toml
[[plugin]]
  binary = "buffalo-pop"
  go_get = "github.com/gobuffalo/buffalo-pop"

-> Buffalo: go.mod
module coke

go 1.13

require (
	github.com/gobuffalo/buffalo v0.15.3
	github.com/gobuffalo/buffalo-pop v1.23.1
	github.com/gobuffalo/envy v1.8.1
	github.com/gobuffalo/mw-csrf v0.0.0-20190129204204-25460a055517
	github.com/gobuffalo/mw-forcessl v0.0.0-20180802152810-73921ae7a130
	github.com/gobuffalo/mw-i18n v0.0.0-20190129204410-552713a3ebb4
	github.com/gobuffalo/mw-paramlogger v0.0.0-20190129202837-395da1998525
	github.com/gobuffalo/packr/v2 v2.7.1
	github.com/gobuffalo/pop v4.13.1+incompatible
	github.com/gobuffalo/suite v2.8.2+incompatible
	github.com/gobuffalo/validate v2.0.3+incompatible
	github.com/gofrs/uuid v3.2.0+incompatible
	github.com/markbates/grift v1.5.0
	github.com/stretchr/testify v1.4.0
	github.com/unrolled/secure v0.0.0-20190103195806-76e6d4e9b90c
)

Flect translating Field into Fieldren

Flect seems to be translating some words wrongly. If I use v0.2.0 user_custom_field plural gets translated to user_custom_fieldren instead of user_custom_fields. It works with v0.1.7.

I noticed this behavior with pop queries:

SELECT user_custom_fieldren.created_at, user_custom_fieldren.custom_field_id, user_custom_fieldren.id, user_custom_fieldren.updated_at, user_custom_fieldren.user_id, user_custom_fieldren.value FROM user_custom_fieldren AS user_custom_fieldren WHERE user_id = $1

Pluralization issues with `Fleet`

Problem

Fleet is not being pluralized to Fleets.

Repro Steps

  • add {"fleet", "fleets"}, to flect_test.go
  • run make test:
--- FAIL: Test_Pluralize (0.00s)
    --- FAIL: Test_Pluralize/fleet (0.00s)
        pluralize_test.go:13: 
                Error Trace:    pluralize_test.go:13
                Error:          Not equal: 
                                expected: "fleets"
                                actual  : "fleet"
                            
                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1 +1 @@
                                -fleets
                                +fleet
                Test:           Test_Pluralize/fleet
--- FAIL: Test_PluralizeWithSize (0.01s)
    --- FAIL: Test_PluralizeWithSize/fleet (0.00s)
        pluralize_test.go:23: 
                Error Trace:    pluralize_test.go:23
                Error:          Not equal: 
                                expected: "fleets"
                                actual  : "fleet"
                            
                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1 +1 @@
                                -fleets
                                +fleet
                Test:           Test_PluralizeWithSize/fleet
--- FAIL: Test_Singularize (0.00s)
    --- FAIL: Test_Singularize/fleet (0.00s)
        singularize_test.go:14: 
                Error Trace:    singularize_test.go:14
                Error:          Not equal: 
                                expected: "fleet"
                                actual  : "floot"
                            
                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1 +1 @@
                                -fleet
                                +floot
                Test:           Test_Singularize/fleet
--- FAIL: Test_SingularizeWithSize (0.01s)
    --- FAIL: Test_SingularizeWithSize/fleet (0.00s)
        singularize_test.go:24: 
                Error Trace:    singularize_test.go:24
                Error:          Not equal: 
                                expected: "fleets"
                                actual  : "fleet"
                            
                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1 +1 @@
                                -fleets
                                +fleet
                Test:           Test_SingularizeWithSize/fleet
FAIL

Package side-effects

Importing flect causes the surprising ("magical" per Peter Bourgon) side-effects referenced below. Could these side effects be removed? They seem like an implementation detail that ought to be left up to the caller.

flect/custom_data.go

Lines 13 to 16 in d4fc286

func init() {
loadCustomData("inflections.json", "INFLECT_PATH", "could not read inflection file", LoadInflections)
loadCustomData("acronyms.json", "ACRONYMS_PATH", "could not read acronyms file", LoadAcronyms)
}

Related to #16.

bug: words ending with -da are not pluralized

Description

Description

Words ending with -da, like andromeda or veranda are not pluralized

Expected Behavior

flect.Pluralize("andromeda") -> andromedas

Actual Behavior

flect.Pluralize("andromeda")-> andromeda

To Reproduce

No response

Additional Context

Details

I'm using github.com/gobuffalo/flect v1.0.2 in a go.mod file

bug: flect behaves poorly on the string DNS which pluralizes to dnsDNSes

Description

Description

Consider the example program:

package main

import (
	"fmt"
	"github.com/gobuffalo/flect"
)

func main() {

	orig := "CNS"
	result := flect.Pluralize(orig)
	fmt.Printf("plural of %s is: %s\n", orig, result)

	orig = "cns"
	result = flect.Pluralize(orig)
	fmt.Printf("plural of %s is: %s\n", orig, result)

	orig = "DNS"
	result = flect.Pluralize(orig)
	fmt.Printf("plural of %s is: %s\n", orig, result)

	orig = "dns"
	result = flect.Pluralize(orig)
	fmt.Printf("plural of %s is: %s\n", orig, result)

	orig = "ENS"
	result = flect.Pluralize(orig)
	fmt.Printf("plural of %s is: %s\n", orig, result)

	orig = "ens"
	result = flect.Pluralize(orig)
	fmt.Printf("plural of %s is: %s\n", orig, result)
}

Which will output:

plural of CNS is: CNSes
plural of cns is: cns
plural of DNS is: DNSes
plural of dns is: dnsDNSes
plural of ENS is: ENSes
plural of ens is: ens

Expected Behavior

I expect "dns" to behave the same as cns and ens to become dns NOT dnsDNSes

Actual Behavior

dns becomes dnsDNSes which doesn't seem correct and isn't the same as other similar 3 character strings.
Yes, DNS is the acronym for Domain Name System, but its plural should not result in lower case followed by uppercase right?

To Reproduce

Build the given go program using the latest release of flect
Run the program and observe the output to stdout

My test go.mod file is:

module flect-test

go 1.22.1

require github.com/gobuffalo/flect v1.0.2

Additional Context

Details: my example go.mod file is

module flect-test

go 1.22.1

require github.com/gobuffalo/flect v1.0.2

Which shows the flect version a v1.0.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.