From 2c52a0864a8bc95cdaf19f042b6395ca9fff6ed0 Mon Sep 17 00:00:00 2001 From: Masafumi Koba Date: Sat, 12 May 2018 00:59:18 +0900 Subject: [PATCH] Add `QUIET` option to the rake task --- CHANGELOG.md | 7 +++++++ README.md | 3 ++- lib/tasks/seed_fu.rake | 7 +++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42b4a4a..0107012 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +Version 2.3.10 +------------- + +Features: + +* Add `QUIET` option to the rake task. + Version 2.3.8 ------------- diff --git a/README.md b/README.md index 72e17c2..88214af 100644 --- a/README.md +++ b/README.md @@ -109,10 +109,11 @@ When loading lots of records, the above block-based syntax can be quite verbose. Rake task --------- -Seed files can be run automatically using `rake db:seed_fu`. There are two options which you can pass: +Seed files can be run automatically using `rake db:seed_fu`. There are following options which you can pass: * `rake db:seed_fu FIXTURE_PATH=path/to/fixtures` -- Where to find the fixtures * `rake db:seed_fu FILTER=users,articles` -- Only run seed files with a filename matching the `FILTER` +* `rake db:seed_fu QUIET=true` -- Same effect as `SeedFu.quiet = true` You can also do a similar thing in your code by calling `SeedFu.seed(fixture_paths, filter)`. diff --git a/lib/tasks/seed_fu.rake b/lib/tasks/seed_fu.rake index 777d91c..5c04f8d 100644 --- a/lib/tasks/seed_fu.rake +++ b/lib/tasks/seed_fu.rake @@ -23,6 +23,9 @@ namespace :db do # to load files from RAILS_ROOT/features/fixtures rake db:seed_fu FIXTURE_PATH=features/fixtures + + # to disable output + rake db:seed_fu QUIET=true EOS task :seed_fu => :environment do if ENV["FILTER"] @@ -33,6 +36,10 @@ namespace :db do fixture_paths = [ENV["FIXTURE_PATH"], ENV["FIXTURE_PATH"] + '/' + Rails.env] end + if ENV["QUIET"] == "true" + SeedFu.quiet = true + end + SeedFu.seed(fixture_paths, filter) end end