yuno-proofreader 0.1.1 → 0.1.3

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.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/lib/yuno/proofreader/analysis/adjustments.rb +30 -32
  4. data/lib/yuno/proofreader/analysis/crawler.rb +71 -73
  5. data/lib/yuno/proofreader/analysis/entries.rb +52 -54
  6. data/lib/yuno/proofreader/analysis/extractor.rb +162 -164
  7. data/lib/yuno/proofreader/analysis/graph.rb +86 -88
  8. data/lib/yuno/proofreader/analysis/judge.rb +80 -82
  9. data/lib/yuno/proofreader/analysis/judge_prompt.rb +50 -52
  10. data/lib/yuno/proofreader/analysis/judgments.rb +50 -52
  11. data/lib/yuno/proofreader/analysis/links.rb +44 -46
  12. data/lib/yuno/proofreader/analysis/list_order.rb +20 -22
  13. data/lib/yuno/proofreader/analysis/reasons.rb +44 -43
  14. data/lib/yuno/proofreader/analysis/report.rb +79 -81
  15. data/lib/yuno/proofreader/analysis/runner.rb +133 -135
  16. data/lib/yuno/proofreader/analysis/scorer.rb +97 -99
  17. data/lib/yuno/proofreader/analysis/settings.rb +65 -67
  18. data/lib/yuno/proofreader/analysis/signals.rb +77 -79
  19. data/lib/yuno/proofreader/analysis/structured_data.rb +40 -42
  20. data/lib/yuno/proofreader/analysis/url_tree.rb +34 -36
  21. data/lib/yuno/proofreader/analysis/weights.rb +67 -69
  22. data/lib/yuno/proofreader/audit/agenda.rb +63 -65
  23. data/lib/yuno/proofreader/audit/agenda_report.rb +44 -46
  24. data/lib/yuno/proofreader/audit/answers.rb +53 -55
  25. data/lib/yuno/proofreader/audit/attempt.rb +50 -52
  26. data/lib/yuno/proofreader/audit/batch.rb +49 -49
  27. data/lib/yuno/proofreader/audit/batch_report.rb +62 -64
  28. data/lib/yuno/proofreader/audit/cadence.rb +47 -49
  29. data/lib/yuno/proofreader/audit/instructions.rb +15 -17
  30. data/lib/yuno/proofreader/audit/log_fields.rb +16 -18
  31. data/lib/yuno/proofreader/audit/prompt.rb +118 -120
  32. data/lib/yuno/proofreader/audit/report.rb +116 -118
  33. data/lib/yuno/proofreader/audit/runner.rb +150 -152
  34. data/lib/yuno/proofreader/audit/schemas.rb +49 -0
  35. data/lib/yuno/proofreader/audit/steps.rb +46 -48
  36. data/lib/yuno/proofreader/cli/analysis_commands.rb +36 -38
  37. data/lib/yuno/proofreader/cli/audit_commands.rb +89 -91
  38. data/lib/yuno/proofreader/cli/command_log.rb +34 -36
  39. data/lib/yuno/proofreader/cli/flags.rb +33 -35
  40. data/lib/yuno/proofreader/cli/generate_commands.rb +99 -101
  41. data/lib/yuno/proofreader/cli/init_command.rb +123 -125
  42. data/lib/yuno/proofreader/cli/model_commands.rb +35 -37
  43. data/lib/yuno/proofreader/cli/queue_commands.rb +79 -81
  44. data/lib/yuno/proofreader/cli/sheet_commands.rb +42 -44
  45. data/lib/yuno/proofreader/cli.rb +197 -199
  46. data/lib/yuno/proofreader/config.rb +13 -17
  47. data/lib/yuno/proofreader/context.rb +45 -50
  48. data/lib/yuno/proofreader/env_file.rb +52 -56
  49. data/lib/yuno/proofreader/errors.rb +7 -9
  50. data/lib/yuno/proofreader/findings/finding.rb +73 -75
  51. data/lib/yuno/proofreader/findings/matching.rb +21 -23
  52. data/lib/yuno/proofreader/findings/merger.rb +35 -37
  53. data/lib/yuno/proofreader/findings/outline.rb +50 -52
  54. data/lib/yuno/proofreader/findings/plan.rb +14 -16
  55. data/lib/yuno/proofreader/findings/reconciler.rb +170 -172
  56. data/lib/yuno/proofreader/findings/source.rb +54 -56
  57. data/lib/yuno/proofreader/findings/text.rb +24 -26
  58. data/lib/yuno/proofreader/generate/cache.rb +54 -56
  59. data/lib/yuno/proofreader/generate/collector.rb +98 -100
  60. data/lib/yuno/proofreader/generate/describe.rb +18 -20
  61. data/lib/yuno/proofreader/generate/llm/prompt.rb +50 -52
  62. data/lib/yuno/proofreader/generate/llm/reader.rb +84 -86
  63. data/lib/yuno/proofreader/generate/llm/wording.rb +12 -14
  64. data/lib/yuno/proofreader/generate/llms_builder.rb +36 -38
  65. data/lib/yuno/proofreader/generate/llms_report.rb +82 -84
  66. data/lib/yuno/proofreader/generate/llms_txt.rb +99 -101
  67. data/lib/yuno/proofreader/generate/llms_writer.rb +43 -45
  68. data/lib/yuno/proofreader/generate/outline.rb +67 -69
  69. data/lib/yuno/proofreader/generate/passage.rb +41 -43
  70. data/lib/yuno/proofreader/generate/saved_answer.rb +42 -44
  71. data/lib/yuno/proofreader/http/client.rb +94 -96
  72. data/lib/yuno/proofreader/http/net_http_transport.rb +35 -37
  73. data/lib/yuno/proofreader/http/robots.rb +51 -53
  74. data/lib/yuno/proofreader/init/ask.rb +45 -47
  75. data/lib/yuno/proofreader/init/detector.rb +75 -77
  76. data/lib/yuno/proofreader/init/interview.rb +155 -157
  77. data/lib/yuno/proofreader/init/parsing.rb +37 -39
  78. data/lib/yuno/proofreader/init/web.rb +22 -24
  79. data/lib/yuno/proofreader/llm/client.rb +118 -113
  80. data/lib/yuno/proofreader/llm/defaults.rb +10 -12
  81. data/lib/yuno/proofreader/llm/errors.rb +18 -18
  82. data/lib/yuno/proofreader/llm/factory.rb +34 -36
  83. data/lib/yuno/proofreader/llm/handoff.rb +86 -88
  84. data/lib/yuno/proofreader/llm/http_transport.rb +25 -27
  85. data/lib/yuno/proofreader/llm/json_text.rb +12 -14
  86. data/lib/yuno/proofreader/llm/provider.rb +49 -51
  87. data/lib/yuno/proofreader/llm/providers/gemini.rb +111 -111
  88. data/lib/yuno/proofreader/llm/providers/manual.rb +34 -36
  89. data/lib/yuno/proofreader/llm/providers.rb +17 -19
  90. data/lib/yuno/proofreader/llm/types.rb +6 -8
  91. data/lib/yuno/proofreader/llm/usage.rb +8 -10
  92. data/lib/yuno/proofreader/log.rb +88 -96
  93. data/lib/yuno/proofreader/pages/fetcher.rb +53 -55
  94. data/lib/yuno/proofreader/pages/report.rb +37 -39
  95. data/lib/yuno/proofreader/pages/snapshot.rb +32 -34
  96. data/lib/yuno/proofreader/pages/trimmer.rb +23 -25
  97. data/lib/yuno/proofreader/settings_file.rb +35 -38
  98. data/lib/yuno/proofreader/site.rb +52 -54
  99. data/lib/yuno/proofreader/site_reader.rb +122 -124
  100. data/lib/yuno/proofreader/sitemap/aligner.rb +58 -60
  101. data/lib/yuno/proofreader/sitemap/importer.rb +19 -21
  102. data/lib/yuno/proofreader/sitemap/loader.rb +95 -97
  103. data/lib/yuno/proofreader/sitemap/mismatch.rb +53 -55
  104. data/lib/yuno/proofreader/sitemap/pairer.rb +171 -173
  105. data/lib/yuno/proofreader/sitemap/parser.rb +50 -52
  106. data/lib/yuno/proofreader/sitemap/report.rb +72 -74
  107. data/lib/yuno/proofreader/store/cells.rb +55 -49
  108. data/lib/yuno/proofreader/store/gateways/csv.rb +53 -56
  109. data/lib/yuno/proofreader/store/gateways/google.rb +152 -158
  110. data/lib/yuno/proofreader/store/memory.rb +60 -64
  111. data/lib/yuno/proofreader/store/records.rb +18 -20
  112. data/lib/yuno/proofreader/store/schema.rb +85 -89
  113. data/lib/yuno/proofreader/store/sheets.rb +132 -145
  114. data/lib/yuno/proofreader/store/tab_setup.rb +51 -54
  115. data/lib/yuno/proofreader/version.rb +1 -1
  116. data/lib/yuno/proofreader.rb +3 -4
  117. data/proofreader.example.yml +15 -10
  118. metadata +3 -2
