psychgus 1.3.4 → 1.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,15 +3,13 @@
3
3
 
4
4
  #--
5
5
  # This file is part of Psychgus.
6
- # Copyright (c) 2019-2021 Jonathan Bradley Whited
6
+ # Copyright (c) 2019 Bradley Whited
7
7
  #
8
8
  # SPDX-License-Identifier: LGPL-3.0-or-later
9
9
  #++
10
10
 
11
-
12
11
  require 'delegate'
13
12
 
14
-
15
13
  module Psychgus
16
14
  class SuperSniffer
17
15
  ###
@@ -31,9 +29,6 @@ module Psychgus
31
29
  # # of Psychgus or that is not exposed by Parent
32
30
  # end
33
31
  #
34
- # @author Jonathan Bradley Whited
35
- # @since 1.0.0
36
- #
37
32
  # @see SuperSniffer
38
33
  # @see SuperSniffer#start_parent SuperSniffer#start_parent
39
34
  # @see SuperSniffer#end_parent SuperSniffer#end_parent
@@ -82,8 +77,6 @@ module Psychgus
82
77
  # Check if the children of this parent are keys to a Mapping.
83
78
  #
84
79
  # @return [true,false] whether the children are keys to a Mapping
85
- #
86
- # @since 1.2.0
87
80
  def child_key?
88
81
  return @child_type == :key
89
82
  end
@@ -91,8 +84,6 @@ module Psychgus
91
84
  # Check if the children of this parent are values to a Mapping (i.e., values to a key).
92
85
  #
93
86
  # @return [true,false] whether the children are values to a Mapping (i.e., values to a key)
94
- #
95
- # @since 1.2.0
96
87
  def child_value?
97
88
  return @child_type == :value
98
89
  end
@@ -3,21 +3,17 @@
3
3
 
4
4
  #--
5
5
  # This file is part of Psychgus.
6
- # Copyright (c) 2019-2021 Jonathan Bradley Whited
6
+ # Copyright (c) 2019 Bradley Whited
7
7
  #
8
8
  # SPDX-License-Identifier: LGPL-3.0-or-later
9
9
  #++
10
10
 
11
-
12
11
  require 'psychgus/super_sniffer/parent'
13
12
 
14
13
  module Psychgus
15
14
  class SuperSniffer
16
15
  ###
17
16
  # An empty {SuperSniffer} used for speed when you don't need sniffing in {StyledTreeBuilder}.
18
- #
19
- # @author Jonathan Bradley Whited
20
- # @since 1.0.0
21
17
  ###
22
18
  class Empty < SuperSniffer
23
19
  def add_alias(*) end
@@ -132,9 +128,6 @@ module Psychgus
132
128
  # @note You should never call the methods that are not readers, like {#add_alias}, {#start_mapping}, etc.
133
129
  # unless you are extending this class (creating a subclass).
134
130
  #
135
- # @author Jonathan Bradley Whited
136
- # @since 1.0.0
137
- #
138
131
  # @see StyledTreeBuilder
139
132
  # @see Styler
140
133
  # @see Blueberry#psychgus_stylers
@@ -3,13 +3,12 @@
3
3
 
4
4
  #--
5
5
  # This file is part of Psychgus.
6
- # Copyright (c) 2017-2021 Jonathan Bradley Whited
6
+ # Copyright (c) 2017 Bradley Whited
7
7
  #
8
8
  # SPDX-License-Identifier: LGPL-3.0-or-later
9
9
  #++
10
10
 
11
-
12
11
  module Psychgus
13
- # Version of this gem in "#.#.#" format
14
- VERSION = '1.3.4'
12
+ # Version of this gem in "#.#.#" format.
13
+ VERSION = '1.3.6'
15
14
  end
data/lib/psychgus.rb CHANGED
@@ -3,16 +3,14 @@
3
3
 
4
4
  #--
5
5
  # This file is part of Psychgus.
6
- # Copyright (c) 2017-2021 Jonathan Bradley Whited
6
+ # Copyright (c) 2017 Bradley Whited
7
7
  #
8
8
  # SPDX-License-Identifier: LGPL-3.0-or-later
9
9
  #++
10
10
 
11
-
12
11
  require 'psych'
13
12
 
14
13
  require 'psychgus/blueberry'
15
- require 'psychgus/ext'
16
14
  require 'psychgus/stylables'
