psychgus 1.3.5 → 1.3.7

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.
data/psychgus.gemspec CHANGED
@@ -14,11 +14,12 @@ Gem::Specification.new do |spec|
14
14
  spec.description = 'Easily style YAML files using Psych, like Sequence/Mapping Flow style.'
15
15
 
16
16
  spec.metadata = {
17
- 'homepage_uri' => 'https://github.com/esotericpig/psychgus',
18
- 'source_code_uri' => 'https://github.com/esotericpig/psychgus',
19
- 'bug_tracker_uri' => 'https://github.com/esotericpig/psychgus/issues',
20
- 'changelog_uri' => 'https://github.com/esotericpig/psychgus/blob/master/CHANGELOG.md',
21
- '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',
22
23
  }
23
24
 
24
25
  spec.required_ruby_version = '>= 2.2'
@@ -26,11 +27,11 @@ Gem::Specification.new do |spec|
26
27
  spec.bindir = 'bin'
27
28
 
28
29
  spec.files = [
29
- Dir.glob(File.join("{#{spec.require_paths.join(',')}}",'**','*.{erb,rb}')),
30
- Dir.glob(File.join(spec.bindir,'*')),
31
- Dir.glob(File.join('{samples,test,yard}','**','*.{erb,rb}')),
32
- %W[ Gemfile #{spec.name}.gemspec Rakefile .yardopts ],
33
- %w[ LICENSE.txt CHANGELOG.md README.md ],
30
+ Dir.glob("{#{spec.require_paths.join(',')}}/**/*.{erb,rb}"),
31
+ Dir.glob("#{spec.bindir}/*"),
32
+ Dir.glob('{samples,test,yard}/**/*.{erb,rb}'),
33
+ %W[Gemfile #{spec.name}.gemspec Rakefile .yardopts],
34
+ %w[LICENSE.txt CHANGELOG.md README.md],
34
35
  ].flatten
35
36
 
36
37
  # Test using different Gem versions:
@@ -41,6 +42,8 @@ Gem::Specification.new do |spec|
41
42
  if !gemspec_test.empty?
42
43
  case gemspec_test
43
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'
44
47
  end
45
48
 
46
49
  puts 'Using Gem versions:'
@@ -8,29 +8,39 @@
8
8
  # SPDX-License-Identifier: LGPL-3.0-or-later
9
9
  #++
10
10
 
11
- require 'psychgus_tester'
11
+ require 'test_helper'
12
12
 
13
- class Burger
14
- include Psychgus::Blueberry
15
-
16
- attr_accessor :bun
17
- attr_accessor :cheese
18
- attr_accessor :sauce
19
-
20
- def initialize(sauce,cheese,bun)
21
- @bun = bun
22
- @cheese = cheese
23
- @sauce = sauce
13
+ class BlueberryTest < Minitest::Test
14
+ def setup
15
+ @burgers = Burgers.new
24
16
  end
25
17
 
26
- def encode_with(coder)
27
- coder['Bun'] = @bun
28
- coder['Cheese'] = @cheese
29
- coder['Sauce'] = @sauce
30
- 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
31
42
 
32
- def psychgus_stylers(sniffer)
33
- return BurgerStyler.new(sniffer)
43
+ assert_equal expected,@burgers.to_yaml
34
44
  end
35
45
  end
36
46
 
@@ -42,13 +52,13 @@ class Burgers
42
52
  @burgers = {
43
53
  'Classic' => Burger.new(['Ketchup','Mustard'],'American','Sesame Seed'),
44
54
  'BBQ' => Burger.new('Honey BBQ','Cheddar','Kaiser'),
45
- 'Fancy' => Burger.new('Spicy Wasabi','Smoked Gouda','Hawaiian')
55
+ 'Fancy' => Burger.new('Spicy Wasabi','Smoked Gouda','Hawaiian'),
46
56
  }
47
57
 
48
58
  @toppings = [
49
59
  'Mushrooms',
50
60
  %w[Lettuce Onions Pickles Tomatoes],
51
- [%w[Ketchup Mustard],%w[Salt Pepper]]
61
+ [%w[Ketchup Mustard],%w[Salt Pepper]],
52
62
  ]
53
63
  end
54
64
 
@@ -66,64 +76,53 @@ class BurgerStyler
66
76
  @position = sniffer.position
67
77
  end
68
78
 
69
- def style(sniffer,node)
70
- # Remove ugly and unsafe "!ruby/object:Burger"
79
+ def style(_sniffer,node)
80
+ # Remove ugly and unsafe `!ruby/object:Burger`.
71
81
  node.tag = nil if node.respond_to?(:tag)
72
82
  end
73
83
 
74
84
  def style_mapping(sniffer,node)
75
85
  parent = sniffer.parent
76
86
 
77
- if !parent.nil?
78
- # BBQ
79
- 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
80
90
  end
81
91
  end
82
92
 
83
- def style_scalar(sniffer,node)
84
- # Only for Burgers
93
+ def style_scalar(_sniffer,node)
94
+ # Only for Burgers.
85
95
  node.style = Psychgus::SCALAR_SINGLE_QUOTED
86
96
  end
87
97
 
88
98
  def style_sequence(sniffer,node)
89
99
  relative_level = (sniffer.level - @level) + 1
90
100
 
91
- # [Ketchup, Mustard]
101
+ # [Ketchup, Mustard].
92
102
  node.style = Psychgus::SEQUENCE_FLOW if relative_level == 3
93
103
  end
94
104
  end
95
105
 
96
- class BlueberryTest < PsychgusTester
97
- def setup
98
- @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
99
117
  end
100
118
 
101
- def test_blueberry
102
- expected = <<-YAML
103
- |--- !ruby/object:Burgers
104
- |Burgers:
105
- | Classic:
106
- | 'Bun': 'Sesame Seed'
107
- | 'Cheese': 'American'
108
- | 'Sauce': ['Ketchup', 'Mustard']
109
- | BBQ: {'Bun': 'Kaiser', 'Cheese': 'Cheddar', 'Sauce': 'Honey BBQ'}
110
- | Fancy:
111
- | 'Bun': 'Hawaiian'
112
- | 'Cheese': 'Smoked Gouda'
113
- | 'Sauce': 'Spicy Wasabi'
114
- |Toppings:
115
- |- Mushrooms
116
- |- - Lettuce
117
- | - Onions
118
- | - Pickles
119
- | - Tomatoes
120
- |- - - Ketchup
121
- | - Mustard
122
- | - - Salt
123
- | - Pepper
124
- YAML
125
- 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
126
124
 
127
- assert_equal expected,@burgers.to_yaml
125
+ def psychgus_stylers(sniffer)
126
+ return BurgerStyler.new(sniffer)
128
127
  end
129
128
  end
@@ -8,23 +8,11 @@
8
8
  # SPDX-License-Identifier: LGPL-3.0-or-later
9
9
  #++
10
10
 
11
- require 'psychgus_tester'
11
+ require 'test_helper'
12
12
 
13
13
  require 'tempfile'
14
14
 
15
- class FlowStyler
16
- include Psychgus::Styler
17
-
18
- def style_mapping(sniffer,node)
19
- node.style = Psychgus::MAPPING_FLOW if sniffer.level >= 4
20
- end
21
-
22
- def style_sequence(sniffer,node)
23
- node.style = Psychgus::SEQUENCE_FLOW if sniffer.level >= 4
24
- end
25
- end
26
-
27
- class PsychgusTest < PsychgusTester
15
+ class PsychgusTest < Minitest::Test
28
16
  EXPECTED_BURGERS = <<-YAML
29
17
  ---
30
18
  Burgers:
@@ -42,7 +30,7 @@ Toppings:
42
30
  end
43
31
 
44
32
  def test_alias
45
- expected = <<-YAML
33
+ expected = TestHelper.lstrip_pipe(<<-YAML)
46
34
  |---
47
35
  |Dolphins:
48
36
  | Common: {Length: "~2.5m", Weight: "~235kg"}
@@ -53,25 +41,25 @@ Toppings:
53
41
  |- {Length: "~4m", Weight: "~300kg"}
54
42
  |- {Length: "~7m", Weight: "~3600kg"}
55
43
  YAML
56
- expected = self.class.lstrip_pipe(expected)
57
44
 
58
- 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)
59
46
  end
60
47
 
61
48
  def test_dump
62
- assert_equal EXPECTED_BURGERS,Psychgus.dump(BURGERS_DATA,stylers: @flow_styler)
63
- assert_equal EXPECTED_BURGERS,Psychgus.dump_stream(BURGERS_DATA,stylers: @flow_styler)
64
- 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)
65
52
  end
