codeless_code 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +1 -1
  3. data/.reek.yml +14 -0
  4. data/.rubocop.yml +18 -0
  5. data/.ruby-version +1 -0
  6. data/{test/test_codeless_code.rb → .travis.yml} +12 -10
  7. data/Gemfile +5 -0
  8. data/Gemfile.lock +21 -0
  9. data/Guardfile +13 -1
  10. data/README.md +6 -0
  11. data/Rakefile +26 -11
  12. data/VERSION +1 -1
  13. data/bin/codeless_code +3 -1
  14. data/codeless_code.gemspec +33 -12
  15. data/lib/codeless_code/catalog.rb +3 -1
  16. data/lib/codeless_code/cli.rb +56 -24
  17. data/lib/codeless_code/commands/filter_fables.rb +15 -10
  18. data/lib/codeless_code/commands/list_translations.rb +3 -0
  19. data/lib/codeless_code/fable.rb +42 -53
  20. data/lib/codeless_code/fable_set.rb +8 -6
  21. data/lib/codeless_code/filters/builders.rb +4 -2
  22. data/lib/codeless_code/filters/composite.rb +3 -1
  23. data/lib/codeless_code/filters/date.rb +40 -30
  24. data/lib/codeless_code/filters/from_options.rb +45 -28
  25. data/lib/codeless_code/filters/headers/base.rb +61 -0
  26. data/lib/codeless_code/filters/{header_integer.rb → headers/integer.rb} +16 -19
  27. data/lib/codeless_code/filters/{header_string.rb → headers/string.rb} +12 -22
  28. data/lib/codeless_code/filters/lang.rb +3 -0
  29. data/lib/codeless_code/filters/translator.rb +7 -2
  30. data/lib/codeless_code/filters.rb +16 -8
  31. data/lib/codeless_code/formats/base.rb +20 -7
  32. data/lib/codeless_code/formats/parsers/base.rb +106 -0
  33. data/lib/codeless_code/formats/parsers/plain.rb +49 -0
  34. data/lib/codeless_code/formats/parsers/term.rb +79 -0
  35. data/lib/codeless_code/formats/plain.rb +21 -12
  36. data/lib/codeless_code/formats/raw.rb +2 -0
  37. data/lib/codeless_code/formats/term.rb +21 -15
  38. data/lib/codeless_code/language_set.rb +7 -4
  39. data/lib/codeless_code/options.rb +5 -3
  40. data/lib/codeless_code/renderers/fable.rb +13 -8
  41. data/lib/codeless_code/renderers/term_page.rb +46 -31
  42. data/lib/codeless_code.rb +119 -106
  43. data/test/codeless_code/commands/test_filter_fables.rb +89 -0
  44. data/test/codeless_code/filters/headers/test_integer.rb +86 -0
  45. data/test/codeless_code/filters/headers/test_string.rb +86 -0
  46. data/test/codeless_code/filters/test_builders.rb +4 -2
  47. data/test/codeless_code/filters/test_composite.rb +70 -0
  48. data/test/codeless_code/filters/test_date.rb +99 -0
  49. data/test/codeless_code/filters/test_langs.rb +50 -0
  50. data/test/codeless_code/filters/test_translator.rb +51 -0
  51. data/test/codeless_code/renderers/test_fable.rb +98 -0
  52. data/test/codeless_code/renderers/test_term_page.rb +87 -0
  53. data/test/codeless_code/test_catalog.rb +12 -5
  54. data/test/codeless_code/test_cli.rb +85 -0
  55. data/test/codeless_code/test_fable.rb +19 -10
  56. data/test/codeless_code/test_fable_set.rb +17 -5
  57. data/test/codeless_code/test_language_set.rb +16 -3
  58. data/test/codeless_code/test_options.rb +3 -11
  59. data/test/helper.rb +36 -10
  60. data/test/support/fs.rb +103 -0
  61. metadata +65 -11
  62. data/.document +0 -5
  63. data/data/README.md +0 -34
  64. data/lib/codeless_code/formats/plain_generator.rb +0 -157
  65. data/lib/codeless_code/formats/term_generator.rb +0 -167
  66. data/test/codeless_code/filters/test_header_integer.rb +0 -82
  67. data/test/codeless_code/filters/test_header_string.rb +0 -82
