thinking-sphinx 4.2.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +6 -12
- data/CHANGELOG.markdown +16 -0
- data/README.textile +2 -2
- data/bin/loadsphinx +45 -53
- data/lib/thinking_sphinx/commands/base.rb +4 -0
- data/lib/thinking_sphinx/commands/prepare.rb +2 -0
- data/lib/thinking_sphinx/commands/running.rb +2 -0
- data/lib/thinking_sphinx/commands/start_attached.rb +1 -1
- data/lib/thinking_sphinx/commands/start_detached.rb +1 -1
- data/lib/thinking_sphinx/configuration.rb +5 -2
- data/lib/thinking_sphinx/configuration/distributed_indices.rb +1 -1
- data/lib/thinking_sphinx/core/index.rb +4 -1
- data/lib/thinking_sphinx/distributed/index.rb +13 -3
- data/spec/acceptance/facets_spec.rb +14 -0
- data/spec/thinking_sphinx/commands/prepare_spec.rb +9 -1
- data/spec/thinking_sphinx/commands/running_spec.rb +30 -0
- data/spec/thinking_sphinx/commands/start_detached_spec.rb +11 -1
- data/spec/thinking_sphinx/configuration_spec.rb +15 -2
- data/thinking-sphinx.gemspec +1 -1
- metadata +6 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 30fe9d6940dc5f385310346374829bc1ff941332583060ad549ea8675a6a34ce
         | 
| 4 | 
            +
              data.tar.gz: 4b5a25fe1120cba82bf9bd6b9f80be7e1d5175dce887d8acaffc3ba1da78e458
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: f8f25c99b61c6bf80f9a81eb71ab1c1a6af005009099cd18c7ef1a13e694f4e65b7ddc3d654167033ecf0fac072c91d88864d6ab5cf44c5f00fea69447195ce2
         | 
| 7 | 
            +
              data.tar.gz: b78abfa34ebcfb24ed65e99b07dfb04dc545cc2be74c994a9b786a507b8b69bfa46afce05c74830dfde5bebc6b823e0d44b3073637967090b35ffe85c9629b41
         | 
    
        data/.travis.yml
    CHANGED
    
    | @@ -1,15 +1,9 @@ | |
| 1 1 | 
             
            language: ruby
         | 
| 2 2 | 
             
            rvm:
         | 
| 3 3 | 
             
            - 2.3.8
         | 
| 4 | 
            -
            - 2.4. | 
| 5 | 
            -
            - 2.5. | 
| 6 | 
            -
            - 2.6. | 
| 7 | 
            -
            addons:
         | 
| 8 | 
            -
              apt:
         | 
| 9 | 
            -
                packages:
         | 
| 10 | 
            -
                - cmake
         | 
| 11 | 
            -
                - bison
         | 
| 12 | 
            -
                - flex
         | 
| 4 | 
            +
            - 2.4.6
         | 
| 5 | 
            +
            - 2.5.5
         | 
| 6 | 
            +
            - 2.6.2
         | 
| 13 7 | 
             
            before_install:
         | 
| 14 8 | 
             
            - pip install --upgrade --user awscli
         | 
| 15 9 | 
             
            - gem update --system
         | 
| @@ -23,7 +17,6 @@ before_script: | |
| 23 17 | 
             
            script: bundle exec appraisal rspec
         | 
| 24 18 | 
             
            env:
         | 
| 25 19 | 
             
              global:
         | 
| 26 | 
            -
              - SPHINX_BIN=ext/sphinx/bin/
         | 
| 27 20 | 
             
              - secure: cUPinkilBafqDSPsTkl/PXYc2aXNKUQKXGK8poBBMqKN9/wjfJx1DWgtowDKalekdZELxDhc85Ye3bL1xlW4nLjOu+U6Tkt8eNw2Nhs1flodHzA/RyENdBLr/tBHt43EjkrDehZx5sBHmWQY4miHs8AJz0oKO9Ae2inTOHx9Iuc=
         | 
| 28 21 | 
             
              matrix:
         | 
| 29 22 | 
             
              - DATABASE=mysql2 SPHINX_VERSION=2.1.9 SPHINX_ENGINE=sphinx
         | 
| @@ -37,11 +30,12 @@ env: | |
| 37 30 | 
             
              - DATABASE=postgresql SPHINX_VERSION=2.6.4 SPHINX_ENGINE=manticore
         | 
