puffy 0.3.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ccc93913a571a25b75f1984f53315be9df0001f27fd7d1062c274a8ae398a890
4
- data.tar.gz: e39938f8393291ccdf37f4c9817abb1dd40c8816a67cadf9c5aea43d57b3969c
3
+ metadata.gz: b05f6a865607d5ece6a83d81f3ef925decf281b4fa0fc54daf7aaa2213135831
4
+ data.tar.gz: 9ac1891cb02cf876b0ac64fc19dc857996c1e3dfa3141e5b339c82f98603ced9
5
5
  SHA512:
6
- metadata.gz: c701450c7f9fcd9417cde14b41e25381beeec5ef835931e8bfdc30ee10a539b951503b907866d7176064218bfa4120f1ddfc594a4ab461ccf4034221940fa2b4
7
- data.tar.gz: 91c204a40f678eaf37ada1ed9f48a4a7ca08e012296df8f8cb2ed92d533a0044b5282ffe19d3ba9abdbb604a8bd12c2e425feca6a894215ec5d458f6b6d4d8a0
6
+ metadata.gz: 73c1d65f67292e4e3d2452978ad21bc2bca7001cce5304472686a8a843bf742e635b11c86606f43a1af1024cb30bf63faf7f1444cc4b380ee7f589300086bb2b
7
+ data.tar.gz: f93e5ffc88eda099624f28ce13997dbe0a9222955eb76aa6e5e725d77be3a313da0b38ccddf3f10a550f60418cb44e39bb3724e2a02aab952c2a6b643ec7d28c
@@ -0,0 +1,18 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ # Open PR for gem updates
9
+ - package-ecosystem: "bundler" # See documentation for possible values
10
+ directory: "/" # Location of package manifests
11
+ schedule:
12
+ interval: "daily"
13
+
14
+ # Open PR for GitHub Actions updates
15
+ - package-ecosystem: "github-actions"
16
+ directory: "/"
17
+ schedule:
18
+ interval: "daily"
@@ -14,7 +14,7 @@ jobs:
14
14
  rubocop:
15
15
  runs-on: ubuntu-latest
16
16
  steps:
17
- - uses: actions/checkout@v2
17
+ - uses: actions/checkout@v4
18
18
  - name: Setup ruby
19
19
  uses: ruby/setup-ruby@v1
20
20
  with:
@@ -33,9 +33,10 @@ jobs:
33
33
  - "3.0"
34
34
  - "3.1"
35
35
  - "3.2"
36
+ - "3.3"
36
37
  name: Ruby ${{ matrix.ruby }}
37
38
  steps:
38
- - uses: actions/checkout@v2
39
+ - uses: actions/checkout@v4
39
40
  - name: Setup ruby
40
41
  uses: ruby/setup-ruby@v1
41
42
  with:
@@ -48,7 +49,7 @@ jobs:
48
49
  run: bundle exec rake
49
50
  - name: Run tests and upload coverage to Code Climate
50
51
  if: ${{ matrix.ruby == '3.0' }}
51
- uses: paambaati/codeclimate-action@v3.0.0
52
+ uses: paambaati/codeclimate-action@v5.0.0
52
53
  env:
53
54
  CC_TEST_REPORTER_ID: ${{ secrets.CODECLIMATE_TOKEN }}
