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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa00bfe0768a30b9679056fe748769e53827b254d8899bcaacc032fc236e5791
|
4
|
+
data.tar.gz: 46a834b2f517190e9c6b28e6f87964a186c69b7b2bdaf45465d59f2ac1f06603
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bcbf539c47cfb64273682b0d1fa76c3745e523e0a792f2a9dec92e1df80352c6c987762edcebd9fc21bccc36450619b42572f5e37fe66e5002ffad2e2e15eb6
|
7
|
+
data.tar.gz: 338ffe5daaafb1ddc79fac1f939058928d839f64f96bd3c8198bbda7f8426da0fea04ab6fead6b114628d64466901499c844bdc14fa55d8795f05d34b89d11ec
|
data/.yardopts
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,18 +1,42 @@
|
|
1
1
|
# Changelog | Psychgus
|
2
2
|
|
3
|
-
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
-
|
5
|
+
Format is based on [Keep a Changelog v1.0.0](https://keepachangelog.com/en/1.0.0),
|
6
|
+
and this project adheres to [Semantic Versioning v2.0.0](https://semver.org/spec/v2.0.0.html).
|
6
7
|
|
7
|
-
## [v1.3.
|
8
|
+
## [[Unreleased]](https://github.com/esotericpig/psychgus/compare/v1.3.5...HEAD)
|
9
|
+
|
10
|
+
|
11
|
+
## [v1.3.5] - 2024-09-06
|
12
|
+
### Fixed
|
13
|
+
- Fixed to_yaml() to work with older-style gems.
|
14
|
+
- Example Gem: moneta
|
15
|
+
- Fixed deref aliases to work with Psych v5.1.2.
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
- Updated min Ruby to v2.2.
|
19
|
+
- Updated Gems.
|
20
|
+
|
21
|
+
|
22
|
+
## [v1.3.4] - 2021-06-20
|
23
|
+
### Fixed
|
24
|
+
- Fixed test file to use `unsafe_load()` for Psych v4+.
|
25
|
+
|
26
|
+
### Changed
|
27
|
+
- Changed `SuperSniffer::Parent` to use `SimpleDelegator`.
|
28
|
+
- Updated Gems.
|
29
|
+
- Formatted files with RuboCop.
|
8
30
|
|
31
|
+
|
32
|
+
## [v1.3.3] - 2020-04-25
|
9
33
|
### Fixed
|
10
34
|
- SuperSniffer::Parent
|
11
35
|
- Added require of `delegate` for Delegator
|
12
36
|
- Rake test task didn't catch this (must already include it)
|
13
37
|
|
14
|
-
## [v1.3.2] - 2020-04-23
|
15
38
|
|
39
|
+
## [v1.3.2] - 2020-04-23
|
16
40
|
### Changed
|
17
41
|
- SuperSniffer::Parent
|
18
42
|
- Changed to use Delegator to delegate all methods of `node`
|
@@ -22,16 +46,16 @@ Format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
22
46
|
### Fixed
|
23
47
|
- Fixed some Ruby 2.7 warnings in tests
|
24
48
|
|
25
|
-
## [v1.2.2] - 2020-03-15
|
26
49
|
|
50
|
+
## [v1.2.2] - 2020-03-15
|
27
51
|
### Fixed
|
28
52
|
- Fixed Psych version to be >= 3.0 for `to_yaml/encode_with` warnings
|
29
53
|
- This is mainly for Windows
|
30
54
|
- [Ruby-lang Bug #13115](https://bugs.ruby-lang.org/issues/13115)
|
31
55
|
- [GitHub Psych Commit](https://github.com/ruby/psych/commit/712a65a53f3c15105cd86e8ad3ee3c779050ada4)
|
32
56
|
|
33
|
-
## [v1.2.1] - 2019-12-18
|
34
57
|
|
58
|
+
## [v1.2.1] - 2019-12-18
|
35
59
|
### Added
|
36
60
|
- Use of YardGhurt gem for Rakefile tasks
|
37
61
|
|
@@ -44,8 +68,8 @@ Format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
44
68
|
### Fixed
|
45
69
|
- Updated gems
|
46
70
|
|
47
|
-
## [v1.2.0] - 2019-07-11
|
48
71
|
|
72
|
+
## [v1.2.0] - 2019-07-11
|
49
73
|
### Added
|
50
74
|
- Commonly-used Stylers and Stylables
|
51
75
|
- Changelog
|
@@ -60,6 +84,7 @@ Format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
60
84
|
### Fixed
|
61
85
|
- Psychgus.dump_stream() if you only pass in a Hash w/ symbols as keys (options would be set to it, instead of objects)
|
62
86
|
|
87
|
+
|
63
88
|
## [v1.0.0] - 2019-07-03
|
64
89
|
### Added
|
65
90
|
### Changed
|
data/Gemfile
CHANGED
@@ -1,25 +1,22 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
# This file is part of Psychgus.
|
6
|
-
# Copyright (c) 2017-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
|
-
#++
|
4
|
+
source 'https://rubygems.org'
|
21
5
|
|
6
|
+
group(:development) do
|
7
|
+
# Build.
|
8
|
+
gem 'bundler' ,'~> 2.5'
|
9
|
+
gem 'rake' ,'~> 13.2'
|
22
10
|
|
23
|
-
|
11
|
+
# Doc.
|
12
|
+
gem 'rdoc' ,'~> 6.7' # RDoc for YARD (*.rb).
|
13
|
+
gem 'redcarpet' ,'~> 3.6' # Markdown for YARD (*.md).
|
14
|
+
gem 'yard' ,'~> 0.9' # Doc.
|
15
|
+
gem 'yard_ghurt','~> 1.2' # YARD GitHub rake tasks.
|
16
|
+
end
|
17
|
+
|
18
|
+
group(:test) do
|
19
|
+
gem 'minitest' ,'~> 5.25'
|
20
|
+
end
|
24
21
|
|
25
22
|
gemspec
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Psychgus
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/psychgus.svg)](https://badge.fury.io/rb/psychgus)
|
4
|
-
[![
|
4
|
+
[![CI Status](https://github.com/esotericpig/psychgus/actions/workflows/ci.yml/badge.svg)](https://github.com/esotericpig/psychgus/actions/workflows/ci.yml)
|
5
5
|
[![Doc Coverage](http://inch-ci.org/github/esotericpig/psychgus.svg?branch=master)](https://inch-ci.org/github/esotericpig/psychgus)
|
6
6
|
|
7
7
|
[![Documentation](https://img.shields.io/badge/doc-yard-%23A0522D.svg)](https://esotericpig.github.io/docs/psychgus/yardoc/index.html)
|
@@ -40,7 +40,7 @@ Psych Gus:
|
|
40
40
|
Skills: [The Blueberry, The Super Sniffer, Positive Work Attitude]
|
41
41
|
```
|
42
42
|
|
43
|
-
Thank you to the people that
|
43
|
+
Thank you to the people that work hard on the Psych project.
|
44
44
|
|
45
45
|
The Psychgus name comes from the well-styled character Gus from the TV show Psych.
|
46
46
|
|
@@ -59,7 +59,7 @@ The Psychgus name comes from the well-styled character Gus from the TV show Psyc
|
|
59
59
|
- [Generating Doc](#generating-doc)
|
60
60
|
- [License](#license)
|
61
61
|
|
62
|
-
## [
|
62
|
+
## [//](#contents) Setup
|
63
63
|
|
64
64
|
Pick your poison...
|
65
65
|
|
@@ -71,7 +71,7 @@ In your *Gemspec* (*<project>.gemspec*):
|
|
71
71
|
|
72
72
|
```Ruby
|
73
73
|
# Pick one...
|
74
|
-
spec.
|
74
|
+
spec.add_dependency 'psychgus', '~> X.X.X'
|
75
75
|
spec.add_development_dependency 'psychgus', '~> X.X.X'
|
76
76
|
```
|
77
77
|
|
@@ -93,7 +93,7 @@ $ bundle install
|
|
93
93
|
$ bundle exec rake install:local
|
94
94
|
```
|
95
95
|
|
96
|
-
## [
|
96
|
+
## [//](#contents) Using
|
97
97
|
|
98
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).
|
99
99
|
|
@@ -111,14 +111,14 @@ Instead of making your own styler, you can also use one of the [pre-defined styl
|
|
111
111
|
| [Advanced Usage](#advanced-usage)
|
112
112
|
| [Common Stylers](#common-stylers)
|
113
113
|
|
114
|
-
### [
|
114
|
+
### [//](#using) Simple Example
|
115
115
|
|
116
116
|
```Ruby
|
117
117
|
require 'psychgus'
|
118
118
|
|
119
119
|
class CoffeeStyler
|
120
120
|
include Psychgus::Styler
|
121
|
-
|
121
|
+
|
122
122
|
def style_sequence(sniffer,node)
|
123
123
|
node.style = Psychgus::SEQUENCE_FLOW
|
124
124
|
end
|
@@ -138,12 +138,12 @@ puts coffee.to_yaml(stylers: CoffeeStyler.new)
|
|
138
138
|
|
139
139
|
class Coffee
|
140
140
|
include Psychgus::Blueberry
|
141
|
-
|
141
|
+
|
142
142
|
def initialize
|
143
143
|
@roast = ['Light', 'Medium', 'Dark', 'Extra Dark']
|
144
144
|
@style = ['Cappuccino', 'Espresso', 'Latte', 'Mocha']
|
145
145
|
end
|
146
|
-
|
146
|
+
|
147
147
|
def psychgus_stylers(sniffer)
|
148
148
|
CoffeeStyler.new
|
149
149
|
end
|
@@ -157,27 +157,27 @@ puts Coffee.new.to_yaml
|
|
157
157
|
# style: [Cappuccino, Espresso, Latte, Mocha]
|
158
158
|
```
|
159
159
|
|
160
|
-
### [
|
160
|
+
### [//](#using) Hash Example
|
161
161
|
|
162
162
|
```Ruby
|
163
163
|
require 'psychgus'
|
164
164
|
|
165
165
|
class BurgerStyler
|
166
166
|
include Psychgus::Styler # Mix in methods needed for styling
|
167
|
-
|
167
|
+
|
168
168
|
# Style maps (Psych::Nodes::Mapping)
|
169
169
|
# - Hashes (key/value pairs)
|
170
170
|
# - Example: "Burgers: Classic {}"
|
171
171
|
def style_mapping(sniffer,node)
|
172
172
|
node.style = Psychgus::MAPPING_FLOW if sniffer.level >= 4
|
173
173
|
end
|
174
|
-
|
174
|
+
|
175
175
|
# Style scalars (Psych::Nodes::Scalar)
|
176
176
|
# - Any text (non-alias)
|
177
177
|
def style_scalar(sniffer,node)
|
178
178
|
# Remove colon (change symbols into strings)
|
179
179
|
node.value = node.value.sub(':','')
|
180
|
-
|
180
|
+
|
181
181
|
# Capitalize each word
|
182
182
|
node.value = node.value.split(' ').map do |v|
|
183
183
|
if v.casecmp('BBQ') == 0
|
@@ -186,11 +186,11 @@ class BurgerStyler
|
|
186
186
|
v.capitalize()
|
187
187
|
end
|
188
188
|
end.join(' ')
|
189
|
-
|
189
|
+
|
190
190
|
# Change lettuce to spinach
|
191
191
|
node.value = 'Spinach' if node.value == 'Lettuce'
|
192
192
|
end
|
193
|
-
|
193
|
+
|
194
194
|
# Style sequences (Psych::Nodes::Sequence)
|
195
195
|
# - Arrays
|
196
196
|
# - Example: "[Lettuce, Onions, Pickles, Tomatoes]"
|
@@ -252,57 +252,57 @@ puts burgers.to_yaml({:indent => 3,:stylers => BurgerStyler.new,:deref_aliases =
|
|
252
252
|
# Bun: Kaiser
|
253
253
|
```
|
254
254
|
|
255
|
-
### [
|
255
|
+
### [//](#using) Class Example
|
256
256
|
|
257
257
|
```Ruby
|
258
258
|
require 'psychgus'
|
259
259
|
|
260
260
|
class BurgerStyler
|
261
261
|
include Psychgus::Styler # Mix in methods needed for styling
|
262
|
-
|
262
|
+
|
263
263
|
def initialize(sniffer)
|
264
264
|
@class_level = sniffer.level
|
265
265
|
@class_position = sniffer.position
|
266
266
|
end
|
267
|
-
|
267
|
+
|
268
268
|
# Style all nodes (Psych::Nodes::Node)
|
269
269
|
def style(sniffer,node)
|
270
270
|
# Remove "!ruby/object:..." for Burger classes (not Burgers class)
|
271
271
|
node.tag = nil if node.node_of?(:mapping,:scalar,:sequence)
|
272
|
-
|
272
|
+
|
273
273
|
# This is another way to do the above
|
274
274
|
#node.tag = nil if node.respond_to?(:tag=)
|
275
275
|
end
|
276
|
-
|
276
|
+
|
277
277
|
# Style maps (Psych::Nodes::Mapping)
|
278
278
|
# - Hashes (key/value pairs)
|
279
279
|
# - Example: "Burgers: Classic {}"
|
280
280
|
def style_mapping(sniffer,node)
|
281
281
|
parent = sniffer.parent
|
282
|
-
|
282
|
+
|
283
283
|
if !parent.nil?()
|
284
284
|
# BBQ
|
285
285
|
node.style = Psychgus::MAPPING_FLOW if parent.node_of?(:scalar) &&
|
286
286
|
parent.value.casecmp('BBQ') == 0
|
287
287
|
end
|
288
288
|
end
|
289
|
-
|
289
|
+
|
290
290
|
# Style scalars (Psych::Nodes::Scalar)
|
291
291
|
# - Any text (non-alias)
|
292
292
|
def style_scalar(sniffer,node)
|
293
293
|
parent = sniffer.parent
|
294
|
-
|
294
|
+
|
295
295
|
# Single quote scalars that are not keys to a map
|
296
296
|
# - "child_key?" is the same as "child_type == :key"
|
297
297
|
node.style = Psychgus::SCALAR_SINGLE_QUOTED unless parent.child_key?()
|
298
298
|
end
|
299
|
-
|
299
|
+
|
300
300
|
# Style sequences (Psych::Nodes::Sequence)
|
301
301
|
# - Arrays
|
302
302
|
# - Example: "[Lettuce, Onions, Pickles, Tomatoes]"
|
303
303
|
def style_sequence(sniffer,node)
|
304
304
|
relative_level = (sniffer.level - @class_level) + 1
|
305
|
-
|
305
|
+
|
306
306
|
# "[Ketchup, Mustard]"
|
307
307
|
node.style = Psychgus::SEQUENCE_FLOW if relative_level == 3
|
308
308
|
end
|
@@ -310,23 +310,23 @@ end
|
|
310
310
|
|
311
311
|
class Burger
|
312
312
|
include Psychgus::Blueberry # Mix in methods needed to be stylable
|
313
|
-
|
313
|
+
|
314
314
|
attr_accessor :bun
|
315
315
|
attr_accessor :cheese
|
316
316
|
attr_accessor :sauce
|
317
|
-
|
317
|
+
|
318
318
|
def initialize(sauce,cheese,bun)
|
319
319
|
@bun = bun
|
320
320
|
@cheese = cheese
|
321
321
|
@sauce = sauce
|
322
322
|
end
|
323
|
-
|
323
|
+
|
324
324
|
# Return our styler(s)
|
325
325
|
# - Can be an Array: [MyStyler1.new, MyStyler2.new]
|
326
326
|
def psychgus_stylers(sniffer)
|
327
327
|
return BurgerStyler.new(sniffer)
|
328
328
|
end
|
329
|
-
|
329
|
+
|
330
330
|
# You can still use Psych's encode_with(), no problem
|
331
331
|
def encode_with(coder)
|
332
332
|
coder['Bun'] = @bun
|
@@ -339,23 +339,23 @@ class Burgers
|
|
339
339
|
attr_accessor :burgers
|
340
340
|
attr_accessor :toppings
|
341
341
|
attr_accessor :favorite
|
342
|
-
|
342
|
+
|
343
343
|
def initialize()
|
344
344
|
@burgers = {
|
345
345
|
'Classic' => Burger.new(['Ketchup','Mustard'],'American' ,'Sesame Seed'),
|
346
346
|
'BBQ' => Burger.new('Honey BBQ' ,'Cheddar' ,'Kaiser'),
|
347
347
|
'Fancy' => Burger.new('Spicy Wasabi' ,'Smoked Gouda','Hawaiian')
|
348
348
|
}
|
349
|
-
|
349
|
+
|
350
350
|
@toppings = [
|
351
351
|
'Mushrooms',
|
352
352
|
%w(Lettuce Onions Pickles Tomatoes),
|
353
353
|
[%w(Ketchup Mustard),%w(Salt Pepper)]
|
354
354
|
]
|
355
|
-
|
355
|
+
|
356
356
|
@favorite = @burgers['BBQ'] # Alias
|
357
357
|
end
|
358
|
-
|
358
|
+
|
359
359
|
# You can still use Psych's encode_with(), no problem
|
360
360
|
def encode_with(coder)
|
361
361
|
coder['Burgers'] = @burgers
|
@@ -423,14 +423,14 @@ puts burgers.to_yaml({:indent => 3,:deref_aliases => true})
|
|
423
423
|
# Sauce: 'Honey BBQ'
|
424
424
|
```
|
425
425
|
|
426
|
-
### [
|
426
|
+
### [//](#using) Advanced Usage
|
427
427
|
|
428
428
|
```Ruby
|
429
429
|
require 'psychgus'
|
430
430
|
|
431
431
|
class MyStyler
|
432
432
|
include Psychgus::Styler
|
433
|
-
|
433
|
+
|
434
434
|
def style_sequence(sniffer,node)
|
435
435
|
node.style = Psychgus::SEQUENCE_FLOW
|
436
436
|
end
|
@@ -514,7 +514,7 @@ puts parser.handler.root.to_ruby
|
|
514
514
|
puts
|
515
515
|
```
|
516
516
|
|
517
|
-
### [
|
517
|
+
### [//](#using) Common Stylers
|
518
518
|
|
519
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.
|
520
520
|
|
@@ -527,7 +527,7 @@ A collection of commonly-used [Stylers](https://esotericpig.github.io/docs/psych
|
|
527
527
|
| [NoTagStyler](https://esotericpig.github.io/docs/psychgus/yardoc/Psychgus/Stylers/NoTagStyler.html) | Tag remover for classes |
|
528
528
|
| [SeqFlowStyler](https://esotericpig.github.io/docs/psychgus/yardoc/Psychgus/Stylers/SeqFlowStyler.html) | FLOW style changer for Sequences only |
|
529
529
|
|
530
|
-
#### [
|
530
|
+
#### [//](#common-stylers) Stylers Example
|
531
531
|
|
532
532
|
```Ruby
|
533
533
|
require 'psychgus'
|
@@ -571,7 +571,7 @@ puts EggCarton.new.to_yaml
|
|
571
571
|
# - green
|
572
572
|
```
|
573
573
|
|
574
|
-
## [
|
574
|
+
## [//](#contents) Hacking
|
575
575
|
|
576
576
|
```
|
577
577
|
$ git clone 'https://github.com/esotericpig/psychgus.git'
|
@@ -580,17 +580,13 @@ $ bundle install
|
|
580
580
|
$ bundle exec rake -T
|
581
581
|
```
|
582
582
|
|
583
|
-
### [
|
583
|
+
### [//](#hacking) Testing
|
584
584
|
|
585
|
-
Run tests
|
585
|
+
Run tests:
|
586
586
|
|
587
587
|
`$ bundle exec rake test`
|
588
588
|
|
589
|
-
|
590
|
-
|
591
|
-
`$ bundle exec rake test_all`
|
592
|
-
|
593
|
-
### [Generating Doc](#hacking)
|
589
|
+
### [//](#hacking) Generating Doc
|
594
590
|
|
595
591
|
Generate doc:
|
596
592
|
|
@@ -600,12 +596,12 @@ Clean & generate pristine doc:
|
|
600
596
|
|
601
597
|
`$ bundle exec rake clobber doc`
|
602
598
|
|
603
|
-
## [
|
599
|
+
## [//](#contents) License
|
604
600
|
|
605
601
|
[GNU LGPL v3+](LICENSE.txt)
|
606
602
|
|
607
603
|
> Psychgus (<https://github.com/esotericpig/psychgus>)
|
608
|
-
> Copyright (c) 2017-
|
604
|
+
> Copyright (c) 2017-2024 Bradley Whited
|
609
605
|
>
|
610
606
|
> Psychgus is free software: you can redistribute it and/or modify
|
611
607
|
> it under the terms of the GNU Lesser General Public License as published by
|
data/Rakefile
CHANGED
@@ -1,23 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
|
3
|
-
#--
|
4
|
-
# This file is part of Psychgus.
|
5
|
-
# Copyright (c) 2019-2020 Jonathan Bradley Whited (@esotericpig)
|
6
|
-
#
|
7
|
-
# Psychgus is free software: you can redistribute it and/or modify
|
8
|
-
# it under the terms of the GNU Lesser General Public License as published by
|
9
|
-
# the Free Software Foundation, either version 3 of the License, or
|
10
|
-
# (at your option) any later version.
|
11
|
-
#
|
12
|
-
# Psychgus is distributed in the hope that it will be useful,
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
-
# GNU Lesser General Public License for more details.
|
16
|
-
#
|
17
|
-
# You should have received a copy of the GNU Lesser General Public License
|
18
|
-
# along with Psychgus. If not, see <https://www.gnu.org/licenses/>.
|
19
|
-
#++
|
20
|
-
|
2
|
+
# frozen_string_literal: true
|
21
3
|
|
22
4
|
require 'bundler/gem_tasks'
|
23
5
|
|
@@ -29,64 +11,43 @@ require 'psychgus/version'
|
|
29
11
|
require 'rake/clean'
|
30
12
|
require 'rake/testtask'
|
31
13
|
|
32
|
-
|
33
14
|
task default: [:test]
|
34
15
|
|
35
16
|
CLEAN.exclude('.git/','stock/')
|
36
17
|
CLOBBER.include('doc/')
|
37
18
|
|
38
|
-
|
39
|
-
# Execute "rake clobber doc" for pristine docs
|
19
|
+
# Execute "rake clobber doc" for pristine docs.
|
40
20
|
desc 'Generate documentation (YARDoc)'
|
41
|
-
task :
|
42
|
-
end
|
21
|
+
task doc: %i[yard yard_gfm_fix]
|
43
22
|
|
44
|
-
|
23
|
+
# To test using different Gem versions:
|
24
|
+
# GST=1 bundle update && bundle exec rake test
|
25
|
+
Rake::TestTask.new do |task|
|
45
26
|
task.libs = ['lib','test']
|
46
27
|
task.pattern = File.join('test','**','*_test.rb')
|
47
28
|
task.description += " ('#{task.pattern}')"
|
48
|
-
#task.options = '--verbose' # Execute "rake test TESTOPT=-v" instead
|
29
|
+
#task.options = '--verbose' # Execute "rake test TESTOPT=-v" instead.
|
49
30
|
task.verbose = true
|
50
31
|
task.warning = true
|
51
32
|
end
|
52
33
|
|
53
|
-
|
54
|
-
task :test_all do |task|
|
55
|
-
ENV['PSYCHGUS_TEST'] = 'all'
|
56
|
-
|
57
|
-
test_task = Rake::Task[:test]
|
58
|
-
|
59
|
-
test_task.reenable()
|
60
|
-
test_task.invoke()
|
61
|
-
end
|
62
|
-
|
63
|
-
YARD::Rake::YardocTask.new() do |task|
|
34
|
+
YARD::Rake::YardocTask.new do |task|
|
64
35
|
task.files = [File.join('lib','**','*.rb')]
|
65
|
-
|
66
|
-
task.options += ['--files','CHANGELOG.md,LICENSE.txt']
|
67
|
-
task.options += ['--readme','README.md']
|
68
|
-
|
69
|
-
task.options << '--protected' # Show protected methods
|
70
|
-
task.options += ['--template-path',File.join('yard','templates')]
|
71
|
-
task.options += ['--title',"Psychgus v#{Psychgus::VERSION} Doc"]
|
72
36
|
end
|
73
37
|
|
74
|
-
YardGhurt::GFMFixTask.new
|
38
|
+
YardGhurt::GFMFixTask.new do |task|
|
75
39
|
task.description = 'Fix (find & replace) text in the YARD files for GitHub differences'
|
76
|
-
|
40
|
+
|
77
41
|
task.arg_names = [:dev]
|
78
42
|
task.dry_run = false
|
79
43
|
task.fix_code_langs = true
|
80
44
|
task.md_files = ['index.html']
|
81
|
-
|
82
|
-
task.before =
|
45
|
+
|
46
|
+
task.before = proc do |t2,args|
|
83
47
|
# Delete this file as it's never used (index.html is an exact copy)
|
84
|
-
YardGhurt.rm_exist(File.join(
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
task.css_styles << %Q(<link rel="stylesheet" type="text/css" href="#{GHP_ROOT}/css/prism.css" />)
|
90
|
-
task.js_scripts << %Q(<script src="#{GHP_ROOT}/js/prism.js"></script>)
|
48
|
+
YardGhurt.rm_exist(File.join(t2.doc_dir,'file.README.html'))
|
49
|
+
|
50
|
+
t2.css_styles << '<link rel="stylesheet" type="text/css" href="/css/prism.css" />'
|
51
|
+
t2.js_scripts << '<script src="/js/prism.js"></script>)'
|
91
52
|
end
|
92
53
|
end
|