Class: CopyrightHeader::Syntax
- Inherits:
-
Object
- Object
- CopyrightHeader::Syntax
- Defined in:
- lib/copyright_header/parser.rb
Instance Method Summary collapse
- #ext(file) ⇒ Object
- #header(file) ⇒ Object
-
#initialize(config) ⇒ Syntax
constructor
A new instance of Syntax.
- #supported?(file) ⇒ Boolean
Constructor Details
#initialize(config) ⇒ Syntax
Returns a new instance of Syntax.
134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/copyright_header/parser.rb', line 134 def initialize(config) @config = {} syntax = YAML.load_file(config) syntax.each_value do |format| format['ext'].each do |ext| @config[ext] = { :before => format['before'], :after => format['after'], :comment => format['comment'] } end end end |
Instance Method Details
#ext(file) ⇒ Object
148 149 150 |
# File 'lib/copyright_header/parser.rb', line 148 def ext(file) File.extname(file) end |
#header(file) ⇒ Object
156 157 158 |
# File 'lib/copyright_header/parser.rb', line 156 def header(file) Header.new(file, @config[ext(file)]) end |
#supported?(file) ⇒ Boolean
152 153 154 |
# File 'lib/copyright_header/parser.rb', line 152 def supported?(file) @config.has_key? ext(file) end |