lib/fluent/format/check.rb in fluent-format-0.2.5 vs lib/fluent/format/check.rb in fluent-format-0.2.6
- old
+ new
@@ -23,18 +23,26 @@
@opts[:plugin_dirs] += opts[:plugin_dirs] if opts[:plugin_dirs] and !opts[:plugin_dirs].empty?
@opts[:libs] += opts[:libs] if opts[:libs] and !opts[:libs].empty?
@opts[:inline_config] = opts[:inline_config]
@opts[:gemfile] = opts[:gemfile]
@opts[:gem_install_path] = opts[:gem_install_path]
+ if config_dev.respond_to?(:read) # IO object
+ @opts[:config_path] = Tempfile.open('fluent-format') {|f| f.puts(config_dev.read); f.path }
+ end
end
# Check config file
#
# @raise Fluent::ConfigParseError if conf has syntax errors
# @raise Fluent::ConfigError if plugin raises config error
# @return true if success
def run
+ if @opts[:config_path].respond_to?(:read) # IO object
+ @opts[:config_path] = Tempfile.open('fluent-format') {|fp|
+ fp.puts(@opts[:config_path].read); fp.path
+ }
+ end
Fluent::Format::BundlerInjection.new(@opts).run
Fluent::Supervisor.new(@opts).extended_dry_run
end
end
end
@@ -87,36 +95,20 @@
# lib/fluent/supervisor.rb
# Open the existing class and define new methods
module Fluent
class Supervisor
- # Extended to accept IO object
+ # Extended not to exit
#
# @raise Fluent::ConfigParseError if conf has syntax errors
# @raise Fluent::ConfigError if plugin raises config error
# @return true if success
def extended_dry_run
- extended_read_config
+ read_config
change_privilege
init_engine
install_main_process_signal_handlers
run_configure
true
- end
-
- # Extended to accept IO object
- def extended_read_config
- if @config_path.respond_to?(:read) # IO object
- @config_data = @config_path.read
- else
- @config_fname = File.basename(@config_path)
- @config_basedir = File.dirname(@config_path)
- @config_data = File.read(@config_path)
- end
- if @inline_config == '-'
- @config_data << "\n" << STDIN.read
- elsif @inline_config
- @config_data << "\n" << @inline_config.gsub("\\n","\n")
- end
end
end
end