Class: Bard::Config
- Inherits:
-
Object
- Object
- Bard::Config
- Defined in:
- lib/bard/config.rb
Instance Attribute Summary collapse
-
#project_name ⇒ Object
readonly
Returns the value of attribute project_name.
-
#servers ⇒ Object
readonly
Returns the value of attribute servers.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #backup(*args) ⇒ Object
- #data(*paths) ⇒ Object
-
#initialize(project_name, path: nil, source: nil) ⇒ Config
constructor
A new instance of Config.
- #server(key, &block) ⇒ Object
Constructor Details
#initialize(project_name, path: nil, source: nil) ⇒ Config
Returns a new instance of Config.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/bard/config.rb', line 5 def initialize project_name, path: nil, source: nil @project_name = project_name @servers = { local: Server.new( project_name, :local, false, "./", ["#{project_name}.local"], ), gubs: Server.new( project_name, :gubs, "[email protected]:22022", "Sites/#{project_name}", false, ), ci: Server.new( project_name, :ci, "[email protected]:22022", "jobs/#{project_name}/workspace", false, ), staging: Server.new( project_name, :staging, "[email protected]:22022", project_name, ["#{project_name}.botandrose.com"], ), } if path && File.exist?(path) source = File.read(path) end if source instance_eval source end end |
Instance Attribute Details
#project_name ⇒ Object (readonly)
Returns the value of attribute project_name.
45 46 47 |
# File 'lib/bard/config.rb', line 45 def project_name @project_name end |
#servers ⇒ Object (readonly)
Returns the value of attribute servers.
45 46 47 |
# File 'lib/bard/config.rb', line 45 def servers @servers end |
Instance Method Details
#[](key) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/bard/config.rb', line 52 def [] key key = key.to_sym if @servers[key].nil? && key == :production key = :staging end @servers[key] end |
#backup(*args) ⇒ Object
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/bard/config.rb', line 68 def backup *args if args.length == 1 @backup = args.first elsif args.length == 0 return @backup if defined?(@backup) @backup = true else raise ArgumentError end end |
#data(*paths) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/bard/config.rb', line 60 def data *paths if paths.length == 0 Array(@data) else @data = paths end end |