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/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, 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.2.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.
51
52
53
|
# File 'lib/docopslab/dev.rb', line 51
def manifest
@manifest
end
|
.manifest_path ⇒ Object
54
55
56
|
# File 'lib/docopslab/dev.rb', line 54
def manifest_path
@manifest_path || MANIFEST_PATH
end
|
Returns the value of attribute tools_data.
51
52
53
|
# File 'lib/docopslab/dev.rb', line 51
def tools_data
@tools_data
end
|
.xdg_cache_subpath ⇒ Object
58
59
60
|
# File 'lib/docopslab/dev.rb', line 58
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)
81
82
83
|
# File 'lib/docopslab/dev.rb', line 81
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
67
68
69
|
# File 'lib/docopslab/dev.rb', line 67
def default_library_branch
'labdev-library'
end
|
.default_library_repo ⇒ Object
Upstream library defaults
63
64
65
|
# File 'lib/docopslab/dev.rb', line 63
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
307
308
309
|
# File 'lib/docopslab/dev.rb', line 307
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
138
139
140
141
142
143
144
|
# File 'lib/docopslab/dev.rb', line 138
def get_tool_entry tool_slug
manifest = load_manifest
return nil unless manifest
manifest['tools']&.find { |t| t['tool'] == tool_slug }
end
|
146
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
|
# File 'lib/docopslab/dev.rb', line 146
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
|
132
133
134
135
136
|
# File 'lib/docopslab/dev.rb', line 132
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
76
77
78
|
# File 'lib/docopslab/dev.rb', line 76
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
364
365
366
|
# File 'lib/docopslab/dev.rb', line 364
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
107
108
109
110
111
112
113
114
115
|
# File 'lib/docopslab/dev.rb', line 107
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
|
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/docopslab/dev.rb', line 117
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/)
91
92
93
|
# File 'lib/docopslab/dev.rb', line 91
def manifest_def_path
File.join(GEM_ROOT, 'specs', 'data', 'default-manifest.yml')
end
|
.rubocop_config_path ⇒ Object
Shorthand for rubocop (most commonly referenced)
86
87
88
|
# File 'lib/docopslab/dev.rb', line 86
def rubocop_config_path
config_paths[:rubocop]
end
|
.run_actionlint(opts_string = '') ⇒ Object
333
334
335
|
# File 'lib/docopslab/dev.rb', line 333
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
341
342
343
344
|
# File 'lib/docopslab/dev.rb', line 341
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
354
355
356
|
# File 'lib/docopslab/dev.rb', line 354
def run_linter_group group_name, linters
Linters.run_linter_group(self, group_name, linters)
end
|
.run_rubocop(file_path = nil, opts_string = '') ⇒ Object
321
322
323
|
# File 'lib/docopslab/dev.rb', line 321
def run_rubocop file_path=nil, opts_string=''
Linters.run_rubocop(self, file_path, opts_string)
end
|
.run_rubocop_auto_fix(path: nil) ⇒ Object
346
347
348
|
# File 'lib/docopslab/dev.rb', line 346
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
187
188
189
|
# File 'lib/docopslab/dev.rb', line 187
def run_script script_name, args=[]
ScriptManager.run_script(script_name, args)
end
|
.run_shellcheck(file_path = nil, opts_string = '') ⇒ Object
329
330
331
|
# File 'lib/docopslab/dev.rb', line 329
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
358
359
360
361
362
|
# File 'lib/docopslab/dev.rb', line 358
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
179
180
181
|
# File 'lib/docopslab/dev.rb', line 179
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
370
371
372
373
374
375
376
377
378
379
|
# File 'lib/docopslab/dev.rb', line 370
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
223
224
225
|
# File 'lib/docopslab/dev.rb', line 223
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
227
228
229
|
# File 'lib/docopslab/dev.rb', line 227
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
239
240
241
|
# File 'lib/docopslab/dev.rb', line 239
def sync_docs force: false
SyncOps.sync_docs(self, force: force)
end
|
.sync_scripts ⇒ Object
231
232
233
|
# File 'lib/docopslab/dev.rb', line 231
def sync_scripts
SyncOps.sync_scripts(self)
end
|
.sync_templates(force: false) ⇒ Object
243
244
245
|
# File 'lib/docopslab/dev.rb', line 243
def sync_templates force: false
SyncOps.sync_templates(self, force: force)
end
|
.sync_vale_styles(local: false) ⇒ Object
235
236
237
|
# File 'lib/docopslab/dev.rb', line 235
def sync_vale_styles local: false
SyncOps.sync_vale_styles(self, local: local)
end
|
95
96
97
|
# File 'lib/docopslab/dev.rb', line 95
def tools_def_path
File.join(GEM_ROOT, 'specs', 'data', 'tools.yml')
end
|
.update_hooks_interactive ⇒ Object