Module: ROM::Files::Plugins::Schema::Shebang
- Defined in:
- lib/rom/files/plugins/schema/shebang.rb
Overview
A plugin for automatically adding shebang of file to the schema definition
Defined Under Namespace
Modules: DSL
Constant Summary collapse
- TYPE =
Types::String
- NAME =
:run_with
Class Method Summary collapse
Class Method Details
.apply(schema, name: NAME, type: TYPE) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
42 43 44 45 46 47 48 |
# File 'lib/rom/files/plugins/schema/shebang.rb', line 42 def self.apply(schema, name: NAME, type: TYPE) shebang = type.(name: name, source: schema.name, __proc__: method(:read_shebang)) schema.attributes.concat( schema.class.attributes([shebang], schema.attr_class) ) end |
.read_shebang(path) ⇒ String?
36 37 38 39 |
# File 'lib/rom/files/plugins/schema/shebang.rb', line 36 def self.read_shebang(path) shebang = path.readlines.first || '' shebang[2..-1].chomp if shebang.match?(/\A#!/) end |