-
Notifications
You must be signed in to change notification settings - Fork 92
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# frozen_string_literal: true | ||
module Seedbank | ||
VERSION = '0.5.0' | ||
VERSION = '0.6.0' | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,13 +19,16 @@ 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| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
regex = Regexp.new('(?<=' + Seedbank.seeds_root + ')(.*)') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
path = regex.match directory | ||
environment = path[1] | ||
|
||
environment_dependencies = seed_tasks_matching(environment, Seedbank.matcher) | ||
|
||
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 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/TrailingWhitespace: Trailing whitespace detected. |
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
override_dependency << "db:seed:#{environment}" if defined?(Rails) && Rails.env == environment | ||
end | ||
|
There was a problem hiding this comment.
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.