lib/bard/config.rb in bard-0.68.0 vs lib/bard/config.rb in bard-0.69.0
- old
+ new
@@ -1,6 +1,8 @@
require "uri"
+require "bard/command"
+require "bard/copy"
module Bard
class Config
def initialize project_name, path: nil, source: nil
@project_name = project_name
@@ -46,15 +48,24 @@
end
attr_reader :project_name, :servers
def server key, &block
+ key = key.to_sym
@servers[key] ||= Server.new(project_name, key)
@servers[key].instance_eval &block if block_given?
@servers[key]
end
+ def [] key
+ key = key.to_sym
+ if @servers[key].nil? && key == :production
+ key = :staging
+ end
+ @servers[key]
+ end
+
def data *paths
if paths.length == 0
Array(@data)
else
@data = paths
@@ -120,9 +131,29 @@
elsif args.length == 0
super() || project_name
else
raise ArgumentError
end
+ end
+
+ def to_sym
+ key
+ end
+
+ def run! command, home: false, verbose: false
+ Bard::Command.run! command, on: self, home:, verbose:
+ end
+
+ def exec! command, home: false
+ Bard::Command.exec! command, on: self, home:
+ end
+
+ def copy_file path, to:, verbose: false
+ Bard::Copy.file path, from: self, to:, verbose:
+ end
+
+ def copy_dir
+ Bard::Copy.dir path, from: self, to:, verbose:
end
end
end
end