Class: Tailwindcss::Compiler::Output
- Inherits:
-
Object
- Object
- Tailwindcss::Compiler::Output
- Defined in:
- lib/tailwindcss/compiler/output.rb
Instance Method Summary collapse
- #absolute_path(path) ⇒ Object
- #add_entry(file_path:, classes:) ⇒ Object
- #compile_classes_dir ⇒ Object
- #content ⇒ Object
- #create_output_folder(file_path:) ⇒ Object
- #output_file_path(file_path:) ⇒ Object
Instance Method Details
#absolute_path(path) ⇒ Object
43 44 45 |
# File 'lib/tailwindcss/compiler/output.rb', line 43 def absolute_path(path) File.(path) end |
#add_entry(file_path:, classes:) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/tailwindcss/compiler/output.rb', line 6 def add_entry(file_path:, classes:) file_path = absolute_path(file_path) return if classes.blank? path = output_file_path(file_path:) folder = create_output_folder(file_path: path) path += ".classes" File.open(path, "wb") do |file| file << classes.join("\n") end File.delete(path) if File.empty?(path) end |
#compile_classes_dir ⇒ Object
20 21 22 |
# File 'lib/tailwindcss/compiler/output.rb', line 20 def compile_classes_dir absolute_path(Tailwindcss.config.compiler.compile_classes_dir.call) end |
#content ⇒ Object
39 40 41 |
# File 'lib/tailwindcss/compiler/output.rb', line 39 def content Tailwindcss.config.content.call.map { |path| absolute_path(path) } end |
#create_output_folder(file_path:) ⇒ Object
24 25 26 27 |
# File 'lib/tailwindcss/compiler/output.rb', line 24 def create_output_folder(file_path:) dir_name = File.dirname(file_path) FileUtils.mkdir_p(dir_name) end |
#output_file_path(file_path:) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/tailwindcss/compiler/output.rb', line 29 def output_file_path(file_path:) content.each do |folder| if file_path.start_with?(folder) return File.join(compile_classes_dir, file_path.delete_prefix(folder.to_s)) end end return nil end |