psychgus 1.3.3 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +5 -0
- data/CHANGELOG.md +32 -7
- data/Gemfile +15 -18
- data/README.md +43 -47
- data/Rakefile +16 -55
- data/lib/psychgus/blueberry.rb +26 -41
- data/lib/psychgus/ext/core_ext.rb +19 -31
- data/lib/psychgus/ext/node_ext.rb +11 -26
- data/lib/psychgus/ext/yaml_tree_ext.rb +34 -41
- data/lib/psychgus/stylables.rb +76 -91
- data/lib/psychgus/styled_document_stream.rb +12 -27
- data/lib/psychgus/styled_tree_builder.rb +88 -103
- data/lib/psychgus/styler.rb +29 -47
- data/lib/psychgus/stylers.rb +65 -80
- data/lib/psychgus/super_sniffer/parent.rb +38 -56
- data/lib/psychgus/super_sniffer.rb +107 -126
- data/lib/psychgus/version.rb +5 -18
- data/lib/psychgus.rb +166 -186
- data/psychgus.gemspec +37 -51
- data/test/blueberry_test.rb +30 -42
- data/test/psychgus_test.rb +51 -67
- data/test/psychgus_tester.rb +19 -37
- data/test/sniffer_test.rb +18 -33
- data/test/styler_test.rb +20 -32
- data/test/stylers_test.rb +32 -47
- metadata +9 -107
- data/lib/psychgus/ext.rb +0 -32
data/test/styler_test.rb
CHANGED
@@ -1,68 +1,56 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
1
|
# encoding: UTF-8
|
2
|
+
# frozen_string_literal: true
|
3
3
|
|
4
4
|
#--
|
5
5
|
# This file is part of Psychgus.
|
6
|
-
# Copyright (c) 2019
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# it under the terms of the GNU Lesser General Public License as published by
|
10
|
-
# the Free Software Foundation, either version 3 of the License, or
|
11
|
-
# (at your option) any later version.
|
12
|
-
#
|
13
|
-
# Psychgus is distributed in the hope that it will be useful,
|
14
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
-
# GNU Lesser General Public License for more details.
|
17
|
-
#
|
18
|
-
# You should have received a copy of the GNU Lesser General Public License
|
19
|
-
# along with Psychgus. If not, see <http://www.gnu.org/licenses/>.
|
6
|
+
# Copyright (c) 2019 Bradley Whited
|
7
|
+
#
|
8
|
+
# SPDX-License-Identifier: LGPL-3.0-or-later
|
20
9
|
#++
|
21
10
|
|
22
|
-
|
23
11
|
require 'psychgus_tester'
|
24
12
|
|
25
13
|
class MyStyler
|
26
14
|
include Psychgus::Styler
|
27
|
-
|
15
|
+
|
28
16
|
def style(sniffer,node)
|
29
17
|
end
|
30
|
-
|
18
|
+
|
31
19
|
def style_alias(sniffer,node)
|
32
20
|
end
|
33
|
-
|
21
|
+
|
34
22
|
def style_mapping(sniffer,node)
|
35
23
|
parent = sniffer.parent
|
36
|
-
|
37
|
-
if !parent.nil?
|
24
|
+
|
25
|
+
if !parent.nil?
|
38
26
|
# BBQ
|
39
27
|
node.style = Psychgus::MAPPING_FLOW if parent.node_of?(:scalar) && parent.value.casecmp('BBQ') == 0
|
40
|
-
|
28
|
+
|
41
29
|
# Fancy
|
42
30
|
node.style = Psychgus::MAPPING_FLOW if parent.level == 4 && parent.position == 3
|
43
31
|
end
|
44
32
|
end
|
45
|
-
|
33
|
+
|
46
34
|
def style_scalar(sniffer,node)
|
47
35
|
node.style = Psychgus::SCALAR_SINGLE_QUOTED if node.value.casecmp('Mushrooms') == 0
|
48
36
|
node.value = 'Spinach' if node.value.casecmp('Lettuce') == 0
|
49
37
|
end
|
50
|
-
|
38
|
+
|
51
39
|
def style_sequence(sniffer,node)
|
52
40
|
node.style = Psychgus::SEQUENCE_FLOW if sniffer.level >= 3
|
53
|
-
|
41
|
+
|
54
42
|
# Burgers=>Classic=>Sauce and Mushrooms
|
55
43
|
node.style = Psychgus::SEQUENCE_BLOCK if sniffer.position == 1
|
56
44
|
end
|
57
45
|
end
|
58
46
|
|
59
47
|
class StylerTest < PsychgusTester
|
60
|
-
def setup
|
61
|
-
@styler = MyStyler.new
|
48
|
+
def setup
|
49
|
+
@styler = MyStyler.new
|
62
50
|
end
|
63
|
-
|
64
|
-
def test_styler
|
65
|
-
expected = <<-
|
51
|
+
|
52
|
+
def test_styler
|
53
|
+
expected = <<-YAML
|
66
54
|
|---
|
67
55
|
|Burgers:
|
68
56
|
| Classic:
|
@@ -77,9 +65,9 @@ class StylerTest < PsychgusTester
|
|
77
65
|
|- 'Mushrooms'
|
78
66
|
|- [Spinach, Onions, Pickles, Tomatoes]
|
79
67
|
|- [[Ketchup, Mustard], [Salt, Pepper]]
|
80
|
-
|
68
|
+
YAML
|
81
69
|
expected = self.class.lstrip_pipe(expected)
|
82
|
-
|
70
|
+
|
83
71
|
assert_equal expected,BURGERS_DATA.to_yaml(stylers: @styler)
|
84
72
|
end
|
85
73
|
end
|
data/test/stylers_test.rb
CHANGED
@@ -1,93 +1,78 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
1
|
# encoding: UTF-8
|
2
|
+
# frozen_string_literal: true
|
3
3
|
|
4
4
|
#--
|
5
5
|
# This file is part of Psychgus.
|
6
|
-
# Copyright (c) 2019
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# it under the terms of the GNU Lesser General Public License as published by
|
10
|
-
# the Free Software Foundation, either version 3 of the License, or
|
11
|
-
# (at your option) any later version.
|
12
|
-
#
|
13
|
-
# Psychgus is distributed in the hope that it will be useful,
|
14
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
-
# GNU Lesser General Public License for more details.
|
17
|
-
#
|
18
|
-
# You should have received a copy of the GNU Lesser General Public License
|
19
|
-
# along with Psychgus. If not, see <http://www.gnu.org/licenses/>.
|
6
|
+
# Copyright (c) 2019 Bradley Whited
|
7
|
+
#
|
8
|
+
# SPDX-License-Identifier: LGPL-3.0-or-later
|
20
9
|
#++
|
21
10
|
|
22
|
-
|
23
11
|
require 'psychgus_tester'
|
24
12
|
|
25
13
|
class EggCarton
|
26
14
|
include Psychgus::Blueberry
|
27
|
-
|
28
|
-
def initialize
|
15
|
+
|
16
|
+
def initialize
|
29
17
|
@eggs = {
|
30
|
-
:
|
31
|
-
:
|
18
|
+
styles: ['omelette','BBQ eggs','hard-boiled eggs','soft_boiled eggs','fried@eggs'],
|
19
|
+
colors: ['brown','white',['blue','green']]
|
32
20
|
}
|
33
21
|
end
|
34
|
-
|
22
|
+
|
35
23
|
def psychgus_stylers(sniffer)
|
36
24
|
return Psychgus::FlowStyler.new(4)
|
37
25
|
end
|
38
26
|
end
|
39
27
|
|
40
|
-
###
|
41
|
-
# @since 1.2.0
|
42
|
-
###
|
43
28
|
class StylersTest < PsychgusTester
|
44
|
-
def setup
|
45
|
-
@egg_carton = EggCarton.new
|
29
|
+
def setup
|
30
|
+
@egg_carton = EggCarton.new
|
46
31
|
end
|
47
|
-
|
48
|
-
def test_capstyler
|
32
|
+
|
33
|
+
def test_capstyler
|
49
34
|
actual = @egg_carton.to_yaml(stylers: Psychgus::CapStyler.new(each_word: false))
|
50
|
-
expected = <<-
|
35
|
+
expected = <<-YAML
|
51
36
|
|--- !ruby/object:EggCarton
|
52
37
|
|Eggs:
|
53
38
|
| :styles: [Omelette, BBQ eggs, Hard-boiled eggs, Soft_boiled eggs, Fried@eggs]
|
54
39
|
| :colors: [Brown, White, [Blue, Green]]
|
55
|
-
|
56
|
-
|
40
|
+
YAML
|
41
|
+
|
57
42
|
assert_equal self.class.lstrip_pipe(expected),actual
|
58
|
-
|
43
|
+
|
59
44
|
actual = @egg_carton.to_yaml(stylers: Psychgus::CapStyler.new(new_delim: '+',delim: /[\s_\-@]/))
|
60
|
-
expected = <<-
|
45
|
+
expected = <<-YAML
|
61
46
|
|--- !ruby/object:EggCarton
|
62
47
|
|Eggs:
|
63
48
|
| :styles: [Omelette, BBQ+Eggs, Hard+Boiled+Eggs, Soft+Boiled+Eggs, Fried+Eggs]
|
64
49
|
| :colors: [Brown, White, [Blue, Green]]
|
65
|
-
|
66
|
-
|
50
|
+
YAML
|
51
|
+
|
67
52
|
assert_equal self.class.lstrip_pipe(expected),actual
|
68
53
|
end
|
69
|
-
|
70
|
-
def test_nosymstyler
|
71
|
-
actual = @egg_carton.to_yaml(stylers: Psychgus::NoSymStyler.new
|
72
|
-
expected = <<-
|
54
|
+
|
55
|
+
def test_nosymstyler
|
56
|
+
actual = @egg_carton.to_yaml(stylers: Psychgus::NoSymStyler.new)
|
57
|
+
expected = <<-YAML
|
73
58
|
|--- !ruby/object:EggCarton
|
74
59
|
|eggs:
|
75
60
|
| Styles: [omelette, BBQ eggs, hard-boiled eggs, soft_boiled eggs, fried@eggs]
|
76
61
|
| Colors: [brown, white, [blue, green]]
|
77
|
-
|
78
|
-
|
62
|
+
YAML
|
63
|
+
|
79
64
|
assert_equal self.class.lstrip_pipe(expected),actual
|
80
65
|
end
|
81
|
-
|
82
|
-
def test_notagstyler
|
83
|
-
actual = @egg_carton.to_yaml(stylers: Psychgus::NoTagStyler.new
|
84
|
-
expected = <<-
|
66
|
+
|
67
|
+
def test_notagstyler
|
68
|
+
actual = @egg_carton.to_yaml(stylers: Psychgus::NoTagStyler.new)
|
69
|
+
expected = <<-YAML
|
85
70
|
|---
|
86
71
|
|eggs:
|
87
72
|
| :styles: [omelette, BBQ eggs, hard-boiled eggs, soft_boiled eggs, fried@eggs]
|
88
73
|
| :colors: [brown, white, [blue, green]]
|
89
|
-
|
90
|
-
|
74
|
+
YAML
|
75
|
+
|
91
76
|
assert_equal self.class.lstrip_pipe(expected),actual
|
92
77
|
end
|
93
78
|
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.
|
4
|
+
version: 1.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Bradley Whited
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: psych
|
@@ -24,111 +24,14 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '2.1'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '2.1'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: minitest
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '5.14'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '5.14'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rake
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '13.0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '13.0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rdoc
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '6.2'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '6.2'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: redcarpet
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '3.5'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '3.5'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: yard
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0.9'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0.9'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: yard_ghurt
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '1.2'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '1.2'
|
125
27
|
description: Easily style YAML files using Psych, like Sequence/Mapping Flow style.
|
126
28
|
email:
|
127
|
-
-
|
29
|
+
- code@esotericpig.com
|
128
30
|
executables: []
|
129
31
|
extensions: []
|
130
32
|
extra_rdoc_files: []
|
131
33
|
files:
|
34
|
+
- ".yardopts"
|
132
35
|
- CHANGELOG.md
|
133
36
|
- Gemfile
|
134
37
|
- LICENSE.txt
|
@@ -136,7 +39,6 @@ files:
|
|
136
39
|
- Rakefile
|
137
40
|
- lib/psychgus.rb
|
138
41
|
- lib/psychgus/blueberry.rb
|
139
|
-
- lib/psychgus/ext.rb
|
140
42
|
- lib/psychgus/ext/core_ext.rb
|
141
43
|
- lib/psychgus/ext/node_ext.rb
|
142
44
|
- lib/psychgus/ext/yaml_tree_ext.rb
|
@@ -160,11 +62,11 @@ homepage: https://github.com/esotericpig/psychgus
|
|
160
62
|
licenses:
|
161
63
|
- LGPL-3.0-or-later
|
162
64
|
metadata:
|
65
|
+
homepage_uri: https://github.com/esotericpig/psychgus
|
66
|
+
source_code_uri: https://github.com/esotericpig/psychgus
|
163
67
|
bug_tracker_uri: https://github.com/esotericpig/psychgus/issues
|
164
68
|
changelog_uri: https://github.com/esotericpig/psychgus/blob/master/CHANGELOG.md
|
165
69
|
documentation_uri: https://esotericpig.github.io/docs/psychgus/yardoc/index.html
|
166
|
-
homepage_uri: https://github.com/esotericpig/psychgus
|
167
|
-
source_code_uri: https://github.com/esotericpig/psychgus
|
168
70
|
post_install_message:
|
169
71
|
rdoc_options: []
|
170
72
|
require_paths:
|
@@ -173,14 +75,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
173
75
|
requirements:
|
174
76
|
- - ">="
|
175
77
|
- !ruby/object:Gem::Version
|
176
|
-
version: 2.
|
78
|
+
version: '2.2'
|
177
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
80
|
requirements:
|
179
81
|
- - ">="
|
180
82
|
- !ruby/object:Gem::Version
|
181
83
|
version: '0'
|
182
84
|
requirements: []
|
183
|
-
rubygems_version: 3.
|
85
|
+
rubygems_version: 3.5.18
|
184
86
|
signing_key:
|
185
87
|
specification_version: 4
|
186
88
|
summary: Easily style YAML files using Psych.
|
data/lib/psychgus/ext.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: UTF-8
|
3
|
-
|
4
|
-
#--
|
5
|
-
# This file is part of Psychgus.
|
6
|
-
# Copyright (c) 2019 Jonathan Bradley Whited (@esotericpig)
|
7
|
-
#
|
8
|
-
# Psychgus is free software: you can redistribute it and/or modify
|
9
|
-
# it under the terms of the GNU Lesser General Public License as published by
|
10
|
-
# the Free Software Foundation, either version 3 of the License, or
|
11
|
-
# (at your option) any later version.
|
12
|
-
#
|
13
|
-
# Psychgus is distributed in the hope that it will be useful,
|
14
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
-
# GNU Lesser General Public License for more details.
|
17
|
-
#
|
18
|
-
# You should have received a copy of the GNU Lesser General Public License
|
19
|
-
# along with Psychgus. If not, see <http://www.gnu.org/licenses/>.
|
20
|
-
#++
|
21
|
-
|
22
|
-
|
23
|
-
module Psychgus
|
24
|
-
###
|
25
|
-
# Contains all of the extensions (monkey patching) to core/Psych classes/modules.
|
26
|
-
#
|
27
|
-
# @author Jonathan Bradley Whited (@esotericpig)
|
28
|
-
# @since 1.0.0
|
29
|
-
###
|
30
|
-
module Ext
|
31
|
-
end
|
32
|
-
end
|