Class: FuncE::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/func_e/config.rb

Overview

Singleton class for configuring FuncE.

Constant Summary collapse

DEFAULT_PORT =
3030
DEFAULT_INSTALL_DIR =
'funcs'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#fn_dir_pathObject

Returns the value of attribute fn_dir_path.



14
15
16
# File 'lib/func_e/config.rb', line 14

def fn_dir_path
  @fn_dir_path
end

#local_serverObject

Returns the value of attribute local_server.



14
15
16
# File 'lib/func_e/config.rb', line 14

def local_server
  @local_server
end

#local_server_portObject

Returns the value of attribute local_server_port.



14
15
16
# File 'lib/func_e/config.rb', line 14

def local_server_port
  @local_server_port
end

Class Method Details

.configObject



28
29
30
# File 'lib/func_e/config.rb', line 28

def self.config
  instance
end

.configure {|instance| ... } ⇒ Object

Yields:

  • (instance)


16
17
18
19
20
21
22
23
24
25
26
# File 'lib/func_e/config.rb', line 16

def self.configure
  yield instance
  
  # Set default values if they are not set.
  instance.local_server ||= false
  instance.local_server_port ||= DEFAULT_PORT
  instance.fn_dir_path ||= DEFAULT_INSTALL_DIR

  # Start the server if the local_server option is set to true.
  FuncE::Http.start_server if instance.local_server
end

.install_pathObject



32
33
34
35
36
37
38
39
40
# File 'lib/func_e/config.rb', line 32

def self.install_path
  if defined?(Rails)
    Rails.root.join(config.fn_dir_path)
  elsif defined?(Bundler)
    Bundler.root.join(config.fn_dir_path)
  else
    Pathname.new(Dir.pwd).join(config.fn_dir_path)
  end
end