@@ -2,28 +2,26 @@
2
2
 
3
3
  require "yaml"
4
4
 
5
- module Yuno
6
- module Proofreader
7
- module Audit
8
- # The wording of the instructions, read from prompts/instructions.yml.
9
- module Instructions
10
- PATH = File.join(__dir__, "prompts", "instructions.yml")
11
- KEYS = %w[role effort rules site_wide_parts audit_procedure review_procedure].freeze
12
- Texts = Data.define(*KEYS.map(&:to_sym))
5
+ module Yuno::Proofreader
6
+ module Audit
7
+ # The wording of the instructions, read from prompts/instructions.yml.
8
+ module Instructions
9
+ PATH = File.join(__dir__, "prompts", "instructions.yml")
10
+ KEYS = %w[role effort rules site_wide_parts audit_procedure review_procedure].freeze
11
+ Texts = Data.define(*KEYS.map(&:to_sym))
13
12
 
14
- module_function
13
+ module_function
15
14
 
16
- def default = @default ||= load
15
+ def default = @default ||= load
17
16
 
18
- def load(path = PATH)
19
- data = YAML.safe_load_file(path)
20
- raise Error, "#{path} must hold the instruction texts" unless data.is_a?(Hash)
17
+ def load(path = PATH)
18
+ data = YAML.safe_load_file(path)
19
+ raise Error, "#{path} must hold the instruction texts" unless data.is_a?(Hash)
21
20
 
