Module: AllInRuby::Instruction
- Defined in:
- lib/all_in_ruby/instruction.rb
Constant Summary collapse
- BEGIN_MARKER =
"<!-- BEGIN all_in_ruby -->".freeze
- END_MARKER =
"<!-- END all_in_ruby -->".freeze
- BODY =
<<~MARKDOWN.freeze ## 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
Class Method Summary collapse
Class Method Details
.block ⇒ Object
24 25 26 |
# File 'lib/all_in_ruby/instruction.rb', line 24 def self.block BLOCK end |
.installed?(content) ⇒ Boolean
28 29 30 |
# File 'lib/all_in_ruby/instruction.rb', line 28 def self.installed?(content) content.include?(BEGIN_MARKER) end |
.remove(content) ⇒ Object
32 33 34 |
# File 'lib/all_in_ruby/instruction.rb', line 32 def self.remove(content) content.gsub(/\n?#{Regexp.escape(BEGIN_MARKER)}.*?#{Regexp.escape(END_MARKER)}\n?/m, "\n") end |