Class: VagrantPlugins::TrellisSequel::Spf
- Inherits:
-
Object
- Object
- VagrantPlugins::TrellisSequel::Spf
- Defined in:
- lib/vagrant_plugins/trellis_sequel/spf.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data:, path:) ⇒ Spf
constructor
A new instance of Spf.
- #open ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(data:, path:) ⇒ Spf
Returns a new instance of Spf.
13 14 15 16 17 18 19 |
# File 'lib/vagrant_plugins/trellis_sequel/spf.rb', line 13 def initialize(data:, path:) db_name = data.dig(:database, :name).to_s.gsub(/\s+/, '') raise 'You must provide data[:database][:name]' if db_name.empty? @data = data @path = File.join(path, "#{db_name}.spf") end |
Class Method Details
.create_and_open(args) ⇒ Object
9 10 11 |
# File 'lib/vagrant_plugins/trellis_sequel/spf.rb', line 9 def self.create_and_open(args) new(args).tap(&:write).open end |
Instance Method Details
#open ⇒ Object
27 28 29 |
# File 'lib/vagrant_plugins/trellis_sequel/spf.rb', line 27 def open system("open \"#{@path}\"") end |
#write ⇒ Object
21 22 23 24 25 |
# File 'lib/vagrant_plugins/trellis_sequel/spf.rb', line 21 def write File.open(@path, 'w') do |file| file.write(content) end end |