Class: Racf::Commands::Listgrp

Inherits:
AbstractCommand show all
Defined in:
lib/racf/commands/listgrp.rb,
lib/racf/commands/listgrp/group_members_parser.rb

Defined Under Namespace

Classes: GroupMembersParser

Constant Summary collapse

GROUP_CLUE =
/INFORMATION FOR GROUP|NAME NOT FOUND IN RACF DATA SET/

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ Listgrp

Returns a new instance of Listgrp.



37
38
39
40
41
42
43
# File 'lib/racf/commands/listgrp.rb', line 37

def initialize(session)
  @current_line = nil
  @current_group = {}
  @members_parser = Listgrp::GroupMembersParser.new

  super
end

Instance Method Details

#extract_resources(args) ⇒ Object



88
89
90
91
92
93
94
95
96
97
# File 'lib/racf/commands/listgrp.rb', line 88

def extract_resources(args)
  resources = args.first

  case resources
  when String
    [resources]
  when Array
    resources
  end
end

#run(*args) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/racf/commands/listgrp.rb', line 45

def run(*args)
  @groups = {}
  @current_line = nil

  groups_names = extract_groups_name(args)
  command = "LISTGRP (#{groups_names})"
  raw_output = @session.run_command(command)
  log_number_of_groups(raw_output)

  @group_index = 1

  @number_of_lines = raw_output.lines.to_a.size
  @line_number = 0

  raw_output.each_line do |line|
    @current_line = line.strip
    @line_number += 1

    group_parsed = catch(:group_parsed) do
      case state_name
      when :nothing_processed, :group_processed
        process_name
      when :name_processed
        process_superior_group_and_owner
      when :superior_group_and_owner_processed
        process_description
      when :description_processed
        process_subgroups
      when :subgroups_processed
        @current_group[:members] ||= {}
        @members_parser ||= Listgrp::GroupMembersParser.new

        process_members unless next_group?
        finish_group_parsing if members_parsed?
      end
    end

    process_name if group_parsed == :true and !last_line?
  end

  @groups
end