data/test/helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # codeless_code filters and prints fables from http://thecodelesscode.com
2
4
  # Copyright (C) 2018 Jon Sangster
3
5
  #
@@ -15,9 +17,11 @@
15
17
  # this program. If not, see <https://www.gnu.org/licenses/>.
16
18
  require 'simplecov'
17
19
 
18
- module SimpleCov::Configuration
19
- def clean_filters
20
- @filters = []
20
+ module SimpleCov
21
+ module Configuration
22
+ def clean_filters
23
+ @filters = []
24
+ end
21
25
  end
22
26
  end
23
27
 
@@ -28,6 +32,7 @@ end
28
32
 
29
33
  ENV['COVERAGE'] && SimpleCov.start do
30
34
  add_filter %r{/\..*/}
35
+ add_filter %r{/vendor/.*}
31
36
  end
32
37
 
33
38
  require 'rubygems'
@@ -35,8 +40,8 @@ require 'bundler'
35
40
  begin
36
41
  Bundler.setup(:default, :development)
37
42
  rescue Bundler::BundlerError => e
38
- $stderr.puts e.message
39
- $stderr.puts 'Run `bundle install` to install missing gems'
43
+ warn e.message
44
+ warn 'Run `bundle install` to install missing gems'
40
45
  exit e.status_code
41
46
  end
42
47
 
@@ -44,18 +49,39 @@ require 'minitest/reporters'
44
49
  require 'minitest/test'
45
50
  require 'minitest/autorun'
46
51
 
47
- Minitest::Reporters.use!(Minitest::Reporters::SpecReporter.new)
52
+ Minitest::Reporters.use!(Minitest::Reporters::DefaultReporter.new)
48
53
 
54
+ $LOAD_PATH.unshift(File.join(__dir__))
49
55
  $LOAD_PATH.unshift(File.join(__dir__, '..', 'lib'))
50
56
  require 'pry-byebug'
51
57
  require 'codeless_code'
58
+ require 'support/fs'
59
+
60
+ # Don't allow real data for tests
61
+ CodelessCode.send(:remove_const, :DEFAULT_DATA)
52
62
 
53
63
  class UnitTest < MiniTest::Test
54
64
  include CodelessCode
65
+ include Support
55
66
 
56
- def mock_filter(content)
57
- StringIO.new(content.strip).tap do
58
- |io| io.define_singleton_method(:open) { self }
59
- end
67
+ def mock_fable(content, dir: 'en-test')
68
+ Fable.new(
69
+ StringIO.new(content.strip).tap do |io|
70
+ io.define_singleton_method(:open) { self }
71
+ io.define_singleton_method(:close) { self }
72
+ io.define_singleton_method(:parent) do
73
+ Pathname.new('/test').join(dir)
74
+ end
75
+ io.rewind
76
+ end
77
+ )
78
+ end
79
+
80
+ def catalog(dir = fake_fs)
81
+ (@catalog ||= {})[dir] ||= Catalog.new(dir)
82
+ end
83
+
84
+ def options(*args)
85
+ (@options ||= {})[args] ||= Options.new('codeless_code', args)
60
86
  end