22
- missing = KEYS.select { |key| data[key].to_s.strip.empty? }
23
- raise Error, "#{path} has no text for: #{missing.join(', ')}" unless missing.empty?
21
+ missing = KEYS.select { |key| data[key].to_s.strip.empty? }
22
+ raise Error, "#{path} has no text for: #{missing.join(', ')}" unless missing.empty?
24
23
 
25
- Texts.new(**KEYS.to_h { |key| [key.to_sym, data[key].to_s.strip] })
26
- end
24
+ Texts.new(**KEYS.to_h { |key| [key.to_sym, data[key].to_s.strip] })
27
25
  end
28
26
  end
29
27
  end
@@ -1,27 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Yuno
4
- module Proofreader
5
- module Audit
6
- # What the log says about an audited page.
7
- module LogFields
8
- COUNTED = %i[added reappeared seen_again closed suppressed].freeze
3
+ module Yuno::Proofreader
4
+ module Audit
5
+ # What the log says about an audited page.
6
+ module LogFields
7
+ COUNTED = %i[added reappeared seen_again closed suppressed].freeze
9
8
 
10
- module_function
9
+ module_function
11
10
 
12
- def of(result)
13
- counts = result.plan ? result.plan.counts : {}
14
- { status: result.status, complete: result.complete, dry_run: result.dry_run,
15
- **COUNTED.to_h { |kind| [kind, counts.fetch(kind, 0)] }, **Llm::Usage.of(result.calls) }
16
- end
11
+ def of(result)
12
+ counts = result.plan ? result.plan.counts : {}
13
+ { status: result.status, complete: result.complete, dry_run: result.dry_run,
14
+ **COUNTED.to_h { |kind| [kind, counts.fetch(kind, 0)] }, **Llm::Usage.of(result.calls) }
15
+ end
17
16
 