66
53
 
67
54
  def test_file
68
55
  Tempfile.create(['Psychgus','.yaml']) do |file|
69
- #puts "Testing #{self.class.name} w/ temp file: #{file.path}"
56
+ # puts "Testing #{self.class.name} w/ temp file: #{file.path}"
70
57
 
71
- Psychgus.dump_file(file,BURGERS_DATA,
58
+ Psychgus.dump_file(
59
+ file,TestHelper::BURGERS_DATA,
72
60
  mode: File::CREAT | File::RDWR,
73
61
  opt: {textmode: true},
74
- #perm: 644, # Unix only
62
+ # perm: 644, # Unix only
75
63
  stylers: @flow_styler,
76
64
  )
77
65
 
@@ -85,17 +73,17 @@ Toppings:
85
73
 
86
74
  data = Psych.load_file(file)
87
75
  refute_equal false,data
88
- refute_equal nil,data
76
+ refute_nil data
89
77
 
90
78
  data = Psychgus.parse_file(file)
91
79
  refute_equal false,data
92
- refute_equal nil,data
80
+ refute_nil data
93
81
  end
94
82
  end
95
83
 
96
84
  def test_indent
97
- # Indent of 3 spaces
98
- expected = <<-YAML
85
+ # Indent of 3 spaces, like a crazy person.
86
+ expected = TestHelper.lstrip_pipe(<<-YAML)
99
87
  |---
100
88
  |Burgers:
101
89
  | Classic: {Sauce: [Ketchup, Mustard], Cheese: American, Bun: Sesame Seed}
@@ -106,13 +94,12 @@ Toppings:
106
94
  |- [Lettuce, Onions, Pickles, Tomatoes]
107
95
  |- [[Ketchup, Mustard], [Salt, Pepper]]
108
96
  YAML
109
- expected = self.class.lstrip_pipe(expected)
110
97
 
111
98
  # rubocop:disable Style/HashSyntax
112
- assert_equal expected,BURGERS_DATA.to_yaml(indent: 3,stylers: @flow_styler)
113
- assert_equal expected,BURGERS_DATA.to_yaml(**{:indent => 3,:stylers => @flow_styler})
114
- assert_equal expected,BURGERS_DATA.to_yaml(indentation: 3,stylers: @flow_styler)
115
- 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})
116
103
  # rubocop:enable all
