Permalink
Browse files

Add code to process config files

Add read_disk_settings function content
  • Loading branch information...
1 parent 3085a94 commit b6dcb40c2b683de847b04e23ccbefdc7679be375 @nledez nledez committed with sorbits Jan 7, 2012
Showing with 16 additions and 1 deletion.
  1. +7 −0 README.mdown
  2. +9 −1 rmate
View
@@ -2,6 +2,13 @@
Learn more in this [MacroMates blog post](http://blog.macromates.com/2011/mate-and-rmate/ "TextMate Blog » mate and rmate").
+You can put config in files `/etc/rmate.rc` and/or `~/.rmate.rc` with:
+
+ host: localhost
+ port: 52698
+
+You can leave only one parameter.
+
# General
* [Bundle Styleguide](http://kb.textmate.org/bundle_styleguide) — _before you make changes_
View
@@ -7,6 +7,7 @@ $KCODE = "U" if RUBY_VERSION < "1.9" # -KU
require 'optparse'
require 'socket'
require 'fileutils'
+require 'yaml'
VERSION_STRING = 'rmate version 1.4 (2012-08-14)'
@@ -32,7 +33,14 @@ class Settings
end
def read_disk_settings
- # TODO
+ [ "/etc/rmate.rc", "~/.rmate.rc"].each do |current_file|
+ file = File.expand_path current_file
+ if File.exist? file
+ params = YAML::load(File.open(file))
+ @host = params["host"] unless params["host"].nil?
+ @port = params["port"] unless params["port"].nil?
+ end
+ end
end
def parse_cli_options

0 comments on commit b6dcb40

Please sign in to comment.