17
15
  require 'psychgus/styled_document_stream'
18
16
  require 'psychgus/styled_tree_builder'
@@ -294,14 +292,11 @@ require 'psychgus/super_sniffer/parent'
294
292
  # parser.parse(yaml)
295
293
  # parser.handler
296
294
  # parser.handler.root
297
- #
298
- # @author Jonathan Bradley Whited
299
- # @since 1.0.0
300
295
  ###
301
296
  module Psychgus
302
297
  # Include these in the top namespace for convenience (i.e., less typing).
303
- include Stylables # @since 1.2.0
304
- include Stylers # @since 1.2.0
298
+ include Stylables
299
+ include Stylers
305
300
 
306
301
  NODE_CLASS_ALIASES = {Doc: :Document,Map: :Mapping,Seq: :Sequence}.freeze
307
302
  OPTIONS_ALIASES = {canon: :canonical,indent: :indentation}.freeze
@@ -337,7 +332,7 @@ module Psychgus
337
332
  # @return [Integer,Object] the constant value from the class (usually an int)
338
333
  #
339
334
  # @see .node_class
340
- def self.node_const(class_name,const_name,lenient=true)
335
+ def self.node_const(class_name,const_name,lenient: true)
341
336
  node_class = node_class(class_name)
342
337
  const_name = const_name.to_sym.upcase
343
338
 
@@ -383,7 +378,7 @@ module Psychgus
383
378
  #
384
379
  # @see .dump_stream
385
380
  # @see Psych.dump_stream
386
- def self.dump(object,io=nil,**options)
381
+ def self.dump(object,io = nil,**options)
387
382
  return dump_stream(object,io: io,**options)
388
383
  end
389
384
 
@@ -472,8 +467,10 @@ module Psychgus
472
467
  end
473
468
  end
474
469
 
475
- visitor = Psych::Visitors::YAMLTree.create(options,StyledTreeBuilder.new(*stylers,
476
- deref_aliases: deref_aliases))
470
+ visitor = Psych::Visitors::YAMLTree.create(
471
+ options,
472
+ StyledTreeBuilder.new(*stylers,deref_aliases: deref_aliases)
473
+ )
477
474
 
478
475
  if objects.empty?
479
476
  # Else, will throw a cryptic NoMethodError:
@@ -577,8 +574,6 @@ module Psychgus
577
574
  #
578
575
  # @see Stylers::HierarchyStyler
579
576
  # @see dump_stream
580
- #
581
- # @since 1.2.0
582
577
  def self.hierarchy(*objects,**kargs)
583
578
  styler = Stylers::HierarchyStyler.new(**kargs)
584
579
 
@@ -688,8 +683,9 @@ module Psychgus
688
683
  # @see Psych::SyntaxError
689
684
  def self.parse_stream(yaml,filename: nil,stylers: nil,deref_aliases: false,**options,&block)
690
685
  if block_given?
691
- parser = Psych::Parser.new(StyledDocumentStream.new(*stylers,deref_aliases: deref_aliases,**options,
692
- &block))
686
+ parser = Psych::Parser.new(
687
+ StyledDocumentStream.new(*stylers,deref_aliases: deref_aliases,**options,&block)
688
+ )
693
689
 
694
690
  return parser.parse(yaml,filename)
695
691
  else
@@ -757,9 +753,6 @@ module Psychgus
757
753
  # Private methods of Psych are not defined.
758
754
  #
759
755
  # @note For devs/hacking: because extend is used, do not prefix methods with "self."
760
- #
761
- # @author Jonathan Bradley Whited
762
- # @since 1.0.0
763
756
  ###
764
757
  module PsychDropIn
765
758
  # @see Psych.add_builtin_type
data/psychgus.gemspec CHANGED
@@ -1,14 +1,12 @@
1
1
  # encoding: UTF-8
2
2
  # frozen_string_literal: true
3
3
 
4
-
5
4
  require_relative 'lib/psychgus/version'
6
5
 
7
-
8
6
  Gem::Specification.new do |spec|
9
7
  spec.name = 'psychgus'
10
8
  spec.version = Psychgus::VERSION
11
- spec.authors = ['Jonathan Bradley Whited']
9
+ spec.authors = ['Bradley Whited']
12
10
  spec.email = ['code@esotericpig.com']
