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 # Fallback for development
    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

Class Attribute Details

.manifestObject

Returns the value of attribute manifest.



51
52
53
# File 'lib/docopslab/dev.rb', line 51

def manifest
  @manifest
end

.manifest_pathObject



54
55
56
# File 'lib/docopslab/dev.rb', line 54

def manifest_path
  @manifest_path || MANIFEST_PATH
end

.tools_dataObject

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_subpathObject



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_projectObject



197
198
199
# File 'lib/docopslab/dev.rb', line 197

def bootstrap_project
  Initializer.bootstrap_project
end

.check_config_structureObject



273
274
275
# File 'lib/docopslab/dev.rb', line 273

def check_config_structure
  Checkers.check_config_structure(self)
end

.check_hook_updatesObject



209
210
211
# File 'lib/docopslab/dev.rb', line 209

def check_hook_updates
  GitHooks.check_hook_updates
end

.check_ruby_versionObject



269
270
271
# File 'lib/docopslab/dev.rb', line 269

def check_ruby_version
  Checkers.check_ruby_version
end

.check_standard_rake_tasksObject



277
278
279
# File 'lib/docopslab/dev.rb', line 277

def check_standard_rake_tasks
  Checkers.check_standard_rake_tasks
end

.config_pathsObject

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_dirObject

Project paths (local/runtime)



72
73
74
# File 'lib/docopslab/dev.rb', line 72

def config_vendor_dir
  Paths.config_vendor_dir
end

.create_gitignore_stubObject



217
218
219
# File 'lib/docopslab/dev.rb', line 217

def create_gitignore_stub
  Initializer.create_gitignore_stub
end

.create_project_manifestObject

Initialization



193
194
195
# File 'lib/docopslab/dev.rb', line 193

def create_project_manifest
  Initializer.create_project_manifest
end

.default_library_branchObject



67
68
69
# File 'lib/docopslab/dev.rb', line 67

def default_library_branch
  'labdev-library'
end

.default_library_repoObject

Upstream library defaults



63
64
65
# File 'lib/docopslab/dev.rb', line 63

def default_library_repo
  'DocOps/lab'
end

.docker_available?Boolean

Returns:

  • (Boolean)


253
254
255
# File 'lib/docopslab/dev.rb', line 253

def docker_available?
  ToolExecution.docker_available?
end

.file_matches_ignore_pattern?(file, pattern) ⇒ Boolean

Returns:

  • (Boolean)


297
298
299
# File 'lib/docopslab/dev.rb', line 297

def file_matches_ignore_pattern? file, pattern
  FileUtilities.file_matches_ignore_pattern?(file, pattern)
end

.find_asciidoc_filesObject



289
290
291
# File 'lib/docopslab/dev.rb', line 289

def find_asciidoc_files
  FileUtilities.find_asciidoc_files(self)
end

.find_shell_scriptsObject



281
282
283
# File 'lib/docopslab/dev.rb', line 281

def find_shell_scripts
  FileUtilities.find_shell_scripts(self)
end

.gem_sourced_locally?Boolean

Returns:

  • (Boolean)


265
266
267
# File 'lib/docopslab/dev.rb', line 265

def gem_sourced_locally?
  Checkers.gem_sourced_locally?
end

.generate_htmlproofer_configObject



311
312
313
# File 'lib/docopslab/dev.rb', line 311

def generate_htmlproofer_config
  ConfigManager.generate_htmlproofer_config(self)
end

.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



293
294
295
# File 'lib/docopslab/dev.rb', line 293

def get_path_config tool_slug
  ConfigManager.get_path_config(tool_slug, self)
end

.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
  # Get a tool's configuration from project manifest
  manifest = load_manifest
  return nil unless manifest

  manifest['tools']&.find { |t| t['tool'] == tool_slug }
end

.get_tool_files(tool_slug) ⇒ Object



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
  # Get file mappings for a tool from manifest
  # Returns hash: { base: {upstream:, local:, synced:}, project: {upstream:, local:, synced:} }
  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 # Skip if no target path defined

    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

