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

Enable to use customized file name #71

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

nard-tech
Copy link
Contributor

@nard-tech nard-tech commented Apr 28, 2018

Please check this PR after #72.

After this PR merged we can use customized file names by overriding Seedbank.original_seeds_file

@@ -1,12 +1,16 @@
# frozen_string_literal: true
require Rails.root.join('config', 'initializers', 'seedbank.rb')

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.

@@ -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

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.

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))

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(':')

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\*/, '')

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')

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.

@@ -1,12 +1,16 @@
# frozen_string_literal: true
require Rails.root.join('config', 'initializers', 'seedbank.rb')

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.

@@ -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

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.

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))

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(':')

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\*/, '')

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')

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 nard-tech force-pushed the feature/enable-to-customize-filename branch from fec03ce to ee8ac53 Compare April 28, 2018 16:38
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))

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.


describe 'in an environment directory' do
let(:seeds_root) { '/my/seeds/directory' }
let(:original_seeds_file) { '/my/original/seed_file.rb' }

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 { Seedbank::DSL.original_seeds_file }

describe 'in an environment directory' do
let(:seeds_root) { '/my/seeds/directory' }

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' do
subject { Seedbank::DSL.original_seeds_file }

describe 'in an environment directory' do

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.

@@ -4,6 +4,19 @@
using Seedbank::DSL

describe Seedbank::DSL do
describe 'original_seeds_file' do

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 nard-tech force-pushed the feature/enable-to-customize-filename branch from 569df14 to 7b274ce Compare April 28, 2018 17:52
let(:root) { '/my/seeds/directory' }

it 'returns an expanded path name' do
subject.must_equal Pathname.new('/my/seeds/seeds_original.rb')

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

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

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 nard-tech force-pushed the feature/enable-to-customize-filename branch 2 times, most recently from 36f941b to 689367d Compare April 28, 2018 18:15
@@ -1,6 +1,12 @@
# frozen_string_literal: true
if defined?(Rails)
initializer = Rails.root.join('config', 'initializers', 'seedbank.rb')

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.

@@ -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))

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.

@nard-tech nard-tech force-pushed the feature/enable-to-customize-filename branch 3 times, most recently from c4d966d to c0900aa Compare April 28, 2018 18:22
@@ -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)

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 nard-tech force-pushed the feature/enable-to-customize-filename branch from c0900aa to 1b021df Compare April 28, 2018 18:23
@nard-tech nard-tech force-pushed the feature/enable-to-customize-filename branch from 1b021df to 1dc052b Compare May 6, 2018 06:33
@@ -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__))

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' }

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' }

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

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

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

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) }

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

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

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) }

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 nard-tech changed the title [WIP] Enable to use customized file name Enable to use customized file name May 6, 2018
@nard-tech nard-tech mentioned this pull request May 6, 2018
@james2m
Copy link
Owner

james2m commented Jun 27, 2018

@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 james2m added this to the 1.0 milestone Jun 27, 2018
@nard-tech
Copy link
Contributor Author

@james2m Sorry for the slow response, too.
Thanks you for merging my PR. I am expecting the release of v1.0.0. Thank you.

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.

None yet

3 participants