117
104
  end
118
105
 
@@ -140,15 +127,27 @@ Toppings:
140
127
 
141
128
  def test_parse
142
129
  parser = Psychgus.parser(stylers: @flow_styler)
143
- parser.parse(BURGERS_YAML)
144
- yaml = "---\n" + parser.handler.root.to_yaml
130
+ parser.parse(TestHelper::BURGERS_YAML)
131
+ yaml = "---\n#{parser.handler.root.to_yaml}"
145
132
  assert_equal EXPECTED_BURGERS,yaml
146
133
 
147
- node = Psychgus.parse(BURGERS_YAML,stylers: @flow_styler)
134
+ node = Psychgus.parse(TestHelper::BURGERS_YAML,stylers: @flow_styler)
148
135
  refute_equal false,node
149
136
 
150
- yaml = Psychgus.parse_stream(BURGERS_YAML,stylers: @flow_styler).to_yaml
137
+ yaml = Psychgus.parse_stream(TestHelper::BURGERS_YAML,stylers: @flow_styler).to_yaml
151
138
  yaml = "---\n#{yaml}"
152
139
  assert_equal EXPECTED_BURGERS,yaml
153
140
  end
154
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
@@ -8,23 +8,23 @@
8
8
  # SPDX-License-Identifier: LGPL-3.0-or-later
9
9
  #++
10
10
 
11
- require 'psychgus_tester'
11
+ require 'test_helper'
12
12
 
13
13
  require 'stringio'
14
14
 
15
- class SnifferTest < PsychgusTester
15
+ class SnifferTest < Minitest::Test
16
16
  def setup
17
17
  end
18
18
 
19
19
  def assert_hierarchy(*data,expected)
20
- expected = self.class.lstrip_pipe(expected)
20
+ expected = TestHelper.lstrip_pipe(expected)
21
21
  hierarchy = Psychgus.hierarchy(*data,verbose: true)
22
22
 
23
23
  assert_equal expected,hierarchy
24
24
  end
25
25
 
26
26
  def test_multi_doc