| 38 31 | 
             
              - DATABASE=mysql2 SPHINX_VERSION=2.7.5 SPHINX_ENGINE=manticore
         | 
| 39 32 | 
             
              - DATABASE=postgresql SPHINX_VERSION=2.7.5 SPHINX_ENGINE=manticore
         | 
| 40 | 
            -
              - DATABASE=mysql2 SPHINX_VERSION=2.8. | 
| 41 | 
            -
              - DATABASE=postgresql SPHINX_VERSION=2.8. | 
| 33 | 
            +
              - DATABASE=mysql2 SPHINX_VERSION=2.8.2 SPHINX_ENGINE=manticore
         | 
| 34 | 
            +
              - DATABASE=postgresql SPHINX_VERSION=2.8.2 SPHINX_ENGINE=manticore
         | 
| 42 35 | 
             
              # - DATABASE=postgresql SPHINX_VERSION=3.1.1 SPHINX_ENGINE=sphinx
         | 
| 43 36 | 
             
            sudo: false
         | 
| 44 37 | 
             
            addons:
         | 
| 45 38 | 
             
              postgresql: '9.4'
         | 
| 46 39 | 
             
            services:
         | 
| 40 | 
            +
            - mysql
         | 
| 47 41 | 
             
            - postgresql
         | 
    
        data/CHANGELOG.markdown
    CHANGED
    
    | @@ -2,8 +2,24 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            All notable changes to this project (at least, from v3.0.0 onwards) are documented in this file.
         | 