13
11
  spec.licenses = ['LGPL-3.0-or-later']
14
12
  spec.homepage = 'https://github.com/esotericpig/psychgus'
@@ -16,14 +14,15 @@ Gem::Specification.new do |spec|
16
14
  spec.description = 'Easily style YAML files using Psych, like Sequence/Mapping Flow style.'
17
15
 
18
16
  spec.metadata = {
19
- 'homepage_uri' => 'https://github.com/esotericpig/psychgus',
20
- 'source_code_uri' => 'https://github.com/esotericpig/psychgus',
21
- 'bug_tracker_uri' => 'https://github.com/esotericpig/psychgus/issues',
22
- 'changelog_uri' => 'https://github.com/esotericpig/psychgus/blob/master/CHANGELOG.md',
23
- 'documentation_uri' => 'https://esotericpig.github.io/docs/psychgus/yardoc/index.html',
17
+ 'rubygems_mfa_required' => 'true',
18
+ 'homepage_uri' => 'https://github.com/esotericpig/psychgus',
19
+ 'source_code_uri' => 'https://github.com/esotericpig/psychgus',
20
+ 'bug_tracker_uri' => 'https://github.com/esotericpig/psychgus/issues',
21
+ 'changelog_uri' => 'https://github.com/esotericpig/psychgus/blob/main/CHANGELOG.md',
22
+ 'documentation_uri' => 'https://esotericpig.github.io/docs/psychgus/yardoc/index.html',
24
23
  }
25
24
 
26
- spec.required_ruby_version = '>= 2.1.10'
25
+ spec.required_ruby_version = '>= 2.2'
27
26
  spec.require_paths = ['lib']
28
27
  spec.bindir = 'bin'
29
28
 
@@ -31,18 +30,20 @@ Gem::Specification.new do |spec|
31
30
  Dir.glob(File.join("{#{spec.require_paths.join(',')}}",'**','*.{erb,rb}')),
32
31
  Dir.glob(File.join(spec.bindir,'*')),
33
32
  Dir.glob(File.join('{samples,test,yard}','**','*.{erb,rb}')),