27
- assert_hierarchy(BURGERS_DATA,COURSES_DATA,DOLPHINS_DATA,<<-HIER)
27
+ assert_hierarchy(TestHelper::BURGERS_DATA,TestHelper::COURSES_DATA,TestHelper::DOLPHINS_DATA,<<-HIER)
28
28
  |(1:1):Psych::Nodes::Stream - <root:(0:0)::(:1)>
29
29
  |(1:1):Psych::Nodes::Document - <stream:(1:1)::(:1)>
30
30
  |(1:1):Psych::Nodes::Mapping - <doc:(1:1)::(:1)>
@@ -145,7 +145,7 @@ class SnifferTest < PsychgusTester
145
145
  end
146
146
 
147
147
  def test_single_docs
148
- assert_hierarchy(BURGERS_DATA,<<-HIER)
148
+ assert_hierarchy(TestHelper::BURGERS_DATA,<<-HIER)
149
149
  |(1:1):Psych::Nodes::Stream - <root:(0:0)::(:1)>
150
150
  |(1:1):Psych::Nodes::Document - <stream:(1:1)::(:1)>
151
151
  |(1:1):Psych::Nodes::Mapping - <doc:(1:1)::(:1)>
@@ -194,7 +194,7 @@ class SnifferTest < PsychgusTester
194
194
  | (6:2):Pepper - <seq:(5:2)::(:2)>
195
195
  HIER
196
196
 
197
- assert_hierarchy(COURSES_DATA,<<-HIER)
197
+ assert_hierarchy(TestHelper::COURSES_DATA,<<-HIER)
198
198
  |(1:1):Psych::Nodes::Stream - <root:(0:0)::(:1)>
199
199
  |(1:1):Psych::Nodes::Document - <stream:(1:1)::(:1)>
200
200
  |(1:1):Psych::Nodes::Mapping - <doc:(1:1)::(:1)>
data/test/styler_test.rb CHANGED
@@ -8,7 +8,34 @@
8
8
  # SPDX-License-Identifier: LGPL-3.0-or-later
9
9
  #++
10
10
 
11
- require 'psychgus_tester'
11
+ require 'test_helper'
12
+
13
+ class StylerTest < Minitest::Test
14
+ def setup
15
+ @styler = MyStyler.new
16
+ end
17
+
18
+ def test_styler
19
+ expected = TestHelper.lstrip_pipe(<<-YAML)
20
+ |---
21
+ |Burgers:
22
+ | Classic:
23
+ | Sauce:
24
+ | - Ketchup
25
+ | - Mustard
26
+ | Cheese: American
27
+ | Bun: Sesame Seed
28
+ | BBQ: {Sauce: Honey BBQ, Cheese: Cheddar, Bun: Kaiser}
29
+ | Fancy: {Sauce: Spicy Wasabi, Cheese: Smoked Gouda, Bun: Hawaiian}
30
+ |Toppings:
31
+ |- 'Mushrooms'
32
+ |- [Spinach, Onions, Pickles, Tomatoes]
33
+ |- [[Ketchup, Mustard], [Salt, Pepper]]
34
+ YAML
35
+
36
+ assert_equal expected,TestHelper::BURGERS_DATA.to_yaml(stylers: @styler)
37
+ end
38
+ end
12
39
 
13
40
  class MyStyler
14
41
  include Psychgus::Styler
@@ -23,15 +50,15 @@ class MyStyler
23
50
  parent = sniffer.parent
24
51
 
25
52
  if !parent.nil?
26
- # BBQ
53
+ # BBQ.
27
54
  node.style = Psychgus::MAPPING_FLOW if parent.node_of?(:scalar) && parent.value.casecmp('BBQ') == 0
28
55
 
29
- # Fancy
56
+ # Fancy.
30
57
  node.style = Psychgus::MAPPING_FLOW if parent.level == 4 && parent.position == 3
31
58
  end
32
59
  end
33
60
 
34
- def style_scalar(sniffer,node)
61
+ def style_scalar(_sniffer,node)
35
62
  node.style = Psychgus::SCALAR_SINGLE_QUOTED if node.value.casecmp('Mushrooms') == 0
36
63
  node.value = 'Spinach' if node.value.casecmp('Lettuce') == 0
37
64
  end
@@ -39,35 +66,7 @@ class MyStyler
39
66
  def style_sequence(sniffer,node)
