-
Notifications
You must be signed in to change notification settings - Fork 91
Enable to use customized file name #71
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
base: master
Are you sure you want to change the base?
Enable to use customized file name #71
Conversation
lib/tasks/seed.rake
Outdated
@@ -1,12 +1,16 @@ | |||
# frozen_string_literal: true | |||
require Rails.root.join('config', 'initializers', 'seedbank.rb') |
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.
lib/seedbank/runner.rb
Outdated
@@ -49,6 +49,9 @@ def let!(name, &block) | |||
def evaluate(seed_task, seed_file) | |||
@_seed_task = seed_task | |||
instance_eval(File.read(seed_file), seed_file) | |||
rescue Errno::EISDIR => e | |||
binding.pry |
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.
Lint/Debugger: Remove debugger entry point binding.pry.
lib/seedbank/dsl.rb
Outdated
task.name | ||
end | ||
|
||
def original_seeds_file | ||
@_seedbank_original ||= existent(Pathname.new('../seeds.rb').expand_path(seeds_root)) | ||
@_seedbank_original ||= existent(Pathname.new(Seedbank.original_seeds_file).expand_path(seeds_root)) |
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.
Naming/MemoizedInstanceVariableName: Memoized variable @_seedbank_original does not match method name original_seeds_file. Use @original_seeds_file instead.
fq_name = scopes.push(File.basename(seed_file, '.seeds.rb')).join(':') | ||
scopes = scope_from_seed_file(seed_file) | ||
suffix = Seedbank.matcher.gsub(/\A\*/, '') | ||
fq_name = scopes.push(File.basename(seed_file, suffix)).join(':') |
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.
scopes = scope_from_seed_file(seed_file) | ||
fq_name = scopes.push(File.basename(seed_file, '.seeds.rb')).join(':') | ||
scopes = scope_from_seed_file(seed_file) | ||
suffix = Seedbank.matcher.gsub(/\A\*/, '') |
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.
@@ -21,6 +21,10 @@ def nesting | |||
def matcher | |||
@matcher ||= '*.seeds.rb' | |||
end | |||
|
|||
def original_seeds_file | |||
@original_seeds_file ||= File.join(application_root, 'db', 'seeds.rb') |
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.
lib/tasks/seed.rake
Outdated
@@ -1,12 +1,16 @@ | |||
# frozen_string_literal: true | |||
require Rails.root.join('config', 'initializers', 'seedbank.rb') |
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.
lib/seedbank/runner.rb
Outdated
@@ -49,6 +49,9 @@ def let!(name, &block) | |||
def evaluate(seed_task, seed_file) | |||
@_seed_task = seed_task | |||
instance_eval(File.read(seed_file), seed_file) | |||
rescue Errno::EISDIR => e | |||
binding.pry |
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.
Lint/Debugger: Remove debugger entry point binding.pry.
lib/seedbank/dsl.rb
Outdated
task.name | ||
end | ||
|
||
def original_seeds_file | ||
@_seedbank_original ||= existent(Pathname.new('../seeds.rb').expand_path(seeds_root)) | ||
@_seedbank_original ||= existent(Pathname.new(Seedbank.original_seeds_file).expand_path(seeds_root)) |
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.
Naming/MemoizedInstanceVariableName: Memoized variable @_seedbank_original does not match method name original_seeds_file. Use @original_seeds_file instead.
fq_name = scopes.push(File.basename(seed_file, '.seeds.rb')).join(':') | ||
scopes = scope_from_seed_file(seed_file) | ||
suffix = Seedbank.matcher.gsub(/\A\*/, '') | ||
fq_name = scopes.push(File.basename(seed_file, suffix)).join(':') |
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.
scopes = scope_from_seed_file(seed_file) | ||
fq_name = scopes.push(File.basename(seed_file, '.seeds.rb')).join(':') | ||
scopes = scope_from_seed_file(seed_file) | ||
suffix = Seedbank.matcher.gsub(/\A\*/, '') |
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.
@@ -21,6 +21,10 @@ def nesting | |||
def matcher | |||
@matcher ||= '*.seeds.rb' | |||
end | |||
|
|||
def original_seeds_file | |||
@original_seeds_file ||= File.join(application_root, 'db', 'seeds.rb') |
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.
fec03ce
to
ee8ac53
Compare
lib/seedbank/dsl.rb
Outdated
task.name | ||
end | ||
|
||
def original_seeds_file | ||
@_seedbank_original ||= existent(Pathname.new('../seeds.rb').expand_path(seeds_root)) | ||
@_original_seeds_file ||= existent(Pathname.new(Seedbank.original_seeds_file).expand_path(seeds_root)) |
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.
Naming/MemoizedInstanceVariableName: Memoized variable @_original_seeds_file does not match method name original_seeds_file. Use @original_seeds_file instead.
test/lib/seedbank/dsl_test.rb
Outdated
|
||
describe 'in an environment directory' do | ||
let(:seeds_root) { '/my/seeds/directory' } | ||
let(:original_seeds_file) { '/my/original/seed_file.rb' } |
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.
test/lib/seedbank/dsl_test.rb
Outdated
subject { Seedbank::DSL.original_seeds_file } | ||
|
||
describe 'in an environment directory' do | ||
let(:seeds_root) { '/my/seeds/directory' } |
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.
test/lib/seedbank/dsl_test.rb
Outdated
describe 'original_seeds_file' do | ||
subject { Seedbank::DSL.original_seeds_file } | ||
|
||
describe 'in an environment directory' do |
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.
test/lib/seedbank/dsl_test.rb
Outdated
@@ -4,6 +4,19 @@ | |||
using Seedbank::DSL | |||
|
|||
describe Seedbank::DSL do | |||
describe 'original_seeds_file' do |
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.
569df14
to
7b274ce
Compare
let(:root) { '/my/seeds/directory' } | ||
|
||
it 'returns an expanded path name' do | ||
subject.must_equal Pathname.new('/my/seeds/seeds_original.rb') |
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.
let(:filename) { '../seeds_original.rb' } | ||
let(:root) { '/my/seeds/directory' } | ||
|
||
it 'returns an expanded path name' do |
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.
@@ -163,4 +163,15 @@ def define_prerequisite_task | |||
end | |||
end | |||
end | |||
|
|||
describe 'original_seeds_file_expanded' do |
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.
36f941b
to
689367d
Compare
@@ -1,6 +1,12 @@ | |||
# frozen_string_literal: true | |||
if defined?(Rails) | |||
initializer = Rails.root.join('config', 'initializers', 'seedbank.rb') |
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.
lib/seedbank/dsl.rb
Outdated
@@ -40,7 +41,7 @@ def define_seed_task(seed_file, *args) | |||
end | |||
|
|||
def original_seeds_file | |||
@_seedbank_original ||= existent(Pathname.new('../seeds.rb').expand_path(seeds_root)) | |||
@_original_seeds_file ||= existent(original_seeds_file_expanded(Seedbank.original_seeds_file, seeds_root)) |
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.
Naming/MemoizedInstanceVariableName: Memoized variable @_original_seeds_file does not match method name original_seeds_file. Use @original_seeds_file instead.
c4d966d
to
c0900aa
Compare
@@ -18,7 +18,7 @@ def setup | |||
Rake.application = Rake::Application.new | |||
Dummy::Application.load_tasks | |||
Object.const_set :FakeModel, MiniTest::Mock.new | |||
TOPLEVEL_BINDING.eval('self').send(:instance_variable_set, :@_seedbank_runner, Seedbank::Runner.new) | |||
TOPLEVEL_BINDING.eval('self').send(:instance_variable_set, :@runner, Seedbank::Runner.new) |
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.
c0900aa
to
1b021df
Compare
1b021df
to
1dc052b
Compare
@@ -10,15 +10,15 @@ | |||
|
|||
Rails.backtrace_cleaner.remove_silencers! | |||
|
|||
Seedbank.application_root = Pathname.new(File.expand_path('../dummy', __FILE__)) | |||
Seedbank.application_root = Pathname.new(File.expand_path('dummy', __dir__)) |
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.
subject { original_seeds_file_expanded(filename, root) } | ||
|
||
let(:filename) { '../seeds_original.rb' } | ||
let(:root) { '/my/seeds/directory' } |
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.
describe 'original_seeds_file_expanded' do | ||
subject { original_seeds_file_expanded(filename, root) } | ||
|
||
let(:filename) { '../seeds_original.rb' } |
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.
|
||
Rake::Task[task_name].full_comment.must_equal description | ||
it 'must be empty' do |
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.
|
||
Seedbank::DSL.override_seed_task(task_name => dependencies) | ||
it 'returns an array' do |
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.
let(:seed_file) { File.expand_path('development/shared/accounts.seeds.rb', Seedbank.seeds_root) } | ||
let(:seed_namespace) { %w[development shared] } | ||
|
||
it 'returns the nested scope' do |
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.
end | ||
|
||
describe 'in a nested directory' do | ||
let(:seed_file) { File.expand_path('development/shared/accounts.seeds.rb', Seedbank.seeds_root) } |
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.
end | ||
end | ||
|
||
describe 'in a nested directory' do |
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.
let(:seed_file) { File.expand_path('development/users.seeds.rb', Seedbank.seeds_root) } | ||
let(:seed_namespace) { %w[development] } | ||
|
||
it 'returns the enviroment scope' do |
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.
|
||
Rake::Task[task_name].prerequisite_tasks.must_equal expected_dependencies | ||
describe 'in an environment directory' do | ||
let(:seed_file) { File.expand_path('development/users.seeds.rb', Seedbank.seeds_root) } |
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.
@nard-tech Sorry for the slow response, I've not had much time recently. This looks good, I'll have a more thorough look at start to build a new release shortly. |
@james2m Sorry for the slow response, too. |
Please check this PR after #72.
After this PR merged we can use customized file names by overriding
Seedbank.original_seeds_file