18
- # One line for the page, and a warning when the audit was incomplete, with the notes that say why.
19
- def record(log, result, **extra)
20
- log.info("page #{result.status}", page: result.page, **of(result), **extra)
21
- return if result.status == :skipped || result.complete
17
+ # One line for the page, and a warning when the audit was incomplete, with the notes that say why.
18
+ def record(log, result, **extra)
19
+ log.info("page #{result.status}", page: result.page, **of(result), **extra)
20
+ return if result.status == :skipped || result.complete
22
21
 
23
- log.warn("audit incomplete", page: result.page, notes: result.notes.join(" | "))
24
- end
22
+ log.warn("audit incomplete", page: result.page, notes: result.notes.join(" | "))
25
23
  end
26
24
  end
27
25
  end
@@ -1,156 +1,154 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Yuno
4
- module Proofreader
5
- module Audit
6
- # Builds the text that is sent to a model: the system prompts (what to do and how to answer) and the message
7
- # for one page. The wording comes from the files in prompts/, and what is specific to the site comes from the
8
- # site settings. The JSON format of the answers is written here, because the code that reads the answers
9
- # depends on it.
10
- class Prompt
11
- MAX_ISSUES_PER_STEP = 15
12
- MAX_REVIEW_ISSUES = 40
13
- JSON_RULE = "Return ONLY valid JSON, with no commentary and no markdown fences, in exactly this shape:"
14
- ISSUE = '{"language":"%<languages>s","category":"%<category>s","effort":"quick|bigger",' \
15
- '"original":"<exact text copied from the HTML>","suggested":"<replacement or short instruction>",' \
16
- '"reason":"<one short sentence in English>"}'
17
-
18
- attr_reader :steps
19
-
20
- def initialize(site, steps: Steps.default, instructions: Instructions.default)
21
- @site = site
22
- @instructions = instructions
23
- # With one language there is nothing to compare, so the parity step is left out.
24
- @steps = site.languages.size < 2 ? steps.reject { |step| step.categories.include?("parity") } : steps
25
- end
26
-
27
- def audit_system
28
- [shared, section("AUDIT PROCEDURE", @instructions.audit_procedure), steps_section,
29
- section("OUTPUT FORMAT", audit_format)].join("\n\n")
30
- end
3
+ module Yuno::Proofreader
4
+ module Audit
5
+ # Builds the text that is sent to a model: the system prompts (what to do and how to answer) and the message
6
+ # for one page. The wording comes from the files in prompts/, and what is specific to the site comes from the
7
+ # site settings. The JSON format of the answers is written here, because the code that reads the answers
8
+ # depends on it.
9
+ class Prompt
10
+ MAX_ISSUES_PER_STEP = 15
11
+ MAX_REVIEW_ISSUES = 40
12
+ JSON_RULE = "Return ONLY valid JSON, with no commentary and no markdown fences, in exactly this shape:"
13
+ ISSUE = '{"language":"%<languages>s","category":"%<category>s","effort":"quick|bigger",' \
14
+ '"original":"<exact text copied from the HTML>","suggested":"<replacement or short instruction>",' \
15
+ '"reason":"<one short sentence in English>"}'
16
+
17
+ attr_reader :steps
18
+
19
+ def initialize(site, steps: Steps.default, instructions: Instructions.default)
20
+ @site = site
21
+ @instructions = instructions
22
+ # With one language there is nothing to compare, so the parity step is left out.
23
+ @steps = site.languages.size < 2 ? steps.reject { |step| step.categories.include?("parity") } : steps
24
+ end
31
25
 