40
67
  node.style = Psychgus::SEQUENCE_FLOW if sniffer.level >= 3
41
68
 
42
- # Burgers=>Classic=>Sauce and Mushrooms
69
+ # Burgers => Classic => Sauce and Mushrooms.
43
70
  node.style = Psychgus::SEQUENCE_BLOCK if sniffer.position == 1
44
71
  end
45
72
  end
46
-
47
- class StylerTest < PsychgusTester
48
- def setup
49
- @styler = MyStyler.new
50
- end
51
-
52
- def test_styler
53
- expected = <<-YAML
54
- |---
55
- |Burgers:
56
- | Classic:
57
- | Sauce:
58
- | - Ketchup
59
- | - Mustard
60
- | Cheese: American
61
- | Bun: Sesame Seed
62
- | BBQ: {Sauce: Honey BBQ, Cheese: Cheddar, Bun: Kaiser}
63
- | Fancy: {Sauce: Spicy Wasabi, Cheese: Smoked Gouda, Bun: Hawaiian}
64
- |Toppings:
65
- |- 'Mushrooms'
66
- |- [Spinach, Onions, Pickles, Tomatoes]
67
- |- [[Ketchup, Mustard], [Salt, Pepper]]
68
- YAML
69
- expected = self.class.lstrip_pipe(expected)
70
-
71
- assert_equal expected,BURGERS_DATA.to_yaml(stylers: @styler)
72
- end
73
- end
data/test/stylers_test.rb CHANGED
@@ -8,71 +8,71 @@
8
8
  # SPDX-License-Identifier: LGPL-3.0-or-later
9
9
  #++
10
10
 
11
- require 'psychgus_tester'
11
+ require 'test_helper'
12
12
 
13
- class EggCarton
14
- include Psychgus::Blueberry
15
-
16
- def initialize
17
- @eggs = {
18
- styles: ['omelette','BBQ eggs','hard-boiled eggs','soft_boiled eggs','fried@eggs'],
19
- colors: ['brown','white',['blue','green']]
20
- }
21
- end
22
-
23
- def psychgus_stylers(sniffer)
24
- return Psychgus::FlowStyler.new(4)
25
- end
26
- end
27
-
28
- class StylersTest < PsychgusTester
13
+ class StylersTest < Minitest::Test
29
14
  def setup
30
15
  @egg_carton = EggCarton.new
31
16
  end
32
17
 
33
18
  def test_capstyler
34
19
  actual = @egg_carton.to_yaml(stylers: Psychgus::CapStyler.new(each_word: false))
35
- expected = <<-YAML
20
+ expected = TestHelper.lstrip_pipe(<<-YAML)
36
21
  |--- !ruby/object:EggCarton
37
22
  |Eggs:
38
23
  | :styles: [Omelette, BBQ eggs, Hard-boiled eggs, Soft_boiled eggs, Fried@eggs]
39
24
  | :colors: [Brown, White, [Blue, Green]]
40
25
  YAML
41
26
 
42
- assert_equal self.class.lstrip_pipe(expected),actual
27
+ assert_equal expected,actual
43
28
 
44
29
  actual = @egg_carton.to_yaml(stylers: Psychgus::CapStyler.new(new_delim: '+',delim: /[\s_\-@]/))
45
- expected = <<-YAML
30
+ expected = TestHelper.lstrip_pipe(<<-YAML)
46
31
  |--- !ruby/object:EggCarton
47
32
  |Eggs:
48
33
  | :styles: [Omelette, BBQ+Eggs, Hard+Boiled+Eggs, Soft+Boiled+Eggs, Fried+Eggs]
49
34
  | :colors: [Brown, White, [Blue, Green]]
50
35
  YAML
51
36
 
52
- assert_equal self.class.lstrip_pipe(expected),actual
37
+ assert_equal expected,actual
53
38
  end
54
39
 
55
40
  def test_nosymstyler
56
41
  actual = @egg_carton.to_yaml(stylers: Psychgus::NoSymStyler.new)
57
- expected = <<-YAML
42
+ expected = TestHelper.lstrip_pipe(<<-YAML)
58
43
  |--- !ruby/object:EggCarton
59
44
  |eggs:
60
45
  | Styles: [omelette, BBQ eggs, hard-boiled eggs, soft_boiled eggs, fried@eggs]
61
46
  | Colors: [brown, white, [blue, green]]
62
47
  YAML
63
48
 
