james2m / seedbank

Seedbank gives your seed data a little structure. Create seeds for each environment, share seeds between environments and specify dependencies to load your seeds in order. All nicely integrated with simple rake tasks.
MIT License
1.14k stars 92 forks source link

Use with Sinatra or Padrino? #53

Open pmackay opened 8 years ago

pmackay commented 8 years ago

I dont think seedbank is currently supported for these. Has it ever been considered? Would you have a few tips on what it might require?

james2m commented 8 years ago

Aside from the railtie and some use of rails root in default initialisation it's not dependent on rails. The tests show how to override the default path so you should be able to use it just by setting the seeds_path.

I'm away from keyboard right now so there is an iirc attached to this reply.

james2m commented 8 years ago

There are a couple of places this is dependent on Rails.root, I've tiptoed towards removing them in master, but would happily take pull requests to finish the job.

ivanovaleksey commented 8 years ago

@james2m I would try to make PR if you don't mind. But I don't know much about them gem internals so I need some time.

james2m commented 8 years ago

Hey @ivanovaleksey master has some changes to make this easier. The main thing is get all references to Rails.root out of the code and just let the railtie.rb set the root.

ivanovaleksey commented 8 years ago

Thank you James! I will try to make it.

ivanovaleksey commented 8 years ago

James I have found in TODO.txt

Add generator for seeds directories

I know we can write Rails generator but if we make the gem framework agnostic (as you have wrote in TODO) would we still be able to make such generator for other frameworks?

james2m commented 8 years ago

I wasn't really thinking about the rails generator as such, and the todo pre-dates generators moving into the rails command, I was just thinking of a simple rake task to create the directories probably db/seeds, db/seeds/development, db/seeds/test & db/seeds/production

ivanovaleksey commented 8 years ago

I see. Yeah some thing for fast start would be nice. If I solve this issue it would the next thing to do :relaxed:

wiggly commented 7 years ago

Just tried using it in a grape/rom app I am building and realised it was Rails specific.

Would love to have this Rails/AR agnostic.

Looking forward to Aleksey's PR getting merged.

james2m commented 7 years ago

@wiggly @ivanovaleksey sorry I've been busy moving. I'm back on things this week. I'll finally get to look at the pull requests.

james2m commented 7 years ago

@wiggly you should be able to use in your grape app now thanks to @ivanovaleksey, I don't have any non rails apps to test with, and we haven't got a stand alone environment in the test suite yet, so it would be good to hear how you get on with master.

wiggly commented 7 years ago

So, I have already started using @ivanovaleksey's PR code and it works for me.

I haven't yet played with different environments yet but the basics work and it doesn't trip up due to dependencies on Rails.

I will use master now instead and let you know if anything breaks but I don't expect it to.

I am using the http://rom-rb.org/ system for DB access, once I have tested it using correct seeds for different environments I could try and make a small example.

Right now all I am doing it extending the Seedbank::Runner class with a custome module that allows easy access to the ROM repositories I have set up.

james2m commented 7 years ago

@wiggly @ivanovaleksey I've rolled this up into a 0.5.0.pre version.

wiggly commented 7 years ago

So, yeah, master also works fine as expected.

One question is whether you have thought about what to do about system enviornments. Since you can't rely on RAILS_ENV.

Right now I am building things from the ground up and I have my own env var to flag things that should be configured differently on an environment basis. Perhaps a Seedbank.env that could be set by users to choose the current environment? Then get the railtie to set this using Rails.env and allow others to set it in their own setup phases.

james2m commented 7 years ago

That's an interesting point. I was thinking about pulling all the rails specific stuff out into its own module and letting that setup it's own prerequisites. I like the idea of Seedbank.env. @ivanovaleksey any thoughts on this?

ivanovaleksey commented 7 years ago

Sorry for the delay. I can't really tell anything which about that 😞 The idea of Seedbank.env seems to be nice for me too.

As I understand now the gem doesn't include any environment task in override_dependency list because of this, does it?

wiggly commented 7 years ago

So, I submitted a PR to enhance the rake tasks to allow people to set up their specific DB layer before the seeds get run, I could also take a shot at adding a way for people to easily select environments that is system-agnostic.

@ivanovaleksey Yes, that is exactly what would stop this right now.

james2m commented 7 years ago

@wiggly thanks, I'll give it a poke over the weekend