Skip to content

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.

# 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.

# 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.

2 participants