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

Simple shared directory via config #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/sprig/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
module Sprig
class Configuration

attr_writer :directory, :logger
attr_writer :directory, :logger, :shared_directory

def directory
Rails.root.join(@directory || default_directory, Rails.env)
Rails.root.join(@directory || default_directory, source_directory)
end

def shared_directory
@shared_directory
end

def logger
Expand All @@ -13,6 +17,10 @@ def logger

private

def source_directory
shared_directory || Rails.env
end

def default_directory
'db/seeds'
end
Expand Down
13 changes: 13 additions & 0 deletions spec/lib/sprig/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
end
end

describe "#shared_directory" do
it "returns nil by default" do
expect(subject.shared_directory).to be_nil
end

it "returns a shared directory" do
subject.shared_directory = 'shared'
subject.directory = 'seed_files'

expect(subject.directory.to_path).to eq('~/seed_files/shared')
end
end

describe "#logger" do
it "returns an stdout logger by default" do
logger = double('Logger')
Expand Down