psychgus 1.2.0 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +4 -0
- data/CHANGELOG.md +58 -3
- data/Gemfile +0 -18
- data/README.md +38 -43
- data/Rakefile +33 -126
- data/lib/psychgus.rb +178 -186
- data/lib/psychgus/blueberry.rb +28 -39
- data/lib/psychgus/ext.rb +6 -17
- data/lib/psychgus/ext/core_ext.rb +17 -28
- data/lib/psychgus/ext/node_ext.rb +13 -24
- data/lib/psychgus/ext/yaml_tree_ext.rb +23 -34
- data/lib/psychgus/stylables.rb +78 -89
- data/lib/psychgus/styled_document_stream.rb +14 -25
- data/lib/psychgus/styled_tree_builder.rb +90 -101
- data/lib/psychgus/styler.rb +33 -44
- data/lib/psychgus/stylers.rb +67 -78
- data/lib/psychgus/super_sniffer.rb +128 -138
- data/lib/psychgus/super_sniffer/parent.rb +48 -149
- data/lib/psychgus/version.rb +4 -16
- data/psychgus.gemspec +46 -49
- data/test/blueberry_test.rb +30 -41
- data/test/psychgus_test.rb +73 -54
- data/test/psychgus_tester.rb +23 -31
- data/test/sniffer_test.rb +18 -32
- data/test/styler_test.rb +20 -31
- data/test/stylers_test.rb +32 -43
- metadata +38 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91a1bbacfcd8d1a658b07bfad787182c7a789b0d0b2fb3ab51a30b9954572484
|
4
|
+
data.tar.gz: 6afd3dba752a30d76bd694d3d5866765522605757c5826f3c366c51d7a19cc0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d01c30c222b5da77b34a3c4fd0f97f6d1685fea13a9a4addb4fd91ff178733326aabc57ae72a1e8d4511b11a021210ba4aeb9eec7498b81f23310a7dfa307fd8
|
7
|
+
data.tar.gz: 0d4deeab277e4894124f8fec33f8e1064a5f95c1bd684dd2f09d612427094c3540452608068cd6076080df8545c395d2b9ab55e04437188f164b416bba8568d4
|
data/.yardopts
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,65 @@
|
|
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.
|
8
|
+
## [[Unreleased]](https://github.com/esotericpig/psychgus/compare/v1.3.4...HEAD)
|
9
|
+
-
|
10
|
+
|
11
|
+
|
12
|
+
## [v1.3.4] - 2021-06-20
|
13
|
+
### Fixed
|
14
|
+
- Fixed test file to use `unsafe_load()` for Psych v4+.
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
- Changed `SuperSniffer::Parent` to use `SimpleDelegator`.
|
18
|
+
- Updated Gems.
|
19
|
+
- Formatted files with RuboCop.
|
20
|
+
|
21
|
+
|
22
|
+
## [v1.3.3] - 2020-04-25
|
23
|
+
### Fixed
|
24
|
+
- SuperSniffer::Parent
|
25
|
+
- Added require of `delegate` for Delegator
|
26
|
+
- Rake test task didn't catch this (must already include it)
|
27
|
+
|
28
|
+
|
29
|
+
## [v1.3.2] - 2020-04-23
|
30
|
+
### Changed
|
31
|
+
- SuperSniffer::Parent
|
32
|
+
- Changed to use Delegator to delegate all methods of `node`
|
33
|
+
- Psychgus.dump_file()/parse_file()
|
34
|
+
- Changed `opt` to expect a Hash
|
35
|
+
|
36
|
+
### Fixed
|
37
|
+
- Fixed some Ruby 2.7 warnings in tests
|
8
38
|
|
39
|
+
|
40
|
+
## [v1.2.2] - 2020-03-15
|
41
|
+
### Fixed
|
42
|
+
- Fixed Psych version to be >= 3.0 for `to_yaml/encode_with` warnings
|
43
|
+
- This is mainly for Windows
|
44
|
+
- [Ruby-lang Bug #13115](https://bugs.ruby-lang.org/issues/13115)
|
45
|
+
- [GitHub Psych Commit](https://github.com/ruby/psych/commit/712a65a53f3c15105cd86e8ad3ee3c779050ada4)
|
46
|
+
|
47
|
+
|
48
|
+
## [v1.2.1] - 2019-12-18
|
49
|
+
### Added
|
50
|
+
- Use of YardGhurt gem for Rakefile tasks
|
51
|
+
|
52
|
+
### Changed
|
53
|
+
- Some comments/doc in SuperSniffer, README
|
54
|
+
- yard_fix task in Rakefile to be cleaner
|
55
|
+
- Test constants in PsychgusTest
|
56
|
+
- Summary & files in Gemspec
|
57
|
+
|
58
|
+
### Fixed
|
59
|
+
- Updated gems
|
60
|
+
|
61
|
+
|
62
|
+
## [v1.2.0] - 2019-07-11
|
9
63
|
### Added
|
10
64
|
- Commonly-used Stylers and Stylables
|
11
65
|
- Changelog
|
@@ -20,6 +74,7 @@ Format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
20
74
|
### Fixed
|
21
75
|
- Psychgus.dump_stream() if you only pass in a Hash w/ symbols as keys (options would be set to it, instead of objects)
|
22
76
|
|
77
|
+
|
23
78
|
## [v1.0.0] - 2019-07-03
|
24
79
|
### Added
|
25
80
|
### Changed
|
data/Gemfile
CHANGED
@@ -1,24 +1,6 @@
|
|
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
|
-
#++
|
21
|
-
|
22
4
|
|
23
5
|
source 'https://rubygems.org'
|
24
6
|
|
data/README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# Psychgus
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/psychgus.svg)](https://badge.fury.io/rb/psychgus)
|
4
|
+
[![Doc Coverage](http://inch-ci.org/github/esotericpig/psychgus.svg?branch=master)](https://inch-ci.org/github/esotericpig/psychgus)
|
4
5
|
|
5
|
-
[![Documentation](https://img.shields.io/badge/doc-yard-%23A0522D.svg
|
6
|
-
[![
|
7
|
-
[![
|
6
|
+
[![Documentation](https://img.shields.io/badge/doc-yard-%23A0522D.svg)](https://esotericpig.github.io/docs/psychgus/yardoc/index.html)
|
7
|
+
[![Source Code](https://img.shields.io/badge/source-github-%23211F1F.svg)](https://github.com/esotericpig/psychgus)
|
8
|
+
[![Changelog](https://img.shields.io/badge/changelog-md-%23A0522D.svg)](CHANGELOG.md)
|
9
|
+
[![License](https://img.shields.io/github/license/esotericpig/psychgus.svg)](LICENSE.txt)
|
8
10
|
|
9
11
|
Psychgus uses the core standard library [Psych](https://github.com/ruby/psych) for working with [YAML](https://yaml.org) and extends it so that developers can easily style the YAML according to their needs.
|
10
12
|
|
@@ -92,7 +94,7 @@ $ bundle exec rake install:local
|
|
92
94
|
|
93
95
|
## [Using](#contents)
|
94
96
|
|
95
|
-
Documentation (YARDoc) is available on my [GitHub Page](https://esotericpig.github.io/docs/psychgus/yardoc/index.html) and RubyDoc.info
|
97
|
+
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).
|
96
98
|
|
97
99
|
To begin styling, create a class and mix in (include) `Psychgus::Styler`. Then pass it in as a keyword arg (`stylers: MyStyler.new` or `stylers: [MyStyler1.new,MyStyler2.new]`) into one of the Psychgus methods.
|
98
100
|
|
@@ -115,7 +117,7 @@ require 'psychgus'
|
|
115
117
|
|
116
118
|
class CoffeeStyler
|
117
119
|
include Psychgus::Styler
|
118
|
-
|
120
|
+
|
119
121
|
def style_sequence(sniffer,node)
|
120
122
|
node.style = Psychgus::SEQUENCE_FLOW
|
121
123
|
end
|
@@ -135,12 +137,12 @@ puts coffee.to_yaml(stylers: CoffeeStyler.new)
|
|
135
137
|
|
136
138
|
class Coffee
|
137
139
|
include Psychgus::Blueberry
|
138
|
-
|
140
|
+
|
139
141
|
def initialize
|
140
142
|
@roast = ['Light', 'Medium', 'Dark', 'Extra Dark']
|
141
143
|
@style = ['Cappuccino', 'Espresso', 'Latte', 'Mocha']
|
142
144
|
end
|
143
|
-
|
145
|
+
|
144
146
|
def psychgus_stylers(sniffer)
|
145
147
|
CoffeeStyler.new
|
146
148
|
end
|
@@ -161,20 +163,20 @@ require 'psychgus'
|
|
161
163
|
|
162
164
|
class BurgerStyler
|
163
165
|
include Psychgus::Styler # Mix in methods needed for styling
|
164
|
-
|
166
|
+
|
165
167
|
# Style maps (Psych::Nodes::Mapping)
|
166
168
|
# - Hashes (key/value pairs)
|
167
169
|
# - Example: "Burgers: Classic {}"
|
168
170
|
def style_mapping(sniffer,node)
|
169
171
|
node.style = Psychgus::MAPPING_FLOW if sniffer.level >= 4
|
170
172
|
end
|
171
|
-
|
173
|
+
|
172
174
|
# Style scalars (Psych::Nodes::Scalar)
|
173
175
|
# - Any text (non-alias)
|
174
176
|
def style_scalar(sniffer,node)
|
175
177
|
# Remove colon (change symbols into strings)
|
176
178
|
node.value = node.value.sub(':','')
|
177
|
-
|
179
|
+
|
178
180
|
# Capitalize each word
|
179
181
|
node.value = node.value.split(' ').map do |v|
|
180
182
|
if v.casecmp('BBQ') == 0
|
@@ -183,11 +185,11 @@ class BurgerStyler
|
|
183
185
|
v.capitalize()
|
184
186
|
end
|
185
187
|
end.join(' ')
|
186
|
-
|
188
|
+
|
187
189
|
# Change lettuce to spinach
|
188
190
|
node.value = 'Spinach' if node.value == 'Lettuce'
|
189
191
|
end
|
190
|
-
|
192
|
+
|
191
193
|
# Style sequences (Psych::Nodes::Sequence)
|
192
194
|
# - Arrays
|
193
195
|
# - Example: "[Lettuce, Onions, Pickles, Tomatoes]"
|
@@ -256,50 +258,50 @@ require 'psychgus'
|
|
256
258
|
|
257
259
|
class BurgerStyler
|
258
260
|
include Psychgus::Styler # Mix in methods needed for styling
|
259
|
-
|
261
|
+
|
260
262
|
def initialize(sniffer)
|
261
263
|
@class_level = sniffer.level
|
262
264
|
@class_position = sniffer.position
|
263
265
|
end
|
264
|
-
|
266
|
+
|
265
267
|
# Style all nodes (Psych::Nodes::Node)
|
266
268
|
def style(sniffer,node)
|
267
269
|
# Remove "!ruby/object:..." for Burger classes (not Burgers class)
|
268
270
|
node.tag = nil if node.node_of?(:mapping,:scalar,:sequence)
|
269
|
-
|
271
|
+
|
270
272
|
# This is another way to do the above
|
271
273
|
#node.tag = nil if node.respond_to?(:tag=)
|
272
274
|
end
|
273
|
-
|
275
|
+
|
274
276
|
# Style maps (Psych::Nodes::Mapping)
|
275
277
|
# - Hashes (key/value pairs)
|
276
278
|
# - Example: "Burgers: Classic {}"
|
277
279
|
def style_mapping(sniffer,node)
|
278
280
|
parent = sniffer.parent
|
279
|
-
|
281
|
+
|
280
282
|
if !parent.nil?()
|
281
283
|
# BBQ
|
282
284
|
node.style = Psychgus::MAPPING_FLOW if parent.node_of?(:scalar) &&
|
283
285
|
parent.value.casecmp('BBQ') == 0
|
284
286
|
end
|
285
287
|
end
|
286
|
-
|
288
|
+
|
287
289
|
# Style scalars (Psych::Nodes::Scalar)
|
288
290
|
# - Any text (non-alias)
|
289
291
|
def style_scalar(sniffer,node)
|
290
292
|
parent = sniffer.parent
|
291
|
-
|
293
|
+
|
292
294
|
# Single quote scalars that are not keys to a map
|
293
295
|
# - "child_key?" is the same as "child_type == :key"
|
294
296
|
node.style = Psychgus::SCALAR_SINGLE_QUOTED unless parent.child_key?()
|
295
297
|
end
|
296
|
-
|
298
|
+
|
297
299
|
# Style sequences (Psych::Nodes::Sequence)
|
298
300
|
# - Arrays
|
299
301
|
# - Example: "[Lettuce, Onions, Pickles, Tomatoes]"
|
300
302
|
def style_sequence(sniffer,node)
|
301
303
|
relative_level = (sniffer.level - @class_level) + 1
|
302
|
-
|
304
|
+
|
303
305
|
# "[Ketchup, Mustard]"
|
304
306
|
node.style = Psychgus::SEQUENCE_FLOW if relative_level == 3
|
305
307
|
end
|
@@ -307,23 +309,23 @@ end
|
|
307
309
|
|
308
310
|
class Burger
|
309
311
|
include Psychgus::Blueberry # Mix in methods needed to be stylable
|
310
|
-
|
312
|
+
|
311
313
|
attr_accessor :bun
|
312
314
|
attr_accessor :cheese
|
313
315
|
attr_accessor :sauce
|
314
|
-
|
316
|
+
|
315
317
|
def initialize(sauce,cheese,bun)
|
316
318
|
@bun = bun
|
317
319
|
@cheese = cheese
|
318
320
|
@sauce = sauce
|
319
321
|
end
|
320
|
-
|
322
|
+
|
321
323
|
# Return our styler(s)
|
322
324
|
# - Can be an Array: [MyStyler1.new, MyStyler2.new]
|
323
325
|
def psychgus_stylers(sniffer)
|
324
326
|
return BurgerStyler.new(sniffer)
|
325
327
|
end
|
326
|
-
|
328
|
+
|
327
329
|
# You can still use Psych's encode_with(), no problem
|
328
330
|
def encode_with(coder)
|
329
331
|
coder['Bun'] = @bun
|
@@ -336,23 +338,23 @@ class Burgers
|
|
336
338
|
attr_accessor :burgers
|
337
339
|
attr_accessor :toppings
|
338
340
|
attr_accessor :favorite
|
339
|
-
|
341
|
+
|
340
342
|
def initialize()
|
341
343
|
@burgers = {
|
342
344
|
'Classic' => Burger.new(['Ketchup','Mustard'],'American' ,'Sesame Seed'),
|
343
345
|
'BBQ' => Burger.new('Honey BBQ' ,'Cheddar' ,'Kaiser'),
|
344
346
|
'Fancy' => Burger.new('Spicy Wasabi' ,'Smoked Gouda','Hawaiian')
|
345
347
|
}
|
346
|
-
|
348
|
+
|
347
349
|
@toppings = [
|
348
350
|
'Mushrooms',
|
349
351
|
%w(Lettuce Onions Pickles Tomatoes),
|
350
352
|
[%w(Ketchup Mustard),%w(Salt Pepper)]
|
351
353
|
]
|
352
|
-
|
354
|
+
|
353
355
|
@favorite = @burgers['BBQ'] # Alias
|
354
356
|
end
|
355
|
-
|
357
|
+
|
356
358
|
# You can still use Psych's encode_with(), no problem
|
357
359
|
def encode_with(coder)
|
358
360
|
coder['Burgers'] = @burgers
|
@@ -427,7 +429,7 @@ require 'psychgus'
|
|
427
429
|
|
428
430
|
class MyStyler
|
429
431
|
include Psychgus::Styler
|
430
|
-
|
432
|
+
|
431
433
|
def style_sequence(sniffer,node)
|
432
434
|
node.style = Psychgus::SEQUENCE_FLOW
|
433
435
|
end
|
@@ -572,6 +574,7 @@ puts EggCarton.new.to_yaml
|
|
572
574
|
|
573
575
|
```
|
574
576
|
$ git clone 'https://github.com/esotericpig/psychgus.git'
|
577
|
+
$ cd psychgus
|
575
578
|
$ bundle install
|
576
579
|
$ bundle exec rake -T
|
577
580
|
```
|
@@ -588,28 +591,20 @@ Run all tests:
|
|
588
591
|
|
589
592
|
### [Generating Doc](#hacking)
|
590
593
|
|
591
|
-
Generate
|
592
|
-
|
593
|
-
`$ bundle exec rake yard`
|
594
|
-
|
595
|
-
Fix GitHub-specific differences:
|
596
|
-
|
597
|
-
`$ bundle exec rake yard_fix`
|
598
|
-
|
599
|
-
Clean doc & run all of the above:
|
594
|
+
Generate doc:
|
600
595
|
|
601
|
-
`$ bundle exec rake
|
596
|
+
`$ bundle exec rake doc`
|
602
597
|
|
603
|
-
|
598
|
+
Clean & generate pristine doc:
|
604
599
|
|
605
|
-
`$ bundle exec rake
|
600
|
+
`$ bundle exec rake clobber doc`
|
606
601
|
|
607
602
|
## [License](#contents)
|
608
603
|
|
609
604
|
[GNU LGPL v3+](LICENSE.txt)
|
610
605
|
|
611
606
|
> Psychgus (<https://github.com/esotericpig/psychgus>)
|
612
|
-
> Copyright (c) 2017-
|
607
|
+
> Copyright (c) 2017-2021 Jonathan Bradley Whited
|
613
608
|
>
|
614
609
|
> Psychgus is free software: you can redistribute it and/or modify
|
615
610
|
> it under the terms of the GNU Lesser General Public License as published by
|
data/Rakefile
CHANGED
@@ -1,66 +1,33 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
|
3
|
-
#--
|
4
|
-
# This file is part of Psychgus.
|
5
|
-
# Copyright (c) 2019 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 <http://www.gnu.org/licenses/>.
|
19
|
-
#++
|
2
|
+
# frozen_string_literal: true
|
20
3
|
|
21
4
|
|
22
5
|
require 'bundler/gem_tasks'
|
23
6
|
|
24
7
|
require 'yard'
|
8
|
+
require 'yard_ghurt'
|
25
9
|
|
26
10
|
require 'psychgus/version'
|
27
11
|
|
28
12
|
require 'rake/clean'
|
29
13
|
require 'rake/testtask'
|
30
14
|
|
15
|
+
|
31
16
|
task default: [:test]
|
32
17
|
|
33
18
|
CLEAN.exclude('.git/','stock/')
|
34
19
|
CLOBBER.include('doc/')
|
35
20
|
|
36
|
-
module PsychgusRake
|
37
|
-
# Remove if exists
|
38
|
-
def self.rm_exist(filename,output=true)
|
39
|
-
if File.exist?(filename)
|
40
|
-
puts "Delete [#{filename}]" if output
|
41
|
-
File.delete(filename)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
21
|
|
46
|
-
# Execute "rake
|
47
|
-
|
48
|
-
|
49
|
-
task :ghp_doc,[:deploy] do |task,args|
|
50
|
-
dry_run = args.deploy ? '' : '--dry-run'
|
51
|
-
rsync_cmd = "rsync -ahv --delete-after --progress #{dry_run} 'doc/' '../esotericpig.github.io/docs/psychgus/yardoc/'"
|
52
|
-
|
53
|
-
sh rsync_cmd
|
54
|
-
|
55
|
-
if !args.deploy
|
56
|
-
puts
|
57
|
-
puts 'Execute "rake ghp_doc[true]" for actually deploying (non-dry-run)'
|
58
|
-
end
|
59
|
-
end
|
22
|
+
# Execute "rake clobber doc" for pristine docs
|
23
|
+
desc 'Generate documentation (YARDoc)'
|
24
|
+
task doc: %i[yard yard_gfm_fix]
|
60
25
|
|
61
|
-
|
26
|
+
# To test using different Gem versions:
|
27
|
+
# GST=1 bundle update && bundle exec rake test
|
28
|
+
Rake::TestTask.new do |task|
|
62
29
|
task.libs = ['lib','test']
|
63
|
-
task.pattern = 'test
|
30
|
+
task.pattern = File.join('test','**','*_test.rb')
|
64
31
|
task.description += " ('#{task.pattern}')"
|
65
32
|
#task.options = '--verbose' # Execute "rake test TESTOPT=-v" instead
|
66
33
|
task.verbose = true
|
@@ -70,94 +37,34 @@ end
|
|
70
37
|
desc 'Run all tests (including writing to temp files, etc.)'
|
71
38
|
task :test_all do |task|
|
72
39
|
ENV['PSYCHGUS_TEST'] = 'all'
|
73
|
-
|
40
|
+
|
74
41
|
test_task = Rake::Task[:test]
|
75
|
-
|
76
|
-
test_task.
|
42
|
+
|
43
|
+
test_task.reenable
|
44
|
+
test_task.invoke
|
77
45
|
end
|
78
46
|
|
79
|
-
|
80
|
-
|
81
|
-
task.files = ['lib/**/*.rb']
|
82
|
-
|
83
|
-
task.options += ['--files','CHANGELOG.md,LICENSE.txt']
|
84
|
-
task.options += ['--readme','README.md']
|
85
|
-
|
86
|
-
task.options << '--protected' # Show protected methods
|
87
|
-
task.options += ['--template-path','yard/templates/']
|
47
|
+
YARD::Rake::YardocTask.new do |task|
|
48
|
+
task.files = [File.join('lib','**','*.rb')]
|
88
49
|
task.options += ['--title',"Psychgus v#{Psychgus::VERSION} Doc"]
|
89
50
|
end
|
90
51
|
|
91
|
-
|
92
|
-
task
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
lines = []
|
100
|
-
write = false
|
101
|
-
|
102
|
-
File.open(filename,'r') do |file|
|
103
|
-
file.each_line do |line|
|
104
|
-
out = false
|
105
|
-
|
106
|
-
# CSS
|
107
|
-
if line =~ /^\s*\<\/head\>\s*$/i
|
108
|
-
line = '<link href="'
|
109
|
-
line << (args.dev ? '../../esotericpig.github.io/' : '../../../')
|
110
|
-
line << 'css/prism.css" rel="stylesheet" /> </head>'
|
111
|
-
|
112
|
-
out = true
|
113
|
-
end
|
114
|
-
|
115
|
-
# JS
|
116
|
-
if line =~ /^\s*\<\/body\>\s*$/i
|
117
|
-
line = '<script src="'
|
118
|
-
line << (args.dev ? '../../esotericpig.github.io/' : '../../../')
|
119
|
-
line << 'js/prism.js"></script> </body>'
|
120
|
-
|
121
|
-
out = true
|
122
|
-
end
|
123
|
-
|
124
|
-
# Anchor links
|
125
|
-
tag = 'href="#'
|
126
|
-
quoted_tag = Regexp.quote(tag)
|
127
|
-
|
128
|
-
if !(i = line.index(Regexp.new(quoted_tag + '[a-z]'))).nil?()
|
129
|
-
line = line.gsub(Regexp.new(quoted_tag + '[a-z][^"]*"')) do |href|
|
130
|
-
link = href[tag.length..-2]
|
131
|
-
link = link.split('-').map(&:capitalize).join('_')
|
132
|
-
|
133
|
-
%Q(#{tag}#{link}")
|
134
|
-
end
|
135
|
-
|
136
|
-
out = true
|
137
|
-
end
|
138
|
-
|
139
|
-
out = !line.gsub!('href="CHANGELOG.md"','href="file.CHANGELOG.html"').nil?() || out
|
140
|
-
out = !line.gsub!('href="LICENSE.txt"','href="file.LICENSE.html"').nil?() || out
|
141
|
-
out = !line.gsub!('code class="Ruby"','code class="language-ruby"').nil?() || out
|
142
|
-
out = !line.gsub!('code class="YAML"','code class="language-yaml"').nil?() || out
|
143
|
-
|
144
|
-
if out
|
145
|
-
puts " #{line}"
|
146
|
-
write = true
|
147
|
-
end
|
148
|
-
|
149
|
-
lines << line
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
if write
|
154
|
-
File.open(filename,'w') do |file|
|
155
|
-
file.puts lines
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
end
|
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']
|
160
59
|
|
161
|
-
|
162
|
-
|
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
|
163
70
|
end
|