markdown_helper 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +10 -4
  4. data/lib/markdown_helper/version.rb +1 -1
  5. data/lib/markdown_helper.rb +14 -5
  6. data/markdown/readme/README.template.md +8 -3
  7. data/markdown/use_cases/Rakefile +17 -20
  8. data/markdown/use_cases/include_files/diagnose_circular_includes/diagnose_circular_includes.err +9 -9
  9. data/markdown/use_cases/include_files/diagnose_circular_includes/use_case.md +16 -25
  10. data/markdown/use_cases/include_files/diagnose_missing_includee/diagnose_missing_includee.err +9 -9
  11. data/markdown/use_cases/include_files/diagnose_missing_includee/use_case.md +16 -25
  12. data/markdown/use_cases/include_files/include_code_block/use_case.md +7 -17
  13. data/markdown/use_cases/include_files/include_highlighted_code/use_case.md +7 -17
  14. data/markdown/use_cases/include_files/include_markdown/use_case.md +7 -18
  15. data/markdown/use_cases/include_files/include_page_toc/included.md +0 -6
  16. data/markdown/use_cases/include_files/include_page_toc/use_case.md +7 -30
  17. data/markdown/use_cases/include_files/include_text_as_comment/use_case.md +7 -18
  18. data/markdown/use_cases/include_files/include_text_as_details/details.md +5 -0
  19. data/markdown/use_cases/include_files/include_text_as_details/included.md +10 -0
  20. data/markdown/use_cases/include_files/include_text_as_details/includer.md +4 -0
  21. data/markdown/use_cases/include_files/include_text_as_details/use_case.md +84 -0
  22. data/markdown/use_cases/include_files/include_text_as_details/use_case_template.md +31 -0
  23. data/markdown/use_cases/include_files/include_text_as_pre/use_case.md +7 -18
  24. data/markdown/use_cases/include_files/include_with_added_comments/included.md +0 -4
  25. data/markdown/use_cases/include_files/include_with_added_comments/use_case.md +0 -4
  26. data/markdown/use_cases/include_files/interface.md +8 -17
  27. data/markdown/use_cases/include_files/nest_inclusions/use_case.md +7 -16
  28. data/markdown/use_cases/include_files/reuse_text/use_case.md +7 -18
  29. data/markdown/use_cases/use_cases.md +1 -0
  30. metadata +8 -20
  31. data/markdown/use_cases/include_files/diagnose_circular_includes/include.rb +0 -5
  32. data/markdown/use_cases/include_files/diagnose_circular_includes/use_case_builder.rb +0 -64
  33. data/markdown/use_cases/include_files/diagnose_missing_includee/include.rb +0 -5
  34. data/markdown/use_cases/include_files/diagnose_missing_includee/use_case_builder.rb +0 -66
  35. data/markdown/use_cases/include_files/include_code_block/use_case_builder.rb +0 -78
  36. data/markdown/use_cases/include_files/include_generated_text/use_case_builder.rb +0 -37
  37. data/markdown/use_cases/include_files/include_highlighted_code/use_case_builder.rb +0 -82
  38. data/markdown/use_cases/include_files/include_markdown/use_case_builder.rb +0 -80
  39. data/markdown/use_cases/include_files/include_page_toc/use_case_builder.rb +0 -121
  40. data/markdown/use_cases/include_files/include_text_as_comment/use_case_builder.rb +0 -71
  41. data/markdown/use_cases/include_files/include_text_as_pre/use_case_builder.rb +0 -68
  42. data/markdown/use_cases/include_files/include_use_case.rb +0 -104
  43. data/markdown/use_cases/include_files/include_with_added_comments/use_case_builder.rb +0 -66
  44. data/markdown/use_cases/include_files/nest_inclusions/use_case_builder.rb +0 -60
  45. data/markdown/use_cases/include_files/reuse_text/include.rb +0 -5
  46. data/markdown/use_cases/include_files/reuse_text/use_case_builder.rb +0 -48
