Kouhei Sutou
null+****@clear*****
Thu Mar 20 00:30:09 JST 2014
Kouhei Sutou 2014-03-20 00:30:09 +0900 (Thu, 20 Mar 2014) New Revision: ce2b5c4b7be93e1bd2537953b202db926abc371b https://github.com/droonga/drntest/commit/ce2b5c4b7be93e1bd2537953b202db926abc371b Message: Use more meaningful method names Modified files: lib/drntest/engine.rb Modified: lib/drntest/engine.rb (+9 -8) =================================================================== --- lib/drntest/engine.rb 2014-03-20 00:27:23 +0900 (ed57a4a) +++ lib/drntest/engine.rb 2014-03-20 00:30:09 +0900 (323ea42) @@ -25,8 +25,7 @@ module Drntest end def start(target_path) - catalog_json = prepare(target_path) - setup(catalog_json) + setup(target_path) end def stop @@ -42,24 +41,24 @@ module Drntest end private - def prepare(target_path) + def load_catalog_json(target_path) catalog_json = JSON.parse(catalog_file.read) @config.catalog_version = catalog_json["version"] case****@confi*****_version when 1 - prepare_catalog_v1(catalog_json) + extract_connection_info_catalog_v1(catalog_json) when 2 custom_catalog_json_file = target_path.sub_ext(".catalog.json") if custom_catalog_json_file.exist? custom_catalog_json = JSON.parse(custom_catalog_json_file.read) merge_catalog_v2!(catalog_json, custom_catalog_json) end - prepare_catalog_v2(catalog_json) + extract_connection_info_catalog_v2(catalog_json) end catalog_json end - def prepare_catalog_v1(catalog_json) + def extract_connection_info_catalog_v1(catalog_json) zone = catalog_json["zones"].first /\A([^:]+):(\d+)\/(.+)\z/ =~ zone @config.host = "localhost" # $1 @@ -84,7 +83,7 @@ module Drntest end end - def prepare_catalog_v2(catalog_json) + def extract_connection_info_catalog_v2(catalog_json) catch do |tag| datasets = catalog_json["datasets"] datasets.each do |name, dataset| @@ -102,13 +101,15 @@ module Drntest end end - def setup(catalog_json) + def setup(target_path) return unless temporary? setup_temporary_dir temporary_config = temporary_dir + "fluentd.conf" FileUtils.cp(config_file, temporary_config) + + catalog_json = load_catalog_json(target_path) temporary_catalog = temporary_dir + "catalog.json" temporary_catalog.open("w") do |output| output.puts(JSON.pretty_generate(catalog_json)) -------------- next part -------------- HTML����������������������������...Download