| 4 4 |  | 
| 5 | 
            +
            ## 4.3.0 - 2019-05-18
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            [Release Notes](https://github.com/pat/thinking-sphinx/releases/tag/v4.3.0)
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            ### Added
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            * Allow overriding of Sphinx's running state, which is useful when Sphinx commands are interacting with a remote Sphinx daemon. As per discussions in [#1131](https://github.com/pat/thinking-sphinx/pull/1124).
         | 
| 12 | 
            +
            * Allow skipping of directory creation, as per discussions in [#1131](https://github.com/pat/thinking-sphinx/pull/1131).
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            ### Fixed
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            * Use ActiveSupport's lock monitor where possible (Rails 5.1.5 onwards) to avoid database deadlocks. Essential investigation by [Jonathan del Strother](https://github.com/jdelstrother) ([#1132](https://github.com/pat/thinking-sphinx/pull/1132)).
         | 
| 17 | 
            +
            * Allow facet searching on distributed indices ([#1135](https://github.com/pat/thinking-sphinx/pull/1132)).
         | 
| 18 | 
            +
             | 
| 5 19 | 
             
            ## 4.2.0 - 2019-03-09
         | 
| 6 20 |  | 
| 21 | 
            +
            [Release Notes](https://github.com/pat/thinking-sphinx/releases/tag/v4.2.0)
         | 
| 22 | 
            +
             | 
| 7 23 | 
             
            ### Added
         | 
| 8 24 |  | 
| 9 25 | 
             
            * Allow changing the default encoding for MySQL database connections from utf8 to something else via the `mysql_encoding` setting in `config/thinking_sphinx.yml`. In the next significant release, the default will change to utf8mb4 (which is supported in MySQL 5.5.3 and newer).
         | 
    
        data/README.textile
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            h1. Thinking Sphinx
         | 
| 2 2 |  | 
| 3 | 
            -
            Thinking Sphinx is a library for connecting ActiveRecord to the Sphinx full-text search tool, and integrates closely with Rails (but also works with other Ruby web frameworks). The current release is v4. | 
| 3 | 
            +
            Thinking Sphinx is a library for connecting ActiveRecord to the Sphinx full-text search tool, and integrates closely with Rails (but also works with other Ruby web frameworks). The current release is v4.3.0.
         | 
| 4 4 |  | 
| 5 5 | 
             
            h2. Upgrading
         | 
| 6 6 |  | 
| @@ -14,7 +14,7 @@ It's a gem, so install it like you would any other gem. You will also need to sp | |
| 14 14 |  | 
| 15 15 | 
             
            <pre><code>gem 'mysql2',          '~> 0.3',    :platform => :ruby
         | 
| 16 16 | 
             
            gem 'jdbc-mysql',      '~> 5.1.35', :platform => :jruby
         | 
| 17 | 
            -
            gem 'thinking-sphinx', '~> 4. | 
| 17 | 
            +
            gem 'thinking-sphinx', '~> 4.3'</code></pre>
         | 
| 18 18 |  | 
| 19 19 | 
             
            The MySQL gems mentioned are required for connecting to Sphinx, so please include it even when you're using PostgreSQL for your database. If you're using JRuby with a version of Sphinx prior to 2.2.11, there is "currently an issue with Sphinx and jdbc-mysql 5.1.36 or newer":http://sphinxsearch.com/forum/view.html?id=13939, so you'll need to stick to nothing more recent than 5.1.35, or upgrade Sphinx.
         | 
| 20 20 |  | 
    
        data/bin/loadsphinx
    CHANGED
    
    | @@ -2,65 +2,57 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            version=$1
         | 
| 4 4 | 
             
            engine=$2
         | 
| 5 | 
            -
            name="$engine-$version"
         | 
| 6 | 
            -
            bucket="thinking-sphinx"
         | 
| 7 | 
            -
            directory="ext/sphinx"
         | 
| 8 | 
            -
            prefix="`pwd`/$directory"
         | 
| 9 | 
            -
            file="ext/$name.tar.gz"
         | 
| 10 5 |  | 
| 11 | 
            -
             | 
| 12 | 
            -
               | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
                 | 
| 6 | 
            +
            load_sphinx () {
         | 
| 7 | 
            +
              case $version in
         | 
| 8 | 
            +
                2.1.9)
         | 
| 9 | 
            +
                  url="http://sphinxsearch.com/files/sphinxsearch_2.1.9-release-0ubuntu11~trusty_amd64.deb"
         | 
| 10 | 
            +
                  format="deb";;
         | 
| 11 | 
            +
                2.2.11)
         | 
| 12 | 
            +
                  url="http://sphinxsearch.com/files/sphinxsearch_2.2.11-release-1~trusty_amd64.deb"
         | 
| 13 | 
            +
                  format="deb";;
         | 
| 14 | 
            +
                3.0.3)
         | 
| 15 | 
            +
                  url="http://sphinxsearch.com/files/sphinx-3.0.3-facc3fb-linux-amd64.tar.gz"
         | 
| 16 | 
            +
                  format="gz";;
         | 
| 17 | 
            +
                3.1.1)
         | 
| 18 | 
            +
                  url="http://sphinxsearch.com/files/sphinx-3.1.1-612d99f-linux-amd64.tar.gz"
         | 
| 19 | 
            +
                  format="gz";;
         | 
| 20 | 
            +
                *)
         | 
| 21 | 
            +
                  echo "No Sphinx version $version available"
         | 
| 22 | 
            +
                  exit 1;;
         | 
| 23 | 
            +
              esac
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              if [ "$format" == "deb" ]; then
         | 
| 26 | 
            +
                curl --location $url -o sphinx.deb
         | 
| 27 | 
            +
                sudo apt-get install ./sphinx.deb
         | 
| 20 28 | 
             
              else
         | 
| 21 | 
            -
                 | 
| 29 | 
            +
                curl $url -o sphinx.tar.gz
         | 
| 30 | 
            +
                tar -zxvf sphinx.tar.gz
         | 
| 31 | 
            +
                sudo mv sphinx-$version/bin/* /usr/local/bin/.
         | 
| 22 32 | 
             
              fi
         | 
| 23 33 | 
             
            }
         | 
| 24 34 |  | 
| 25 | 
            -
             | 
| 26 | 
            -
               | 
| 27 | 
            -
             | 
| 28 | 
            -
               | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
               | 
| 39 | 
            -
             | 
| 40 | 
            -
               | 
| 41 | 
            -
               | 
| 42 | 
            -
              cmake -D WITH_MYSQL=TRUE -D WITH_PGSQL=TRUE -D DISABLE_TESTING=TRUE -D CMAKE_INSTALL_PREFIX=$prefix ..
         | 
| 43 | 
            -
              make -j4
         | 
| 44 | 
            -
              make install
         | 
| 45 | 
            -
              cd ../..
         | 
| 46 | 
            -
              rm -rf $engine
         | 
| 35 | 
            +
            load_manticore () {
         | 
| 36 | 
            +
              url="https://github.com/manticoresoftware/manticore/releases/download/$version/manticore_$version.deb"
         | 
| 37 | 
            +
             | 
| 38 | 
            +
              case $version in
         | 
| 39 | 
            +
                2.6.4)
         | 
| 40 | 
            +
                  url="https://github.com/manticoresoftware/manticoresearch/releases/download/2.6.4/manticore_2.6.4-180503-37308c3-release-stemmer.trusty_amd64-bin.deb";;
         | 
| 41 | 
            +
                2.7.5)
         | 
| 42 | 
            +
                  url="https://github.com/manticoresoftware/manticoresearch/releases/download/2.7.5/manticore_2.7.5-181204-0f016406-release-stemmer.trusty_amd64-bin.deb";;
         | 
| 43 | 
            +
                2.8.2)
         | 
| 44 | 
            +
                  url="https://github.com/manticoresoftware/manticoresearch/releases/download/2.8.2/manticore_2.8.2-190402-4e81114-release-stemmer.trusty_amd64-bin.deb";;
         | 
| 45 | 
            +
                *)
         | 
| 46 | 
            +
                  echo "No Manticore version $version available"
         | 
| 47 | 
            +
                  exit 1;;
         | 
| 48 | 
            +
              esac
         | 
| 49 | 
            +
             | 
| 50 | 
            +
              curl --location $url -o manticore.deb
         | 
| 51 | 
            +
              sudo apt-get install ./manticore.deb
         | 
| 47 52 | 
             
            }
         | 
| 48 53 |  | 
| 49 | 
            -
             | 
| 50 | 
            -
               | 
| 51 | 
            -
              curl -o $file http://$bucket.s3.amazonaws.com/bincaches/$name.tar.gz
         | 
| 52 | 
            -
              tar -zxf $file
         | 
| 53 | 
            -
            }
         | 
| 54 | 
            -
             | 
| 55 | 
            -
            push_cache () {
         | 
| 56 | 
            -
              tar -czf $file $directory
         | 
| 57 | 
            -
              aws s3 cp $file s3://$bucket/bincaches/$name.tar.gz --acl public-read
         | 
| 58 | 
            -
            }
         | 
| 59 | 
            -
             | 
| 60 | 
            -
            if curl -i --head --fail http://$bucket.s3.amazonaws.com/bincaches/$name.tar.gz
         | 
| 61 | 
            -
            then
         | 
| 62 | 
            -
              load_cache
         | 
| 54 | 
            +
            if [ "$engine" == "sphinx" ]; then
         | 
| 55 | 
            +
              load_sphinx
         | 
| 63 56 | 
             
            else
         | 
| 64 | 
            -
               | 
| 65 | 
            -
              push_cache
         | 
| 57 | 
            +
              load_manticore
         | 
| 66 58 | 
             
            fi
         | 
| @@ -2,7 +2,7 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            class ThinkingSphinx::Commands::StartAttached < ThinkingSphinx::Commands::Base
         | 
| 4 4 | 
             
              def call
         | 
| 5 | 
            -
                FileUtils.mkdir_p configuration.indices_location
         | 
| 5 | 
            +
                FileUtils.mkdir_p configuration.indices_location unless skip_directories?
         | 
| 6 6 |  | 
| 7 7 | 
             
                unless pid = fork
         | 
| 8 8 | 
             
                  controller.start :verbose => options[:verbose], :nodetach => true
         | 
| @@ -2,7 +2,7 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            class ThinkingSphinx::Commands::StartDetached < ThinkingSphinx::Commands::Base
         | 
| 4 4 | 
             
              def call
         | 
| 5 | 
            -
                FileUtils.mkdir_p configuration.indices_location
         | 
| 5 | 
            +
                FileUtils.mkdir_p configuration.indices_location unless skip_directories?
         | 
| 6 6 |  | 
| 7 7 | 
             
                result = controller.start :verbose => options[:verbose]
         | 
| 8 8 |  | 
| @@ -10,7 +10,8 @@ class ThinkingSphinx::Configuration < Riddle::Configuration | |
| 10 10 |  | 
| 11 11 | 
             
              delegate :environment, :to => :framework
         | 
| 12 12 |  | 
| 13 | 
            -
              @@mutex =  | 
| 13 | 
            +
              @@mutex = defined?(ActiveSupport::Concurrency::LoadInterlockAwareMonitor) ?
         | 
| 14 | 
            +
                ActiveSupport::Concurrency::LoadInterlockAwareMonitor.new : Mutex.new
         | 
| 14 15 |  | 
| 15 16 | 
             
              def initialize
         | 
| 16 17 | 
             
                super
         | 
| @@ -105,7 +106,9 @@ class ThinkingSphinx::Configuration < Riddle::Configuration | |
| 105 106 | 
             
              end
         | 
| 106 107 |  | 
| 107 108 | 
             
              def render_to_file
         | 
| 108 | 
            -
                 | 
| 109 | 
            +
                unless settings['skip_directory_creation'] || searchd.binlog_path.blank?
         | 
| 110 | 
            +
                  FileUtils.mkdir_p searchd.binlog_path
         | 
| 111 | 
            +
                end
         | 
| 109 112 |  | 
| 110 113 | 
             
                open(configuration_file, 'w') { |file| file.write render }
         | 
| 111 114 | 
             
              end
         | 
| @@ -21,7 +21,7 @@ class ThinkingSphinx::Configuration::DistributedIndices | |
| 21 21 |  | 
| 22 22 | 
             
              def distributed_index(reference, indices)
         | 
| 23 23 | 
             
                index = ThinkingSphinx::Distributed::Index.new reference
         | 
| 24 | 
            -
                index. | 
| 24 | 
            +
                index.local_index_objects = indices
         | 
| 25 25 | 
             
                index
         | 
| 26 26 | 
             
              end
         | 
| 27 27 |  | 
| @@ -98,7 +98,10 @@ module ThinkingSphinx::Core::Index | |
| 98 98 | 
             
              end
         | 
| 99 99 |  | 
| 100 100 | 
             
              def set_path
         | 
| 101 | 
            -
                 | 
| 101 | 
            +
                unless config.settings['skip_directory_creation']
         | 
| 102 | 
            +
                  FileUtils.mkdir_p path_prefix
         | 
| 103 | 
            +
                end
         | 
| 104 | 
            +
             | 
| 102 105 | 
             
                @path = File.join path_prefix, name
         | 
| 103 106 | 
             
              end
         | 
| 104 107 | 
             
            end
         | 
| @@ -3,11 +3,12 @@ | |
| 3 3 | 
             
            class ThinkingSphinx::Distributed::Index <
         | 
| 4 4 | 
             
              Riddle::Configuration::DistributedIndex
         | 
| 5 5 |  | 
| 6 | 
            -
              attr_reader :reference, :options
         | 
| 6 | 
            +
              attr_reader :reference, :options, :local_index_objects
         | 
| 7 7 |  | 
| 8 8 | 
             
              def initialize(reference)
         | 
| 9 | 
            -
                @reference | 
| 10 | 
            -
                @options | 
| 9 | 
            +
                @reference           = reference
         | 
| 10 | 
            +
                @options             = {}
         | 
| 11 | 
            +
                @local_index_objects = []
         | 
| 11 12 |  | 
| 12 13 | 
             
                super reference.to_s.gsub('/', '_')
         | 
| 13 14 | 
             
              end
         | 
| @@ -20,6 +21,15 @@ class ThinkingSphinx::Distributed::Index < | |
| 20 21 | 
             
                true
         | 
| 21 22 | 
             
              end
         | 
| 22 23 |  | 
| 24 | 
            +
              def facets
         | 
| 25 | 
            +
                local_index_objects.collect(&:facets).flatten
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              def local_index_objects=(indices)
         | 
| 29 | 
            +
                self.local_indices = indices.collect(&:name)
         | 
| 30 | 
            +
                @local_index_objects = indices
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
             | 
| 23 33 | 
             
              def model
         | 
| 24 34 | 
             
                @model ||= reference.to_s.camelize.constantize
         | 
| 25 35 | 
             
              end
         | 
| @@ -124,4 +124,18 @@ describe 'Faceted searching', :live => true do | |
| 124 124 | 
             
                  calls += 1
         | 
| 125 125 | 
             
                end
         | 
| 126 126 | 
             
              end
         | 
| 127 | 
            +
             | 
| 128 | 
            +
              it "can be called on distributed indices" do
         | 
| 129 | 
            +
                blue  = Colour.create! :name => 'blue'
         | 
| 130 | 
            +
                green = Colour.create! :name => 'green'
         | 
| 131 | 
            +
             | 
| 132 | 
            +
                Tee.create! :colour => blue
         | 
| 133 | 
            +
                Tee.create! :colour => blue
         | 
| 134 | 
            +
                Tee.create! :colour => green
         | 
| 135 | 
            +
                index
         | 
| 136 | 
            +
             | 
| 137 | 
            +
                expect(Tee.facets(:indices => ["tee"]).to_hash[:colour_id]).to eq({
         | 
| 138 | 
            +
                  blue.id => 2, green.id => 1
         | 
| 139 | 
            +
                })
         | 
| 140 | 
            +
              end
         | 
| 127 141 | 
             
            end
         | 
| @@ -7,7 +7,7 @@ RSpec.describe ThinkingSphinx::Commands::Prepare do | |
| 7 7 | 
             
                configuration, {}, stream
         | 
| 8 8 | 
             
              ) }
         | 
| 9 9 | 
             
              let(:configuration) { double 'configuration',
         | 
| 10 | 
            -
                :indices_location => '/path/to/indices'
         | 
| 10 | 
            +
                :indices_location => '/path/to/indices', :settings => {}
         | 
| 11 11 | 
             
              }
         | 
| 12 12 | 
             
              let(:stream)        { double :puts => nil }
         | 
| 13 13 |  | 
| @@ -20,4 +20,12 @@ RSpec.describe ThinkingSphinx::Commands::Prepare do | |
| 20 20 |  | 
| 21 21 | 
             
                command.call
         | 
| 22 22 | 
             
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              it "skips directory creation if flag is set" do
         | 
| 25 | 
            +
                configuration.settings['skip_directory_creation'] = true
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                expect(FileUtils).to_not receive(:mkdir_p)
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                command.call
         | 
| 30 | 
            +
              end
         | 
| 23 31 | 
             
            end
         | 
| @@ -0,0 +1,30 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'spec_helper'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            RSpec.describe ThinkingSphinx::Commands::Running do
         | 
| 6 | 
            +
              let(:command)    { ThinkingSphinx::Commands::Running.new(
         | 
| 7 | 
            +
                configuration, {}, stream
         | 
| 8 | 
            +
              ) }
         | 
| 9 | 
            +
              let(:configuration) {
         | 
| 10 | 
            +
                double 'configuration', :controller => controller, :settings => {}
         | 
| 11 | 
            +
              }
         | 
| 12 | 
            +
              let(:stream)        { double :puts => nil }
         | 
| 13 | 
            +
              let(:controller)    { double 'controller', :running? => false }
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              it 'returns true when Sphinx is running' do
         | 
| 16 | 
            +
                allow(controller).to receive(:running?).and_return(true)
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                expect(command.call).to eq(true)
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              it 'returns false when Sphinx is not running' do
         | 
| 22 | 
            +
                expect(command.call).to eq(false)
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              it 'returns true if the flag is set' do
         | 
| 26 | 
            +
                configuration.settings['skip_running_check'] = true
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                expect(command.call).to eq(true)
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
            end
         | 
| @@ -6,7 +6,9 @@ RSpec.describe ThinkingSphinx::Commands::StartDetached do | |
| 6 6 | 
             
              let(:command)    {
         | 
| 7 7 | 
             
                ThinkingSphinx::Commands::StartDetached.new(configuration, {}, stream)
         | 
| 8 8 | 
             
              }
         | 
| 9 | 
            -
              let(:configuration) { | 
| 9 | 
            +
              let(:configuration) {
         | 
| 10 | 
            +
                double 'configuration', :controller => controller, :settings => {}
         | 
| 11 | 
            +
              }
         | 
| 10 12 | 
             
              let(:controller)    { double 'controller', :start => result, :pid => 101 }
         | 
| 11 13 | 
             
              let(:result)        { double 'result', :command => 'start', :status => 1,
         | 
| 12 14 | 
             
                :output => '' }
         | 
| @@ -29,6 +31,14 @@ RSpec.describe ThinkingSphinx::Commands::StartDetached do | |
| 29 31 | 
             
                command.call
         | 
| 30 32 | 
             
              end
         | 
| 31 33 |  | 
| 34 | 
            +
              it "skips directory creation if flag is set" do
         | 
| 35 | 
            +
                configuration.settings['skip_directory_creation'] = true
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                expect(FileUtils).to_not receive(:mkdir_p)
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                command.call
         | 
| 40 | 
            +
              end
         | 
| 41 | 
            +
             | 
| 32 42 | 
             
              it "starts the daemon" do
         | 
| 33 43 | 
             
                expect(controller).to receive(:start)
         | 
| 34 44 |  | 
| @@ -342,10 +342,13 @@ describe ThinkingSphinx::Configuration do | |
| 342 342 | 
             
              end
         | 
| 343 343 |  | 
| 344 344 | 
             
              describe '#render_to_file' do
         | 
| 345 | 
            -
                let(:file) | 
| 346 | 
            -
                let(:output) | 
| 345 | 
            +
                let(:file)             { double('file') }
         | 
| 346 | 
            +
                let(:output)           { config.render }
         | 
| 347 | 
            +
                let(:skip_directories) { false }
         | 
| 347 348 |  | 
| 348 349 | 
             
                before :each do
         | 
| 350 | 
            +
                  write_configuration('skip_directory_creation' => skip_directories)
         | 
| 351 | 
            +
             | 
| 349 352 | 
             
                  allow(config.searchd).to receive_messages :render => 'searchd { }'
         | 
| 350 353 | 
             
                end
         | 
| 351 354 |  | 
| @@ -376,6 +379,16 @@ describe ThinkingSphinx::Configuration do | |
| 376 379 |  | 
| 377 380 | 
             
                  config.render_to_file
         | 
| 378 381 | 
             
                end
         | 
| 382 | 
            +
             | 
| 383 | 
            +
                context 'skipping directory creation' do
         | 
| 384 | 
            +
                  let(:skip_directories) { true }
         | 
| 385 | 
            +
             | 
| 386 | 
            +
                  it "skips creating a directory when flag is set" do
         | 
| 387 | 
            +
                    expect(FileUtils).not_to receive(:mkdir_p)
         | 
| 388 | 
            +
             | 
| 389 | 
            +
                    config.render_to_file
         | 
| 390 | 
            +
                  end
         | 
| 391 | 
            +
                end
         | 
| 379 392 | 
             
              end
         | 
| 380 393 |  | 
| 381 394 | 
             
              describe '#searchd' do
         | 
    
        data/thinking-sphinx.gemspec
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: thinking-sphinx
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 4. | 
| 4 | 
            +
              version: 4.3.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Pat Allan
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2019- | 
| 11 | 
            +
            date: 2019-05-18 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activerecord
         | 
| @@ -454,6 +454,7 @@ files: | |
| 454 454 | 
             
            - spec/thinking_sphinx/commands/merge_and_update_spec.rb
         | 
| 455 455 | 
             
            - spec/thinking_sphinx/commands/merge_spec.rb
         | 
| 456 456 | 
             
            - spec/thinking_sphinx/commands/prepare_spec.rb
         | 
| 457 | 
            +
            - spec/thinking_sphinx/commands/running_spec.rb
         | 
| 457 458 | 
             
            - spec/thinking_sphinx/commands/start_detached_spec.rb
         | 
| 458 459 | 
             
            - spec/thinking_sphinx/commands/stop_spec.rb
         | 
| 459 460 | 
             
            - spec/thinking_sphinx/configuration/minimum_fields_spec.rb
         | 
| @@ -520,7 +521,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 520 521 | 
             
                - !ruby/object:Gem::Version
         | 
| 521 522 | 
             
                  version: '0'
         | 
| 522 523 | 
             
            requirements: []
         | 
| 523 | 
            -
             | 
| 524 | 
            +
            rubyforge_project: thinking-sphinx
         | 
| 525 | 
            +
            rubygems_version: 2.7.6.2
         | 
| 524 526 | 
             
            signing_key: 
         | 
| 525 527 | 
             
            specification_version: 4
         | 
| 526 528 | 
             
            summary: A smart wrapper over Sphinx for ActiveRecord
         | 
| @@ -630,6 +632,7 @@ test_files: | |
| 630 632 | 
             
            - spec/thinking_sphinx/commands/merge_and_update_spec.rb
         | 
| 631 633 | 
             
            - spec/thinking_sphinx/commands/merge_spec.rb
         | 
| 632 634 | 
             
            - spec/thinking_sphinx/commands/prepare_spec.rb
         | 
| 635 | 
            +
            - spec/thinking_sphinx/commands/running_spec.rb
         | 
| 633 636 | 
             
            - spec/thinking_sphinx/commands/start_detached_spec.rb
         | 
| 634 637 | 
             
            - spec/thinking_sphinx/commands/stop_spec.rb
         | 
| 635 638 | 
             
            - spec/thinking_sphinx/configuration/minimum_fields_spec.rb
         |