Module: DocOpsLab::Dev
- Defined in:
- lib/docopslab/dev.rb,
lib/docopslab/dev/help.rb,
lib/docopslab/dev/skim.rb,
lib/docopslab/dev/paths.rb,
lib/docopslab/dev/tasks.rb,
lib/docopslab/dev/library.rb,
lib/docopslab/dev/linters.rb,
lib/docopslab/dev/version.rb,
lib/docopslab/dev/cast_ops.rb,
lib/docopslab/dev/checkers.rb,
lib/docopslab/dev/manifest.rb,
lib/docopslab/dev/sync_ops.rb,
lib/docopslab/dev/git_hooks.rb,
lib/docopslab/dev/data_utils.rb,
lib/docopslab/dev/file_utils.rb,
lib/docopslab/dev/git_branch.rb,
lib/docopslab/dev/log_parser.rb,
lib/docopslab/dev/initializer.rb,
lib/docopslab/dev/spell_check.rb,
lib/docopslab/dev/docker_aware.rb,
lib/docopslab/dev/library/cache.rb,
lib/docopslab/dev/library/fetch.rb,
lib/docopslab/dev/config_manager.rb,
lib/docopslab/dev/script_manager.rb,
lib/docopslab/dev/tool_execution.rb,
lib/docopslab/dev/auto_fix_asciidoc.rb
Defined Under Namespace
Modules: AutoFixAsciidoc, CastOps, Checkers, ConfigManager, DataUtils, DockerAware, FileUtilities, GitBranch, GitHooks, Help, Initializer, Library, Linters, LogParser, Manifest, Paths, ScriptManager, Skim, SpellCheck, SyncOps, ToolExecution
Classes: Tasks
Constant Summary
collapse
- GEM_ROOT =
begin
spec = Gem::Specification.find_by_name('docopslab-dev')
if spec
spec.gem_dir
else File.expand_path('../../../', __dir__)
end
end
- MANIFEST_PATH =
Path constants (Backwards compatibility)
'.config/docopslab-dev.yml'
- XDG_CACHE_SUBPATH =
'docopslab/dev/library'
- VERSION =
'0.3.0'
- RUBY_TARGET =
'3.2.7'
Class Attribute Summary collapse
Class Method Summary
collapse
-
.bootstrap_project ⇒ Object
-
.check_config_structure ⇒ Object
-
.check_hook_updates ⇒ Object
-
.check_ruby_version ⇒ Object
-
.check_standard_rake_tasks ⇒ Object
-
.config_paths ⇒ Object
Runtime/generated config files (merged from base + local).
-
.config_vendor_dir ⇒ Object
Project paths (local/runtime).
-
.create_gitignore_stub ⇒ Object
-
.create_project_manifest ⇒ Object
-
.default_library_branch ⇒ Object
-
.default_library_repo ⇒ Object
Upstream library defaults.
-
.docker_available? ⇒ Boolean
-
.file_matches_ignore_pattern?(file, pattern) ⇒ Boolean
-
.find_asciidoc_files ⇒ Object
-
.find_shell_scripts ⇒ Object
-
.gem_sourced_locally? ⇒ Boolean
-
.generate_htmlproofer_config ⇒ Object
-
.generate_vale_config(style_override: nil) ⇒ Object
Special Runtime Config Handling.
-
.get_path_config(tool_slug) ⇒ Object
-
.get_tool_entry(tool_slug) ⇒ Object
-
.get_tool_files(tool_slug) ⇒ Object
-
.get_tool_metadata(tool_slug) ⇒ Object
-
.git_tracked_or_staged?(file) ⇒ Boolean
-
.hooks_dir ⇒ Object
-
.image_available? ⇒ Boolean
-
.install_missing_hooks ⇒ Object
-
.install_vale_styles ⇒ Object
-
.lab_dev_mode? ⇒ Boolean
-
.library_path(subpath = nil) ⇒ Object
Asset paths are resolved at runtime from the remote library cache.
-
.lint_file(file_path) ⇒ Object
-
.list_hook_templates ⇒ Object
-
.list_script_templates ⇒ Object
-
.load_htmlproofer_config ⇒ Object
-
.load_manifest(force_reload: false) ⇒ Object
-
.load_tools_data ⇒ Object
-
.manifest_def_path ⇒ Object
Gem data paths (bundled with gem in specs/data/).
-
.rubocop_config_path ⇒ Object
Shorthand for rubocop (most commonly referenced).
-
.run_actionlint(opts_string = '') ⇒ Object
-
.run_adoc_auto_fix(path = nil) ⇒ Object
-
.run_all_linters ⇒ Object
-
.run_auto_fix ⇒ Object
-
.run_in_docker(command) ⇒ Object
-
.run_linter_group(group_name, linters) ⇒ Object
-
.run_rubocop(file_path = nil, opts_string = '') ⇒ Object
-
.run_rubocop_auto_fix(path: nil) ⇒ Object
-
.run_rubocop_with_filter(filter_name) ⇒ Object
-
.run_script(script_name, args = []) ⇒ Object
-
.run_shellcheck(file_path = nil, opts_string = '') ⇒ Object
-
.run_vale(file_path = nil, opts_string = '', output_format: :cli, filter: nil, style_override: nil) ⇒ Object
-
.run_with_fallback(tool_name, command, use_docker: false) ⇒ Object
-
.shell_shebang?(file) ⇒ Boolean
-
.show_lint_rule(tool, rule) ⇒ Object
-
.sync_config_files(tool_filter = :all, offline: false) ⇒ Object
-
.sync_directory(source_dir, target_dir, synced: false, expected_targets: nil) ⇒ Object
-
.sync_docs(force: false) ⇒ Object
-
.sync_scripts ⇒ Object
-
.sync_templates(force: false) ⇒ Object
-
.sync_vale_styles(local: false) ⇒ Object
-
.tool_available?(tool_name) ⇒ Boolean
-
.tools_def_path ⇒ Object
-
.update_hooks_interactive ⇒ Object
Class Attribute Details
.manifest ⇒ Object
Returns the value of attribute manifest.
52
53
54
|
# File 'lib/docopslab/dev.rb', line 52
def manifest
@manifest
end
|
.manifest_path ⇒ Object
55
56
57
|
# File 'lib/docopslab/dev.rb', line 55
def manifest_path
@manifest_path || MANIFEST_PATH
end
|
Returns the value of attribute tools_data.
52
53
54
|
# File 'lib/docopslab/dev.rb', line 52
def tools_data
@tools_data
end
|
.xdg_cache_subpath ⇒ Object
59
60
61
|
# File 'lib/docopslab/dev.rb', line 59
def xdg_cache_subpath
@xdg_cache_subpath || XDG_CACHE_SUBPATH
end
|
Class Method Details
.bootstrap_project ⇒ Object
.check_config_structure ⇒ Object
.check_hook_updates ⇒ Object
.check_ruby_version ⇒ Object
.check_standard_rake_tasks ⇒ Object
.config_paths ⇒ Object
Runtime/generated config files (merged from base + local)
82
83
84
|
# File 'lib/docopslab/dev.rb', line 82
def config_paths
Paths::CONFIG_FILES
end
|
.config_vendor_dir ⇒ Object
Project paths (local/runtime)
.create_gitignore_stub ⇒ Object
.create_project_manifest ⇒ Object
.default_library_branch ⇒ Object
68
69
70
|
# File 'lib/docopslab/dev.rb', line 68
def default_library_branch
'labdev-library'
end
|
.default_library_repo ⇒ Object
Upstream library defaults
64
65
66
|
# File 'lib/docopslab/dev.rb', line 64
def default_library_repo
'DocOps/lab'
end
|
.docker_available? ⇒ Boolean
.file_matches_ignore_pattern?(file, pattern) ⇒ Boolean
.find_asciidoc_files ⇒ Object
.find_shell_scripts ⇒ Object
.gem_sourced_locally? ⇒ Boolean
.generate_htmlproofer_config ⇒ Object
.generate_vale_config(style_override: nil) ⇒ Object
Special Runtime Config Handling
308
309
310
|
# File 'lib/docopslab/dev.rb', line 308
def generate_vale_config style_override: nil
ConfigManager.generate_vale_config(self, style_override: style_override)
end
|
.get_path_config(tool_slug) ⇒ Object
.get_tool_entry(tool_slug) ⇒ Object
139
140
141
142
143
144
145
|
# File 'lib/docopslab/dev.rb', line 139
def get_tool_entry tool_slug
manifest = load_manifest
return nil unless manifest
manifest['tools']&.find { |t| t['tool'] == tool_slug }
end
|
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
# File 'lib/docopslab/dev.rb', line 147
def get_tool_files tool_slug
tool_entry = get_tool_entry(tool_slug)
return {} unless tool_entry
files = {}
tool_entry['files']&.each do |file_config|
target_path = file_config['target']
source_path = file_config['source']
next unless target_path
if target_path.include?('.vendor/')
files[:base] = {
source: source_path,
local: target_path,
synced: file_config.fetch('synced', true)
}
else
files[:project] = {
source: source_path,
local: target_path,
synced: file_config.fetch('synced', false)
}
end
end
files
end
|
133
134
135
136
137
|
# File 'lib/docopslab/dev.rb', line 133
def get_tool_metadata tool_slug
tools_data = load_tools_data
tools_data.find { |t| t['slug'] == tool_slug }
end
|
.git_tracked_or_staged?(file) ⇒ Boolean
.hooks_dir ⇒ Object
77
78
79
|
# File 'lib/docopslab/dev.rb', line 77
def hooks_dir
'.git/hooks'
end
|
.image_available? ⇒ Boolean
.install_missing_hooks ⇒ Object
.install_vale_styles ⇒ Object
.library_path(subpath = nil) ⇒ Object
Asset paths are resolved at runtime from the remote library cache. Use Library.resolve(‘config-packs/…’), Library.resolve(‘templates/…’) etc.
.lint_file(file_path) ⇒ Object
365
366
367
|
# File 'lib/docopslab/dev.rb', line 365
def lint_file file_path
Linters.lint_file(self, file_path)
end
|
.list_hook_templates ⇒ Object
.list_script_templates ⇒ Object
.load_htmlproofer_config ⇒ Object
.load_manifest(force_reload: false) ⇒ Object
108
109
110
111
112
113
114
115
116
|
# File 'lib/docopslab/dev.rb', line 108
def load_manifest force_reload: false
return @manifest if @manifest && !force_reload
@manifest = YAML.load_file(manifest_path) if File.exist?(manifest_path)
@manifest
rescue StandardError => e
warn "Failed to load manifest at #{manifest_path}: #{e.message}"
nil
end
|
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/docopslab/dev.rb', line 118
def load_tools_data
return @tools_data if @tools_data
@tools_data = begin
if File.exist?(tools_def_path)
YAML.load_file(tools_def_path)
else
[]
end
rescue StandardError => e
warn "Failed to load tools data: #{e.message}"
[]
end
end
|
.manifest_def_path ⇒ Object
Gem data paths (bundled with gem in specs/data/)
92
93
94
|
# File 'lib/docopslab/dev.rb', line 92
def manifest_def_path
File.join(GEM_ROOT, 'specs', 'data', 'default-manifest.yml')
end
|
.rubocop_config_path ⇒ Object
Shorthand for rubocop (most commonly referenced)
87
88
89
|
# File 'lib/docopslab/dev.rb', line 87
def rubocop_config_path
config_paths[:rubocop]
end
|
.run_actionlint(opts_string = '') ⇒ Object
334
335
336
|
# File 'lib/docopslab/dev.rb', line 334
def run_actionlint opts_string=''
Linters.run_actionlint(self, opts_string)
end
|
.run_adoc_auto_fix(path = nil) ⇒ Object
.run_all_linters ⇒ Object
.run_auto_fix ⇒ Object
342
343
344
345
|
# File 'lib/docopslab/dev.rb', line 342
def run_auto_fix
Linters.run_auto_fix
AsciiidocAutoFix.fix_asciidoc_files(self)
end
|
.run_in_docker(command) ⇒ Object
.run_linter_group(group_name, linters) ⇒ Object
355
356
357
|
# File 'lib/docopslab/dev.rb', line 355
def run_linter_group group_name, linters
Linters.run_linter_group(self, group_name, linters)
end
|
.run_rubocop(file_path = nil, opts_string = '') ⇒ Object
322
323
324
|
# File 'lib/docopslab/dev.rb', line 322
def run_rubocop file_path=nil, opts_string=''
Linters.run_rubocop(self, file_path, opts_string)
end
|
.run_rubocop_auto_fix(path: nil) ⇒ Object
347
348
349
|
# File 'lib/docopslab/dev.rb', line 347
def run_rubocop_auto_fix path: nil
Linters.run_rubocop_auto_fix(self, path: path)
end
|
.run_rubocop_with_filter(filter_name) ⇒ Object
.run_script(script_name, args = []) ⇒ Object
188
189
190
|
# File 'lib/docopslab/dev.rb', line 188
def run_script script_name, args=[]
ScriptManager.run_script(script_name, args)
end
|
.run_shellcheck(file_path = nil, opts_string = '') ⇒ Object
330
331
332
|
# File 'lib/docopslab/dev.rb', line 330
def run_shellcheck file_path=nil, opts_string=''
Linters.run_shellcheck(self, file_path, opts_string)
end
|
.run_vale(file_path = nil, opts_string = '', output_format: :cli, filter: nil, style_override: nil) ⇒ Object
359
360
361
362
363
|
# File 'lib/docopslab/dev.rb', line 359
def run_vale file_path=nil, opts_string='', output_format: :cli, filter: nil, style_override: nil
Linters.run_vale(
self, file_path, opts_string,
output_format: output_format, filter: filter, style_override: style_override)
end
|
.run_with_fallback(tool_name, command, use_docker: false) ⇒ Object
180
181
182
|
# File 'lib/docopslab/dev.rb', line 180
def run_with_fallback tool_name, command, use_docker: false
ToolExecution.run_with_fallback(tool_name, command, use_docker: use_docker)
end
|
.shell_shebang?(file) ⇒ Boolean
.show_lint_rule(tool, rule) ⇒ Object
371
372
373
374
375
376
377
378
379
380
|
# File 'lib/docopslab/dev.rb', line 371
def show_lint_rule tool, rule
case tool
when 'vale'
print_vale_style(rule)
when 'rubocop'
print_cop(rule)
else
puts "❌ Unknown or unsupported tool: #{tool}. Supported tools: vale, rubocop"
end
end
|
.sync_config_files(tool_filter = :all, offline: false) ⇒ Object
224
225
226
|
# File 'lib/docopslab/dev.rb', line 224
def sync_config_files tool_filter=:all, offline: false
SyncOps.sync_config_files(self, tool_filter: tool_filter, offline: offline)
end
|
.sync_directory(source_dir, target_dir, synced: false, expected_targets: nil) ⇒ Object
228
229
230
|
# File 'lib/docopslab/dev.rb', line 228
def sync_directory source_dir, target_dir, synced: false, expected_targets: nil
SyncOps.sync_directory(source_dir, target_dir, synced: synced, expected_targets: expected_targets)
end
|
.sync_docs(force: false) ⇒ Object
240
241
242
|
# File 'lib/docopslab/dev.rb', line 240
def sync_docs force: false
SyncOps.sync_docs(self, force: force)
end
|
.sync_scripts ⇒ Object
232
233
234
|
# File 'lib/docopslab/dev.rb', line 232
def sync_scripts
SyncOps.sync_scripts(self)
end
|
.sync_templates(force: false) ⇒ Object
244
245
246
|
# File 'lib/docopslab/dev.rb', line 244
def sync_templates force: false
SyncOps.sync_templates(self, force: force)
end
|
.sync_vale_styles(local: false) ⇒ Object
236
237
238
|
# File 'lib/docopslab/dev.rb', line 236
def sync_vale_styles local: false
SyncOps.sync_vale_styles(self, local: local)
end
|
96
97
98
|
# File 'lib/docopslab/dev.rb', line 96
def tools_def_path
File.join(GEM_ROOT, 'specs', 'data', 'tools.yml')
end
|
.update_hooks_interactive ⇒ Object