Module: Code0::License::Boundary
- Defined in:
- lib/code0/license/boundary.rb
Overview
Responsible for adding and removing boundaries of strings
Constant Summary collapse
- BOUNDARY_START =
/(\A|\r?\n)-*BEGIN .+? LICENSE-*\r?\n/
- BOUNDARY_END =
/\r?\n-*END .+? LICENSE-*(\r?\n|\z)/
Class Method Summary collapse
Class Method Details
.add_boundary(data, license_name) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/code0/license/boundary.rb', line 11 def add_boundary(data, license_name) data = remove_boundary(data) [ pad("BEGIN #{license_name} LICENSE", 60), data.strip, pad("END #{license_name} LICENSE", 60) ].join("\n") end |
.remove_boundary(data) ⇒ Object
21 22 23 24 |
# File 'lib/code0/license/boundary.rb', line 21 def remove_boundary(data) after_boundary = data.split(BOUNDARY_START).last after_boundary&.split(BOUNDARY_END)&.first end |