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 # 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.3.0'
RUBY_TARGET =
'3.2.7'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.manifestObject

Returns the value of attribute manifest.



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

def manifest
  @manifest
end

.manifest_pathObject



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

def manifest_path
  @manifest_path || MANIFEST_PATH
end

.tools_dataObject

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_subpathObject



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_projectObject



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

def bootstrap_project
  Initializer.bootstrap_project(self)
end

.check_config_structureObject



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

def check_config_structure
  Checkers.check_config_structure(self)
end

.check_hook_updatesObject



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

def check_hook_updates
  GitHooks.check_hook_updates
end

.check_ruby_versionObject



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

def check_ruby_version
  Checkers.check_ruby_version
end

.check_standard_rake_tasksObject



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

def check_standard_rake_tasks
  Checkers.check_standard_rake_tasks
end

.config_pathsObject

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_dirObject

Project paths (local/runtime)



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

def config_vendor_dir
  Paths.config_vendor_dir
end

.create_gitignore_stubObject



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

def create_gitignore_stub
  Initializer.create_gitignore_stub
end

.create_project_manifestObject

Initialization



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

def create_project_manifest
  Initializer.create_project_manifest
end

.default_library_branchObject



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

def default_library_branch
  'labdev-library'
end

.default_library_repoObject

Upstream library defaults



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

def default_library_repo
  'DocOps/lab'
end

.docker_available?Boolean

Returns:

  • (Boolean)


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

def docker_available?
  ToolExecution.docker_available?
end

.file_matches_ignore_pattern?(file, pattern) ⇒ Boolean

Returns:

  • (Boolean)


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

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

.find_asciidoc_filesObject



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

def find_asciidoc_files
  FileUtilities.find_asciidoc_files(self)
end

.find_shell_scriptsObject



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

def find_shell_scripts
  FileUtilities.find_shell_scripts(self)
end

.gem_sourced_locally?Boolean

Returns:

  • (Boolean)


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

def gem_sourced_locally?
  Checkers.gem_sourced_locally?
end

.generate_htmlproofer_configObject



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

def generate_htmlproofer_config
  ConfigManager.generate_htmlproofer_config(self)
end

.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



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

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

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



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



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

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)


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

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

.hooks_dirObject



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

def hooks_dir
  '.git/hooks'
end

.image_available?Boolean

Returns:

  • (Boolean)


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

def image_available?
  ToolExecution.image_available?
end

.install_missing_hooksObject



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

def install_missing_hooks
  GitHooks.install_missing_hooks
end

.install_vale_stylesObject



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

def install_vale_styles
  SyncOps.install_vale_styles(self)
end

.lab_dev_mode?Boolean

Returns:

  • (Boolean)


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

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.



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

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



365
366
367
# File 'lib/docopslab/dev.rb', line 365

def lint_file file_path
  Linters.lint_file(self, file_path)
end

.list_hook_templatesObject



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

def list_hook_templates
  GitHooks.list_hook_templates
end

.list_script_templatesObject



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

def list_script_templates
  ScriptManager.list_script_templates
end

.load_htmlproofer_configObject



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

def load_htmlproofer_config
  ConfigManager.load_htmlproofer_config
end

.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

.load_tools_dataObject



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_pathObject

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_pathObject

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



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

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

.run_all_lintersObject



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

def run_all_linters
  Linters.run_all_linters(self)
end

.run_auto_fixObject



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



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

def run_in_docker command
  ToolExecution.run_in_docker(command)
end

.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

Run Linters



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



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

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

.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

Tool Execution



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

Returns:

  • (Boolean)


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

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

.show_lint_rule(tool, rule) ⇒ Object

Show Stuff



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

Sync Operations



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_scriptsObject



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

.tool_available?(tool_name) ⇒ Boolean

Checkers & Finders

Returns:

  • (Boolean)


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

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

.tools_def_pathObject



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_interactiveObject



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

def update_hooks_interactive
  GitHooks.update_hooks_interactive
end