<commit_before>package soda

import (
	"github.com/gobuffalo/makr"
	sg "github.com/gobuffalo/pop/soda/cmd/generate"
)

// Run the soda generator
func (sd Generator) Run(root string, data makr.Data) error {
	g := makr.New()
	defer g.Fmt(root)

	should := func(data makr.Data) bool {
		return sd.App.WithPop
	}

	f := makr.NewFile("models/models.go", nModels)
	f.Should = should
	g.Add(f)

	f = makr.NewFile("models/models_test.go", nModelsTest)
	f.Should = should
	g.Add(f)

	f = makr.NewFile("grifts/db.go", nSeedGrift)
	f.Should = should
	g.Add(f)

	c := makr.NewCommand(makr.GoGet("github.com/gobuffalo/pop/..."))
	c.Should = should
	g.Add(c)

	g.Add(&makr.Func{
		Should: should,
		Runner: func(rootPath string, data makr.Data) error {
			data["dialect"] = sd.Dialect
			return sg.GenerateConfig("./database.yml", data)
		},
	})

	return g.Run(root, data)
}

const nModels = `package models

import (
	"log"

	"github.com/gobuffalo/envy"
	"github.com/gobuffalo/pop"
)

// DB is a connection to your database to be used
// throughout your application.
var DB *pop.Connection

func init() {
	var err error
	env := envy.Get("GO_ENV", "development")
	DB, err = pop.Connect(env)
	if err != nil {
		log.Fatal(err)
	}
	pop.Debug = env == "development"
}<commit_msg>Fix soda GenerateConfig deprecation (#1166)<commit_after>package soda

import (
	"github.com/gobuffalo/makr"
	"github.com/gobuffalo/pop/soda/cmd/generate"
)

// Run the soda generator
func (sd Generator) Run(root string, data makr.Data) error {
	g := makr.New()
	defer g.Fmt(root)

	should := func(data makr.Data) bool {
		return sd.App.WithPop
	}

	f := makr.NewFile("models/models.go", nModels)
	f.Should = should
	g.Add(f)

	f = makr.NewFile("models/models_test.go", nModelsTest)
	f.Should = should
	g.Add(f)

	f = makr.NewFile("grifts/db.go", nSeedGrift)
	f.Should = should
	g.Add(f)

	c := makr.NewCommand(makr.GoGet("github.com/gobuffalo/pop/..."))
	c.Should = should
	g.Add(c)

	g.Add(&makr.Func{
		Should: should,
		Runner: func(rootPath string, data makr.Data) error {
			data["dialect"] = sd.Dialect
			return generate.Config("./database.yml", data)
		},
	})

	return g.Run(root, data)
}

const nModels = `package models

import (
	"log"

	"github.com/gobuffalo/envy"
	"github.com/gobuffalo/pop"
)

// DB is a connection to your database to be used
// throughout your application.
var DB *pop.Connection

func init() {
	var err error
	env := envy.Get("GO_ENV", "development")
	DB, err = pop.Connect(env)
	if err != nil {
		log.Fatal(err)
	}
	pop.Debug = env == "development"
}
{'fraction_non_alphanumeric': 0.15901060070671377, 'fraction_numerical': 0.0015704750687082843, 'mean_word_length': 3.6496350364963503, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2607297', 'n_tokens_mistral': 1094, 'n_tokens_neox': 1013, 'n_words': 223}