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.
- checksums.yaml +4 -4
- data/.yardopts +1 -1
- data/CHANGELOG.md +25 -5
- data/Gemfile +15 -1
- data/README.md +18 -21
- data/Rakefile +4 -41
- data/lib/psychgus/blueberry.rb +2 -6
- data/lib/psychgus/ext/core_ext.rb +5 -6
- data/lib/psychgus/ext/node_ext.rb +1 -5
- data/lib/psychgus/ext/yaml_tree_ext.rb +17 -14
- data/lib/psychgus/stylables.rb +8 -12
- data/lib/psychgus/styled_document_stream.rb +2 -6
- data/lib/psychgus/styled_tree_builder.rb +3 -7
- data/lib/psychgus/styler.rb +1 -8
- data/lib/psychgus/stylers.rb +1 -5
- data/lib/psychgus/super_sniffer/parent.rb +1 -10
- data/lib/psychgus/super_sniffer.rb +1 -8
- data/lib/psychgus/version.rb +3 -4
- data/lib/psychgus.rb +12 -19
- data/psychgus.gemspec +15 -22
- data/test/blueberry_test.rb +58 -60
- data/test/psychgus_test.rb +34 -42
- data/test/sniffer_test.rb +7 -8
- data/test/styler_test.rb +32 -34
- data/test/stylers_test.rb +26 -30
- data/test/{psychgus_tester.rb → test_helper.rb} +8 -18
- metadata +11 -110
- data/lib/psychgus/ext.rb +0 -21
- data/yard/templates/default/layout/html/footer.erb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01544ac84a4c500d36c933328b920f43bbe878609d10f60c615d6ccccf7ca9da
|
4
|
+
data.tar.gz: 2856f8d12ebe3881513acfbb4ec8da5af40fd98a35a36b9ec227260643c2193e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0e41a6e5b84bd23527583e6cbd46db820e8c53e67d241a85e08182770114ee1ee0e57d2b706ca87acd42367fe27001d1de61a67ae9e700211823948ff780c4f
|
7
|
+
data.tar.gz: 558601409148d719e718a4132f703ad46b06bbb7f19f0ce1d46befd3021051c714a4a6bc0613766ae7d05294f312764b4e1f6b82ba65c13da92a5990210ef136
|
data/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,32 @@
|
|
1
1
|
# Changelog | Psychgus
|
2
2
|
|
3
|
-
|
3
|
+
- [Keep a Changelog v1.0.0](https://keepachangelog.com/en/1.0.0)
|
4
|
+
- [Semantic Versioning v2.0.0](https://semver.org/spec/v2.0.0.html)
|
4
5
|
|
5
|
-
|
6
|
-
|
6
|
+
## [Unreleased]
|
7
|
+
- https://github.com/esotericpig/psychgus/compare/v1.3.6...HEAD
|
7
8
|
|
8
|
-
|
9
|
-
-
|
9
|
+
|
10
|
+
## [v1.3.6] - 2025-05-01
|
11
|
+
### Fixed
|
12
|
+
- Fixed deref aliases for Psych v5.2.0+.
|
13
|
+
|
14
|
+
### Changed
|
15
|
+
- Renamed `master` branch to `main`.
|
16
|
+
- Applied RuboCop suggestions.
|
17
|
+
- Refactored tests.
|
18
|
+
- Removed `yard_ghurt` gem.
|
19
|
+
|
20
|
+
|
21
|
+
## [v1.3.5] - 2024-09-06
|
22
|
+
### Fixed
|
23
|
+
- Fixed to_yaml() to work with older-style gems.
|
24
|
+
- Example Gem: moneta
|
25
|
+
- Fixed deref aliases to work with Psych v5.1.2.
|
26
|
+
|
27
|
+
### Changed
|
28
|
+
- Updated min Ruby to v2.2.
|
29
|
+
- Updated Gems.
|
10
30
|
|
11
31
|
|
12
32
|
## [v1.3.4] - 2021-06-20
|
data/Gemfile
CHANGED
@@ -1,7 +1,21 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
4
|
source 'https://rubygems.org'
|
6
5
|
|
6
|
+
group(:development,:test) do
|
7
|
+
# Build.
|
8
|
+
gem 'bundler' ,'~> 2.6'
|
9
|
+
gem 'rake' ,'~> 13.2'
|
10
|
+
|
11
|
+
# Doc.
|
12
|
+
gem 'rdoc' ,'~> 6.13' # RDoc (*.rb).
|
13
|
+
gem 'redcarpet' ,'~> 3.6' # Markdown (*.md).
|
14
|
+
gem 'yard' ,'~> 0.9' # Doc.
|
15
|
+
end
|
16
|
+
|
17
|
+
group(:test) do
|
18
|
+
gem 'minitest' ,'~> 5.25'
|
19
|
+
end
|
20
|
+
|
7
21
|
gemspec
|
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# Psychgus
|
2
2
|
|
3
3
|
[](https://badge.fury.io/rb/psychgus)
|
4
|
-
[](https://github.com/esotericpig/psychgus/actions/workflows/ci.yml)
|
5
|
+
[](https://inch-ci.org/github/esotericpig/psychgus)
|
5
6
|
|
6
7
|
[](https://esotericpig.github.io/docs/psychgus/yardoc/index.html)
|
7
8
|
[](https://github.com/esotericpig/psychgus)
|
@@ -39,7 +40,7 @@ Psych Gus:
|
|
39
40
|
Skills: [The Blueberry, The Super Sniffer, Positive Work Attitude]
|
40
41
|
```
|
41
42
|
|
42
|
-
Thank you to the people that
|
43
|
+
Thank you to the people that work hard on the Psych project.
|
43
44
|
|
44
45
|
The Psychgus name comes from the well-styled character Gus from the TV show Psych.
|
45
46
|
|
@@ -58,7 +59,7 @@ The Psychgus name comes from the well-styled character Gus from the TV show Psyc
|
|
58
59
|
- [Generating Doc](#generating-doc)
|
59
60
|
- [License](#license)
|
60
61
|
|
61
|
-
##
|
62
|
+
## Setup
|
62
63
|
|
63
64
|
Pick your poison...
|
64
65
|
|
@@ -70,7 +71,7 @@ In your *Gemspec* (*<project>.gemspec*):
|
|
70
71
|
|
71
72
|
```Ruby
|
72
73
|
# Pick one...
|
73
|
-
spec.
|
74
|
+
spec.add_dependency 'psychgus', '~> X.X.X'
|
74
75
|
spec.add_development_dependency 'psychgus', '~> X.X.X'
|
75
76
|
```
|
76
77
|
|
@@ -92,7 +93,7 @@ $ bundle install
|
|
92
93
|
$ bundle exec rake install:local
|
93
94
|
```
|
94
95
|
|
95
|
-
##
|
96
|
+
## Using
|
96
97
|
|
97
98
|
Documentation (YARDoc) is available on my [GitHub Page](https://esotericpig.github.io/docs/psychgus/yardoc/index.html) and on [RubyDoc.info](https://www.rubydoc.info/gems/psychgus).
|
98
99
|
|
@@ -110,7 +111,7 @@ Instead of making your own styler, you can also use one of the [pre-defined styl
|
|
110
111
|
| [Advanced Usage](#advanced-usage)
|
111
112
|
| [Common Stylers](#common-stylers)
|
112
113
|
|
113
|
-
###
|
114
|
+
### Simple Example
|
114
115
|
|
115
116
|
```Ruby
|
116
117
|
require 'psychgus'
|
@@ -156,7 +157,7 @@ puts Coffee.new.to_yaml
|
|
156
157
|
# style: [Cappuccino, Espresso, Latte, Mocha]
|
157
158
|
```
|
158
159
|
|
159
|
-
###
|
160
|
+
### Hash Example
|
160
161
|
|
161
162
|
```Ruby
|
162
163
|
require 'psychgus'
|
@@ -251,7 +252,7 @@ puts burgers.to_yaml({:indent => 3,:stylers => BurgerStyler.new,:deref_aliases =
|
|
251
252
|
# Bun: Kaiser
|
252
253
|
```
|
253
254
|
|
254
|
-
###
|
255
|
+
### Class Example
|
255
256
|
|
256
257
|
```Ruby
|
257
258
|
require 'psychgus'
|
@@ -422,7 +423,7 @@ puts burgers.to_yaml({:indent => 3,:deref_aliases => true})
|
|
422
423
|
# Sauce: 'Honey BBQ'
|
423
424
|
```
|
424
425
|
|
425
|
-
###
|
426
|
+
### Advanced Usage
|
426
427
|
|
427
428
|
```Ruby
|
428
429
|
require 'psychgus'
|
@@ -513,7 +514,7 @@ puts parser.handler.root.to_ruby
|
|
513
514
|
puts
|
514
515
|
```
|
515
516
|
|
516
|
-
###
|
517
|
+
### Common Stylers
|
517
518
|
|
518
519
|
A collection of commonly-used [Stylers](https://esotericpig.github.io/docs/psychgus/yardoc/Psychgus/Stylers.html) and [Stylables](https://esotericpig.github.io/docs/psychgus/yardoc/Psychgus/Stylables.html) are included with Psychgus.
|
519
520
|
|
@@ -526,7 +527,7 @@ A collection of commonly-used [Stylers](https://esotericpig.github.io/docs/psych
|
|
526
527
|
| [NoTagStyler](https://esotericpig.github.io/docs/psychgus/yardoc/Psychgus/Stylers/NoTagStyler.html) | Tag remover for classes |
|
527
528
|
| [SeqFlowStyler](https://esotericpig.github.io/docs/psychgus/yardoc/Psychgus/Stylers/SeqFlowStyler.html) | FLOW style changer for Sequences only |
|
528
529
|
|
529
|
-
####
|
530
|
+
#### Stylers Example
|
530
531
|
|
531
532
|
```Ruby
|
532
533
|
require 'psychgus'
|
@@ -570,7 +571,7 @@ puts EggCarton.new.to_yaml
|
|
570
571
|
# - green
|
571
572
|
```
|
572
573
|
|
573
|
-
##
|
574
|
+
## Hacking
|
574
575
|
|
575
576
|
```
|
576
577
|
$ git clone 'https://github.com/esotericpig/psychgus.git'
|
@@ -579,17 +580,13 @@ $ bundle install
|
|
579
580
|
$ bundle exec rake -T
|
580
581
|
```
|
581
582
|
|
582
|
-
###
|
583
|
+
### Testing
|
583
584
|
|
584
|
-
Run tests
|
585
|
+
Run tests:
|
585
586
|
|
586
587
|
`$ bundle exec rake test`
|
587
588
|
|
588
|
-
|
589
|
-
|
590
|
-
`$ bundle exec rake test_all`
|
591
|
-
|
592
|
-
### [Generating Doc](#hacking)
|
589
|
+
### Generating Doc
|
593
590
|
|
594
591
|
Generate doc:
|
595
592
|
|
@@ -599,12 +596,12 @@ Clean & generate pristine doc:
|
|
599
596
|
|
600
597
|
`$ bundle exec rake clobber doc`
|
601
598
|
|
602
|
-
##
|
599
|
+
## License
|
603
600
|
|
604
601
|
[GNU LGPL v3+](LICENSE.txt)
|
605
602
|
|
606
603
|
> Psychgus (<https://github.com/esotericpig/psychgus>)
|
607
|
-
> Copyright (c) 2017-
|
604
|
+
> Copyright (c) 2017-2025 Bradley Whited
|
608
605
|
>
|
609
606
|
> Psychgus is free software: you can redistribute it and/or modify
|
610
607
|
> it under the terms of the GNU Lesser General Public License as published by
|
data/Rakefile
CHANGED
@@ -1,70 +1,33 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
4
|
require 'bundler/gem_tasks'
|
6
5
|
|
7
6
|
require 'yard'
|
8
|
-
require 'yard_ghurt'
|
9
7
|
|
10
8
|
require 'psychgus/version'
|
11
|
-
|
12
9
|
require 'rake/clean'
|
13
10
|
require 'rake/testtask'
|
14
11
|
|
15
|
-
|
16
|
-
task default: [:test]
|
12
|
+
task default: %i[test]
|
17
13
|
|
18
14
|
CLEAN.exclude('.git/','stock/')
|
19
15
|
CLOBBER.include('doc/')
|
20
16
|
|
21
|
-
|
22
|
-
# Execute "rake clobber doc" for pristine docs
|
17
|
+
# Execute "rake clobber doc" for pristine docs.
|
23
18
|
desc 'Generate documentation (YARDoc)'
|
24
|
-
task doc: %i[yard
|
19
|
+
task doc: %i[yard]
|
25
20
|
|
26
21
|
# To test using different Gem versions:
|
27
22
|
# GST=1 bundle update && bundle exec rake test
|
28
23
|
Rake::TestTask.new do |task|
|
29
24
|
task.libs = ['lib','test']
|
30
25
|
task.pattern = File.join('test','**','*_test.rb')
|
31
|
-
task.
|
32
|
-
#task.options = '--verbose' # Execute "rake test TESTOPT=-v" instead
|
26
|
+
# task.options = '--verbose' # Execute "rake test TESTOPT=-v" instead.
|
33
27
|
task.verbose = true
|
34
28
|
task.warning = true
|
35
29
|
end
|
36
30
|
|
37
|
-
desc 'Run all tests (including writing to temp files, etc.)'
|
38
|
-
task :test_all do |task|
|
39
|
-
ENV['PSYCHGUS_TEST'] = 'all'
|
40
|
-
|
41
|
-
test_task = Rake::Task[:test]
|
42
|
-
|
43
|
-
test_task.reenable
|
44
|
-
test_task.invoke
|
45
|
-
end
|
46
|
-
|
47
31
|
YARD::Rake::YardocTask.new do |task|
|
48
32
|
task.files = [File.join('lib','**','*.rb')]
|
49
|
-
task.options += ['--title',"Psychgus v#{Psychgus::VERSION} Doc"]
|
50
|
-
end
|
51
|
-
|
52
|
-
YardGhurt::GFMFixTask.new do |task|
|
53
|
-
task.description = 'Fix (find & replace) text in the YARD files for GitHub differences'
|
54
|
-
|
55
|
-
task.arg_names = [:dev]
|
56
|
-
task.dry_run = false
|
57
|
-
task.fix_code_langs = true
|
58
|
-
task.md_files = ['index.html']
|
59
|
-
|
60
|
-
task.before = proc do |t2,args|
|
61
|
-
# Delete this file as it's never used (index.html is an exact copy)
|
62
|
-
YardGhurt.rm_exist(File.join(t2.doc_dir,'file.README.html'))
|
63
|
-
|
64
|
-
# Root dir of my GitHub Page for CSS/JS
|
65
|
-
ghp_root = YardGhurt.to_bool(args.dev) ? '../../esotericpig.github.io' : '../../..'
|
66
|
-
|
67
|
-
t2.css_styles << %Q(<link rel="stylesheet" type="text/css" href="#{ghp_root}/css/prism.css" />)
|
68
|
-
t2.js_scripts << %Q(<script src="#{ghp_root}/js/prism.js"></script>)
|
69
|
-
end
|
70
33
|
end
|
data/lib/psychgus/blueberry.rb
CHANGED
@@ -3,12 +3,11 @@
|
|
3
3
|
|
4
4
|
#--
|
5
5
|
# This file is part of Psychgus.
|
6
|
-
# Copyright (c) 2017
|
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
12
|
###
|
14
13
|
# This is the OOP way to style your classes/modules/etc.
|
@@ -78,9 +77,6 @@ module Psychgus
|
|
78
77
|
#
|
79
78
|
# "The Blueberry" is the name of Gus's car from the TV show Psych.
|
80
79
|
#
|
81
|
-
# @author Jonathan Bradley Whited
|
82
|
-
# @since 1.0.0
|
83
|
-
#
|
84
80
|
# @see Ext::YAMLTreeExt
|
85
81
|
# @see Ext::YAMLTreeExt#accept
|
86
82
|
###
|
@@ -92,7 +88,7 @@ module Psychgus
|
|
92
88
|
# class/module/etc.
|
93
89
|
#
|
94
90
|
# @return [Styler,Array<Styler>,nil] {Styler}(s) for this class/module/etc.
|
95
|
-
def psychgus_stylers(
|
91
|
+
def psychgus_stylers(_sniffer)
|
96
92
|
return nil
|
97
93
|
end
|
98
94
|
end
|
@@ -3,20 +3,16 @@
|
|
3
3
|
|
4
4
|
#--
|
5
5
|
# This file is part of Psychgus.
|
6
|
-
# Copyright (c) 2019
|
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
|
module Psychgus
|
13
12
|
module Ext
|
14
13
|
###
|
15
14
|
# Core extensions to Object.
|
16
15
|
#
|
17
|
-
# @author Jonathan Bradley Whited
|
18
|
-
# @since 1.0.0
|
19
|
-
#
|
20
16
|
# @see https://github.com/ruby/psych/blob/master/lib/psych/core_ext.rb
|
21
17
|
###
|
22
18
|
module ObjectExt
|
@@ -55,7 +51,10 @@ module Psychgus
|
|
55
51
|
# @return [String] the YAML generated from this Object
|
56
52
|
#
|
57
53
|
# @see Psychgus.dump
|
58
|
-
def to_yaml(
|
54
|
+
def to_yaml(options = {})
|
55
|
+
# NOTE: This method signature must use old-style `options={}` instead of `**options`!
|
56
|
+
# Because some Gems, like `Moneta`, depend on this.
|
57
|
+
|
59
58
|
# Do not use Psych.dump() if no Stylers, because a class might be a Blueberry
|
60
59
|
return Psychgus.dump(self,**options)
|
61
60
|
end
|
@@ -3,21 +3,17 @@
|
|
3
3
|
|
4
4
|
#--
|
5
5
|
# This file is part of Psychgus.
|
6
|
-
# Copyright (c) 2019
|
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 'psych'
|
13
12
|
|
14
13
|
module Psychgus
|
15
14
|
module Ext
|
16
15
|
###
|
17
16
|
# Extensions to Psych::Nodes::Node.
|
18
|
-
#
|
19
|
-
# @author Jonathan Bradley Whited
|
20
|
-
# @since 1.0.0
|
21
17
|
###
|
22
18
|
module NodeExt
|
23
19
|
# Check if this Node is of a certain type (Alias, Mapping, Scalar, Sequence, etc.).
|
@@ -3,38 +3,43 @@
|
|
3
3
|
|
4
4
|
#--
|
5
5
|
# This file is part of Psychgus.
|
6
|
-
# Copyright (c) 2019
|
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 'psych'
|
12
|
+
require 'rubygems/version'
|
13
13
|
|
14
14
|
require 'psychgus/styled_tree_builder'
|
15
15
|
|
16
16
|
module Psychgus
|
17
17
|
module Ext
|
18
|
+
PSYCHGUS_PSYCH_VERSION = Gem::Version.create(Psych::VERSION)
|
19
|
+
PSYCHGUS_PSYCH_VERSION_5_1_2 = Gem::Version.create('5.1.2')
|
20
|
+
|
18
21
|
###
|
19
22
|
# Extensions to Psych::Visitors::YAMLTree::Registrar.
|
20
|
-
#
|
21
|
-
# @author Jonathan Bradley Whited
|
22
|
-
# @since 1.0.0
|
23
23
|
###
|
24
24
|
module RegistrarExt
|
25
25
|
# Remove +target+ from this Registrar to prevent it becoming an alias.
|
26
26
|
#
|
27
27
|
# @param target [Object] the Object to remove from this Registrar
|
28
|
-
def
|
29
|
-
|
28
|
+
def psychgus_unregister(target)
|
29
|
+
if PSYCHGUS_PSYCH_VERSION < PSYCHGUS_PSYCH_VERSION_5_1_2
|
30
|
+
return unless key?(target) && target.respond_to?(:object_id)
|
31
|
+
|
32
|
+
@obj_to_node.delete(target.object_id)
|
33
|
+
else # 5.1.2+
|
34
|
+
return unless key?(target)
|
35
|
+
|
36
|
+
@obj_to_node.delete(target)
|
37
|
+
end
|
30
38
|
end
|
31
39
|
end
|
32
40
|
|
33
41
|
###
|
34
42
|
# Extensions to Psych::Visitors::YAMLTree.
|
35
|
-
#
|
36
|
-
# @author Jonathan Bradley Whited
|
37
|
-
# @since 1.0.0
|
38
43
|
###
|
39
44
|
module YAMLTreeExt
|
40
45
|
# Accepts a new Object to convert to YAML.
|
@@ -72,12 +77,10 @@ module Psychgus
|
|
72
77
|
end
|
73
78
|
|
74
79
|
# Dereference aliases?
|
75
|
-
if @emitter.deref_aliases?
|
76
|
-
@st.remove_alias(target) if target.respond_to?(:object_id) && @st.key?(target)
|
77
|
-
end
|
80
|
+
@st.psychgus_unregister(target) if @emitter.deref_aliases?
|
78
81
|
end
|
79
82
|
|
80
|
-
result = super(target)
|
83
|
+
result = super(target) # rubocop:disable Style/SuperArguments
|
81
84
|
|
82
85
|
# Check styler_count because @emitter may not be a StyledTreeBuilder and target may not be a Blueberry
|
83
86
|
@emitter.pop_styler(styler_count) if styler_count > 0
|
data/lib/psychgus/stylables.rb
CHANGED
@@ -3,12 +3,11 @@
|
|
3
3
|
|
4
4
|
#--
|
5
5
|
# This file is part of Psychgus.
|
6
|
-
# Copyright (c) 2019
|
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/styler'
|
13
12
|
require 'psychgus/super_sniffer'
|
14
13
|
|
@@ -19,9 +18,6 @@ module Psychgus
|
|
19
18
|
# A collection of commonly-used {Styler} mixins
|
20
19
|
# that can be included in a class instead of {Styler}.
|
21
20
|
#
|
22
|
-
# @author Jonathan Bradley Whited
|
23
|
-
# @since 1.2.0
|
24
|
-
#
|
25
21
|
# @see Stylers
|
26
22
|
# @see Styler
|
27
23
|
###
|
@@ -42,7 +38,7 @@ module Psychgus
|
|
42
38
|
# @param min_level [Integer] the minimum level (inclusive) to style
|
43
39
|
# @param new_style [Integer] the new style to set the nodes to
|
44
40
|
# @param kargs [Hash] capture extra keyword args, so no error for undefined args
|
45
|
-
def initialize(min_level=0,new_style: nil,**
|
41
|
+
def initialize(min_level = 0,new_style: nil,**_kargs)
|
46
42
|
@min_level = min_level
|
47
43
|
@new_style = new_style
|
48
44
|
end
|
@@ -71,7 +67,7 @@ module Psychgus
|
|
71
67
|
# @param new_delim [nil,String] the replacement for each +delim+ if not nil
|
72
68
|
# @param delim [String,Regexp] the delimiter to split on
|
73
69
|
# @param kargs [Hash] capture extra keyword args, so no error for undefined args
|
74
|
-
def initialize(each_word: true,new_delim: nil,delim: /[\s_\-]/,**
|
70
|
+
def initialize(each_word: true,new_delim: nil,delim: /[\s_\-]/,**_kargs)
|
75
71
|
delim = Regexp.quote(delim.to_s) unless delim.is_a?(Regexp)
|
76
72
|
|
77
73
|
@delim = Regexp.new("(#{delim})")
|
@@ -99,7 +95,7 @@ module Psychgus
|
|
99
95
|
#
|
100
96
|
# @see cap_word
|
101
97
|
# @see Styler#style_scalar
|
102
|
-
def style_scalar(
|
98
|
+
def style_scalar(_sniffer,node)
|
103
99
|
if !@each_word || node.value.nil? || node.value.empty?
|
104
100
|
node.value = cap_word(node.value)
|
105
101
|
return
|
@@ -132,7 +128,7 @@ module Psychgus
|
|
132
128
|
# @param io [IO] the IO to write to
|
133
129
|
# @param verbose [true,false] whether to be more verbose (e.g., write child info)
|
134
130
|
# @param kargs [Hash] capture extra keyword args, so no error for undefined args
|
135
|
-
def initialize(io: StringIO.new,verbose: false,**
|
131
|
+
def initialize(io: StringIO.new,verbose: false,**_kargs)
|
136
132
|
@io = io
|
137
133
|
@verbose = verbose
|
138
134
|
end
|
@@ -203,14 +199,14 @@ module Psychgus
|
|
203
199
|
|
204
200
|
# @param cap [true,false] whether to capitalize the symbol
|
205
201
|
# @param kargs [Hash] capture extra keyword args, so no error for undefined args
|
206
|
-
def initialize(cap: true,**
|
202
|
+
def initialize(cap: true,**_kargs)
|
207
203
|
@cap = cap
|
208
204
|
end
|
209
205
|
|
210
206
|
# If +node.value+ is a symbol, change it into a string and capitalize it.
|
211
207
|
#
|
212
208
|
# @see Styler#style_scalar
|
213
|
-
def style_scalar(
|
209
|
+
def style_scalar(_sniffer,node)
|
214
210
|
return if node.value.nil? || node.value.empty?
|
215
211
|
return if node.value[0] != ':'
|
216
212
|
|
@@ -228,7 +224,7 @@ module Psychgus
|
|
228
224
|
# If +node.tag+ is settable, set it to nil.
|
229
225
|
#
|
230
226
|
# @see Styler#style
|
231
|
-
def style(
|
227
|
+
def style(_sniffer,node)
|
232
228
|
node.tag = nil if node.respond_to?(:tag=)
|
233
229
|
end
|
234
230
|
end
|
@@ -3,12 +3,11 @@
|
|
3
3
|
|
4
4
|
#--
|
5
5
|
# This file is part of Psychgus.
|
6
|
-
# Copyright (c) 2019
|
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 'psych'
|
13
12
|
|
14
13
|
require 'psychgus/styled_tree_builder'
|
@@ -17,9 +16,6 @@ module Psychgus
|
|
17
16
|
###
|
18
17
|
# Use this wherever Psych::Handlers::DocumentStream would have been used, to enable styling.
|
19
18
|
#
|
20
|
-
# @author Jonathan Bradley Whited
|
21
|
-
# @since 1.0.0
|
22
|
-
#
|
23
19
|
# @see Psychgus.parse_stream Psychgus.parse_stream
|
24
20
|
# @see Psych::Handlers::DocumentStream
|
25
21
|
###
|
@@ -39,7 +35,7 @@ module Psychgus
|
|
39
35
|
# This mimics the behavior of Psych::Handlers::DocumentStream#end_document.
|
40
36
|
#
|
41
37
|
# @see Psych::Handlers::DocumentStream#end_document
|
42
|
-
def end_document(implicit_end
|
38
|
+
def end_document(implicit_end = !streaming?)
|
43
39
|
@last.implicit_end = implicit_end
|
44
40
|
@block.call(pop)
|
45
41
|
end
|
@@ -3,12 +3,11 @@
|
|
3
3
|
|
4
4
|
#--
|
5
5
|
# This file is part of Psychgus.
|
6
|
-
# Copyright (c) 2019
|
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 'psych'
|
13
12
|
|
14
13
|
require 'psychgus/styler'
|
@@ -18,9 +17,6 @@ module Psychgus
|
|
18
17
|
###
|
19
18
|
# Use this wherever Psych::TreeBuilder would have been used, to enable styling.
|
20
19
|
#
|
21
|
-
# @author Jonathan Bradley Whited
|
22
|
-
# @since 1.0.0
|
23
|
-
#
|
24
20
|
# @see Psychgus.parser Psychgus.parser
|
25
21
|
# @see Psychgus.dump_stream Psychgus.dump_stream
|
26
22
|
# @see Psych::TreeBuilder
|
@@ -41,7 +37,7 @@ module Psychgus
|
|
41
37
|
# @param stylers [Styler] {Styler}(s) to use for styling this TreeBuilder
|
42
38
|
# @param deref_aliases [true,false] whether to dereference aliases; output the actual value
|
43
39
|
# instead of the alias
|
44
|
-
def initialize(*stylers,deref_aliases: false,**
|
40
|
+
def initialize(*stylers,deref_aliases: false,**_options)
|
45
41
|
super()
|
46
42
|
|
47
43
|
@deref_aliases = deref_aliases
|
@@ -147,7 +143,7 @@ module Psychgus
|
|
147
143
|
# @param count [Integer] the optional amount of tail elements to pop
|
148
144
|
#
|
149
145
|
# @return [Styler,Array<Styler>,nil] the last {Styler}(s), or if empty or count==0, nil
|
150
|
-
def pop_styler(count=1)
|
146
|
+
def pop_styler(count = 1)
|
151
147
|
return nil if count == 0
|
152
148
|
return @stylers.pop if count == 1
|
153
149
|
|
data/lib/psychgus/styler.rb
CHANGED
@@ -3,21 +3,17 @@
|
|
3
3
|
|
4
4
|
#--
|
5
5
|
# This file is part of Psychgus.
|
6
|
-
# Copyright (c) 2019
|
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'
|
13
12
|
|
14
13
|
module Psychgus
|
15
14
|
module Styler
|
16
15
|
###
|
17
16
|
# An empty {Styler} as a class.
|
18
|
-
#
|
19
|
-
# @author Jonathan Bradley Whited
|
20
|
-
# @since 1.0.0
|
21
17
|
###
|
22
18
|
class Empty
|
23
19
|
include Styler
|
@@ -53,9 +49,6 @@ module Psychgus
|
|
53
49
|
# # Roast: [Light, Medium, Dark, Extra Dark]
|
54
50
|
# # Style: [Cappuccino, Espresso, Latte, Mocha]
|
55
51
|
#
|
56
|
-
# @author Jonathan Bradley Whited
|
57
|
-
# @since 1.0.0
|
58
|
-
#
|
59
52
|
# @see Psychgus
|
60
53
|
# @see Ext::ObjectExt#to_yaml
|
61
54
|
# @see Blueberry
|
data/lib/psychgus/stylers.rb
CHANGED
@@ -3,12 +3,11 @@
|
|
3
3
|
|
4
4
|
#--
|
5
5
|
# This file is part of Psychgus.
|
6
|
-
# Copyright (c) 2019
|
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/stylables'
|
13
12
|
|
14
13
|
module Psychgus
|
@@ -63,9 +62,6 @@ module Psychgus
|
|
63
62
|
# # (7:1):Blue - <seq:(6:3)>
|
64
63
|
# # (7:2):Green - <seq:(6:3)>
|
65
64
|
#
|
66
|
-
# @author Jonathan Bradley Whited
|
67
|
-
# @since 1.2.0
|
68
|
-
#
|
69
65
|
# @see Stylables
|
70
66
|
# @see Styler
|
71
67
|
###
|