Module: DocOpsLab::Dev

Defined in:
lib/docopslab/dev.rb,
lib/docopslab/dev/help.rb,
lib/docopslab/dev/paths.rb,
lib/docopslab/dev/tasks.rb,
lib/docopslab/dev/linters.rb,
lib/docopslab/dev/version.rb,
lib/docopslab/dev/checkers.rb,
lib/docopslab/dev/sync_ops.rb,
lib/docopslab/dev/git_hooks.rb,
lib/docopslab/dev/file_utils.rb,
lib/docopslab/dev/log_parser.rb,
lib/docopslab/dev/initializer.rb,
lib/docopslab/dev/spell_check.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, Checkers, ConfigManager, FileUtilities, GitHooks, Help, Initializer, Linters, LogParser, Paths, ScriptManager, 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 Project paths (local/runtime)

'.config/docopslab-dev.yml'
CONFIG_VENDOR_DIR =
Paths.config_vendor_dir
HOOKS_DIR =
'.git/hooks'
CONFIG_PATHS =

Runtime/generated config files (merged from base + local)

Paths::CONFIG_FILES
RUBOCOP_CONFIG_PATH =

Shorthand for rubocop (most commonly referenced)

MANIFEST_DEF_PATH =

Gem source paths (assets bundled with gem)

File.join(GEM_ROOT, 'specs', 'data', 'default-manifest.yml')
TOOLS_DEF_PATH =
File.join(GEM_ROOT, 'specs', 'data', 'tools.yml')
CONFIG_PACKS_SOURCE_DIR =
Paths.gem_config_packs
SCRIPTS_SOURCE_DIR =
Paths.gem_scripts
HOOKS_SOURCE_DIR =
Paths.gem_hooks
TEMPLATES_DIR =
File.join(GEM_ROOT, 'assets', 'templates')
GITIGNORE_STUB_SOURCE_PATH =
File.join(TEMPLATES_DIR, 'gitignore')
GEMFILE_STUB_SOURCE_PATH =
File.join(TEMPLATES_DIR, 'Gemfile')
RAKEFILE_STUB_SOURCE_PATH =
File.join(TEMPLATES_DIR, 'Rakefile')
VERSION =
'0.1.0'
RUBY_TARGET =
'3.2.7'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.manifestObject

Returns the value of attribute manifest.



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

def manifest
  @manifest
end

.tools_dataObject

Returns the value of attribute tools_data.



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

def tools_data
  @tools_data
end

Class Method Details

.bootstrap_projectObject



162
163
164
# File 'lib/docopslab/dev.rb', line 162

def bootstrap_project
  Initializer.bootstrap_project
end

.check_config_structureObject



234
235
236
# File 'lib/docopslab/dev.rb', line 234

def check_config_structure
  Checkers.check_config_structure(self)
end

.check_hook_updatesObject



174
175
176
# File 'lib/docopslab/dev.rb', line 174

def check_hook_updates
  GitHooks.check_hook_updates
end

.check_ruby_versionObject



230
231
232
# File 'lib/docopslab/dev.rb', line 230

def check_ruby_version
  Checkers.check_ruby_version
end

.check_standard_rake_tasksObject



238
239
240
# File 'lib/docopslab/dev.rb', line 238

def check_standard_rake_tasks
  Checkers.check_standard_rake_tasks
end

.create_gitignore_stubObject



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

def create_gitignore_stub
  Initializer.create_gitignore_stub
end

.create_project_manifestObject

Initialization



158
159
160
# File 'lib/docopslab/dev.rb', line 158

def create_project_manifest
  Initializer.create_project_manifest
end

.docker_available?Boolean

Returns:



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

def docker_available?
  ToolExecution.docker_available?
end

.file_matches_ignore_pattern?(file, pattern) ⇒ Boolean

Returns:



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

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

.find_asciidoc_filesObject



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

def find_asciidoc_files
  FileUtilities.find_asciidoc_files(self)
end

.find_shell_scriptsObject



242
243
244
# File 'lib/docopslab/dev.rb', line 242

def find_shell_scripts
  FileUtilities.find_shell_scripts(self)
end

.gem_sourced_locally?Boolean

Returns:



226
227
228
# File 'lib/docopslab/dev.rb', line 226

def gem_sourced_locally?
  Checkers.gem_sourced_locally?
end

.generate_htmlproofer_configObject



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

def generate_htmlproofer_config
  ConfigManager.generate_htmlproofer_config(self)
end

.generate_vale_config(style_override: nil) ⇒ Object

Special Runtime Config Handling



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

