Class: EmacsOrgProtocolServer::Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/emacs_org_protocol_server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server: '0.0.0.0', port: 4567, bind: '0.0.0.0', config_file: nil) ⇒ Settings

Returns a new instance of Settings.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/emacs_org_protocol_server.rb', line 12

def initialize(server: '0.0.0.0', port: 4567, bind: '0.0.0.0', config_file: nil)
  self.config_file = config_file || ENV['EMACS_ORG_PROTOCOL_CONFIG'] || File.join(ENV['HOME'], '.config', 'emacs_org_protocol_server.yml')
  self.settings = {}
  if File.exist?(self.config_file)
    self.settings = YAML.load(
      ERB.new(
        File.read(self.config_file)
        ).result
      )
  end

  self.server      = ENV['EMACS_ORG_PROTOCOL_SERVER'] || settings["server"] || %w[thin mongrel webrick]
  self.port        = ENV['EMACS_ORG_PROTOCOL_PORT']   || settings["port"]   || '4567'
  self.bind        = ENV['EMACS_ORG_PROTOCOL_BIND']   || settings["bind"]   || '0.0.0.0'
  self.emacsclient = ENV['EMACSCLIENT']               || "/usr/local/bin/emacsclient"
end

Instance Attribute Details

#bindObject

Returns the value of attribute bind.



11
12
13
# File 'lib/emacs_org_protocol_server.rb', line 11

def bind
  @bind
end

#config_fileObject

Returns the value of attribute config_file.



11
12
13
# File 'lib/emacs_org_protocol_server.rb', line 11

def config_file
  @config_file
end

#emacsclientObject

Returns the value of attribute emacsclient.



11
12
13
# File 'lib/emacs_org_protocol_server.rb', line 11

def emacsclient
  @emacsclient
end

#portObject

Returns the value of attribute port.



11
12
13
# File 'lib/emacs_org_protocol_server.rb', line 11

def port
  @port
end

#serverObject

Returns the value of attribute server.



11
12
13
# File 'lib/emacs_org_protocol_server.rb', line 11

def server
  @server
end

#settingsObject

Returns the value of attribute settings.



11
12
13
# File 'lib/emacs_org_protocol_server.rb', line 11

def settings
  @settings
end