Sha256: 226b7e37ba8f8ac895bf62cdf829c325849813186601658816c4ca19bc336a48
Contents?: true
Size: 928 Bytes
Versions: 4
Compression:
Stored size: 928 Bytes
Contents
module LogView class Config extend Forwardable CONFIG_FILE_NAME = ".log_view.yml" CONFIG_SAMPLE = %Q{ # This is a sample, please fill the options with your own configurations # # # project_name: # user: my_ssh_user # password: my_ssh_password # servers: # - some_name@some_server.com # files: # - "/log/dir/my_log_file.log" # } def_delegators :@project, :user, :password, :servers, :files attr_reader :projects def initialize path = Config.config_file_path File.open(path, "w") {|f| f.write(CONFIG_SAMPLE)} unless File.exists?(path) hash = YAML.load_file(path) @projects = hash ? hash.keys : [] @config = OpenStruct.new(hash) end def load_project name project_config = @config.send("#{name}") OpenStruct.new(project_config) end def self.config_file_path File.join(Dir.home, CONFIG_FILE_NAME) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
log_view-0.2.1 | lib/log_view/config.rb |
log_view-0.2.0 | lib/log_view/config.rb |
log_view-0.1.0 | lib/log_view/config.rb |
log_view-0.0.1 | lib/log_view/config.rb |