From 6653d5f2f82ae97f58d04468b231c0d86d412093 Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 16 Jul 2020 10:13:57 +0200 Subject: [PATCH 01/19] Add check for production and produciton_only flag --- lib/searchyll.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/searchyll.rb b/lib/searchyll.rb index db89e0b..6fa81cd 100644 --- a/lib/searchyll.rb +++ b/lib/searchyll.rb @@ -12,6 +12,7 @@ Jekyll::Hooks.register(:site, :pre_render) do |site| config = Searchyll::Configuration.new(site) if config.valid? + return if site.config['environment'] == "production" && site.config['elasticsearch']['production_only'] == true puts "setting up indexer hook" indexers[site] = Searchyll::Indexer.new(config) indexers[site].start From a3345139838f399f1094bc8be5f0e27c959115be Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 16 Jul 2020 10:16:55 +0200 Subject: [PATCH 02/19] Move checking of config only to configuration.rb --- lib/searchyll.rb | 2 +- lib/searchyll/configuration.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/searchyll.rb b/lib/searchyll.rb index 6fa81cd..2d8744b 100644 --- a/lib/searchyll.rb +++ b/lib/searchyll.rb @@ -12,7 +12,7 @@ Jekyll::Hooks.register(:site, :pre_render) do |site| config = Searchyll::Configuration.new(site) if config.valid? - return if site.config['environment'] == "production" && site.config['elasticsearch']['production_only'] == true + return if config.elasticsearch_production_only puts "setting up indexer hook" indexers[site] = Searchyll::Indexer.new(config) indexers[site].start diff --git a/lib/searchyll/configuration.rb b/lib/searchyll/configuration.rb index 5e7326a..fd70ab5 100644 --- a/lib/searchyll/configuration.rb +++ b/lib/searchyll/configuration.rb @@ -79,6 +79,10 @@ def elasticsearch_settings_path site.config['elasticsearch']['custom_settings'] end + def elasticsearch_production_only + site.config['environment'] == "production" && site.config['elasticsearch']['production_only'] == true + end + def elasticsearch_mapping read_yaml(elasticsearch_mapping_path, nil) end From db24cb3f0c409d14b565d1fb9e90ecbf01725add Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 16 Jul 2020 10:18:32 +0200 Subject: [PATCH 03/19] Add checks for production only in all hooks --- lib/searchyll.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/searchyll.rb b/lib/searchyll.rb index 2d8744b..ad468ae 100644 --- a/lib/searchyll.rb +++ b/lib/searchyll.rb @@ -12,6 +12,7 @@ Jekyll::Hooks.register(:site, :pre_render) do |site| config = Searchyll::Configuration.new(site) if config.valid? + # return if we should only run in production return if config.elasticsearch_production_only puts "setting up indexer hook" indexers[site] = Searchyll::Indexer.new(config) @@ -32,6 +33,8 @@ # gets random pages like your home page Jekyll::Hooks.register :pages, :post_render do |page| + # return if we should only run in production + return if config.elasticsearch_production_only # strip html nokogiri_doc = Nokogiri::HTML(page.output) @@ -48,6 +51,8 @@ # gets both posts and collections Jekyll::Hooks.register :documents, :post_render do |document| + # return if we should only run in production + return if config.elasticsearch_production_only # strip html nokogiri_doc = Nokogiri::HTML(document.output) From f20f715a8c4fbf8f4d02f7e64f772a59d16058fa Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 16 Jul 2020 10:25:28 +0200 Subject: [PATCH 04/19] Removed check for config as it isn't available Moved loading of html to after we check if we should run the page --- lib/searchyll.rb | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/lib/searchyll.rb b/lib/searchyll.rb index ad468ae..81f98e3 100644 --- a/lib/searchyll.rb +++ b/lib/searchyll.rb @@ -33,14 +33,11 @@ # gets random pages like your home page Jekyll::Hooks.register :pages, :post_render do |page| - # return if we should only run in production - return if config.elasticsearch_production_only - # strip html - nokogiri_doc = Nokogiri::HTML(page.output) - - # puts %( indexing page #{page.url}) - if (indexer = indexers[page.site]) + # strip html + nokogiri_doc = Nokogiri::HTML(page.output) + + # puts %( indexing page #{page.url}) indexer << ({ "id" => page.name, "url" => page.url, @@ -51,14 +48,11 @@ # gets both posts and collections Jekyll::Hooks.register :documents, :post_render do |document| - # return if we should only run in production - return if config.elasticsearch_production_only - # strip html - nokogiri_doc = Nokogiri::HTML(document.output) - - # puts %( indexing document #{document.url}) - if (indexer = indexers[document.site]) + # strip html + nokogiri_doc = Nokogiri::HTML(document.output) + # puts %( indexing document #{document.url}) + indexer << ({ "id" => document.id, "url" => document.url, From 819dde706bda11eb6c0e5412127f30cc486a09d5 Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 16 Jul 2020 11:53:13 +0200 Subject: [PATCH 05/19] Added questionmark --- lib/searchyll.rb | 2 +- lib/searchyll/configuration.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/searchyll.rb b/lib/searchyll.rb index 81f98e3..2fe72dd 100644 --- a/lib/searchyll.rb +++ b/lib/searchyll.rb @@ -13,7 +13,7 @@ config = Searchyll::Configuration.new(site) if config.valid? # return if we should only run in production - return if config.elasticsearch_production_only + return if config.elasticsearch_production_only? puts "setting up indexer hook" indexers[site] = Searchyll::Indexer.new(config) indexers[site].start diff --git a/lib/searchyll/configuration.rb b/lib/searchyll/configuration.rb index fd70ab5..c23009d 100644 --- a/lib/searchyll/configuration.rb +++ b/lib/searchyll/configuration.rb @@ -79,7 +79,7 @@ def elasticsearch_settings_path site.config['elasticsearch']['custom_settings'] end - def elasticsearch_production_only + def elasticsearch_production_only? site.config['environment'] == "production" && site.config['elasticsearch']['production_only'] == true end From 652247fd1d00ab16275b3f73c9affb4002c84a90 Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 16 Jul 2020 11:56:26 +0200 Subject: [PATCH 06/19] Flipped check for production only --- lib/searchyll.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/searchyll.rb b/lib/searchyll.rb index 2fe72dd..a531d66 100644 --- a/lib/searchyll.rb +++ b/lib/searchyll.rb @@ -13,7 +13,7 @@ config = Searchyll::Configuration.new(site) if config.valid? # return if we should only run in production - return if config.elasticsearch_production_only? + return unless config.elasticsearch_production_only? puts "setting up indexer hook" indexers[site] = Searchyll::Indexer.new(config) indexers[site].start From c5629ea1e7f4776d684af0feddeb66198ad69641 Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 16 Jul 2020 12:01:35 +0200 Subject: [PATCH 07/19] Remove return statement --- lib/searchyll.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/searchyll.rb b/lib/searchyll.rb index a531d66..d263e1a 100644 --- a/lib/searchyll.rb +++ b/lib/searchyll.rb @@ -13,10 +13,13 @@ config = Searchyll::Configuration.new(site) if config.valid? # return if we should only run in production - return unless config.elasticsearch_production_only? - puts "setting up indexer hook" - indexers[site] = Searchyll::Indexer.new(config) - indexers[site].start + unless config.elasticsearch_production_only? + puts "setting up indexer hook" + indexers[site] = Searchyll::Indexer.new(config) + indexers[site].start + else + puts "Not running outside of produciton" + end else puts 'Invalid Elasticsearch configuration provided, skipping indexing...' config.reasons.each do |r| From 37b29d6ad6e44d98b6d00151edbdd3bbd6b98192 Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 16 Jul 2020 12:10:03 +0200 Subject: [PATCH 08/19] Fix produciton check --- lib/searchyll/configuration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/searchyll/configuration.rb b/lib/searchyll/configuration.rb index c23009d..bbc59ce 100644 --- a/lib/searchyll/configuration.rb +++ b/lib/searchyll/configuration.rb @@ -80,7 +80,7 @@ def elasticsearch_settings_path end def elasticsearch_production_only? - site.config['environment'] == "production" && site.config['elasticsearch']['production_only'] == true + site.config['environment'] == "production" || site.config['elasticsearch']['production_only'] == true end def elasticsearch_mapping From 67d2031955fceeeb4d58a1ea11d5efc731ce9713 Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 16 Jul 2020 12:27:11 +0200 Subject: [PATCH 09/19] Add configuration_spec.rb --- spec/searchyll/configuration_spec.rb | 81 ++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 spec/searchyll/configuration_spec.rb diff --git a/spec/searchyll/configuration_spec.rb b/spec/searchyll/configuration_spec.rb new file mode 100644 index 0000000..d9cc4a8 --- /dev/null +++ b/spec/searchyll/configuration_spec.rb @@ -0,0 +1,81 @@ +require File.expand_path('../spec_helper', File.dirname(__FILE__)) +require "jekyll" + +describe Searchyll::Configuration do + + it 'is expected to return true when production and flag not set' do + site_config = { + 'environment' => 'production', + 'elasticsearch' => { + 'production_only' => false + }, + 'source' => __dir__, + 'destination' => __dir__, + 'cache_dir' => __dir__, + 'permalink' => __dir__, + 'liquid' => { + 'error_mode' => false + } + } + site = TestSite.new site_config + conf = Searchyll::Configuration.new site + expect(conf.elasticsearch_production_only?).to eq(true) + end + + it 'is expected to return true when production and flag is set' do + site_config = { + 'environment' => 'production', + 'elasticsearch' => { + 'production_only' => true + }, + 'source' => __dir__, + 'destination' => __dir__, + 'cache_dir' => __dir__, + 'permalink' => __dir__, + 'liquid' => { + 'error_mode' => false + } + } + site = TestSite.new site_config + conf = Searchyll::Configuration.new site + expect(conf.elasticsearch_production_only?).to eq(true) + end + + it 'is expected to return false when not production and flag is set' do + site_config = { + 'environment' => 'not_production', + 'elasticsearch' => { + 'production_only' => true + }, + 'source' => __dir__, + 'destination' => __dir__, + 'cache_dir' => __dir__, + 'permalink' => __dir__, + 'liquid' => { + 'error_mode' => false + } + } + site = TestSite.new site_config + conf = Searchyll::Configuration.new site + expect(conf.elasticsearch_production_only?).to eq(false) + end + + it 'is expected to return false when not production and flag is not set' do + site_config = { + 'environment' => 'not_production', + 'elasticsearch' => { + 'production_only' => false + }, + 'source' => __dir__, + 'destination' => __dir__, + 'cache_dir' => __dir__, + 'permalink' => __dir__, + 'liquid' => { + 'error_mode' => false + } + } + site = TestSite.new site_config + conf = Searchyll::Configuration.new site + expect(conf.elasticsearch_production_only?).to eq(false) + end +end From 0988fa1f4f0e91e3bb38de003153d7cf9ae743ce Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 16 Jul 2020 13:27:06 +0200 Subject: [PATCH 10/19] Added TestSite to test Configuration --- spec/searchyll/configuration_spec.rb | 43 +++++++--------------------- 1 file changed, 11 insertions(+), 32 deletions(-) diff --git a/spec/searchyll/configuration_spec.rb b/spec/searchyll/configuration_spec.rb index d9cc4a8..7c60f45 100644 --- a/spec/searchyll/configuration_spec.rb +++ b/spec/searchyll/configuration_spec.rb @@ -1,6 +1,13 @@ require File.expand_path('../spec_helper', File.dirname(__FILE__)) require "jekyll" +class TestSite + attr_accessor :config + def initialize(config) + @config = config + end +end + describe Searchyll::Configuration do it 'is expected to return true when production and flag not set' do @@ -8,13 +15,6 @@ 'environment' => 'production', 'elasticsearch' => { 'production_only' => false - }, - 'source' => __dir__, - 'destination' => __dir__, - 'cache_dir' => __dir__, - 'permalink' => __dir__, - 'liquid' => { - 'error_mode' => false } } site = TestSite.new site_config @@ -27,13 +27,6 @@ 'environment' => 'production', 'elasticsearch' => { 'production_only' => true - }, - 'source' => __dir__, - 'destination' => __dir__, - 'cache_dir' => __dir__, - 'permalink' => __dir__, - 'liquid' => { - 'error_mode' => false } } site = TestSite.new site_config @@ -41,37 +34,23 @@ expect(conf.elasticsearch_production_only?).to eq(true) end - it 'is expected to return false when not production and flag is set' do + it 'is expected to return false when not production and flag is not set' do site_config = { 'environment' => 'not_production', 'elasticsearch' => { - 'production_only' => true - }, - 'source' => __dir__, - 'destination' => __dir__, - 'cache_dir' => __dir__, - 'permalink' => __dir__, - 'liquid' => { - 'error_mode' => false + 'production_only' => false } } site = TestSite.new site_config conf = Searchyll::Configuration.new site - expect(conf.elasticsearch_production_only?).to eq(false) + expect(conf.elasticsearch_production_only?).to eq(true) end - it 'is expected to return false when not production and flag is not set' do + it 'is expected to return false when not production and flag is set' do site_config = { 'environment' => 'not_production', 'elasticsearch' => { 'production_only' => false - }, - 'source' => __dir__, - 'destination' => __dir__, - 'cache_dir' => __dir__, - 'permalink' => __dir__, - 'liquid' => { - 'error_mode' => false } } site = TestSite.new site_config From 067541c9698b9afba98117e4fec9735ddab59f40 Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 16 Jul 2020 13:28:15 +0200 Subject: [PATCH 11/19] Update min version of Bundler in gemspec --- searchyll.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searchyll.gemspec b/searchyll.gemspec index 2ff62ab..992392c 100644 --- a/searchyll.gemspec +++ b/searchyll.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_development_dependency "bundler", "~> 1.10" + spec.add_development_dependency "bundler", ">= 1.10" spec.add_development_dependency "rake", "~> 10.0" spec.add_development_dependency "rspec" spec.add_development_dependency "guard-rspec" From cd5d407aac44d1889d49af7b4910b1e5574a9bd1 Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 16 Jul 2020 13:29:01 +0200 Subject: [PATCH 12/19] Fix failing test in configuration_spec.rb --- spec/searchyll/configuration_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/searchyll/configuration_spec.rb b/spec/searchyll/configuration_spec.rb index 7c60f45..eb16fcb 100644 --- a/spec/searchyll/configuration_spec.rb +++ b/spec/searchyll/configuration_spec.rb @@ -43,14 +43,14 @@ def initialize(config) } site = TestSite.new site_config conf = Searchyll::Configuration.new site - expect(conf.elasticsearch_production_only?).to eq(true) + expect(conf.elasticsearch_production_only?).to eq(false) end it 'is expected to return false when not production and flag is set' do site_config = { 'environment' => 'not_production', 'elasticsearch' => { - 'production_only' => false + 'production_only' => true } } site = TestSite.new site_config From 8a864ac4f6b35c1f651586e6bc1bec8a6203ab5b Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 16 Jul 2020 13:53:46 +0200 Subject: [PATCH 13/19] Rename method production_only to should_execute_in_current_environment --- lib/searchyll.rb | 4 ++-- lib/searchyll/configuration.rb | 4 ++-- spec/searchyll/configuration_spec.rb | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/searchyll.rb b/lib/searchyll.rb index d263e1a..b3d65fe 100644 --- a/lib/searchyll.rb +++ b/lib/searchyll.rb @@ -13,12 +13,12 @@ config = Searchyll::Configuration.new(site) if config.valid? # return if we should only run in production - unless config.elasticsearch_production_only? + if config.should_execute_in_current_environment? puts "setting up indexer hook" indexers[site] = Searchyll::Indexer.new(config) indexers[site].start else - puts "Not running outside of produciton" + puts "Not running outside of production" end else puts 'Invalid Elasticsearch configuration provided, skipping indexing...' diff --git a/lib/searchyll/configuration.rb b/lib/searchyll/configuration.rb index bbc59ce..511377d 100644 --- a/lib/searchyll/configuration.rb +++ b/lib/searchyll/configuration.rb @@ -79,8 +79,8 @@ def elasticsearch_settings_path site.config['elasticsearch']['custom_settings'] end - def elasticsearch_production_only? - site.config['environment'] == "production" || site.config['elasticsearch']['production_only'] == true + def should_execute_in_current_environment? + site.config['elasticsearch']['production_only'] == true || site.config['environment'] == "production" end def elasticsearch_mapping diff --git a/spec/searchyll/configuration_spec.rb b/spec/searchyll/configuration_spec.rb index eb16fcb..b2dceff 100644 --- a/spec/searchyll/configuration_spec.rb +++ b/spec/searchyll/configuration_spec.rb @@ -19,7 +19,7 @@ def initialize(config) } site = TestSite.new site_config conf = Searchyll::Configuration.new site - expect(conf.elasticsearch_production_only?).to eq(true) + expect(conf.should_execute_in_current_environment?).to eq(true) end it 'is expected to return true when production and flag is set' do @@ -31,7 +31,7 @@ def initialize(config) } site = TestSite.new site_config conf = Searchyll::Configuration.new site - expect(conf.elasticsearch_production_only?).to eq(true) + expect(conf.should_execute_in_current_environment?).to eq(true) end it 'is expected to return false when not production and flag is not set' do @@ -43,7 +43,7 @@ def initialize(config) } site = TestSite.new site_config conf = Searchyll::Configuration.new site - expect(conf.elasticsearch_production_only?).to eq(false) + expect(conf.should_execute_in_current_environment?).to eq(false) end it 'is expected to return false when not production and flag is set' do @@ -55,6 +55,6 @@ def initialize(config) } site = TestSite.new site_config conf = Searchyll::Configuration.new site - expect(conf.elasticsearch_production_only?).to eq(false) + expect(conf.should_execute_in_current_environment?).to eq(false) end end From 2efbbdabb78817911a0d43d7bb0fc5acf6ac055b Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 16 Jul 2020 13:53:56 +0200 Subject: [PATCH 14/19] Add doc about production_only flag --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a80a420..6d3f3d2 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ elasticsearch: default_type: "post" # Optional. Default type is "post". custom_settings: _es_settings.yml # Optional. No default. Relative to your src folder custom_mappings: _es_mappings.yml # Optional. No default. Relative to your src folder + production_only: false # Optional. Defaults to false. ``` ### Custom Settings File Example @@ -69,4 +70,4 @@ prompt that will allow you to experiment. ## Contributing Bug reports and pull requests are welcome on GitHub at -https://github.com/omc/searchyll + From 672a3b988cb7095c31dd18f261716996c7af4273 Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 16 Jul 2020 14:25:24 +0200 Subject: [PATCH 15/19] Change supported environments to array --- README.md | 4 +++- lib/searchyll/configuration.rb | 7 +++++- spec/searchyll/configuration_spec.rb | 34 +++++++++++++++++++--------- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 6d3f3d2..4938386 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,9 @@ elasticsearch: default_type: "post" # Optional. Default type is "post". custom_settings: _es_settings.yml # Optional. No default. Relative to your src folder custom_mappings: _es_mappings.yml # Optional. No default. Relative to your src folder - production_only: false # Optional. Defaults to false. + environments: # Optional. Set environments where Searchyll should run + - 'production' # Default runs on all environment if empty + - 'development' # If set will only run in speccified environments ``` ### Custom Settings File Example diff --git a/lib/searchyll/configuration.rb b/lib/searchyll/configuration.rb index 511377d..0eb79d6 100644 --- a/lib/searchyll/configuration.rb +++ b/lib/searchyll/configuration.rb @@ -80,7 +80,12 @@ def elasticsearch_settings_path end def should_execute_in_current_environment? - site.config['elasticsearch']['production_only'] == true || site.config['environment'] == "production" + settings = site.config['elasticsearch'] + + return true if settings['environments'].nil? + return true unless settings['environments'].is_a?(Array) + + site.config['elasticsearch']['environments'].include? site.config['environment'] end def elasticsearch_mapping diff --git a/spec/searchyll/configuration_spec.rb b/spec/searchyll/configuration_spec.rb index b2dceff..0174177 100644 --- a/spec/searchyll/configuration_spec.rb +++ b/spec/searchyll/configuration_spec.rb @@ -10,11 +10,10 @@ def initialize(config) describe Searchyll::Configuration do - it 'is expected to return true when production and flag not set' do + it 'is expected to return true when production no environment spessified' do site_config = { 'environment' => 'production', 'elasticsearch' => { - 'production_only' => false } } site = TestSite.new site_config @@ -22,11 +21,11 @@ def initialize(config) expect(conf.should_execute_in_current_environment?).to eq(true) end - it 'is expected to return true when production and flag is set' do + it 'is expected to return true when production and environment is nil' do site_config = { 'environment' => 'production', 'elasticsearch' => { - 'production_only' => true + 'environments' => nil } } site = TestSite.new site_config @@ -34,27 +33,40 @@ def initialize(config) expect(conf.should_execute_in_current_environment?).to eq(true) end - it 'is expected to return false when not production and flag is not set' do + it 'is expected to return true when production and environment is not a array' do site_config = { - 'environment' => 'not_production', + 'environment' => 'production', 'elasticsearch' => { - 'production_only' => false + 'environments' => true } } site = TestSite.new site_config conf = Searchyll::Configuration.new site - expect(conf.should_execute_in_current_environment?).to eq(false) + expect(conf.should_execute_in_current_environment?).to eq(true) end - it 'is expected to return false when not production and flag is set' do + it 'is expected to return false when production and different environment spessified' do site_config = { - 'environment' => 'not_production', + 'environment' => 'production', 'elasticsearch' => { - 'production_only' => true + 'environments' => ['dev'] } } site = TestSite.new site_config conf = Searchyll::Configuration.new site expect(conf.should_execute_in_current_environment?).to eq(false) end + + it 'is expected to return true when production and several environment spessified' do + site_config = { + 'environment' => 'production', + 'elasticsearch' => { + 'environments' => ['dev', 'test', 'stage', 'production'] + } + } + site = TestSite.new site_config + conf = Searchyll::Configuration.new site + expect(conf.should_execute_in_current_environment?).to eq(true) + end + end From 2a88c31371933e611a558782c685314495e1da1d Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 16 Jul 2020 14:44:00 +0200 Subject: [PATCH 16/19] Update debug statement --- lib/searchyll.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/searchyll.rb b/lib/searchyll.rb index b3d65fe..7068145 100644 --- a/lib/searchyll.rb +++ b/lib/searchyll.rb @@ -18,7 +18,7 @@ indexers[site] = Searchyll::Indexer.new(config) indexers[site].start else - puts "Not running outside of production" + puts config['elasticsearch']['environments'] end else puts 'Invalid Elasticsearch configuration provided, skipping indexing...' From 5dc9a50f2d606fb8048f72f9275e5ec5a55b0bf1 Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 16 Jul 2020 14:57:36 +0200 Subject: [PATCH 17/19] Simplify configuration access Update debug statement in searchyll.rb --- lib/searchyll.rb | 2 +- lib/searchyll/configuration.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/searchyll.rb b/lib/searchyll.rb index 7068145..853389b 100644 --- a/lib/searchyll.rb +++ b/lib/searchyll.rb @@ -18,7 +18,7 @@ indexers[site] = Searchyll::Indexer.new(config) indexers[site].start else - puts config['elasticsearch']['environments'] + puts "Not running in #{config['elasticsearch']['environments']}" end else puts 'Invalid Elasticsearch configuration provided, skipping indexing...' diff --git a/lib/searchyll/configuration.rb b/lib/searchyll/configuration.rb index 0eb79d6..0b1286d 100644 --- a/lib/searchyll/configuration.rb +++ b/lib/searchyll/configuration.rb @@ -85,7 +85,7 @@ def should_execute_in_current_environment? return true if settings['environments'].nil? return true unless settings['environments'].is_a?(Array) - site.config['elasticsearch']['environments'].include? site.config['environment'] + settings['environments'].include? site.config['environment'] end def elasticsearch_mapping From 0a9a8a71817c4a75da5148a4f1c9dbd23876a1a9 Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 16 Jul 2020 15:12:05 +0200 Subject: [PATCH 18/19] Update debug statement --- lib/searchyll.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/searchyll.rb b/lib/searchyll.rb index 853389b..281b9b6 100644 --- a/lib/searchyll.rb +++ b/lib/searchyll.rb @@ -18,7 +18,7 @@ indexers[site] = Searchyll::Indexer.new(config) indexers[site].start else - puts "Not running in #{config['elasticsearch']['environments']}" + puts "Only running in #{config['elasticsearch']['environments']}" end else puts 'Invalid Elasticsearch configuration provided, skipping indexing...' From d11aeb3b79c4031aa5ba8760a3d8fa83c6f4b7ef Mon Sep 17 00:00:00 2001 From: Daniel Granerud <42067409+NullableInt@users.noreply.github.com> Date: Mon, 17 Aug 2020 13:48:42 +0200 Subject: [PATCH 19/19] Update searchyll.rb Fix null error --- lib/searchyll.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/searchyll.rb b/lib/searchyll.rb index 281b9b6..a633d76 100644 --- a/lib/searchyll.rb +++ b/lib/searchyll.rb @@ -18,7 +18,7 @@ indexers[site] = Searchyll::Indexer.new(config) indexers[site].start else - puts "Only running in #{config['elasticsearch']['environments']}" + puts "Only running in #{site.config['elasticsearch']['environments']}" end else puts 'Invalid Elasticsearch configuration provided, skipping indexing...'