Class: Prettyp::Formatter::JSON::Python
Class Method Summary
collapse
Instance Method Summary
collapse
#check_requirement, inherited, inherited_classes
Methods included from Logger
logger, #logger
Class Method Details
.check_requirement ⇒ Object
10
11
12
|
# File 'lib/prettyp/formatter/json/python.rb', line 10
def self.check_requirement
!%x|which #{executeable}|.empty?
end
|
.executeable ⇒ Object
9
|
# File 'lib/prettyp/formatter/json/python.rb', line 9
def self.executeable; 'python'; end
|
.languages ⇒ Object
5
6
7
|
# File 'lib/prettyp/formatter/json/python.rb', line 5
def self.languages
['JSON']
end
|
Instance Method Details
14
15
16
17
18
19
|
# File 'lib/prettyp/formatter/json/python.rb', line 14
def format input, language
with_file(input) do |file|
out = execute_command("cat #{file.path} | #{self.class.executeable} -m json.tool",
on_error: Proc.new { |output| raise FormatError, output })
end
end
|