Class: Planter::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/planter/config.rb

Overview

Configure the application seeder.

Examples:

Planter.configure { |seeder| seeder.seeders = %i[users] }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Create a new instance of the config.



81
82
83
84
85
86
# File 'lib/planter/config.rb', line 81

def initialize
  @quiet = false
  @progress_bar = true
  @seeders_directory = ::File.join("db", "seeds")
  @csv_files_directory = ::File.join("db", "seed_files")
end

Instance Attribute Details

#adapterObject

Return the configured adapter, or lazily load the default Active Record adapter.

Returns:

  • (Object)


75
76
77
# File 'lib/planter/config.rb', line 75

def adapter
  @adapter ||= default_adapter
end

#csv_files_directoryString

Tell the application where the CSV seed files are kept. Must be a path relative to Rails.root.

Parameters:

  • directory (String)

Returns:

  • (String)


26
27
28
# File 'lib/planter/config.rb', line 26

def csv_files_directory
  @csv_files_directory
end

#erb_trim_modeString

The default trim mode for ERB. Must be "%", "<>", ">", or "-". For more information, see documentation for ERB::new.

Parameters:

  • erb_trim_mode (String)

Returns:

  • (String)


60
61
62
# File 'lib/planter/config.rb', line 60

def erb_trim_mode
  @erb_trim_mode
end

#progress_barBoolean

When false, don't print progress bars while seeding.

Parameters:

  • progress_bar (Boolean)

Returns:

  • (Boolean)


51
52
53
# File 'lib/planter/config.rb', line 51

def progress_bar
  @progress_bar
end

#quietBoolean

When true, don't print output when seeding.

Parameters:

  • quiet (Boolean)

Returns:

  • (Boolean)


43
44
45
# File 'lib/planter/config.rb', line 43

def quiet
  @quiet
end

#seedersArray

Tell the application what seeders exist. Elements should be in the correct order to seed the tables successfully, and can be strings or symbols.

Parameters:

  • seeders (Array)

Returns:

  • (Array)


35
36
37
# File 'lib/planter/config.rb', line 35

def seeders
  @seeders
end

#seeders_directoryString

Tell the application where the seeder classes are kept. Must be a path relative to Rails.root.

Parameters:

  • directory (String)

Returns:

  • (String)


17
18
19
# File 'lib/planter/config.rb', line 17

def seeders_directory
  @seeders_directory
end