32
- def review_system
33
- [shared, section("REVIEW PROCEDURE", @instructions.review_procedure), checklist_section,
34
- section("OUTPUT FORMAT", review_format)].join("\n\n")
35
- end
26
+ def audit_system
27
+ [shared, section("AUDIT PROCEDURE", @instructions.audit_procedure), steps_section,
28
+ section("OUTPUT FORMAT", audit_format)].join("\n\n")
29
+ end
36
30
 
37
- # The message for one page. html_limit shortens each version, for showing it on screen.
38
- def user_message(fetched, html_limit: nil)
39
- usable = fetched.snapshots.select(&:ok?)
40
- if usable.empty?
41
- raise Error, "No language version of #{fetched.name} could be fetched, so there is nothing to review."
42
- end
31
+ def review_system
32
+ [shared, section("REVIEW PROCEDURE", @instructions.review_procedure), checklist_section,
33
+ section("OUTPUT FORMAT", review_format)].join("\n\n")
34
+ end
43
35
 
44
- notes = [header(fetched, usable), *cut_notes(usable)].join("\n")
45
- ([notes] + usable.map { |snapshot| version(snapshot, html_limit) }).join("\n\n")
36
+ # The message for one page. html_limit shortens each version, for showing it on screen.
37
+ def user_message(fetched, html_limit: nil)
38
+ usable = fetched.snapshots.select(&:ok?)
39
+ if usable.empty?
40
+ raise Error, "No language version of #{fetched.name} could be fetched, so there is nothing to review."
46
41
  end
47
42
 
48
- private
43
+ notes = [header(fetched, usable), *cut_notes(usable)].join("\n")
44
+ ([notes] + usable.map { |snapshot| version(snapshot, html_limit) }).join("\n\n")
45
+ end
49
46
 
50
- def section(title, text) = "## #{title}\n#{text}"
47
+ private
51
48
 
52
- def one_line(text) = Findings::Text.collapse(text)
49
+ def section(title, text) = "## #{title}\n#{text}"
53
50
 
54
- # ---- the system prompts ----
51
+ def one_line(text) = Findings::Text.collapse(text)
55
52
 
56
- def shared
57
- [section("ROLE", @instructions.role), *site_sections, section("EFFORT", @instructions.effort),
58
- section("RULES", @instructions.rules),
59
- section("SITE-WIDE PARTS", @instructions.site_wide_parts)].join("\n\n")
60
- end
53
+ # ---- the system prompts ----
61
54
 
62
- def site_sections
63
- context = @site.context
64
- [context_section, bulleted("STYLE GUIDE", context.rules), ignore_section,
65
- bulleted("INTENTIONAL DIFFERENCES", context.intentional_differences)].compact
66
- end
55
+ def shared
56
+ [section("ROLE", @instructions.role), *site_sections, section("EFFORT", @instructions.effort),
57
+ section("RULES", @instructions.rules),
58
+ section("SITE-WIDE PARTS", @instructions.site_wide_parts)].join("\n\n")
59
+ end
67
60
 
68
- def context_section
69
- context = @site.context
70
- facts = { "Website" => @site.website, "What the site is and offers" => context.business,
71
- "Audience" => context.audience, "Tone" => context.tone }
72
- lines = facts.reject { |_label, value| value.empty? }.map { |label, value| "#{label}: #{one_line(value)}" }
73
- lines << "Language versions of every page (the first is the default language): #{@site.languages.join(', ')}"
74
- section("SITE CONTEXT", [*lines, *language_notes].join("\n"))
75
- end
61
+ def site_sections
62
+ context = @site.context
63
+ [context_section, bulleted("STYLE GUIDE", context.rules), ignore_section,
64
+ bulleted("INTENTIONAL DIFFERENCES", context.intentional_differences)].compact
65
+ end
76
66
 
