Class: ShellContext

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, config_path, argv_token) ⇒ ShellContext

Returns a new instance of ShellContext.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/context.rb', line 13

def initialize(user, config_path, argv_token)
  @commands = {}
  @config_path = config_path
  @sysbh = Sys.new
  @sysbh.write_initial_memory

  if !user.nil?
    @config = @sysbh.load_config_user(config_path, user)
    @client = @sysbh.client
    @deep = User
  else
    @config = @sysbh.load_config(config_path, argv_token) # retorna la configuracion ya guardada anteriormente
    @client = @sysbh.client
    @deep = @sysbh.return_deep(config_path)
  end
  @sysbh.load_memory(config_path, @config)
  unless @client.nil?
    @sysbh.add_history_str(2, Organization.new.read_orgs(@client))
  end

  # let commands class access context variables
  share_context = Commands.new
  share_context.load_enviroment(self)
  @commands = COMMANDS
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



8
9
10
# File 'lib/context.rb', line 8

def client
  @client
end

#commandsObject

Returns the value of attribute commands.



10
11
12
# File 'lib/context.rb', line 10

def commands
  @commands
end

#configObject

Returns the value of attribute config.



7
8
9
# File 'lib/context.rb', line 7

def config
  @config
end

#config_pathObject

Returns the value of attribute config_path.



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

def config_path
  @config_path
end

#deepObject

Returns the value of attribute deep.



6
7
8
# File 'lib/context.rb', line 6

def deep
  @deep
end

#sysbhObject

Returns the value of attribute sysbh.



9
10
11
# File 'lib/context.rb', line 9

def sysbh
  @sysbh
end

Instance Method Details

#promptObject



39
40
41
# File 'lib/context.rb', line 39

def prompt
  @deep.shell_prompt(@config)
end