def generate_vale_config style_override: nil
  ConfigManager.generate_vale_config(self, style_override: style_override)
end

.get_path_config(tool_slug) ⇒ Object



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

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

.get_tool_entry(tool_slug) ⇒ Object



103
104
105
106
107
108
109
# File 'lib/docopslab/dev.rb', line 103

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



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/docopslab/dev.rb', line 111

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



97
98
99
100
101
# File 'lib/docopslab/dev.rb', line 97

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:



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

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

.image_available?Boolean

Returns:



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

def image_available?
  ToolExecution.image_available?
end

.install_missing_hooksObject



170
171
172
# File 'lib/docopslab/dev.rb', line 170

def install_missing_hooks
  GitHooks.install_missing_hooks
end

.install_vale_stylesObject



166
167
168
# File 'lib/docopslab/dev.rb', line 166

def install_vale_styles
  SyncOps.install_vale_styles(self)
end

.lab_dev_mode?Boolean

Returns:



222
223
224
# File 'lib/docopslab/dev.rb', line 222

def lab_dev_mode?
  Checkers.lab_dev_mode?
end

.lint_file(file_path) ⇒ Object



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

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

.list_hook_templatesObject



341
342
343
# File 'lib/docopslab/dev.rb', line 341

def list_hook_templates
  GitHooks.list_hook_templates
end

.list_script_templatesObject



345
346
347
# File 'lib/docopslab/dev.rb', line 345

def list_script_templates
  ScriptManager.list_script_templates
end

.load_htmlproofer_configObject



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

def load_htmlproofer_config
  ConfigManager.load_htmlproofer_config
end

.load_manifest(force_reload: false) ⇒ Object

Common Utility



72
73
74
75
76
77
78
79
80
# File 'lib/docopslab/dev.rb', line 72

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: #{e.message}"
  nil
end

.load_tools_dataObject



82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/docopslab/dev.rb', line 82

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

.run_actionlint(opts_string = '') ⇒ Object



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

def run_actionlint opts_string=''
  Linters.run_actionlint(self, opts_string)
end

.run_adoc_auto_fix(path = nil) ⇒ Object



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

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

.run_all_lintersObject



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

def run_all_linters
  Linters.run_all_linters(self)
end

.run_auto_fixObject



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

def run_auto_fix
  Linters.run_auto_fix
  AsciiidocAutoFix.fix_asciidoc_files(self)
end

.run_in_docker(command) ⇒ Object



148
149
150
# File 'lib/docopslab/dev.rb', line 148

def run_in_docker command
  ToolExecution.run_in_docker(command)
end

.run_linter_group(group_name, linters) ⇒ Object



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

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



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

def run_rubocop file_path=nil, opts_string=''
  Linters.run_rubocop(self, file_path, opts_string)
end

.run_rubocop_auto_fix(path: nil) ⇒ Object



307
308
309
# File 'lib/docopslab/dev.rb', line 307

def run_rubocop_auto_fix path: nil
  Linters.run_rubocop_auto_fix(self, path: path)
end

.run_rubocop_with_filter(filter_name) ⇒ Object



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

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

.run_script(script_name, args = []) ⇒ Object



152
153
154
# File 'lib/docopslab/dev.rb', line 152

def run_script script_name, args=[]
  ScriptManager.run_script(script_name, args)
end

.run_shellcheck(file_path = nil, opts_string = '') ⇒ Object



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

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



319
320
321
322
# File 'lib/docopslab/dev.rb', line 319

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



144
145
146
# File 'lib/docopslab/dev.rb', line 144

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:



246
247
248
# File 'lib/docopslab/dev.rb', line 246

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

.show_lint_rule(tool, rule) ⇒ Object

Show Stuff



330
331
332
333
334
335
336
337
338
339
# File 'lib/docopslab/dev.rb', line 330

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



188
189
190
# File 'lib/docopslab/dev.rb', line 188

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



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

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



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

def sync_docs force: false
  SyncOps.sync_docs(self, force: force)
end

.sync_scriptsObject



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

def sync_scripts
  SyncOps.sync_scripts(self)
end

.sync_vale_styles(local: false) ⇒ Object



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

def sync_vale_styles local: false
  SyncOps.sync_vale_styles(self, local: local)
end

.tool_available?(tool_name) ⇒ Boolean

Checkers & Finders

Returns:



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

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

.update_hooks_interactiveObject



178
179
180
# File 'lib/docopslab/dev.rb', line 178

def update_hooks_interactive
  GitHooks.update_hooks_interactive
end