Class: EacRailsUtils::Htmlbeautifier

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

Class Method Summary collapse

Class Method Details

.beautify(string) ⇒ Object


7
8
9
# File 'lib/eac_rails_utils/htmlbeautifier.rb', line 7

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

.beautify_file(file) ⇒ Object


16
17
18
19
20
21
22
23
24
25
# File 'lib/eac_rails_utils/htmlbeautifier.rb', line 16

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)

11
12
13
14
# File 'lib/eac_rails_utils/htmlbeautifier.rb', line 11

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