Module: Fluent::Auditify::Helper::Test
- Defined in:
- lib/fluent/auditify/helper/test.rb
Instance Method Summary collapse
- #discard ⇒ Object
- #test_mask_charges(options = {}) ⇒ Object
- #test_parse_content_with_debug(content, klass: Fluent::Auditify::Parser::V1ConfigParser) ⇒ Object
- #test_parse_includes(params) {|parent, child| ... } ⇒ Object
- #test_parse_path_with_debug(path, klass: Fluent::Auditify::Parser::V1ConfigParser) ⇒ Object
- #test_parse_with_debug(path_or_content, klass = Fluent::Auditify::Parser::V1ConfigParser) ⇒ Object
Instance Method Details
#discard ⇒ Object
6 7 8 |
# File 'lib/fluent/auditify/helper/test.rb', line 6 def discard Fluent::Auditify::Plugin.discard end |
#test_mask_charges(options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fluent/auditify/helper/test.rb', line 10 def test_mask_charges(={}) masked = [] Fluent::Auditify::Plugin.charges.each do |entry| level, , attrs = entry value = { path: File.basename(attrs[:path]), content: attrs[:content], line: attrs[:line] } if [:omit_line] value.delete(:line) end if [:strip_content] value[:content].strip! end masked << [level, , value] end masked end |
#test_parse_content_with_debug(content, klass: Fluent::Auditify::Parser::V1ConfigParser) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fluent/auditify/helper/test.rb', line 39 def test_parse_content_with_debug(content, klass: Fluent::Auditify::Parser::V1ConfigParser) begin parser = klass.new object = parser.parse(content) rescue => e pastel = Pastel.new puts pastel.white.on_red("[FAIL]") + " class: #{klass}" puts ">>>\n" + content.strip + "\n<<<\n" puts e.parse_failure_cause.ascii_tree end object end |
#test_parse_includes(params) {|parent, child| ... } ⇒ Object
65 66 67 68 69 |
# File 'lib/fluent/auditify/helper/test.rb', line 65 def test_parse_includes(params) parent = test_parse_with_debug(params[:parent_class], params[:parent_path]) child = test_parse_with_debug(params[:child_class], params[:child_path]) yield parent, child end |
#test_parse_path_with_debug(path, klass: Fluent::Auditify::Parser::V1ConfigParser) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/fluent/auditify/helper/test.rb', line 52 def test_parse_path_with_debug(path, klass: Fluent::Auditify::Parser::V1ConfigParser) begin parser = klass.new object = parser.parse(File.read(test_fixture_path(path))) rescue => e pastel = Pastel.new puts pastel.white.on_red("[FAIL]") + " class: #{klass}, path: #{path}" puts ">>>\n" + File.read(test_fixture_path(path)) + "<<<\n" puts e.parse_failure_cause.ascii_tree end object end |
#test_parse_with_debug(path_or_content, klass = Fluent::Auditify::Parser::V1ConfigParser) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/fluent/auditify/helper/test.rb', line 30 def test_parse_with_debug(path_or_content, klass = Fluent::Auditify::Parser::V1ConfigParser) object = if File.exist?(test_fixture_path(path_or_content)) test_parse_path_with_debug(path_or_content, klass) else test_parse_content_with_debug(path_or_content, klass) end object end |