54
55
  with:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [v1.0.0](https://github.com/opus-codium/puffy/tree/v1.0.0) (2024-04-09)
4
+
5
+ [Full Changelog](https://github.com/opus-codium/puffy/compare/v0.3.1...v1.0.0)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Setup dependabot [\#36](https://github.com/opus-codium/puffy/pull/36) ([smortex](https://github.com/smortex))
10
+ - Add support for Ruby 3.3 [\#33](https://github.com/opus-codium/puffy/pull/33) ([smortex](https://github.com/smortex))
11
+
3
12
  ## [v0.3.1](https://github.com/opus-codium/puffy/tree/v0.3.1) (2023-11-22)
4
13
 
5
14
  [Full Changelog](https://github.com/opus-codium/puffy/compare/v0.3.0...v0.3.1)
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ Cucumber::Rake::Task.new(:features)
14
14
  GitHubChangelogGenerator::RakeTask.new :changelog do |config|
15
15
  config.user = 'opus-codium'
16
16
  config.project = 'puffy'
17
- config.exclude_labels = ['skip-changelog']
17
+ config.exclude_labels = %w[dependencies skip-changelog]
18
18
  config.future_release = "v#{Puffy::VERSION}"
19
19
  end
20
20
 
@@ -28,5 +28,5 @@ desc 'Generate the puffy language parser'
28
28
  task gen_parser: 'lib/puffy/parser.tab.rb'
29
29
 
30
30
  file 'lib/puffy/parser.tab.rb' => 'lib/puffy/parser.y' do
31
- `racc -S lib/puffy/parser.y`
31
+ `racc --embedded --frozen --output-status lib/puffy/parser.y`
32
32
  end
data/lib/core_ext.rb CHANGED
@@ -59,15 +59,13 @@ end
59
59
 
60
60
  class Array # :nodoc:
61
61
  def deep_dup
62
- array = []
63
- each do |value|
64
- array << if value.respond_to?(:deep_dup)
65
- value.deep_dup
66
- else
67
- value.dup
68
- end
62
+ map do |value|
63
+ if value.respond_to?(:deep_dup)
64
+ value.deep_dup
65
+ else
66
+ value.dup
67
+ end
69
68
  end
70
- array
71
69
  end
72
70
  end
73
71
 
@@ -116,13 +116,21 @@ module Puffy
116
116
  def emit_rdr_to(rule)
117
117
  return unless rule.rdr?
118
118
 
119
- keyword = Puffy::Formatters::Base.loopback_addresses.include?(rule.rdr_to_host) ? 'divert-to' : 'rdr-to'
119
+ keyword = rdr_to_keyword(rule)
120
120
  destination = rule.rdr_to_host || loopback_address(rule.af)
121
121
  raise 'Unspecified address family' if destination.nil?
122
122
 
123
123
  emit_endpoint_specification(keyword, destination, rule.rdr_to_port)
124
124
  end
125
125
 
126
+ def rdr_to_keyword(rule)
127
+ if Puffy::Formatters::Base.loopback_addresses.include?(rule.rdr_to_host)
128
+ 'divert-to'
129
+ else
130
+ 'rdr-to'
131
+ end
132
+ end
133
+
126
134
  def emit_nat_to(rule)
127
135
  "nat-to #{emit_address(rule.nat_to)}" if rule.nat_to
128
136
  end
@@ -1,10 +1,661 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # DO NOT MODIFY!!!!
3
4
  # This file is automatically generated by Racc 1.7.3
4
5
  # from Racc grammar file "parser.y".
5
6
  #
6
7
 
7
- require 'racc/parser.rb'
8
+ ###### racc/parser.rb begin
9
+ unless $".find {|p| p.end_with?('/racc/parser.rb')}
10
+ $".push "#{__dir__}/racc/parser.rb"
11
+ self.class.module_eval(<<'...end racc/parser.rb/module_eval...', 'racc/parser.rb', 1)
12
+ #--
13
+ # Copyright (c) 1999-2006 Minero Aoki
14
+ #
15
+ # This program is free software.
16
+ # You can distribute/modify this program under the same terms of ruby.
17
+ #
18
+ # As a special exception, when this code is copied by Racc
19
+ # into a Racc output file, you may use that output file
20
+ # without restriction.
21
+ #++
22
+
23
+ unless $".find {|p| p.end_with?('/racc/info.rb')}
24
+ $".push "#{__dir__}/racc/info.rb"
25
+
26
+ module Racc
27
+ VERSION = '1.7.3'
28
+ Version = VERSION
29
+ Copyright = 'Copyright (c) 1999-2006 Minero Aoki'
30
+ end
31
+
32
+ end
33
+
34
+
35
+ unless defined?(NotImplementedError)
36
+ NotImplementedError = NotImplementError # :nodoc:
37
+ end
38
+
39
+ module Racc
40
+ class ParseError < StandardError; end
41
+ end
42
+ unless defined?(::ParseError)
43
+ ParseError = Racc::ParseError # :nodoc:
44
+ end
45
+
46
+ # Racc is a LALR(1) parser generator.
47
+ # It is written in Ruby itself, and generates Ruby programs.
48
+ #
49
+ # == Command-line Reference
50
+ #
51
+ # racc [-o<var>filename</var>] [--output-file=<var>filename</var>]
52
+ # [-e<var>rubypath</var>] [--executable=<var>rubypath</var>]
53
+ # [-v] [--verbose]
54
+ # [-O<var>filename</var>] [--log-file=<var>filename</var>]
55
+ # [-g] [--debug]
56
+ # [-E] [--embedded]
57
+ # [-l] [--no-line-convert]
58
+ # [-c] [--line-convert-all]
59
+ # [-a] [--no-omit-actions]
60
+ # [-C] [--check-only]
61
+ # [-S] [--output-status]
62
+ # [--version] [--copyright] [--help] <var>grammarfile</var>
63
+ #
64
+ # [+grammarfile+]
65
+ # Racc grammar file. Any extension is permitted.
66
+ # [-o+outfile+, --output-file=+outfile+]
67
+ # A filename for output. default is <+filename+>.tab.rb
68
+ # [-O+filename+, --log-file=+filename+]
69
+ # Place logging output in file +filename+.
70
+ # Default log file name is <+filename+>.output.
71
+ # [-e+rubypath+, --executable=+rubypath+]
72
+ # output executable file(mode 755). where +path+ is the Ruby interpreter.
73
+ # [-v, --verbose]
74
+ # verbose mode. create +filename+.output file, like yacc's y.output file.
75
+ # [-g, --debug]
76
+ # add debug code to parser class. To display debugging information,
77
+ # use this '-g' option and set @yydebug true in parser class.
78
+ # [-E, --embedded]
79
+ # Output parser which doesn't need runtime files (racc/parser.rb).
80
+ # [-F, --frozen]
81
+ # Output parser which declares frozen_string_literals: true
82
+ # [-C, --check-only]
83
+ # Check syntax of racc grammar file and quit.
84
+ # [-S, --output-status]
85
+ # Print messages time to time while compiling.
86
+ # [-l, --no-line-convert]
87
+ # turns off line number converting.
88
+ # [-c, --line-convert-all]
89
+ # Convert line number of actions, inner, header and footer.
90
+ # [-a, --no-omit-actions]
91
+ # Call all actions, even if an action is empty.
92
+ # [--version]
93
+ # print Racc version and quit.
94
+ # [--copyright]
95
+ # Print copyright and quit.
96
+ # [--help]
97
+ # Print usage and quit.
98
+ #
99
+ # == Generating Parser Using Racc
100
+ #
101
+ # To compile Racc grammar file, simply type:
102
+ #
103
+ # $ racc parse.y
104
+ #
105
+ # This creates Ruby script file "parse.tab.y". The -o option can change the output filename.
106
+ #
107
+ # == Writing A Racc Grammar File
108
+ #
109
+ # If you want your own parser, you have to write a grammar file.
110
+ # A grammar file contains the name of your parser class, grammar for the parser,
111
+ # user code, and anything else.
112
+ # When writing a grammar file, yacc's knowledge is helpful.
113
+ # If you have not used yacc before, Racc is not too difficult.
114
+ #
115
+ # Here's an example Racc grammar file.
116
+ #
117
+ # class Calcparser
118
+ # rule
119
+ # target: exp { print val[0] }
120
+ #
121
+ # exp: exp '+' exp
122
+ # | exp '*' exp
123
+ # | '(' exp ')'
124
+ # | NUMBER
125
+ # end
126
+ #
127
+ # Racc grammar files resemble yacc files.
128
+ # But (of course), this is Ruby code.
129
+ # yacc's $$ is the 'result', $0, $1... is
130
+ # an array called 'val', and $-1, $-2... is an array called '_values'.
131
+ #
132
+ # See the {Grammar File Reference}[rdoc-ref:lib/racc/rdoc/grammar.en.rdoc] for
133
+ # more information on grammar files.
134
+ #
135
+ # == Parser
136
+ #
137
+ # Then you must prepare the parse entry method. There are two types of
138
+ # parse methods in Racc, Racc::Parser#do_parse and Racc::Parser#yyparse
139
+ #
140
+ # Racc::Parser#do_parse is simple.
141
+ #
142
+ # It's yyparse() of yacc, and Racc::Parser#next_token is yylex().
143
+ # This method must returns an array like [TOKENSYMBOL, ITS_VALUE].
144
+ # EOF is [false, false].
145
+ # (TOKENSYMBOL is a Ruby symbol (taken from String#intern) by default.
146
+ # If you want to change this, see the grammar reference.
147
+ #
148
+ # Racc::Parser#yyparse is little complicated, but useful.
149
+ # It does not use Racc::Parser#next_token, instead it gets tokens from any iterator.
150
+ #
151
+ # For example, <code>yyparse(obj, :scan)</code> causes
152
+ # calling +obj#scan+, and you can return tokens by yielding them from +obj#scan+.
153
+ #
154
+ # == Debugging
155
+ #
156
+ # When debugging, "-v" or/and the "-g" option is helpful.
157
+ #
158
+ # "-v" creates verbose log file (.output).
159
+ # "-g" creates a "Verbose Parser".
160
+ # Verbose Parser prints the internal status when parsing.
161
+ # But it's _not_ automatic.
162
+ # You must use -g option and set +@yydebug+ to +true+ in order to get output.
163
+ # -g option only creates the verbose parser.
164
+ #
165
+ # === Racc reported syntax error.
166
+ #
167
+ # Isn't there too many "end"?
168
+ # grammar of racc file is changed in v0.10.
169
+ #
170
+ # Racc does not use '%' mark, while yacc uses huge number of '%' marks..
171
+ #
172
+ # === Racc reported "XXXX conflicts".
173
+ #
174
+ # Try "racc -v xxxx.y".
175
+ # It causes producing racc's internal log file, xxxx.output.
176
+ #
177
+ # === Generated parsers does not work correctly
178
+ #
179
+ # Try "racc -g xxxx.y".
180
+ # This command let racc generate "debugging parser".
181
+ # Then set @yydebug=true in your parser.
182
+ # It produces a working log of your parser.
183
+ #
184
+ # == Re-distributing Racc runtime
185
+ #
186
+ # A parser, which is created by Racc, requires the Racc runtime module;
187
+ # racc/parser.rb.
188
+ #
189
+ # Ruby 1.8.x comes with Racc runtime module,
190
+ # you need NOT distribute Racc runtime files.
191
+ #
192
+ # If you want to include the Racc runtime module with your parser.
193
+ # This can be done by using '-E' option:
194
+ #
195
+ # $ racc -E -omyparser.rb myparser.y
196
+ #
197
+ # This command creates myparser.rb which `includes' Racc runtime.
198
+ # Only you must do is to distribute your parser file (myparser.rb).
199
+ #
200
+ # Note: parser.rb is ruby license, but your parser is not.
201
+ # Your own parser is completely yours.
202
+ module Racc
203
+
204
+ unless defined?(Racc_No_Extensions)
205
+ Racc_No_Extensions = false # :nodoc:
206
+ end
207
+
208
+ class Parser
209
+
210
+ Racc_Runtime_Version = ::Racc::VERSION
211
+ Racc_Runtime_Core_Version_R = ::Racc::VERSION
212
+
213
+ begin
214
+ if Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
215
+ require 'jruby'
216
+ require 'racc/cparse-jruby.jar'
217
+ com.headius.racc.Cparse.new.load(JRuby.runtime, false)
218
+ else
219
+ require 'racc/cparse'
220
+ end
221
+
222
+ unless new.respond_to?(:_racc_do_parse_c, true)
223
+ raise LoadError, 'old cparse.so'
224
+ end
225
+ if Racc_No_Extensions
226
+ raise LoadError, 'selecting ruby version of racc runtime core'
227
+ end
228
+
229
+ Racc_Main_Parsing_Routine = :_racc_do_parse_c # :nodoc:
230
+ Racc_YY_Parse_Method = :_racc_yyparse_c # :nodoc:
231
+ Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_C # :nodoc:
232
+ Racc_Runtime_Type = 'c' # :nodoc:
233
+ rescue LoadError
234
+ Racc_Main_Parsing_Routine = :_racc_do_parse_rb
235
+ Racc_YY_Parse_Method = :_racc_yyparse_rb
236
+ Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_R
237
+ Racc_Runtime_Type = 'ruby'
238
+ end
239
+
240
+ def Parser.racc_runtime_type # :nodoc:
241
+ Racc_Runtime_Type
242
+ end
243
+
244
+ def _racc_setup
245
+ @yydebug = false unless self.class::Racc_debug_parser
246
+ @yydebug = false unless defined?(@yydebug)
247
+ if @yydebug
248
+ @racc_debug_out = $stderr unless defined?(@racc_debug_out)
249
+ @racc_debug_out ||= $stderr
250
+ end
251
+ arg = self.class::Racc_arg
252
+ arg[13] = true if arg.size < 14
253
+ arg
254
+ end
255
+
256
+ def _racc_init_sysvars
257
+ @racc_state = [0]
258
+ @racc_tstack = []
259
+ @racc_vstack = []
260
+
261
+ @racc_t = nil
262
+ @racc_val = nil
263
+
264
+ @racc_read_next = true
265
+
266
+ @racc_user_yyerror = false
267
+ @racc_error_status = 0
268
+ end
269
+
270
+ # The entry point of the parser. This method is used with #next_token.
271
+ # If Racc wants to get token (and its value), calls next_token.
272
+ #
273
+ # Example:
274
+ # def parse
275
+ # @q = [[1,1],
276
+ # [2,2],
277
+ # [3,3],
278
+ # [false, '$']]
279
+ # do_parse
280
+ # end
281
+ #
282
+ # def next_token
283
+ # @q.shift
284
+ # end
285
+ class_eval <<~RUBY, __FILE__, __LINE__ + 1
286
+ def do_parse
287
+ #{Racc_Main_Parsing_Routine}(_racc_setup(), false)
288
+ end
289
+ RUBY
290
+
291
+ # The method to fetch next token.
292
+ # If you use #do_parse method, you must implement #next_token.
293
+ #
294
+ # The format of return value is [TOKEN_SYMBOL, VALUE].
295
+ # +token-symbol+ is represented by Ruby's symbol by default, e.g. :IDENT
296
+ # for 'IDENT'. ";" (String) for ';'.
297
+ #
298
+ # The final symbol (End of file) must be false.
299
+ def next_token
300
+ raise NotImplementedError, "#{self.class}\#next_token is not defined"
301
+ end
302
+
303
+ def _racc_do_parse_rb(arg, in_debug)
304
+ action_table, action_check, action_default, action_pointer,
305
+ _, _, _, _,
306
+ _, _, token_table, * = arg
307
+
308
+ _racc_init_sysvars
309
+ tok = act = i = nil
310
+
311
+ catch(:racc_end_parse) {
312
+ while true
313
+ if i = action_pointer[@racc_state[-1]]
314
+ if @racc_read_next
315
+ if @racc_t != 0 # not EOF
316
+ tok, @racc_val = next_token()
317
+ unless tok # EOF
318
+ @racc_t = 0
319
+ else
320
+ @racc_t = (token_table[tok] or 1) # error token
321
+ end
322
+ racc_read_token(@racc_t, tok, @racc_val) if @yydebug
323
+ @racc_read_next = false
324
+ end
325
+ end
326
+ i += @racc_t
327
+ unless i >= 0 and
328
+ act = action_table[i] and
329
+ action_check[i] == @racc_state[-1]
330
+ act = action_default[@racc_state[-1]]
331
+ end
332
+ else
333
+ act = action_default[@racc_state[-1]]
334
+ end
335
+ while act = _racc_evalact(act, arg)
336
+ ;
337
+ end
338
+ end
339
+ }
340
+ end
341
+
342
+ # Another entry point for the parser.
343
+ # If you use this method, you must implement RECEIVER#METHOD_ID method.
344
+ #
345
+ # RECEIVER#METHOD_ID is a method to get next token.
346
+ # It must 'yield' the token, which format is [TOKEN-SYMBOL, VALUE].
347
+ class_eval <<~RUBY, __FILE__, __LINE__ + 1
348
+ def yyparse(recv, mid)
349
+ #{Racc_YY_Parse_Method}(recv, mid, _racc_setup(), false)
350
+ end
351
+ RUBY
352
+
353
+ def _racc_yyparse_rb(recv, mid, arg, c_debug)
354
+ action_table, action_check, action_default, action_pointer,
355
+ _, _, _, _,
356
+ _, _, token_table, * = arg
357
+
358
+ _racc_init_sysvars
359
+
360
+ catch(:racc_end_parse) {
361
+ until i = action_pointer[@racc_state[-1]]
362
+ while act = _racc_evalact(action_default[@racc_state[-1]], arg)
363
+ ;
364
+ end
365
+ end
366
+ recv.__send__(mid) do |tok, val|
367
+ unless tok
368
+ @racc_t = 0
369
+ else
370
+ @racc_t = (token_table[tok] or 1) # error token
371
+ end
372
+ @racc_val = val
373
+ @racc_read_next = false
374
+
375
+ i += @racc_t
376
+ unless i >= 0 and
377
+ act = action_table[i] and
378
+ action_check[i] == @racc_state[-1]
379
+ act = action_default[@racc_state[-1]]
380
+ end
381
+ while act = _racc_evalact(act, arg)
382
+ ;
383
+ end
384
+
385
+ while !(i = action_pointer[@racc_state[-1]]) ||
386
+ ! @racc_read_next ||
387
+ @racc_t == 0 # $
388
+ unless i and i += @racc_t and
389
+ i >= 0 and
390
+ act = action_table[i] and
391
+ action_check[i] == @racc_state[-1]
392
+ act = action_default[@racc_state[-1]]
393
+ end
394
+ while act = _racc_evalact(act, arg)
395
+ ;
396
+ end
397
+ end
398
+ end
399
+ }
400
+ end
401
+
402
+ ###
403
+ ### common
404
+ ###
405
+
406
+ def _racc_evalact(act, arg)
407
+ action_table, action_check, _, action_pointer,
408
+ _, _, _, _,
409
+ _, _, _, shift_n,
410
+ reduce_n, * = arg
411
+ nerr = 0 # tmp
412
+
413
+ if act > 0 and act < shift_n
414
+ #
415
+ # shift
416
+ #
417
+ if @racc_error_status > 0
418
+ @racc_error_status -= 1 unless @racc_t <= 1 # error token or EOF
419
+ end
420
+ @racc_vstack.push @racc_val
421
+ @racc_state.push act
422
+ @racc_read_next = true
423
+ if @yydebug
424
+ @racc_tstack.push @racc_t
425
+ racc_shift @racc_t, @racc_tstack, @racc_vstack
426
+ end
427
+
428
+ elsif act < 0 and act > -reduce_n
429
+ #
430
+ # reduce
431
+ #
432
+ code = catch(:racc_jump) {
433
+ @racc_state.push _racc_do_reduce(arg, act)
434
+ false
435
+ }
436
+ if code
437
+ case code
438
+ when 1 # yyerror
439
+ @racc_user_yyerror = true # user_yyerror
440
+ return -reduce_n
441
+ when 2 # yyaccept
442
+ return shift_n
443
+ else
444
+ raise '[Racc Bug] unknown jump code'
445
+ end
446
+ end
447
+
448
+ elsif act == shift_n
449
+ #
450
+ # accept
451
+ #
452
+ racc_accept if @yydebug
453
+ throw :racc_end_parse, @racc_vstack[0]
454
+
455
+ elsif act == -reduce_n
456
+ #
457
+ # error
458
+ #
459
+ case @racc_error_status
460
+ when 0
461
+ unless arg[21] # user_yyerror
462
+ nerr += 1
463
+ on_error @racc_t, @racc_val, @racc_vstack
464
+ end
465
+ when 3
466
+ if @racc_t == 0 # is $
467
+ # We're at EOF, and another error occurred immediately after
468
+ # attempting auto-recovery
469
+ throw :racc_end_parse, nil
470
+ end
471
+ @racc_read_next = true
472
+ end
473
+ @racc_user_yyerror = false
474
+ @racc_error_status = 3
475
+ while true
476
+ if i = action_pointer[@racc_state[-1]]
477
+ i += 1 # error token
478
+ if i >= 0 and
479
+ (act = action_table[i]) and
480
+ action_check[i] == @racc_state[-1]
481
+ break
482
+ end
483
+ end
484
+ throw :racc_end_parse, nil if @racc_state.size <= 1
485
+ @racc_state.pop
486
+ @racc_vstack.pop
487
+ if @yydebug
488
+ @racc_tstack.pop
489
+ racc_e_pop @racc_state, @racc_tstack, @racc_vstack
490
+ end
491
+ end
492
+ return act
493
+
494
+ else
495
+ raise "[Racc Bug] unknown action #{act.inspect}"
496
+ end
497
+
498
+ racc_next_state(@racc_state[-1], @racc_state) if @yydebug
499
+
500
+ nil
501
+ end
502
+
503
+ def _racc_do_reduce(arg, act)
504
+ _, _, _, _,
505
+ goto_table, goto_check, goto_default, goto_pointer,
506
+ nt_base, reduce_table, _, _,
507
+ _, use_result, * = arg
508
+
509
+ state = @racc_state
510
+ vstack = @racc_vstack
511
+ tstack = @racc_tstack
512
+
513
+ i = act * -3
514
+ len = reduce_table[i]
515
+ reduce_to = reduce_table[i+1]
516
+ method_id = reduce_table[i+2]
517
+ void_array = []
518
+
519
+ tmp_t = tstack[-len, len] if @yydebug
520
+ tmp_v = vstack[-len, len]
521
+ tstack[-len, len] = void_array if @yydebug
522
+ vstack[-len, len] = void_array
523
+ state[-len, len] = void_array
524
+
525
+ # tstack must be updated AFTER method call
526
+ if use_result
527
+ vstack.push __send__(method_id, tmp_v, vstack, tmp_v[0])
528
+ else
529
+ vstack.push __send__(method_id, tmp_v, vstack)
530
+ end
531
+ tstack.push reduce_to
532
+
533
+ racc_reduce(tmp_t, reduce_to, tstack, vstack) if @yydebug
534
+
535
+ k1 = reduce_to - nt_base
536
+ if i = goto_pointer[k1]
537
+ i += state[-1]
538
+ if i >= 0 and (curstate = goto_table[i]) and goto_check[i] == k1
539
+ return curstate
540
+ end
541
+ end
542
+ goto_default[k1]
543
+ end
544
+
545
+ # This method is called when a parse error is found.
546
+ #
547
+ # ERROR_TOKEN_ID is an internal ID of token which caused error.
548
+ # You can get string representation of this ID by calling
549
+ # #token_to_str.
550
+ #
551
+ # ERROR_VALUE is a value of error token.
552
+ #
553
+ # value_stack is a stack of symbol values.
554
+ # DO NOT MODIFY this object.
555
+ #
556
+ # This method raises ParseError by default.
557
+ #
558
+ # If this method returns, parsers enter "error recovering mode".
559
+ def on_error(t, val, vstack)
560
+ raise ParseError, sprintf("parse error on value %s (%s)",
561
+ val.inspect, token_to_str(t) || '?')
562
+ end
563
+
564
+ # Enter error recovering mode.
565
+ # This method does not call #on_error.
566
+ def yyerror
567
+ throw :racc_jump, 1
568
+ end
569
+
570
+ # Exit parser.
571
+ # Return value is +Symbol_Value_Stack[0]+.
572
+ def yyaccept
573
+ throw :racc_jump, 2
574
+ end
575
+
576
+ # Leave error recovering mode.
577
+ def yyerrok
578
+ @racc_error_status = 0
579
+ end
580
+
581
+ # For debugging output
582
+ def racc_read_token(t, tok, val)
583
+ @racc_debug_out.print 'read '
584
+ @racc_debug_out.print tok.inspect, '(', racc_token2str(t), ') '
585
+ @racc_debug_out.puts val.inspect
586
+ @racc_debug_out.puts
587
+ end
588
+
589
+ def racc_shift(tok, tstack, vstack)
590
+ @racc_debug_out.puts "shift #{racc_token2str tok}"
591
+ racc_print_stacks tstack, vstack
592
+ @racc_debug_out.puts
593
+ end
594
+
595
+ def racc_reduce(toks, sim, tstack, vstack)
596
+ out = @racc_debug_out
597
+ out.print 'reduce '
598
+ if toks.empty?
599
+ out.print ' <none>'
600
+ else
601
+ toks.each {|t| out.print ' ', racc_token2str(t) }
602
+ end
603
+ out.puts " --> #{racc_token2str(sim)}"
604
+ racc_print_stacks tstack, vstack
605
+ @racc_debug_out.puts
606
+ end
607
+
608
+ def racc_accept
609
+ @racc_debug_out.puts 'accept'
610
+ @racc_debug_out.puts
611
+ end
612
+
613
+ def racc_e_pop(state, tstack, vstack)
614
+ @racc_debug_out.puts 'error recovering mode: pop token'
615
+ racc_print_states state
616
+ racc_print_stacks tstack, vstack
617
+ @racc_debug_out.puts
618
+ end
619
+
620
+ def racc_next_state(curstate, state)
621
+ @racc_debug_out.puts "goto #{curstate}"
622
+ racc_print_states state
623
+ @racc_debug_out.puts
624
+ end
625
+
626
+ def racc_print_stacks(t, v)
627
+ out = @racc_debug_out
628
+ out.print ' ['
629
+ t.each_index do |i|
630
+ out.print ' (', racc_token2str(t[i]), ' ', v[i].inspect, ')'
631
+ end
632
+ out.puts ' ]'
633
+ end
634
+
635
+ def racc_print_states(s)
636
+ out = @racc_debug_out
637
+ out.print ' ['
638
+ s.each {|st| out.print ' ', st }
639
+ out.puts ' ]'
640
+ end
641
+
642
+ def racc_token2str(tok)
643
+ self.class::Racc_token_to_s_table[tok] or
644
+ raise "[Racc Bug] can't convert token #{tok} to string"
645
+ end
646
+
647
+ # Convert internal ID of token symbol to the string.
648
+ def token_to_str(t)
649
+ self.class::Racc_token_to_s_table[t]
650
+ end
651
+
652
+ end
653
+
654
+ end
655
+
656
+ ...end racc/parser.rb/module_eval...
657
+ end
658
+ ###### racc/parser.rb end
8
659
 
9
660
 
10
661
  require 'deep_merge'
data/lib/puffy/rule.rb CHANGED
@@ -64,8 +64,7 @@ module Puffy
64
64
  def initialize(options = {})
65
65
  send_options(options)
66
66
 
67
- @af = detect_af unless af
68
-
67
+ self.af ||= detect_af
69
68
  self.proto ||= from_proto_hint || to_proto_hint
70
69
 
71
70
  raise "unsupported action `#{options[:action]}'" unless valid_action?
data/lib/puffy/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Puffy # :nodoc:
4
- VERSION = '0.3.1'
4
+ VERSION = '1.0.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puffy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Romain Tartière
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-22 00:00:00.000000000 Z
11
+ date: 2024-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cri
@@ -47,6 +47,7 @@ extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
49
  - ".github/CODEOWNERS"
50
+ - ".github/dependabot.yml"
50
51
  - ".github/workflows/ci.yml"
51
52
  - ".gitignore"
52
53
  - ".rspec"
@@ -96,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
97
  - !ruby/object:Gem::Version
97
98
  version: '0'
98
99
  requirements: []
99
- rubygems_version: 3.4.20
100
+ rubygems_version: 3.3.15
100
101
  signing_key:
101
102
  specification_version: 4
102
103
  summary: Network firewall rules made easy!