77
- def language_notes
78
- notes = @site.language_notes.reject { |_code, note| note.empty? }
79
- return [] if notes.empty?
67
+ def context_section
68
+ context = @site.context
69
+ facts = { "Website" => @site.website, "What the site is and offers" => context.business,
70
+ "Audience" => context.audience, "Tone" => context.tone }
71
+ lines = facts.reject { |_label, value| value.empty? }.map { |label, value| "#{label}: #{one_line(value)}" }
72
+ lines << "Language versions of every page (the first is the default language): #{@site.languages.join(', ')}"
73
+ section("SITE CONTEXT", [*lines, *language_notes].join("\n"))
74
+ end
80
75
 
81
- ["Notes on the languages:", *notes.map { |code, note| " #{code}: #{one_line(note)}" }]
82
- end
76
+ def language_notes
77
+ notes = @site.language_notes.reject { |_code, note| note.empty? }
78
+ return [] if notes.empty?
83
79
 
84
- def bulleted(title, items)
85
- return if items.empty?
80
+ ["Notes on the languages:", *notes.map { |code, note| " #{code}: #{one_line(note)}" }]
81
+ end
86
82
 
87
- section(title, items.map { |item| "• #{one_line(item)}" }.join("\n"))
88
- end
83
+ def bulleted(title, items)
84
+ return if items.empty?
89
85
 
90
- def ignore_section
91
- terms = @site.context.ignore_terms
92
- return if terms.empty?
86
+ section(title, items.map { |item| "• #{one_line(item)}" }.join("\n"))
87
+ end
93
88
 
94
- list = terms.map { |term| one_line(term) }.join(", ")
95
- section("IGNORE LIST", "Do not flag these as errors, they are correct as written: #{list}")
96
- end
89
+ def ignore_section
90
+ terms = @site.context.ignore_terms
91
+ return if terms.empty?
97
92
 
98
- def steps_section
99
- body = @steps.map do |step|
100
- "STEP #{step.number} - #{step.name} (allowed categories: #{step.categories.join(', ')})\n#{step.text}"
101
- end
102
- section("STEPS", body.join("\n\n"))
103
- end
93
+ list = terms.map { |term| one_line(term) }.join(", ")
94
+ section("IGNORE LIST", "Do not flag these as errors, they are correct as written: #{list}")
95
+ end
104
96
 
105
- def checklist_section
106
- list = @steps.map { |step| "#{step.number}) #{step.name}: #{step.text}" }
107
- section("CHECKLIST (applies to every language)", list.join("\n"))
97
+ def steps_section
98
+ body = @steps.map do |step|
99
+ "STEP #{step.number} - #{step.name} (allowed categories: #{step.categories.join(', ')})\n#{step.text}"
108
100
  end
101
+ section("STEPS", body.join("\n\n"))
102
+ end
109
103
 
110
- # ---- the answer formats ----
104
+ def checklist_section
105
+ list = @steps.map { |step| "#{step.number}) #{step.name}: #{step.text}" }
106
+ section("CHECKLIST (applies to every language)", list.join("\n"))
107
+ end
111
108
 
112
- def audit_format
113
- issue = format(ISSUE, languages: @site.languages.join("|"),
114
- category: "<one of the allowed categories of that step>")
115
- "#{JSON_RULE}\n{\"steps\":[{\"step\":1,\"issues\":[#{issue}]}]}\n" \
116
- "Include one object for EVERY step, in order, even when a step has no issues (use \"issues\":[]). " \
117
- "Report at most #{MAX_ISSUES_PER_STEP} issues per step."
118
- end
109
+ # ---- the answer formats ----
119
110
 