@@ -1,104 +0,0 @@
1
- require_relative '../use_case'
2
-
3
- class IncludeUseCase < UseCase
4
-
5
- attr_accessor :use_case_dir_name
6
-
7
- INCLUDE_DIR_PATH = File.dirname(__FILE__)
8
-
9
- INCLUDEE_FILE_NAME = 'includee.md'
10
- INCLUDER_FILE_NAME = 'includer.md'
11
- INCLUDED_FILE_NAME = 'included.md'
12
-
13
- RUBY_FILE_NAME = 'include.rb'
14
- RUBY_COMMAND = "ruby #{RUBY_FILE_NAME}"
15
-
16
- INCLUDE_COMMAND = IncludeUseCase.construct_include_command(INCLUDER_FILE_NAME, INCLUDED_FILE_NAME, pristine = true)
17
-
18
- BUILD_COMMAND = UseCase.construct_include_command(TEMPLATE_FILE_NAME, USE_CASE_FILE_NAME, pristine = true)
19
-
20
- def initialize
21
- super
22
- commands_to_execute.push(BUILD_COMMAND)
23
- self.use_case_dir_name = use_case_dir_name
24
- end
25
-
26
- def use_case_dir_path
27
- File.join(File.absolute_path(File.dirname(__FILE__)), use_case_dir_name)
28
- end
29
-
30
- def write_includee_file
31
- File.write(
32
- INCLUDEE_FILE_NAME,
33
- <<EOT
34
- Text in includee file.
35
- EOT
36
- )
37
- end
38
-
39
- def write_includer_file
40
- File.write(
41
- INCLUDER_FILE_NAME,
42
- <<EOT
43
- Text in includer file.
44
-
45
- @[:markdown](#{INCLUDEE_FILE_NAME})
46
-
47
- EOT
48
- )
49
- end
50
-
51
- def write_ruby_file(pristine)
52
- args = pristine ? '(:pristine => true)' : ''
53
- File.write(
54
- RUBY_FILE_NAME,
55
- <<EOT
56
- require 'markdown_helper'
57
-
58
- # Option :pristine suppresses comment insertion.
59
- markdown_helper = MarkdownHelper.new#{args}
60
- markdown_helper.include('#{INCLUDER_FILE_NAME}', '#{INCLUDED_FILE_NAME}')
61
- EOT
62
- )
63
- end
64
-
65
- def self.write_interface_file
66
- interface_file_path = File.join(
67
- INCLUDE_DIR_PATH,
68
- 'interface.md',
69
- )
70
- File.open(interface_file_path, 'w') do |interface_file|
71
- interface_file.puts(<<EOT
72
- #### CLI
73
-
74
- You can use the command-line interface to perform the inclusion.
75
-
76
- ##### Command
77
-
78
- ```sh
79
- #{INCLUDE_COMMAND}
80
- ```
81
-
82
- @[:markdown](../pristine.md)
83
-
84
- #### API
85
-
86
- You can use the API to perform the inclusion.
87
-
88
- ##### Ruby Code
89
-
90
- @[ruby](#{RUBY_FILE_NAME})
91
-
92
- ##### Command
93
-
94
- ```sh
95
- #{RUBY_COMMAND}
96
- ```
97
- EOT
98
- )
99
- end
100
-
101
- end
102
-
103
- end
104
-
@@ -1,66 +0,0 @@
1
- require_relative '../include_use_case'
2
-
3
- class IncludeWithAddedComments < IncludeUseCase
4
-
5
- def self.build
6
-
7
- use_case = self.new
8
-
9
- include_command = IncludeUseCase.construct_include_command(INCLUDER_FILE_NAME, INCLUDED_FILE_NAME, pristine = false)
10
- use_case.commands_to_execute.unshift(include_command)
11
-
12
- use_case.files_to_write.store(
13
- TEMPLATE_FILE_NAME,
14
- <<EOT
15
- ### Include with Added Comments
16
-
17
- By default (that is, without option ```--pristine```) file inclusion adds comments that:
18
-
19
- * Identify the includer file.
20
- * Identify each includee file.
21
-
22
- #### Includee File
23
-
24
- @[markdown](#{INCLUDEE_FILE_NAME})
25
-
26
- #### Includer File
27
-
28
- @[markdown](#{INCLUDER_FILE_NAME})
29
-
30
- #### CLI
31
-
32
- You can use the command-line interface to perform the inclusion.
33
-
34
- ##### Command
35
-
36
- ```sh
37
- markdown_helper include #{INCLUDER_FILE_NAME} #{INCLUDED_FILE_NAME}
38
- ```
39
-
40
- #### API
41
-
42
- You can use the API to perform the inclusion.
43
-
44
- ##### Ruby Code
45
-
46
- ```ruby
47
- require 'markdown_helper'
48
-
49
- markdown_helper = MarkdownHelper.new
50
- markdown_helper.include(#{INCLUDER_FILE_NAME}, #{INCLUDED_FILE_NAME})
51
- ```
52
-
53
- #### File with Inclusion and Added Comments
54
-
55
- @[markdown](#{INCLUDED_FILE_NAME})
56
-
57
- The file path for the included file is relative to the .git directory.
58
- EOT
59
-
60
- )
61
-
62
- use_case.build
63
-
64
- end
65
-
66
- end
@@ -1,60 +0,0 @@
1
- require_relative '../include_use_case'
2
-
3
- class NestInclusions < IncludeUseCase
4
-
5
- def self.build
6
-
7
- use_case = self.new
8
-
9
- nested_includee_file_name = 'nested_includee.md'
10
-
11
- use_case.files_to_write.store(
12
- nested_includee_file_name,
13
- <<EOT
14
- Text for nested inclusion.
15
- EOT
16
- )
17
-
18
- use_case.files_to_write.store(
19
- INCLUDER_FILE_NAME,
20
- <<EOT
21
- File to do nested inclusion.
22
-
23
- @[:markdown](#{INCLUDEE_FILE_NAME})
24
- EOT
25
- )
26
-
27
- use_case.files_to_write.store(
28
- TEMPLATE_FILE_NAME,
29
- <<EOT
30
- ### Nest Inclusions
31
-
32
- An included markdown file can itself include more files.
33
-
34
- #### File To Be Included
35
-
36
- @[markdown](#{INCLUDEE_FILE_NAME})
37
-
38
- #### File For Nested Inclusion
39
-
40
- @[markdown](#{nested_includee_file_name})
41
-
42
- #### Includer File
43
-
44
- @[markdown](#{INCLUDER_FILE_NAME})
45
-
46
- @[:markdown](../interface.md)
47
-
48
- #### File with Inclusion
49
-
50
- Here's the finished file with the inclusion and nested inclusion:
51
-
52
- @[markdown](#{INCLUDED_FILE_NAME})
53
- EOT
54
- )
55
-
56
- use_case.build
57
-
58
- end
59
-
60
- end
@@ -1,5 +0,0 @@
1
- require 'markdown_helper'
2
-
3
- # Option :pristine suppresses comment insertion.
4
- markdown_helper = MarkdownHelper.new(:pristine => true)
5
- markdown_helper.include('includer.md', 'included.md')
@@ -1,48 +0,0 @@
1
- require_relative '../include_use_case'
2
-
3
- class ReuseText < IncludeUseCase
4
-
5
- def self.build
6
-
7
- use_case = self.new
8
-
9
- use_case.write_includee_file
10
- use_case.write_includer_file
11
- use_case.write_ruby_file(pristine = true)
12
-
13
- use_case.commands_to_execute.push('ruby include.rb')
14
-
15
- File.write(
16
- TEMPLATE_FILE_NAME,
17
- <<EOT
18
- ### Reuse Text
19
-
20
- Use file inclusion to stay DRY (Don't Repeat Yourself).
21
-
22
- Maintain reusable text in a separate file, then include it wherever it's needed.
23
-
24
- #### File To Be Included
25
-
26
- @[markdown](#{INCLUDEE_FILE_NAME})
27
-
28
- #### Includer File
29
-
30
- @[markdown](#{INCLUDER_FILE_NAME})
31
-
32
- The treatment token ```:markdown``` specifies that the included text is to be treated as more markdown.
33
-
34
- @[:markdown](../interface.md)
35
-
36
- #### File with Inclusion
37
-
38
- Here's the output file, after inclusion.
39
-
40
- @[markdown](#{INCLUDED_FILE_NAME})
41
- EOT
42
- )
43
-
44
- use_case.build
45
-
46
- end
47
-
48
- end