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
6 7 8 9 |
# File 'lib/seed/configuration.rb', line 6 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
11 12 13 |
# File 'lib/seed/configuration.rb', line 11 def adapter_name @adapter_name ||= ActiveRecord::Base.connection.adapter_name end |
#base_path ⇒ Object
$Rails.root/tmp/dump
24 25 26 |
# File 'lib/seed/configuration.rb', line 24 def base_path Pathname.new(Dir.pwd).join('tmp').join('dump') end |
#current_version_path ⇒ Object
$Rails.root/tmp/dump/123456789.sql’
29 30 31 |
# File 'lib/seed/configuration.rb', line 29 def current_version_path base_path.join(schema_version.to_s + '.sql') end |
#database_options ⇒ Object
19 20 21 |
# File 'lib/seed/configuration.rb', line 19 def ||= ActiveRecord::Base.connection.raw_connection. end |
#make_tmp_dir ⇒ Object
33 34 35 |
# File 'lib/seed/configuration.rb', line 33 def make_tmp_dir FileUtils.mkdir_p(base_path) unless File.exist?(base_path) end |
#schema_version ⇒ Object
15 16 17 |
# File 'lib/seed/configuration.rb', line 15 def schema_version @schema_version ||= Digest::SHA1.hexdigest(get_all_versions.sort.join) end |