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

[WiP] global.seeds.rb prereq file support #70

Closed
wants to merge 1 commit into from

Conversation

swrobel
Copy link

@swrobel swrobel commented Apr 16, 2018

Intended to fix #68 but clearly this was much more difficult than I anticipated. Hoping you can bring it over the finish line w/ your knowledge of how this all works.

@@ -66,7 +66,7 @@ def setup
end

it 'is dependent on only the common seeds' do
prerequisite_seeds = self.class.glob_dummy_seeds.sort.map do |seed_file|
prerequisite_seeds = ['db:seed:global'] + self.class.glob_dummy_seeds.sort.map do |seed_file|

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.

task environment => ['db:seed:common'] + environment_dependencies

override_dependency << "db:seed:#{environment}" if defined?(Rails) && Rails.env == environment
end
end

# Override db:seed to run all the common and environments seeds plus the original db:seed.
desc %(Load the seed data from db/seeds.rb, db/seeds/#{Seedbank.matcher} and db/seeds/ENVIRONMENT/#{Seedbank.matcher}.
desc %(Load the seed data from db/global.seeds.rb, db/seeds.rb, db/seeds/#{Seedbank.matcher} and db/seeds/ENVIRONMENT/#{Seedbank.matcher}.

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [140/132]

@@ -24,15 +24,15 @@ namespace :db do

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}."
desc "Load the seed data from db/global.seeds.rb, db/seeds.rb, db/seeds/#{Seedbank.matcher} and db/seeds/#{environment}/#{Seedbank.matcher}."

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [147/132]

def add_global_dependency(task)
if global_seeds_file
define_seed_task(global_seeds_file)
task.enhance(['db:seed_global'])

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.

task.name
end

def original_seeds_file
@_seedbank_original ||= existent(Pathname.new('../seeds.rb').expand_path(seeds_root))
end

def global_seeds_file
@_seedbank_global ||= existent(Pathname.new('../global.seeds.rb').expand_path(seeds_root))

Choose a reason for hiding this comment

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

Naming/MemoizedInstanceVariableName: Memoized variable @_seedbank_global does not match method name global_seeds_file. Use @global_seeds_file instead.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@swrobel swrobel closed this Dec 2, 2019
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.

Force common/setup to run before any individual seed
2 participants