61
87
  end
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Support
4
+ class FakeFile
5
+ attr_reader :name, :path, :body, :parent
6
+
7
+ def initialize(name, body = '')
8
+ @name = name
9
+ @body = body
10
+
11
+ @parent = nil
12
+ @path = Pathname.new(@name)
13
+ end
14
+
15
+ def directory?
16
+ false
17
+ end
18
+
19
+ def parent=(par)
20
+ @parent = par
21
+ @parent.files << self
22
+ @path = par.path.join(name)
23
+ end
24
+
25
+ def basename
26
+ path.basename
27
+ end
28
+
29
+ def glob(str)
30
+ self if path.fnmatch(str) || path.basename.fnmatch(str)
31
+ end
32
+
33
+ def io
34
+ @io ||= StringIO.new(body.strip).tap do |io|
35
+ io.define_singleton_method(:open) { self }
36
+ io.define_singleton_method(:close) { self }
37
+ end
38
+ end
39
+
40
+ def open
41
+ io.tap do |io|
42
+ io.rewind
43
+ yield io if block_given?
44
+ end
45
+ end
46
+
47
+ def close
48
+ io
49
+ end
50
+
51
+ def inspect
52
+ format('#<FakeFile %p>', name)
53
+ end
54
+ end
55
+
56
+ class FakeDir < FakeFile
57
+ attr_reader :files
58
+
59
+ def initialize(name, files = [])
60
+ super(name)
61
+ @files = files
62
+ end
63
+
64
+ def directory?
65
+ true
66
+ end
67
+
68
+ def parent=(node)
69
+ super(node)
70
+ files.each { |f| f.parent = self }
71
+ end
72
+
73
+ def glob(str)
74
+ [super(str), files.map { |f| f.glob(str) }].flatten.compact
75
+ end
76
+
77
+ def create_path(path, body = nil)
78
+ dirs, base = Pathname.new(path).split
79
+
80
+ path =
81
+ dirs.to_s.split(File::SEPARATOR)
82
+ .inject(self) { |dir, name| dir.get_or_create(name, type: :dir) }
83
+ .create(base.to_s)
84
+
85
+ path.open { |io| io.write(body) && io.rewind } if body
86
+ path
87
+ end
88
+
89
+ def get_or_create(node_name, type: :file)
90
+ files.find { |f| f.name == node_name } || create(node_name, type: type)
91
+ end
92
+
93
+ def create(node_name, type: :file)
94
+ (type == :file ? FakeFile : FakeDir).new(node_name).tap do |file|
95
+ file.parent = self
96
+ end
97
+ end
98
+
99
+ def inspect
100
+ format('#<FakeDir %p, files=%p>', name, files)
101
+ end
102
+ end
103
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codeless_code
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Sangster
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-05 00:00:00.000000000 Z
11
+ date: 2018-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -108,6 +108,34 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '2.4'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard-reek
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
+ - !ruby/object:Gem::Dependency
126
+ name: guard-rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.3'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.3'
111
139
  - !ruby/object:Gem::Dependency
112
140
  name: jeweler
113
141
  requirement: !ruby/object:Gem::Requirement
@@ -206,6 +234,20 @@ dependencies:
206
234
  - - "~>"
207
235
  - !ruby/object:Gem::Version
208
236
  version: '5.2'
237
+ - !ruby/object:Gem::Dependency
238
+ name: rubocop
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: '0.60'
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: '0.60'
209
251
  - !ruby/object:Gem::Dependency
210
252
  name: simplecov
211
253
  requirement: !ruby/object:Gem::Requirement
@@ -246,8 +288,11 @@ extra_rdoc_files:
246
288
  - LICENSE
247
289
  - README.md
248
290
  files:
249
- - ".document"
250
291
  - ".gitmodules"
292
+ - ".reek.yml"
293
+ - ".rubocop.yml"
294
+ - ".ruby-version"
295
+ - ".travis.yml"
251
296
  - Gemfile
252
297
  - Gemfile.lock
253
298
  - Guardfile
@@ -257,7 +302,6 @@ files:
257
302
  - VERSION
258
303
  - bin/codeless_code
259
304
  - codeless_code.gemspec
260
- - data/README.md
261
305
  - data/the-codeless-code/cs-hanzik/case-1.txt
262
306
  - data/the-codeless-code/cs-hanzik/case-10.txt
263
307
  - data/the-codeless-code/cs-hanzik/case-11.txt
@@ -1713,30 +1757,40 @@ files:
1713
1757
  - lib/codeless_code/filters/composite.rb
1714
1758
  - lib/codeless_code/filters/date.rb
1715
1759
  - lib/codeless_code/filters/from_options.rb
1716
- - lib/codeless_code/filters/header_integer.rb
1717
- - lib/codeless_code/filters/header_string.rb
1760
+ - lib/codeless_code/filters/headers/base.rb
1761
+ - lib/codeless_code/filters/headers/integer.rb
1762
+ - lib/codeless_code/filters/headers/string.rb
1718
1763
  - lib/codeless_code/filters/lang.rb
1719
1764
  - lib/codeless_code/filters/translator.rb
1720
1765
  - lib/codeless_code/formats/base.rb
1766
+ - lib/codeless_code/formats/parsers/base.rb
1767
+ - lib/codeless_code/formats/parsers/plain.rb
1768
+ - lib/codeless_code/formats/parsers/term.rb
1721
1769
  - lib/codeless_code/formats/plain.rb