64
- assert_equal self.class.lstrip_pipe(expected),actual
49
+ assert_equal expected,actual
65
50
  end
66
51
 
67
52
  def test_notagstyler
68
53
  actual = @egg_carton.to_yaml(stylers: Psychgus::NoTagStyler.new)
69
- expected = <<-YAML
54
+ expected = TestHelper.lstrip_pipe(<<-YAML)
70
55
  |---
71
56
  |eggs:
72
57
  | :styles: [omelette, BBQ eggs, hard-boiled eggs, soft_boiled eggs, fried@eggs]
73
58
  | :colors: [brown, white, [blue, green]]
74
59
  YAML
75
60
 
76
- assert_equal self.class.lstrip_pipe(expected),actual
61
+ assert_equal expected,actual
62
+ end
63
+ end
64
+
65
+ class EggCarton
66
+ include Psychgus::Blueberry
67
+
68
+ def initialize
69
+ @eggs = {
70
+ styles: ['omelette','BBQ eggs','hard-boiled eggs','soft_boiled eggs','fried@eggs'],
71
+ colors: ['brown','white',['blue','green']],
72
+ }
73
+ end
74
+
75
+ def psychgus_stylers(_sniffer)
76
+ return Psychgus::FlowStyler.new(4)
77
77
  end
78
78
  end
@@ -12,8 +12,14 @@ require 'minitest/autorun'
12
12
 
13
13
  require 'psychgus'
14
14
 
15
- # Changing the YAML/data will break tests
16
- class PsychgusTester < Minitest::Test
15
+ # NOTE: Changing the YAML/data will break tests
16
+ module TestHelper
17
+ # This is for `<<-` heredoc.
18
+ # - Purposely not using `<<~` (tilde) for older Ruby versions.
19
+ def self.lstrip_pipe(str)
20
+ return str.gsub(/^\s*\|/,'')
21
+ end
22
+
17
23
  BURGERS_YAML = <<-YAML
18
24
  Burgers:
19
25
  Classic:
@@ -63,10 +69,4 @@ Popular:
63
69
  # Don't do 'aliases: true' because that doesn't exist
64
70
  # in older versions of Psych.
65
71
  DOLPHINS_DATA = Psych.unsafe_load(DOLPHINS_YAML).freeze
66
-
67
- # This is for "<<-" heredoc
68
- # - Purposely not using "<<~" (tilde) for older Ruby versions
69
- def self.lstrip_pipe(str)
70
- return str.gsub(/^\s*\|/,'')
71
- end
72
72
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: psychgus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.5
4
+ version: 1.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bradley Whited
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-07 00:00:00.000000000 Z
11
+ date: 2025-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: psych
@@ -53,19 +53,19 @@ files:
53
53
  - psychgus.gemspec
54
54
  - test/blueberry_test.rb
55
55
  - test/psychgus_test.rb
56
- - test/psychgus_tester.rb
57
56
  - test/sniffer_test.rb
58
57
  - test/styler_test.rb
59
58
  - test/stylers_test.rb
60
- - yard/templates/default/layout/html/footer.erb
59
+ - test/test_helper.rb
61
60
  homepage: https://github.com/esotericpig/psychgus
62
61
  licenses:
63
62
  - LGPL-3.0-or-later
64
63
  metadata:
64
+ rubygems_mfa_required: 'true'
65
65
  homepage_uri: https://github.com/esotericpig/psychgus
66
66
  source_code_uri: https://github.com/esotericpig/psychgus
67
67
  bug_tracker_uri: https://github.com/esotericpig/psychgus/issues
68
- changelog_uri: https://github.com/esotericpig/psychgus/blob/master/CHANGELOG.md
68
+ changelog_uri: https://github.com/esotericpig/psychgus/blob/main/CHANGELOG.md
69
69
  documentation_uri: https://esotericpig.github.io/docs/psychgus/yardoc/index.html
70
70
  post_install_message:
71
71
  rdoc_options: []
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  requirements: []
85
- rubygems_version: 3.5.18
85
+ rubygems_version: 3.5.21
86
86
  signing_key:
87
87
  specification_version: 4
88
88
  summary: Easily style YAML files using Psych.
@@ -1,5 +0,0 @@
1
- <%# To reduce number of diffs, removed time, YARD version, and Ruby version. %>
2
- <div id="footer">
3
- Generated by
4
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>.
5
- </div>