120
- def review_format
121
- categories = (Findings::Finding::CATEGORIES - ["other"]).join("|")
122
- issue = format(ISSUE, languages: @site.languages.join("|"), category: categories)
123
- "#{JSON_RULE}\n{\"issues\":[#{issue}]}\nReport at most #{MAX_REVIEW_ISSUES} issues in total."
124
- end
111
+ def audit_format
112
+ issue = format(ISSUE, languages: @site.languages.join("|"),
113
+ category: "<one of the allowed categories of that step>")
114
+ "#{JSON_RULE}\n{\"steps\":[{\"step\":1,\"issues\":[#{issue}]}]}\n" \
115
+ "Include one object for EVERY step, in order, even when a step has no issues (use \"issues\":[]). " \
116
+ "Report at most #{MAX_ISSUES_PER_STEP} issues per step."
117
+ end
125
118
 
126
- # ---- the message for a page ----
119
+ def review_format
120
+ categories = (Findings::Finding::CATEGORIES - ["other"]).join("|")
121
+ issue = format(ISSUE, languages: @site.languages.join("|"), category: categories)
122
+ "#{JSON_RULE}\n{\"issues\":[#{issue}]}\nReport at most #{MAX_REVIEW_ISSUES} issues in total."
123
+ end
127
124
 
128
- def header(fetched, usable)
129
- lines = ["Page: #{fetched.name}", "Versions provided: #{usable.map { |s| s.language.upcase }.join(', ')}."]
130
- missing = fetched.snapshots.reject(&:ok?).map { |snapshot| snapshot.language.upcase }
131
- unless missing.empty?
132
- lines << "Not available this time, so do not report parity issues involving: #{missing.join(', ')}."
133
- end
134
- lines.join("\n")
135
- end
125
+ # ---- the message for a page ----
136
126
 
137
- def cut_notes(usable)
138
- usable.select(&:truncated).map do |snapshot|
139
- "The #{snapshot.language.upcase} version was cut after #{snapshot.html.length} characters, so its end " \
140
- "is missing. Do not report problems that may only be caused by the cut."
141
- end
127
+ def header(fetched, usable)
128
+ lines = ["Page: #{fetched.name}", "Versions provided: #{usable.map { |s| s.language.upcase }.join(', ')}."]
129
+ missing = fetched.snapshots.reject(&:ok?).map { |snapshot| snapshot.language.upcase }
130
+ unless missing.empty?
131
+ lines << "Not available this time, so do not report parity issues involving: #{missing.join(', ')}."
142
132
  end
133
+ lines.join("\n")
134
+ end
143
135
 
144
- def version(snapshot, html_limit)
145
- label = snapshot.language.upcase
146
- "=== #{label} | #{snapshot.url} ===\n#{shown(snapshot.html, html_limit)}\n=== END #{label} ==="
136
+ def cut_notes(usable)
137
+ usable.select(&:truncated).map do |snapshot|
138
+ "The #{snapshot.language.upcase} version was cut after #{snapshot.html.length} characters, so its end " \
139
+ "is missing. Do not report problems that may only be caused by the cut."
147
140
  end
141
+ end
142
+
143
+ def version(snapshot, html_limit)
144
+ label = snapshot.language.upcase
145
+ "=== #{label} | #{snapshot.url} ===\n#{shown(snapshot.html, html_limit)}\n=== END #{label} ==="
146
+ end
148
147
 
149
- def shown(html, limit)
150
- return html if limit.nil? || html.length <= limit
148
+ def shown(html, limit)
149
+ return html if limit.nil? || html.length <= limit
151
150
 
152
- "#{html[0, limit]}\n[... #{html.length - limit} more characters not shown here ...]"
153
- end
151
+ "#{html[0, limit]}\n[... #{html.length - limit} more characters not shown here ...]"
154
152
  end
155
153
  end
156
154
  end