34
- %W[ Gemfile #{spec.name}.gemspec Rakefile .yardopts ],
35
- %w[ LICENSE.txt CHANGELOG.md README.md ],
33
+ %W[Gemfile #{spec.name}.gemspec Rakefile .yardopts],
34
+ %w[LICENSE.txt CHANGELOG.md README.md],
36
35
  ].flatten
37
36
 
38
37
  # Test using different Gem versions:
39
- # GST=1 bundle update && bundle exec rake test_all
38
+ # GST=1 bundle update && bundle exec rake test
40
39
  gemspec_test = ENV.fetch('GST','').to_s.strip
41
40
  psych_gemv = false
42
41
 
43
42
  if !gemspec_test.empty?
44
43
  case gemspec_test
45
- when '1' then psych_gemv = '~> 3.0'
44
+ when '1' then psych_gemv = '<= 5.1.1'
45
+ when '2' then psych_gemv = '5.1.2'
46
+ when '3' then psych_gemv = '5.2.0'
46
47
  end
47
48
 
48
49
  puts 'Using Gem versions:'
@@ -52,13 +53,5 @@ Gem::Specification.new do |spec|
52
53
  # 3.0 is needed for this issue:
53
54
  # - https://bugs.ruby-lang.org/issues/13115
54
55
  # - https://github.com/ruby/psych/commit/712a65a53f3c15105cd86e8ad3ee3c779050ada4
55
- spec.add_runtime_dependency 'psych',psych_gemv || '>= 3.0'
56
-
57
- spec.add_development_dependency 'bundler' ,'~> 2.2'
58
- spec.add_development_dependency 'minitest' ,'~> 5.14' # For testing
59
- spec.add_development_dependency 'rake' ,'~> 13.0'
60
- spec.add_development_dependency 'rdoc' ,'~> 6.3' # For RDoc for YARD (*.rb)
61
- spec.add_development_dependency 'redcarpet' ,'~> 3.5' # For Markdown for YARD (*.md)
62
- spec.add_development_dependency 'yard' ,'~> 0.9' # For documentation
63
- spec.add_development_dependency 'yard_ghurt','~> 1.2' # For YARD GitHub rake tasks
56
+ spec.add_dependency 'psych',psych_gemv || '>= 3.0'
64
57
  end
@@ -3,35 +3,44 @@
3
3
 
4
4
  #--
5
5
  # This file is part of Psychgus.
6
- # Copyright (c) 2019-2021 Jonathan Bradley Whited
6
+ # Copyright (c) 2019 Bradley Whited
7
7
  #
8
8
  # SPDX-License-Identifier: LGPL-3.0-or-later
9
9
  #++
10
10
 
11
+ require 'test_helper'
11
12
 
12
- require 'psychgus_tester'
13
-
14
- class Burger
15
- include Psychgus::Blueberry
16
-
17
- attr_accessor :bun
18
- attr_accessor :cheese
19
- attr_accessor :sauce
20
-
21
- def initialize(sauce,cheese,bun)
22
- @bun = bun
23
- @cheese = cheese
24
- @sauce = sauce
13
+ class BlueberryTest < Minitest::Test
14
+ def setup
15
+ @burgers = Burgers.new
25
16
  end
26
17
 
27
- def encode_with(coder)
28
- coder['Bun'] = @bun
29
- coder['Cheese'] = @cheese
30
- coder['Sauce'] = @sauce
31
- end
18
+ def test_blueberry
19
+ expected = TestHelper.lstrip_pipe(<<-YAML)
20
+ |--- !ruby/object:Burgers
21
+ |Burgers:
22
+ | Classic:
23
+ | 'Bun': 'Sesame Seed'
24
+ | 'Cheese': 'American'
25
+ | 'Sauce': ['Ketchup', 'Mustard']
26
+ | BBQ: {'Bun': 'Kaiser', 'Cheese': 'Cheddar', 'Sauce': 'Honey BBQ'}
27
+ | Fancy:
28
+ | 'Bun': 'Hawaiian'
29
+ | 'Cheese': 'Smoked Gouda'
30
+ | 'Sauce': 'Spicy Wasabi'
31
+ |Toppings:
32
+ |- Mushrooms
33
+ |- - Lettuce
34
+ | - Onions
35
+ | - Pickles
36
+ | - Tomatoes
37
+ |- - - Ketchup
38
+ | - Mustard
39
+ | - - Salt
40
+ | - Pepper
41
+ YAML
32
42
 
33
- def psychgus_stylers(sniffer)
34
- return BurgerStyler.new(sniffer)
43
+ assert_equal expected,@burgers.to_yaml
35
44
  end
36
45
  end
37
46
 
@@ -43,13 +52,13 @@ class Burgers
43
52
  @burgers = {
44
53
  'Classic' => Burger.new(['Ketchup','Mustard'],'American','Sesame Seed'),
45
54
  'BBQ' => Burger.new('Honey BBQ','Cheddar','Kaiser'),
46
- 'Fancy' => Burger.new('Spicy Wasabi','Smoked Gouda','Hawaiian')
55
+ 'Fancy' => Burger.new('Spicy Wasabi','Smoked Gouda','Hawaiian'),
47
56
  }
48
57
 
49
58
  @toppings = [
50
59
  'Mushrooms',
51
60
  %w[Lettuce Onions Pickles Tomatoes],
52
- [%w[Ketchup Mustard],%w[Salt Pepper]]
61
+ [%w[Ketchup Mustard],%w[Salt Pepper]],
53
62
  ]
54
63
  end
55
64
 
@@ -67,64 +76,53 @@ class BurgerStyler
67
76
  @position = sniffer.position
68
77
  end
69
78
 
70
- def style(sniffer,node)
71
- # Remove ugly and unsafe "!ruby/object:Burger"
79
+ def style(_sniffer,node)
80
+ # Remove ugly and unsafe `!ruby/object:Burger`.
72
81
  node.tag = nil if node.respond_to?(:tag)
73
82
  end
74
83
 
75
84
  def style_mapping(sniffer,node)
76
85
  parent = sniffer.parent
77
86
 
78
- if !parent.nil?
79
- # BBQ
80
- node.style = Psychgus::MAPPING_FLOW if parent.respond_to?(:value) && parent.value.casecmp('BBQ') == 0
87
+ if !parent.nil? && parent.respond_to?(:value) && parent.value.casecmp('BBQ') == 0
88
+ # BBQ.
89
+ node.style = Psychgus::MAPPING_FLOW
81
90
  end
82
91
  end
83
92
 
84
- def style_scalar(sniffer,node)
85
- # Only for Burgers
93
+ def style_scalar(_sniffer,node)
94
+ # Only for Burgers.
86
95
  node.style = Psychgus::SCALAR_SINGLE_QUOTED
87
96
  end
88
97
 
89
98
  def style_sequence(sniffer,node)
90
99
  relative_level = (sniffer.level - @level) + 1
91
100
 
92
- # [Ketchup, Mustard]
101
+ # [Ketchup, Mustard].
93
102
  node.style = Psychgus::SEQUENCE_FLOW if relative_level == 3
94
103
  end
95
104
  end
96
105
 
97
- class BlueberryTest < PsychgusTester
98
- def setup
99
- @burgers = Burgers.new
106
+ class Burger
107
+ include Psychgus::Blueberry
108
+
109
+ attr_accessor :bun
110
+ attr_accessor :cheese
111
+ attr_accessor :sauce
112
+
113
+ def initialize(sauce,cheese,bun)
114
+ @bun = bun
115
+ @cheese = cheese
116
+ @sauce = sauce
100
117
  end
101
118
 
102
- def test_blueberry
103
- expected = <<-YAML
104
- |--- !ruby/object:Burgers
105
- |Burgers:
106
- | Classic:
107
- | 'Bun': 'Sesame Seed'
108
- | 'Cheese': 'American'
109
- | 'Sauce': ['Ketchup', 'Mustard']
110
- | BBQ: {'Bun': 'Kaiser', 'Cheese': 'Cheddar', 'Sauce': 'Honey BBQ'}
111
- | Fancy:
112
- | 'Bun': 'Hawaiian'
113
- | 'Cheese': 'Smoked Gouda'
114
- | 'Sauce': 'Spicy Wasabi'
115
- |Toppings:
116
- |- Mushrooms
117
- |- - Lettuce
118
- | - Onions
119
- | - Pickles
120
- | - Tomatoes
121
- |- - - Ketchup
122
- | - Mustard
123
- | - - Salt
124
- | - Pepper
125
- YAML
126
- expected = self.class.lstrip_pipe(expected)
119
+ def encode_with(coder)
120
+ coder['Bun'] = @bun
121
+ coder['Cheese'] = @cheese
122
+ coder['Sauce'] = @sauce
123
+ end
127
124
 
128
- assert_equal expected,@burgers.to_yaml
125
+ def psychgus_stylers(sniffer)
126
+ return BurgerStyler.new(sniffer)
129
127
  end
130
128
  end
@@ -3,29 +3,16 @@
3
3
 
4
4
  #--
5
5
  # This file is part of Psychgus.
6
- # Copyright (c) 2019-2021 Jonathan Bradley Whited
6
+ # Copyright (c) 2019 Bradley Whited
7
7
  #
8
8
  # SPDX-License-Identifier: LGPL-3.0-or-later
9
9
  #++
10
10
 
11
-
12
- require 'psychgus_tester'
11
+ require 'test_helper'
13
12
 
14
13
  require 'tempfile'
15
14
 
16
- class FlowStyler
17
- include Psychgus::Styler
18
-
19
- def style_mapping(sniffer,node)
20
- node.style = Psychgus::MAPPING_FLOW if sniffer.level >= 4
21
- end
22
-
23
- def style_sequence(sniffer,node)
24
- node.style = Psychgus::SEQUENCE_FLOW if sniffer.level >= 4
25
- end
26
- end
27
-
28
- class PsychgusTest < PsychgusTester
15
+ class PsychgusTest < Minitest::Test
29
16
  EXPECTED_BURGERS = <<-YAML
30
17
  ---
31
18
  Burgers:
@@ -43,7 +30,7 @@ Toppings:
43
30
  end
44
31
 
45
32
  def test_alias
46
- expected = <<-YAML
33
+ expected = TestHelper.lstrip_pipe(<<-YAML)
47
34
  |---
48
35
  |Dolphins:
49
36
  | Common: {Length: "~2.5m", Weight: "~235kg"}
@@ -54,31 +41,25 @@ Toppings:
54
41
  |- {Length: "~4m", Weight: "~300kg"}
55
42
  |- {Length: "~7m", Weight: "~3600kg"}
56
43
  YAML
57
- expected = self.class.lstrip_pipe(expected)
58
44
 
59
- assert_equal expected,DOLPHINS_DATA.to_yaml(deref_aliases: true,stylers: @flow_styler)
45
+ assert_equal expected,TestHelper::DOLPHINS_DATA.to_yaml(deref_aliases: true,stylers: @flow_styler)
60
46
  end
61
47
 
62
48
  def test_dump
63
- assert_equal EXPECTED_BURGERS,Psychgus.dump(BURGERS_DATA,stylers: @flow_styler)
64
- assert_equal EXPECTED_BURGERS,Psychgus.dump_stream(BURGERS_DATA,stylers: @flow_styler)
65
- assert_equal EXPECTED_BURGERS,BURGERS_DATA.to_yaml(stylers: @flow_styler)
49
+ assert_equal EXPECTED_BURGERS,Psychgus.dump(TestHelper::BURGERS_DATA,stylers: @flow_styler)
50
+ assert_equal EXPECTED_BURGERS,Psychgus.dump_stream(TestHelper::BURGERS_DATA,stylers: @flow_styler)
51
+ assert_equal EXPECTED_BURGERS,TestHelper::BURGERS_DATA.to_yaml(stylers: @flow_styler)
66
52
  end
67
53
 
68
- # Execute "rake test_all" if you update Psychgus.dump_file()/load_file()
69
54
  def test_file
70
- if !TEST_ALL
71
- skip(TEST_ALL_SKIP_MSG)
72
- return # Justin Case
73
- end
74
-
75
55
  Tempfile.create(['Psychgus','.yaml']) do |file|
76
- puts "Testing #{self.class.name} w/ temp file: #{file.path}"
56
+ # puts "Testing #{self.class.name} w/ temp file: #{file.path}"
77
57
 
78
- Psychgus.dump_file(file,BURGERS_DATA,
58
+ Psychgus.dump_file(
59
+ file,TestHelper::BURGERS_DATA,
79
60
  mode: File::CREAT | File::RDWR,
80
61
  opt: {textmode: true},
81
- #perm: 644, # Unix only
62
+ # perm: 644, # Unix only
82
63
  stylers: @flow_styler,
83
64
  )
84
65
 
@@ -101,8 +82,8 @@ Toppings:
101
82
  end
102
83
 
103
84
  def test_indent
104
- # Indent of 3 spaces
105
- expected = <<-YAML
85
+ # Indent of 3 spaces, like a crazy person.
86
+ expected = TestHelper.lstrip_pipe(<<-YAML)
106
87
  |---
107
88
  |Burgers:
108
89
  | Classic: {Sauce: [Ketchup, Mustard], Cheese: American, Bun: Sesame Seed}
@@ -113,13 +94,12 @@ Toppings:
113
94
  |- [Lettuce, Onions, Pickles, Tomatoes]
114
95
  |- [[Ketchup, Mustard], [Salt, Pepper]]
115
96
  YAML
116
- expected = self.class.lstrip_pipe(expected)
117
97
 
118
98
  # rubocop:disable Style/HashSyntax
119
- assert_equal expected,BURGERS_DATA.to_yaml(indent: 3,stylers: @flow_styler)
120
- assert_equal expected,BURGERS_DATA.to_yaml(**{:indent => 3,:stylers => @flow_styler})
121
- assert_equal expected,BURGERS_DATA.to_yaml(indentation: 3,stylers: @flow_styler)
122
- assert_equal expected,BURGERS_DATA.to_yaml(**{:indentation => 3,:stylers => @flow_styler})
99
+ assert_equal expected,TestHelper::BURGERS_DATA.to_yaml(indent: 3,stylers: @flow_styler)
100
+ assert_equal expected,TestHelper::BURGERS_DATA.to_yaml(**{:indent => 3,:stylers => @flow_styler})
101
+ assert_equal expected,TestHelper::BURGERS_DATA.to_yaml(indentation: 3,stylers: @flow_styler)
102
+ assert_equal expected,TestHelper::BURGERS_DATA.to_yaml(**{:indentation => 3,:stylers => @flow_styler})
123
103
  # rubocop:enable all
124
104
  end
125
105
 
@@ -147,15 +127,27 @@ Toppings:
147
127
 
148
128
  def test_parse
149
129
  parser = Psychgus.parser(stylers: @flow_styler)
150
- parser.parse(BURGERS_YAML)
151
- yaml = "---\n" + parser.handler.root.to_yaml
130
+ parser.parse(TestHelper::BURGERS_YAML)
131
+ yaml = "---\n#{parser.handler.root.to_yaml}"
152
132
  assert_equal EXPECTED_BURGERS,yaml
153
133
 
154
- node = Psychgus.parse(BURGERS_YAML,stylers: @flow_styler)
134
+ node = Psychgus.parse(TestHelper::BURGERS_YAML,stylers: @flow_styler)
155
135
  refute_equal false,node
156
136
 
157
- yaml = Psychgus.parse_stream(BURGERS_YAML,stylers: @flow_styler).to_yaml
137
+ yaml = Psychgus.parse_stream(TestHelper::BURGERS_YAML,stylers: @flow_styler).to_yaml
158
138
  yaml = "---\n#{yaml}"
159
139
  assert_equal EXPECTED_BURGERS,yaml
160
140
  end
161
141
  end
142
+
143
+ class FlowStyler
144
+ include Psychgus::Styler
145
+
146
+ def style_mapping(sniffer,node)
147
+ node.style = Psychgus::MAPPING_FLOW if sniffer.level >= 4
148
+ end
149
+
150
+ def style_sequence(sniffer,node)
151
+ node.style = Psychgus::SEQUENCE_FLOW if sniffer.level >= 4
152
+ end
153
+ end
data/test/sniffer_test.rb CHANGED
@@ -3,29 +3,28 @@
3
3
 
4
4
  #--
5
5
  # This file is part of Psychgus.
6
- # Copyright (c) 2019-2021 Jonathan Bradley Whited
6
+ # Copyright (c) 2019 Bradley Whited
7
7
  #
8
8
  # SPDX-License-Identifier: LGPL-3.0-or-later
9
9
  #++
10
10
 
11
-
12
- require 'psychgus_tester'
11
+ require 'test_helper'
13
12
 
14
13
  require 'stringio'
15
14
 
16
- class SnifferTest < PsychgusTester
15
+ class SnifferTest < Minitest::Test
17
16
  def setup
18
17
  end
19
18
 
20
19
  def assert_hierarchy(*data,expected)
21
- expected = self.class.lstrip_pipe(expected)
20
+ expected = TestHelper.lstrip_pipe(expected)
22
21
  hierarchy = Psychgus.hierarchy(*data,verbose: true)
23
22
 
24
23
  assert_equal expected,hierarchy
25
24
  end
26
25
 
27
26
  def test_multi_doc
28
- assert_hierarchy(BURGERS_DATA,COURSES_DATA,DOLPHINS_DATA,<<-HIER)
27
+ assert_hierarchy(TestHelper::BURGERS_DATA,TestHelper::COURSES_DATA,TestHelper::DOLPHINS_DATA,<<-HIER)
29
28
  |(1:1):Psych::Nodes::Stream - <root:(0:0)::(:1)>
30
29
  |(1:1):Psych::Nodes::Document - <stream:(1:1)::(:1)>
31
30
  |(1:1):Psych::Nodes::Mapping - <doc:(1:1)::(:1)>
@@ -146,7 +145,7 @@ class SnifferTest < PsychgusTester
146
145
  end
147
146
 
148
147
  def test_single_docs
149
- assert_hierarchy(BURGERS_DATA,<<-HIER)
148
+ assert_hierarchy(TestHelper::BURGERS_DATA,<<-HIER)
150
149
  |(1:1):Psych::Nodes::Stream - <root:(0:0)::(:1)>
151
150
  |(1:1):Psych::Nodes::Document - <stream:(1:1)::(:1)>
152
151
  |(1:1):Psych::Nodes::Mapping - <doc:(1:1)::(:1)>
@@ -195,7 +194,7 @@ class SnifferTest < PsychgusTester
195
194
  | (6:2):Pepper - <seq:(5:2)::(:2)>
196
195
  HIER
197
196
 
198
- assert_hierarchy(COURSES_DATA,<<-HIER)
197
+ assert_hierarchy(TestHelper::COURSES_DATA,<<-HIER)
199
198
  |(1:1):Psych::Nodes::Stream - <root:(0:0)::(:1)>
200
199
  |(1:1):Psych::Nodes::Document - <stream:(1:1)::(:1)>
201
200
  |(1:1):Psych::Nodes::Mapping - <doc:(1:1)::(:1)>