avm-tools 0.38.0 → 0.39.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 585031f042e816f18293f7db1e5319c947db381562c87a6aad9f6c61ddfb1f1b
4
- data.tar.gz: 44f66d7bdd9776e640dd4cd2e3df43acfea139366676f84d32bf07877c04c9b5
3
+ metadata.gz: 0211c8015a2aa7fef610701de30c0a8ae3966a815e273a88e9caa983d1055c26
4
+ data.tar.gz: 47303eed16db13dcdaf3b15fc373a20c470ecf074494217507c6dd59554552c1
5
5
  SHA512:
6
- metadata.gz: debbe214e6e984483870ed64d9a0a8d2eac5dc5231b6dc5d4f1408e93f81aaa98baec2d1c260aaaf9366a6565eacc49a7e090c2f188eac766d2e74ceeb48f9b5
7
- data.tar.gz: d7a5a4597ee14bf3e1f05c4a021fc678c4cc297bafda9f5e3268160210d9605d5ef7be1408b41b0a9aa2439b9ebe1550082fa58f0accc4aa08b16dd29b03621a
6
+ metadata.gz: 81eddbd5933240b20c2fb75258dc41c9f351c38a15fc9466ccd719389718977e7c6173d9d2943c9078fc4e639fa9a68c4bb2ba2b89360269a64bd6f33f2d4ec8
7
+ data.tar.gz: 732dc09a4318958952cf71820c70b8cc21e3a10013103d4766d63734246f9d0c3b058e6e9dec5f5a8a42bbe388c5022e0769c383fb6eb437fc93988f802878fa
@@ -11,7 +11,7 @@ module Avm
11
11
  enable_console_speaker
12
12
  common_constructor :source_paths, :options
13
13
 
14
- FORMATS = %w[php python generic_plain].freeze
14
+ FORMATS = %w[html php python generic_plain].freeze
15
15
 
16
16
  def run
17
17
  clear
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/files/formatter/formats/generic_plain'
4
+ require 'htmlbeautifier'
5
+
6
+ module Avm
7
+ module Files
8
+ class Formatter
9
+ module Formats
10
+ class Html < ::Avm::Files::Formatter::Formats::GenericPlain
11
+ VALID_EXTENSIONS = %w[.html .html.erb].freeze
12
+ VALID_TYPES = ['html'].freeze
13
+
14
+ def file_apply(path)
15
+ input = ::File.read(path)
16
+ temppath = tempfile_path
17
+ ::File.open(temppath, 'w') do |output|
18
+ beautify path, input, output
19
+ end
20
+ ::FileUtils.mv(temppath, path)
21
+ super(path)
22
+ end
23
+
24
+ private
25
+
26
+ def beautify(name, input, output)
27
+ output.puts ::HtmlBeautifier.beautify(input, htmlbeautify_options)
28
+ rescue StandardError => e
29
+ raise "Error parsing #{name}: #{e}"
30
+ end
31
+
32
+ def htmlbeautify_options
33
+ @htmlbeautify_options ||= { indent: ' ' }
34
+ end
35
+
36
+ def tempfile_path
37
+ tempfile = ::Tempfile.new
38
+ tempfile.close
39
+ tempfile.path
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.38.0'
5
+ VERSION = '0.39.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.38.0
4
+ version: 0.39.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
@@ -120,6 +120,26 @@ dependencies:
120
120
  - - ">="
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
+ - !ruby/object:Gem::Dependency
124
+ name: htmlbeautifier
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: '1.3'
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: 1.3.1
133
+ type: :runtime
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '1.3'
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: 1.3.1
123
143
  - !ruby/object:Gem::Dependency
124
144
  name: minitar
125
145
  requirement: !ruby/object:Gem::Requirement
@@ -213,6 +233,7 @@ files:
213
233
  - lib/avm/files/formatter/formats.rb
214
234
  - lib/avm/files/formatter/formats/base.rb
215
235
  - lib/avm/files/formatter/formats/generic_plain.rb
236
+ - lib/avm/files/formatter/formats/html.rb
216
237
  - lib/avm/files/formatter/formats/php.rb
217
238
  - lib/avm/files/formatter/formats/python.rb
218
239
  - lib/avm/files/formatter/utf8_assert.rb