Class: Seed::Configuration
- Inherits:
-
Object
- Object
- Seed::Configuration
- Defined in:
- lib/seed/configuration.rb
Instance Method Summary collapse
- #adapter_name ⇒ Object
-
#base_path ⇒ Object
$Rails.root/tmp/dump.
-
#current_version_path ⇒ Object
$Rails.root/tmp/dump/123456789.sql’.
- #database_options ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #make_tmp_dir ⇒ Object
- #schema_version ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
5 6 7 8 |
# File 'lib/seed/configuration.rb', line 5 def initialize # error if adapter is not mysql raise 'seed-snapshot support only MySQL' unless adapter_name == 'Mysql2' end |
Instance Method Details
#adapter_name ⇒ Object
10 11 12 |
# File 'lib/seed/configuration.rb', line 10 def adapter_name @adapter_name ||= ActiveRecord::Base.connection.adapter_name end |
#base_path ⇒ Object
$Rails.root/tmp/dump
23 24 25 |
# File 'lib/seed/configuration.rb', line 23 def base_path Pathname.new(Dir.pwd).join('tmp').join('dump') end |
#current_version_path ⇒ Object
$Rails.root/tmp/dump/123456789.sql’
28 29 30 |
# File 'lib/seed/configuration.rb', line 28 def current_version_path base_path.join(schema_version.to_s + '.sql') end |
#database_options ⇒ Object
18 19 20 |
# File 'lib/seed/configuration.rb', line 18 def @options ||= ActiveRecord::Base.connection.raw_connection. end |
#make_tmp_dir ⇒ Object
32 33 34 |
# File 'lib/seed/configuration.rb', line 32 def make_tmp_dir FileUtils.mkdir_p(base_path) unless File.exist?(base_path) end |
#schema_version ⇒ Object
14 15 16 |
# File 'lib/seed/configuration.rb', line 14 def schema_version @schema_version ||= ActiveRecord::Migrator.current_version end |