Class: Snitch::Config
- Inherits:
-
Object
- Object
- Snitch::Config
- Defined in:
- lib/snitch/config.rb
Constant Summary collapse
- @@snitch_config_path =
'/home/deploy/.snitch'
Class Method Summary collapse
-
.config_file_path ⇒ Object
Returns the path to the config file.
-
.config_file_path=(new_path) ⇒ Object
Allows you to change the config file path.
-
.create ⇒ Object
Creates a config file based on a template.
-
.load ⇒ Object
Loads the config file.
Class Method Details
.config_file_path ⇒ Object
Returns the path to the config file.
7 8 9 |
# File 'lib/snitch/config.rb', line 7 def config_file_path @@snitch_config_path end |
.config_file_path=(new_path) ⇒ Object
Allows you to change the config file path.
12 13 14 |
# File 'lib/snitch/config.rb', line 12 def config_file_path=(new_path) @@snitch_config_path = new_path end |
.create ⇒ Object
Creates a config file based on a template.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/snitch/config.rb', line 27 def create snitch_config_tpl = <<EOF # what is the location of svnlook (you can find this on *nix boxes by typing `which svnlook`) svnlook: /usr/bin/svnlook # what services would you like to send commit messages to? services: :campfire: :subdomain: :login: :password: :room: Development :twitter: :login: :password: :email: # You mail server settings: :host: :server: localhost :port: 25 # Your login creds: :login: :password: :method: :login # Our email addresses: :from: Snitch <root@localhost> :to: EOF File.open(config_file_path, 'w') { |f| f.write snitch_config_tpl } unless File.exists?(config_file_path) end |
.load ⇒ Object
Loads the config file. If the file does not exist, it creates it and fills in a blank template that only needs settings.
17 18 19 20 21 22 23 24 |
# File 'lib/snitch/config.rb', line 17 def load begin config = YAML::load(open(@@snitch_config_path)).symbolize_keys! rescue create raise ConfigFileLoadError, "The config file was missing or could not be loaded because of a parse error. It should be here: #{@@snitch_config_path}. Fill it out and try again." end end |