1722
- - lib/codeless_code/formats/plain_generator.rb
1723
1770
  - lib/codeless_code/formats/raw.rb
1724
1771
  - lib/codeless_code/formats/term.rb
1725
- - lib/codeless_code/formats/term_generator.rb
1726
1772
  - lib/codeless_code/language_set.rb
1727
1773
  - lib/codeless_code/options.rb
1728
1774
  - lib/codeless_code/renderers/fable.rb
1729
1775
  - lib/codeless_code/renderers/term_page.rb
1776
+ - test/codeless_code/commands/test_filter_fables.rb
1777
+ - test/codeless_code/filters/headers/test_integer.rb
1778
+ - test/codeless_code/filters/headers/test_string.rb
1730
1779
  - test/codeless_code/filters/test_builders.rb
1731
- - test/codeless_code/filters/test_header_integer.rb
1732
- - test/codeless_code/filters/test_header_string.rb
1780
+ - test/codeless_code/filters/test_composite.rb
1781
+ - test/codeless_code/filters/test_date.rb
1782
+ - test/codeless_code/filters/test_langs.rb
1783
+ - test/codeless_code/filters/test_translator.rb
1784
+ - test/codeless_code/renderers/test_fable.rb
1785
+ - test/codeless_code/renderers/test_term_page.rb
1733
1786
  - test/codeless_code/test_catalog.rb
1787
+ - test/codeless_code/test_cli.rb
1734
1788
  - test/codeless_code/test_fable.rb
1735
1789
  - test/codeless_code/test_fable_set.rb
1736
1790
  - test/codeless_code/test_language_set.rb
1737
1791
  - test/codeless_code/test_options.rb
1738
1792
  - test/helper.rb
1739
- - test/test_codeless_code.rb
1793
+ - test/support/fs.rb
1740
1794
  homepage: https://github.com/sangster/codeless_code
1741
1795
  licenses:
