Class: Eac::Htmlbeautifier

Inherits:
Object
  • Object
show all
Defined in:
lib/eac/htmlbeautifier.rb

Class Method Summary collapse

Class Method Details

.beautify(string) ⇒ Object



5
6
7
# File 'lib/eac/htmlbeautifier.rb', line 5

def self.beautify(string)
  ::HtmlBeautifier.beautify(string, tab_stops: 2) + "\n"
end

.beautify_file(file) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/eac/htmlbeautifier.rb', line 14

def self.beautify_file(file)
  input = File.read(file)
  output = beautify(input)
  if input == output
    false
  else
    File.write(file, output)
    true
  end
end

.file_beautified?(file) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
# File 'lib/eac/htmlbeautifier.rb', line 9

def self.file_beautified?(file)
  input = File.read(file)
  input == beautify(input)
end