Kouhei Sutou
null+****@clear*****
Thu Jan 26 14:23:10 JST 2017
Kouhei Sutou 2017-01-26 14:23:10 +0900 (Thu, 26 Jan 2017) New Revision: 6722e0fe0ea9e821a651fad76465aa386726f9cf https://github.com/ranguba/groonga-client-model/commit/6722e0fe0ea9e821a651fad76465aa386726f9cf Message: Generate config/groonga.yml automatically Modified files: lib/groonga_client_model/railtie.rb test/apps/rails5/Gemfile.lock test/apps/rails5/config/groonga.yml Modified: lib/groonga_client_model/railtie.rb (+31 -0) =================================================================== --- lib/groonga_client_model/railtie.rb 2017-01-26 09:24:54 +0900 (c0f9134) +++ lib/groonga_client_model/railtie.rb 2017-01-26 14:23:10 +0900 (82d5050) @@ -61,6 +61,37 @@ module GroongaClientModel initializer "groonga_client_model.initialize_client" do ActiveSupport.on_load(:groonga_client_model) do + config_dir = Rails.application.paths["config"].existent.first + config_path = Pathname(config_dir) + "groonga.yml" + unless config_path.exist? + config_path.open("w") do |config_file| + config_file.puts(<<-CONFIG) +default: &default + url: http://127.0.0.1:10041/ + # url: https://127.0.0.1:10041/ + # protocol: http + # host: 127.0.0.1 + # port: 10041 + # user: alice + # password: secret + read_timeout: -1 + # read_timeout: 3 + backend: synchronous + +development: + <<: *default + +test: + <<: *default + url: http://127.0.0.1:20041/ + +production: + <<: *default + # url: http://production.example.com:10041/ + read_timeout: 10 + CONFIG + end + end config = Rails.application.config_for(:groonga) Client.url = config["url"] end Modified: test/apps/rails5/Gemfile.lock (+2 -2) =================================================================== --- test/apps/rails5/Gemfile.lock 2017-01-26 09:24:54 +0900 (c578d8e) +++ test/apps/rails5/Gemfile.lock 2017-01-26 14:23:10 +0900 (c8fe96a) @@ -1,7 +1,7 @@ PATH remote: ../../../../groonga-client specs: - groonga-client (0.4.0) + groonga-client (0.4.1) gqtp (>= 1.0.4) groonga-command (>= 1.2.8) groonga-command-parser (>= 1.0.7) @@ -10,7 +10,7 @@ PATH PATH remote: ../../../ specs: - groonga-client-model (0.9.5) + groonga-client-model (0.9.8) activemodel groonga-client (>= 0.3.7) groonga-command-parser Modified: test/apps/rails5/config/groonga.yml (+18 -3) =================================================================== --- test/apps/rails5/config/groonga.yml 2017-01-26 09:24:54 +0900 (6bd3460) +++ test/apps/rails5/config/groonga.yml 2017-01-26 14:23:10 +0900 (e04e0f4) @@ -1,8 +1,23 @@ +default: &default + url: http://127.0.0.1:10041/ + # url: https://127.0.0.1:10041/ + # protocol: http + # host: 127.0.0.1 + # port: 10041 + # user: alice + # password: secret + read_timeout: -1 + # read_timeout: 3 + backend: synchronous + development: - url: http://127.0.0.1:10041 + <<: *default test: - url: http://127.0.0.1:20041 + <<: *default + url: http://127.0.0.1:20041/ production: - url: http://127.0.0.1:10041 + <<: *default + # url: http://production.example.com:10041/ + read_timeout: 10 -------------- next part -------------- HTML����������������������������... Download