1742
1796
  - GPL-3.0
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
data/data/README.md DELETED
@@ -1,34 +0,0 @@
1
- The Codeless Code
2
- =================
3
-
4
- This repository contains all the content of [The Codeless Code](http://www.thecodelesscode.com)
5
- (i.e. the translations and the original cases by Qi), an inspiring and beautiful
6
- collection of “fables and kōans for the software engineer”.
7
-
8
- Adding a translation
9
- --------------------
10
-
11
- If you want to add your translation:
12
-
13
- 1. [Fork the repo](https://github.com/alessandro1997/the-codeless-code/fork).
14
- 2. Create a directory named after your language code and translator name (e.g. **en-qi**).
15
- 3. Add a branch for the case(s) you want to translate (e.g. **case-42** or **cases-1-10**).
16
- 4. Add your translations.
17
- 5. Push the changes.
18
- 6. File a [Pull Request](https://github.com/alessandro1997/the-codeless-code/pulls).
19
-
20
- Translation format
21
- ------------------
22
-
23
- You can find information about the format to follow [here](http://thecodelesscode.com/about#submitting-translations).
24
-
25
- Only keep the `Number` header, translate the `Title`, and possibly
26
- `Tagline` and `Illus.X.title` for the images' `alt` tags.
27
- Add `Lang` with the locale and `Translator` with your translator nickname.
28
- All other headers will be ignored and taken from the original English version.
29
-
30
- Credits
31
- -------
32
-
33
- Many thanks to Qi for this ingenious work of art and to all the translators for
34
- their hard work.
@@ -1,157 +0,0 @@
1
- # codeless_code filters and prints fables from http://thecodelesscode.com
2
- # Copyright (C) 2018 Jon Sangster
3
- #
4
- # This program is free software: you can redistribute it and/or modify it under
5
- # the terms of the GNU General Public License as published by the Free Software
6
- # Foundation, either version 3 of the License, or (at your option) any later
7
- # version.
8
- #
9
- # This program is distributed in the hope that it will be useful, but WITHOUT
10
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
- # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12
- # details.
13
- #
14
- # You should have received a copy of the GNU General Public License along with
15
- # this program. If not, see <https://www.gnu.org/licenses/>.
16
- require 'mediacloth'
17
-
18
- module CodelessCode
19
- module Formats
20
- class PlainGenerator < MediaWikiWalker
21
- def initialize(ctx)
22
- @ctx = ctx
23
- end
24
-
25
- protected
26
-
27
- def parse_wiki_ast(ast)
28
- super(ast).join
29
- end
30
-
31
- #Reimplement this
32
- def parse_paragraph(ast)
33
- parse_wiki_ast(ast)
34
- end
35
-
36
- #Reimplement this
37
- def parse_paste(ast)
38
- parse_wiki_ast(ast)
39
- end
40
-
41
- #Reimplement this
42
- def parse_formatted(ast)
43
- parse_wiki_ast(ast)
44
- end
45
-
46
- #Reimplement this
47
- def parse_text(ast)
48
- ast.contents
49
- end
50
-
51
- #Reimplement this
52
- def parse_list(ast)
53
- ast.children.map do |c|
54
- r = parse_list_item(c) if c.class == ListItemAST
55
- r = parse_list_term(c) if c.class == ListTermAST
56
- r = parse_list_definition(c) if c.class == ListDefinitionAST
57
- r
58
- end
59
- end
60
-
61
- #Reimplement this
62
- def parse_list_item(ast)
63
- parse_wiki_ast(ast)
64
- end
65
-
66
- #Reimplement this
67
- def parse_list_term(ast)
68
- parse_wiki_ast(ast)
69
- end
70
-
71
- #Reimplement this
72
- def parse_list_definition(ast)
73
- parse_wiki_ast(ast)
74
- end
75
-
76
- #Reimplement this
77
- def parse_preformatted(ast)
78
- parse_wiki_ast(ast)
79
- end
80
-
81
- #Reimplement this
82
- def parse_section(ast)
83
- parse_wiki_ast(ast).strip
84
- end
85
-
86
- #Reimplement this
87
- def parse_link(ast)
88
- parse_wiki_ast(ast)
89
- end
90
-
91
- #Reimplement this
92
- def parse_internal_link(ast)
93
- text = parse_wiki_ast(ast)
94
- text.size > 0 ? text : ast.locator
95
- end
96
-
97
- #Reimplement this
98
- def parse_resource_link(ast)
99
- ast.children.map do |c|
100
- parse_internal_link_item(c) if c.class == InternalLinkItemAST
101
- end
102
- end
103
-
104
- #Reimplement this
105
- def parse_category_link(ast)
106
- ast.children.map do |c|
107
- parse_internal_link_item(c) if c.class == InternalLinkItemAST
108
- end
109
- end
110
-
111
- #Reimplement this
112
- def parse_internal_link_item(ast)
113
- parse_wiki_ast(ast)
114
- end
115
-
116
- #Reimplement this
117
- def parse_table(ast)
118
- parse_wiki_ast(ast)
119
- end
120
-
121
- #Reimplement this
122
- def parse_table_row(ast)
123
- parse_wiki_ast(ast)
124
- end
125
-
126
- #Reimplement this
127
- def parse_table_cell(ast)
128
- parse_wiki_ast(ast)
129
- end
130
-
131
- #Reimplement this
132
- def parse_element(ast)
133
- str = parse_wiki_ast(ast)
134
- if ast.name == 'pre'
135
- @ctx.generate(str.gsub(/\A\n*(.*?)\n*\z/m, '\1'))
136
- else
137
- str
138
- end
139
- end
140
-
141
- #Reimplement this
142
- def parse_template(ast)
143
- ast.template_name
144
- end
145
-
146
- #Reimplement this
147
- def parse_category(ast)
148
- raise NotImplementedError
149
- end
150
-
151
- #Reimplement this
152
- def parse_keyword(ast)
153
- parse_wiki_ast(ast)
154
- end
155
- end
156
- end
157
- end
@@ -1,167 +0,0 @@
1
- # codeless_code filters and prints fables from http://thecodelesscode.com
2
- # Copyright (C) 2018 Jon Sangster
3
- #
4
- # This program is free software: you can redistribute it and/or modify it under
5
- # the terms of the GNU General Public License as published by the Free Software
6
- # Foundation, either version 3 of the License, or (at your option) any later
7
- # version.
8
- #
9
- # This program is distributed in the hope that it will be useful, but WITHOUT
10
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
- # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12
- # details.
13
- #
14
- # You should have received a copy of the GNU General Public License along with
15
- # this program. If not, see <https://www.gnu.org/licenses/>.
16
- require 'mediacloth'
17
-
18
- module CodelessCode
19
- module Formats
20
- class TermGenerator < MediaWikiWalker
21
- def initialize(ctx)
22
- @ctx = ctx
23
- end
24
-
25
- protected
26
-
27
- def parse_wiki_ast(ast)
28
- super(ast).join
29
- end
30
-
31
- #Reimplement this
32
- def parse_paragraph(ast)
33
- parse_wiki_ast(ast)
34
- end
35
-
36
- #Reimplement this
37
- def parse_paste(ast)
38
- parse_wiki_ast(ast)
39
- end
40
-
41
- #Reimplement this
42
- def parse_formatted(ast)
43
- if ast.formatting == :Bold
44
- c(parse_wiki_ast(ast)).bold
45
- else
46
- c(parse_wiki_ast(ast)).italic
47
- end
48
- end
49
-
50
- #Reimplement this
51
- def parse_text(ast)
52
- ast.contents
53
- end
54
-
55
- #Reimplement this
56
- def parse_list(ast)
57
- ast.children.map do |c|
58
- r = parse_list_item(c) if c.class == ListItemAST
59
- r = parse_list_term(c) if c.class == ListTermAST
60
- r = parse_list_definition(c) if c.class == ListDefinitionAST
61
- r
62
- end
63
- end
64
-
65
- #Reimplement this
66
- def parse_list_item(ast)
67
- parse_wiki_ast(ast)
68
- end
69
-
70
- #Reimplement this
71
- def parse_list_term(ast)
72
- parse_wiki_ast(ast)
73
- end
74
-
75
- #Reimplement this
76
- def parse_list_definition(ast)
77
- parse_wiki_ast(ast)
78
- end
79
-
80
- #Reimplement this
81
- def parse_preformatted(ast)
82
- c(parse_wiki_ast(ast)).green
83
- end
84
-
85
- #Reimplement this
86
- def parse_section(ast)
87
- c(parse_wiki_ast(ast).strip).blue
88
- end
89
-
90
- #Reimplement this
91
- def parse_link(ast)
92
- c(parse_wiki_ast(ast)).underline
93
- end
94
-
95
- #Reimplement this
96
- def parse_internal_link(ast)
97
- text = parse_wiki_ast(ast)
98
- c(text.size > 0 ? text : ast.locator).underline
99
- end
100
-
101
- #Reimplement this
102
- def parse_resource_link(ast)
103
- ast.children.map do |c|
104
- parse_internal_link_item(c) if c.class == InternalLinkItemAST
105
- end
106
- end
107
-
108
- #Reimplement this
109
- def parse_category_link(ast)
110
- ast.children.map do |c|
111
- parse_internal_link_item(c) if c.class == InternalLinkItemAST
112
- end
113
- end
114
-
115
- #Reimplement this
116
- def parse_internal_link_item(ast)
117
- parse_wiki_ast(ast)
118
- end
119
-
120
- #Reimplement this
121
- def parse_table(ast)
122
- parse_wiki_ast(ast)
123
- end
124
-
125
- #Reimplement this
126
- def parse_table_row(ast)
127
- parse_wiki_ast(ast)
128
- end
129
-
130
- #Reimplement this
131
- def parse_table_cell(ast)
132
- parse_wiki_ast(ast)
133
- end
134
-
135
- #Reimplement this
136
- def parse_element(ast)
137
- str = parse_wiki_ast(ast)
138
- if ast.name == 'pre'
139
- c(@ctx.generate(str.gsub(/\A\n*(.*?)\n*\z/m, '\1'))).red
140
- else
141
- str
142
- end
143
- end
144
-
145
- #Reimplement this
146
- def parse_template(ast)
147
- c(ast.template_name).yellow
148
- end
149
-
150
- #Reimplement this
151
- def parse_category(ast)
152
- raise NotImplementedError
153
- end
154
-
155
- #Reimplement this
156
- def parse_keyword(ast)
157
- c(parse_wiki_ast(ast)).underline
158
- end
159
-
160
- private
161
-
162
- def c(str)
163
- @ctx.c(str)
164
- end
165
- end
166
- end
167
- end