Skip to content

Commit fec03ce

Browse files
committed
tmp for debug
1 parent c63e24d commit fec03ce

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

lib/seedbank/dsl.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,32 @@ def override_seed_task(*args)
1111
end
1212

1313
def seed_tasks_matching(*pattern)
14-
glob_seed_files_matching(*pattern)
14+
tasks = glob_seed_files_matching(*pattern)
1515
.sort
1616
.map { |seed_file| seed_task_from_file(seed_file) }
17+
18+
# binding.pry
19+
tasks
1720
end
1821

1922
def seed_task_from_file(seed_file)
2023
scopes = scope_from_seed_file(seed_file)
2124
suffix = Seedbank.matcher.gsub(/\A\*/, '')
2225
fq_name = scopes.push(File.basename(seed_file, suffix)).join(':')
2326

24-
define_seed_task(seed_file, fq_name)
27+
task_name = define_seed_task(seed_file, fq_name)
28+
# binding.pry
29+
task_name
2530
end
2631

2732
def glob_seed_files_matching(*args, &block)
28-
Dir.glob(File.join(seeds_root, *args), &block)
33+
files = Dir.glob(File.join(seeds_root, *args), &block)
34+
# binding.pry
35+
files
2936
end
3037

3138
def define_seed_task(seed_file, *args)
39+
# binding.pry
3240
task = Rake::Task.define_task(*args) do |seed_task|
3341
runner.evaluate(seed_task, seed_file) if File.exist?(seed_file)
3442
end
@@ -37,6 +45,7 @@ def define_seed_task(seed_file, *args)
3745

3846
task.add_description "Load the seed data from #{relative_file}"
3947
add_environment_dependency(task)
48+
# binding.pry
4049
task.name
4150
end
4251

lib/seedbank/runner.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ def let!(name, &block)
4949
def evaluate(seed_task, seed_file)
5050
@_seed_task = seed_task
5151
instance_eval(File.read(seed_file), seed_file)
52+
rescue Errno::EISDIR => e
53+
binding.pry
54+
raise e
5255
end
5356
end
5457
end

lib/tasks/seed.rake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace :db do
1010
# Create seed tasks for all the seeds in seeds_path and add them to the dependency
1111
# list along with the original db/seeds.rb.
1212
common_dependencies = seed_tasks_matching(Seedbank.matcher)
13+
# binding.pry
1314

1415
# Only add the original seeds if db/seeds.rb exists.
1516
if original_seeds_file
@@ -22,7 +23,9 @@ namespace :db do
2223

2324
# Glob through the directories under seeds_path and create a task for each adding it to the dependency list.
2425
# Then create a task for the environment
26+
# binding.pry
2527
glob_seed_files_matching('/*/').each do |directory|
28+
# binding.pry
2629
environment = File.basename(directory)
2730

2831
environment_dependencies = seed_tasks_matching(environment, Seedbank.matcher)
@@ -34,6 +37,8 @@ namespace :db do
3437
end
3538
end
3639

40+
# binding.pry
41+
3742
# Override db:seed to run all the common and environments seeds plus the original db:seed.
3843
desc %(Load the seed data from db/seeds.rb, db/seeds/#{Seedbank.matcher} and db/seeds/ENVIRONMENT/#{Seedbank.matcher}.
3944
ENVIRONMENT is the current Rails.env.)

0 commit comments

Comments
 (0)