Class: RubyUIConverter::Converter
- Inherits:
-
Object
- Object
- RubyUIConverter::Converter
- Defined in:
- lib/ruby_ui_converter/converter.rb
Overview
Orchestrates the conversion of an entire directory (or single file).
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
-
#initialize(path, config: Configuration.new) ⇒ Converter
constructor
A new instance of Converter.
-
#root ⇒ Object
The namespace root.
- #run ⇒ Object
Constructor Details
#initialize(path, config: Configuration.new) ⇒ Converter
Returns a new instance of Converter.
10 11 12 13 |
# File 'lib/ruby_ui_converter/converter.rb', line 10 def initialize(path, config: Configuration.new) @path = path @config = config end |
Instance Method Details
#root ⇒ Object
The namespace root. Precedence: explicit config.root, then the nearest ‘app/views` ancestor (Rails convention — keeps generated constants matching the Zeitwerk path mapping no matter which subfolder was converted), then the directory the user pointed at.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ruby_ui_converter/converter.rb', line 19 def root @root ||= if @config.root File.(@config.root) else base = if File.directory?(@path) File.(@path) else File.dirname(File.(@path)) end conventional_root(base) || base end end |
#run ⇒ Object
34 35 36 |
# File 'lib/ruby_ui_converter/converter.rb', line 34 def run FileWalker.new(@path).erb_files.map { |file| convert_file(file) } end |