Module: AllInRuby::Instruction
- Defined in:
- lib/all_in_ruby/instruction.rb
Constant Summary collapse
- BEGIN_MARKER =
"<!-- BEGIN all_in_ruby -->"- END_MARKER =
"<!-- END all_in_ruby -->"- BODY =
<<~MARKDOWN ## Scripts Write throwaway and utility scripts (data munging, one-off migrations, file renames, glue code) in Ruby — even in projects written in another language. If it needs a pipe, a loop, a conditional, or more than one line, it is a script: write it in Ruby, not Python, Node, or bash. Single self-contained commands (`grep`, `git status`) are fine as-is. Use only the Ruby standard library. If a gem would clearly save significant effort, stop and ask before using it. Put temporary scripts in a scratch or temp directory, not the repo root, and delete them when done unless asked to keep them. MARKDOWN
- BLOCK =
"#{BEGIN_MARKER}\n#{BODY}#{END_MARKER}\n".freeze
- BLOCK_PATTERN =
/ #{Regexp.escape(BEGIN_MARKER)} (?:(?!#{Regexp.escape(BEGIN_MARKER)}).)*? #{Regexp.escape(END_MARKER)}\n? /mx
Class Method Summary collapse
Class Method Details
.block ⇒ Object
31 32 33 |
# File 'lib/all_in_ruby/instruction.rb', line 31 def self.block BLOCK end |
.body ⇒ Object
35 36 37 |
# File 'lib/all_in_ruby/instruction.rb', line 35 def self.body BODY end |
.installed?(content) ⇒ Boolean
39 40 41 |
# File 'lib/all_in_ruby/instruction.rb', line 39 def self.installed?(content) content.match?(BLOCK_PATTERN) end |
.remove(content) ⇒ Object
43 44 45 |
# File 'lib/all_in_ruby/instruction.rb', line 43 def self.remove(content) content.gsub(BLOCK_PATTERN, "") end |