.get_tool_metadata(tool_slug) ⇒ Object



132
133
134
135
136
# File 'lib/docopslab/dev.rb', line 132

def  tool_slug
  # Get a tool's info from tools definition
  tools_data = load_tools_data
  tools_data.find { |t| t['slug'] == tool_slug }
end

.git_tracked_or_staged?(file) ⇒ Boolean

Returns:

  • (Boolean)


301
302
303
# File 'lib/docopslab/dev.rb', line 301

def git_tracked_or_staged? file
  FileUtilities.git_tracked_or_staged?(file)
end

.hooks_dirObject



76
77
78
# File 'lib/docopslab/dev.rb', line 76

def hooks_dir
  '.git/hooks'
end

.image_available?Boolean

Returns:

  • (Boolean)


257
258
259
# File 'lib/docopslab/dev.rb', line 257

def image_available?
  ToolExecution.image_available?
end

.install_missing_hooksObject



205
206
207
# File 'lib/docopslab/dev.rb', line 205

def install_missing_hooks
  GitHooks.install_missing_hooks
end

.install_vale_stylesObject



201
202
203
# File 'lib/docopslab/dev.rb', line 201

def install_vale_styles
  SyncOps.install_vale_styles(self)
end

.lab_dev_mode?Boolean

Returns:

  • (Boolean)


261
262
263
# File 'lib/docopslab/dev.rb', line 261

def lab_dev_mode?
  Checkers.lab_dev_mode?
end

.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.



101
102
103
104
105
# File 'lib/docopslab/dev.rb', line 101

def library_path subpath=nil
  return Library::Cache.current_path unless subpath

  File.join(Library::Cache.current_path, subpath)
end

.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_templatesObject



381
382
383
# File 'lib/docopslab/dev.rb', line 381

def list_hook_templates
  GitHooks.list_hook_templates
end

.list_script_templatesObject



385
386
387
# File 'lib/docopslab/dev.rb', line 385

def list_script_templates
  ScriptManager.list_script_templates
end

.load_htmlproofer_configObject



315
316
317
# File 'lib/docopslab/dev.rb', line 315

def load_htmlproofer_config
  ConfigManager.load_htmlproofer_config
end

.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

.load_tools_dataObject



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_pathObject

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_pathObject

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



350
351
352
# File 'lib/docopslab/dev.rb', line 350

def run_adoc_auto_fix path=nil
  AutoFixAsciidoc.fix_asciidoc_files(self, path: path)
end

.run_all_lintersObject



337
338
339
# File 'lib/docopslab/dev.rb', line 337

def run_all_linters
  Linters.run_all_linters(self)
end

.run_auto_fixObject



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



183
184
185
# File 'lib/docopslab/dev.rb', line 183

def run_in_docker command
  ToolExecution.run_in_docker(command)
end

.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

Run Linters



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



325
326
327
# File 'lib/docopslab/dev.rb', line 325

def run_rubocop_with_filter filter_name
  Linters.run_rubocop_with_filter(self, filter_name)
end

.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

Tool Execution



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

Returns:

  • (Boolean)


285
286
287
# File 'lib/docopslab/dev.rb', line 285

def shell_shebang? file
  FileUtilities.shell_shebang?(file)
end

.show_lint_rule(tool, rule) ⇒ Object

Show Stuff



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

Sync Operations



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_scriptsObject



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

.tool_available?(tool_name) ⇒ Boolean

Checkers & Finders

Returns:

  • (Boolean)


249
250
251
# File 'lib/docopslab/dev.rb', line 249

def tool_available? tool_name
  ToolExecution.tool_available?(tool_name)
end

.tools_def_pathObject



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_interactiveObject



213
214
215
# File 'lib/docopslab/dev.rb', line 213

def update_hooks_interactive
  GitHooks.update_hooks_interactive
end