Module: MultiTerm
- Defined in:
- lib/multiterm.rb,
lib/multiterm/version.rb
Defined Under Namespace
Modules: VERSION
Class Method Summary collapse
-
.configuration ⇒ Object
Memoized copy of the default configuration.
- .execute ⇒ Object
-
.read_configuration(path = nil) ⇒ Object
Loads the configuration file for the current path.
Class Method Details
.configuration ⇒ Object
Memoized copy of the default configuration.
21 22 23 |
# File 'lib/multiterm.rb', line 21 def self.configuration @@configuration ||= read_configuration end |
.execute ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/multiterm.rb', line 48 def self.execute if configuration app = Osaka::Terminal.new app.activate tab_config = { :directory => configuration[:root], :new_tab => false }.merge(configuration[:parent]) app.tab_configure(tab_config) for tab_config in configuration[:tabs] tab_config = { :directory => configuration[:root], :new_tab => true }.merge(tab_config) tab_config[:directory] = File.realdirpath( tab_config[:directory], (configuration[:root] || File.('.')) ) app.tab_configure(tab_config) end else puts "Missing '.multiterm.yml' configuration." end end |
.read_configuration(path = nil) ⇒ Object
Loads the configuration file for the current path.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/multiterm.rb', line 27 def self.read_configuration(path=nil) if path != nil && File.exists?(path) && File.directory?(path) current_path = path elsif path != nil && File.exists?(path) && !File.directory?(path) current_path = File.dirname(path) else current_path = File.('.') end home_path = File.('~') search_path = current_path while search_path != '/' && search_path != home_path if File.exists?(File.join(search_path, '.multiterm.yml')) settings = YAML.load(File.read(File.join(search_path, '.multiterm.yml'))) settings[:root] = File.(search_path) return settings if settings end search_path = File.(File.join(search_path, '..')) end return nil end |