Class: Construqt::Flavour::Ubuntu::EtcNetworkIptables::Section::Block
- Inherits:
-
Object
- Object
- Construqt::Flavour::Ubuntu::EtcNetworkIptables::Section::Block
- Defined in:
- lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb
Defined Under Namespace
Classes: Row, RowFactory
Instance Method Summary collapse
- #commit ⇒ Object
- #forward ⇒ Object
-
#initialize(section) ⇒ Block
constructor
A new instance of Block.
- #input ⇒ Object
- #output ⇒ Object
- #postrouting ⇒ Object
- #prerouting ⇒ Object
- #table(table, chain = nil) ⇒ Object
Constructor Details
#initialize(section) ⇒ Block
Returns a new instance of Block.
82 83 84 85 |
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 82 def initialize(section) @section = section @rows = [] end |
Instance Method Details
#commit ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 130 def commit #puts @rows.inspect tables = @rows.inject({}) do |r, row| r[row.get_table] ||= {} r[row.get_table][row.get_chain] ||= [] r[row.get_table][row.get_chain] << row r end return "" if tables.empty? ret = ["*#{@section.name}"] ret += tables.keys.sort.map do |k| v = tables[k] if k.empty? v.keys.map{|o| ":#{o} ACCEPT [0:0]" } else ":#{k} - [0:0]" end end tables.keys.sort.each do |k,v| v = tables[k] v.keys.sort.each do |chain| rows = v[chain] table = !k.empty? ? "-A #{k}" : "-A #{chain}" rows.each do |row| ret << "#{table} #{row.get_row}" end end end ret << "COMMIT" ret << "" ret.join("\n") end |
#forward ⇒ Object
118 119 120 |
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 118 def forward table("", 'FORWARD') end |
#input ⇒ Object
126 127 128 |
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 126 def input table("", 'INPUT') end |
#output ⇒ Object
122 123 124 |
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 122 def output table("", 'OUTPUT') end |
#postrouting ⇒ Object
114 115 116 |
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 114 def postrouting table("", 'POSTROUTING') end |
#prerouting ⇒ Object
110 111 112 |
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 110 def prerouting table("", 'PREROUTING') end |
#table(table, chain = nil) ⇒ Object
106 107 108 |
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 106 def table(table, chain = nil) RowFactory.new.rows(@rows).table(table).chain(chain) end |