Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multi-level directories #86

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ej2015
Copy link

@ej2015 ej2015 commented Jul 27, 2020

Would like to not restrict directory levels to one level only.

rails db:seed:development:default:cars # Load the seed data from db/seeds/development/default/cars.seeds.rb

Possible usecase: create tenant-specific rake tasks for multi-tenancy apps

glob_seed_files_matching('/*/').each do |directory|
environment = File.basename(directory)
glob_seed_files_matching('**/*/').each do |directory|
regex = Regexp.new('(?<=' + Seedbank.seeds_root + ')(.*)')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@@ -19,8 +19,10 @@ namespace :db do

# Glob through the directories under seeds_path and create a task for each adding it to the dependency list.
# Then create a task for the environment
glob_seed_files_matching('/*/').each do |directory|
environment = File.basename(directory)
glob_seed_files_matching('**/*/').each do |directory|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.


name = environment.split("/").select(&:present?).join(":")
desc "Load the seed data from db/seeds.rb, db/seeds/#{Seedbank.matcher} and db/seeds#{environment}#{Seedbank.matcher}."
task name => ['db:seed:common'] + environment_dependencies

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.


desc "Load the seed data from db/seeds.rb, db/seeds/#{Seedbank.matcher} and db/seeds/#{environment}/#{Seedbank.matcher}."
task environment => ['db:seed:common'] + environment_dependencies

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingWhitespace: Trailing whitespace detected.

@@ -1,4 +1,4 @@
# frozen_string_literal: true
module Seedbank
VERSION = '0.5.0'
VERSION = '0.6.0'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants