elasticsearch-rails 5.1.0 → 6.0.0.pre
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/Gemfile +5 -0
- data/elasticsearch-rails.gemspec +2 -3
- data/lib/elasticsearch/rails/instrumentation/railtie.rb +0 -4
- data/lib/elasticsearch/rails/lograge.rb +0 -4
- data/lib/elasticsearch/rails/tasks/import.rb +1 -1
- data/lib/elasticsearch/rails/version.rb +1 -1
- data/lib/rails/templates/01-basic.rb +46 -67
- data/lib/rails/templates/02-pretty.rb +35 -15
- data/lib/rails/templates/03-expert.rb +13 -1
- data/lib/rails/templates/index.html.dsl.erb +2 -2
- data/lib/rails/templates/index.html.erb +2 -2
- data/lib/rails/templates/search.css +4 -0
- data/lib/rails/templates/search_controller_test.dsl.rb +1 -1
- data/lib/rails/templates/search_controller_test.rb +1 -1
- data/lib/rails/templates/searchable.rb +1 -1
- data/test/test_helper.rb +1 -1
- metadata +16 -30
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 3e4eb8b0cbedc25e34bb7e26350e43d3fb65ca8ea823f8d594d6165e3333d0b2
         | 
| 4 | 
            +
              data.tar.gz: c0dde79903756818e093f7dded8336fb7ba0191551b4b512d56ad48bf8bdddf8
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 6a614150917fd0c830da52371abb29bbf62135eeb71d35190d363f10ed0cf41b759fe5738ef65718f73f39dbc84a356b6b9b0102224c7f57eb186bc5a1a56855
         | 
| 7 | 
            +
              data.tar.gz: 6b8f12b081b0f3f3d8c7d814d6dd82b3381eedb170300dc6050c0bf4ce1580082980bce40ebd22be0918934d276defdc5f4228f0237a8836f8e81b73c7edabe9
         | 
    
        data/Gemfile
    CHANGED
    
    | @@ -7,3 +7,8 @@ gemspec | |
| 7 7 | 
             
            # if File.exists? File.expand_path("../../elasticsearch-model", __FILE__)
         | 
| 8 8 | 
             
            #   gem 'elasticsearch-model', :path => File.expand_path("../../elasticsearch-model", __FILE__), :require => true
         | 
| 9 9 | 
             
            # end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
             | 
| 12 | 
            +
             | 
| 13 | 
            +
            gem 'elasticsearch-model', :path => File.expand_path("../../elasticsearch-model", __FILE__), :require => false
         | 
| 14 | 
            +
            gem 'elasticsearch-persistence', :path => File.expand_path("../../elasticsearch-persistence", __FILE__), :require => false
         | 
    
        data/elasticsearch-rails.gemspec
    CHANGED
    
    | @@ -27,9 +27,7 @@ Gem::Specification.new do |s| | |
| 27 27 | 
             
              s.add_development_dependency "rake", "~> 11.1"
         | 
| 28 28 |  | 
| 29 29 | 
             
              s.add_development_dependency "elasticsearch-extensions"
         | 
| 30 | 
            -
              s.add_development_dependency "elasticsearch-model"
         | 
| 31 30 |  | 
| 32 | 
            -
              s.add_development_dependency "oj"
         | 
| 33 31 | 
             
              s.add_development_dependency "rails",  ">= 3.1"
         | 
| 34 32 |  | 
| 35 33 | 
             
              s.add_development_dependency "lograge"
         | 
| @@ -40,7 +38,8 @@ Gem::Specification.new do |s| | |
| 40 38 | 
             
              s.add_development_dependency "mocha"
         | 
| 41 39 | 
             
              s.add_development_dependency "turn"
         | 
| 42 40 | 
             
              s.add_development_dependency "yard"
         | 
| 43 | 
            -
              s.add_development_dependency " | 
| 41 | 
            +
              s.add_development_dependency "oj" unless defined?(JRUBY_VERSION)
         | 
| 42 | 
            +
              s.add_development_dependency "ruby-prof" unless defined?(JRUBY_VERSION)
         | 
| 44 43 | 
             
              s.add_development_dependency "pry"
         | 
| 45 44 |  | 
| 46 45 | 
             
              s.add_development_dependency "simplecov"
         | 
| @@ -16,10 +16,6 @@ module Elasticsearch | |
| 16 16 | 
             
                        include Elasticsearch::Rails::Instrumentation::Publishers::SearchRequest
         | 
| 17 17 | 
             
                      end if defined?(Elasticsearch::Model::Searching::SearchRequest)
         | 
| 18 18 |  | 
| 19 | 
            -
                      Elasticsearch::Persistence::Model::Find::SearchRequest.class_eval do
         | 
| 20 | 
            -
                        include Elasticsearch::Rails::Instrumentation::Publishers::SearchRequest
         | 
| 21 | 
            -
                      end if defined?(Elasticsearch::Persistence::Model::Find::SearchRequest)
         | 
| 22 | 
            -
             | 
| 23 19 | 
             
                      ActiveSupport.on_load(:action_controller) do
         | 
| 24 20 | 
             
                        include Elasticsearch::Rails::Instrumentation::ControllerRuntime
         | 
| 25 21 | 
             
                      end
         | 
| @@ -25,10 +25,6 @@ module Elasticsearch | |
| 25 25 | 
             
                        include Elasticsearch::Rails::Instrumentation::Publishers::SearchRequest
         | 
| 26 26 | 
             
                      end if defined?(Elasticsearch::Model::Searching::SearchRequest)
         | 
| 27 27 |  | 
| 28 | 
            -
                      Elasticsearch::Persistence::Model::Find::SearchRequest.class_eval do
         | 
| 29 | 
            -
                        include Elasticsearch::Rails::Instrumentation::Publishers::SearchRequest
         | 
| 30 | 
            -
                      end if defined?(Elasticsearch::Persistence::Model::Find::SearchRequest)
         | 
| 31 | 
            -
             | 
| 32 28 | 
             
                      ActiveSupport.on_load(:action_controller) do
         | 
| 33 29 | 
             
                        include Elasticsearch::Rails::Instrumentation::ControllerRuntime
         | 
| 34 30 | 
             
                      end
         | 
| @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            # A collection of Rake tasks to facilitate importing data from  | 
| 1 | 
            +
            # A collection of Rake tasks to facilitate importing data from your models into Elasticsearch.
         | 
| 2 2 | 
             
            #
         | 
| 3 3 | 
             
            # Add this e.g. into the `lib/tasks/elasticsearch.rake` file in your Rails application:
         | 
| 4 4 | 
             
            #
         | 
| @@ -11,7 +11,6 @@ | |
| 11 11 | 
             
            # * Git
         | 
| 12 12 | 
             
            # * Ruby  >= 1.9.3
         | 
| 13 13 | 
             
            # * Rails >= 5
         | 
| 14 | 
            -
            # * Java  >= 8 (for Elasticsearch)
         | 
| 15 14 | 
             
            #
         | 
| 16 15 | 
             
            # Usage:
         | 
| 17 16 | 
             
            # ------
         | 
| @@ -22,74 +21,54 @@ | |
| 22 21 |  | 
| 23 22 | 
             
            require 'uri'
         | 
| 24 23 | 
             
            require 'net/http'
         | 
| 25 | 
            -
             | 
| 26 | 
            -
            at_exit do
         | 
| 27 | 
            -
              pid = File.read("#{destination_root}/tmp/pids/elasticsearch.pid") rescue nil
         | 
| 28 | 
            -
              if pid
         | 
| 29 | 
            -
                say_status  "Stop", "Elasticsearch", :yellow
         | 
| 30 | 
            -
                run "kill #{pid}"
         | 
| 31 | 
            -
              end
         | 
| 32 | 
            -
            end
         | 
| 24 | 
            +
            require 'json'
         | 
| 33 25 |  | 
| 34 26 | 
             
            $elasticsearch_url = ENV.fetch('ELASTICSEARCH_URL', 'http://localhost:9200')
         | 
| 35 27 |  | 
| 36 | 
            -
            # ----- Check  | 
| 28 | 
            +
            # ----- Check for Elasticsearch -------------------------------------------------------------------
         | 
| 37 29 |  | 
| 38 | 
            -
             | 
| 39 | 
            -
            cluster_info = JSON.parse(cluster_info) if cluster_info
         | 
| 30 | 
            +
            required_elasticsearch_version = '6'
         | 
| 40 31 |  | 
| 41 | 
            -
             | 
| 42 | 
            -
               | 
| 43 | 
            -
             | 
| 44 | 
            -
                 | 
| 45 | 
            -
                 | 
| 46 | 
            -
             | 
| 32 | 
            +
            docker_command =<<-CMD.gsub(/\s{1,}/, ' ').strip
         | 
| 33 | 
            +
              docker run \
         | 
| 34 | 
            +
                --name elasticsearch-rails-searchapp \
         | 
| 35 | 
            +
                --publish 9200:9200 \
         | 
| 36 | 
            +
                --env "discovery.type=single-node" \
         | 
| 37 | 
            +
                --env "cluster.name=elasticsearch-rails" \
         | 
| 38 | 
            +
                --env "cluster.routing.allocation.disk.threshold_enabled=false" \
         | 
| 39 | 
            +
                --rm \
         | 
| 40 | 
            +
                docker.elastic.co/elasticsearch/elasticsearch-oss:6.3.0
         | 
| 41 | 
            +
            CMD
         | 
| 47 42 |  | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 51 | 
            -
             | 
| 52 | 
            -
             | 
| 53 | 
            -
             | 
| 54 | 
            -
             | 
| 55 | 
            -
               | 
| 56 | 
            -
               | 
| 57 | 
            -
             | 
| 58 | 
            -
              say_status | 
| 59 | 
            -
               | 
| 60 | 
            -
             | 
| 61 | 
            -
             | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 65 | 
            -
               | 
| 66 | 
            -
             | 
| 67 | 
            -
             | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 72 | 
            -
             | 
| 73 | 
            -
             | 
| 74 | 
            -
             | 
| 75 | 
            -
             | 
| 76 | 
            -
             | 
| 77 | 
            -
                commands = COMMAND.split("\n")
         | 
| 78 | 
            -
                exec     = commands.pop
         | 
| 79 | 
            -
                inside("vendor") do
         | 
| 80 | 
            -
                  commands.each { |command| run command }
         | 
| 81 | 
            -
                  run "(#{exec})"  # Launch Elasticsearch in subshell
         | 
| 82 | 
            -
                end
         | 
| 83 | 
            -
             | 
| 84 | 
            -
                # Wait for Elasticsearch to be up...
         | 
| 85 | 
            -
                #
         | 
| 86 | 
            -
                system <<-COMMAND
         | 
| 87 | 
            -
                  until $(curl --silent --head --fail #{$elasticsearch_url} > /dev/null 2>&1); do
         | 
| 88 | 
            -
                      printf '.'; sleep 1
         | 
| 89 | 
            -
                  done
         | 
| 90 | 
            -
                COMMAND
         | 
| 91 | 
            -
              end
         | 
| 92 | 
            -
            end unless ENV['RAILS_NO_ES_INSTALL']
         | 
| 43 | 
            +
            begin
         | 
| 44 | 
            +
              cluster_info = Net::HTTP.get(URI.parse($elasticsearch_url))
         | 
| 45 | 
            +
            rescue Errno::ECONNREFUSED => e
         | 
| 46 | 
            +
              say_status "ERROR", "Cannot connect to Elasticsearch on <#{$elasticsearch_url}>\n\n", :red
         | 
| 47 | 
            +
              say_status "", "The application requires an Elasticsearch cluster running, " +
         | 
| 48 | 
            +
                             "but no cluster has been found on <#{$elasticsearch_url}>."
         | 
| 49 | 
            +
              say_status "", "The easiest way of launching Elasticsearch is by running it with Docker (https://www.docker.com/get-docker):\n\n"
         | 
| 50 | 
            +
              say_status "", docker_command + "\n"
         | 
| 51 | 
            +
              exit(1)
         | 
| 52 | 
            +
            rescue StandardError => e
         | 
| 53 | 
            +
              say_status "ERROR", "#{e.class}: #{e.message}", :red
         | 
| 54 | 
            +
              exit(1)
         | 
| 55 | 
            +
            end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
            cluster_info = JSON.parse(cluster_info)
         | 
| 58 | 
            +
             | 
| 59 | 
            +
            unless cluster_info['version']
         | 
| 60 | 
            +
              say_status "ERROR", "Cannot determine Elasticsearch version from <#{$elasticsearch_url}>", :red
         | 
| 61 | 
            +
              say_status "", JSON.dump(cluster_info), :red
         | 
| 62 | 
            +
              exit(1)
         | 
| 63 | 
            +
            end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
            if cluster_info['version']['number'] < required_elasticsearch_version
         | 
| 66 | 
            +
              say_status "ERROR",
         | 
| 67 | 
            +
                         "The application requires Elasticsearch version #{required_elasticsearch_version} or higher, found version #{cluster_info['version']['number']}.\n\n", :red
         | 
| 68 | 
            +
              say_status "", "The easiest way of launching Elasticsearch is by running it with Docker (https://www.docker.com/get-docker):\n\n"
         | 
| 69 | 
            +
              say_status "", docker_command + "\n"
         | 
| 70 | 
            +
              exit(1)
         | 
| 71 | 
            +
            end
         | 
| 93 72 |  | 
| 94 73 | 
             
            # ----- Application skeleton ----------------------------------------------------------------------
         | 
| 95 74 |  | 
| @@ -144,7 +123,7 @@ end | |
| 144 123 |  | 
| 145 124 | 
             
            # ----- Auxiliary gems ----------------------------------------------------------------------------
         | 
| 146 125 |  | 
| 147 | 
            -
            gem 'mocha', group: 'test' | 
| 126 | 
            +
            gem 'mocha', group: 'test'
         | 
| 148 127 | 
             
            gem 'rails-controller-testing', group: 'test'
         | 
| 149 128 |  | 
| 150 129 | 
             
            # ----- Remove CoffeeScript, Sass and "all that jazz" ---------------------------------------------
         | 
| @@ -160,9 +139,9 @@ puts | |
| 160 139 | 
             
            say_status  "Rubygems", "Adding Elasticsearch libraries into Gemfile...\n", :yellow
         | 
| 161 140 | 
             
            puts        '-'*80, ''; sleep 0.75
         | 
| 162 141 |  | 
| 163 | 
            -
            gem 'elasticsearch',       git: ' | 
| 164 | 
            -
            gem 'elasticsearch-model', git: ' | 
| 165 | 
            -
            gem 'elasticsearch-rails', git: ' | 
| 142 | 
            +
            gem 'elasticsearch',       git: 'https://github.com/elasticsearch/elasticsearch-ruby.git'
         | 
| 143 | 
            +
            gem 'elasticsearch-model', git: 'https://github.com/elasticsearch/elasticsearch-rails.git'
         | 
| 144 | 
            +
            gem 'elasticsearch-rails', git: 'https://github.com/elasticsearch/elasticsearch-rails.git'
         | 
| 166 145 |  | 
| 167 146 |  | 
| 168 147 | 
             
            git add:    "Gemfile*"
         | 
| @@ -109,8 +109,13 @@ gsub_file "#{Rails::VERSION::STRING > '4' ? 'test/models' : 'test/unit' }/articl | |
| 109 109 | 
             
              end
         | 
| 110 110 | 
             
            CODE
         | 
| 111 111 |  | 
| 112 | 
            +
            insert_into_file "test/test_helper.rb",
         | 
| 113 | 
            +
                             "require 'mocha/minitest'\n\n",
         | 
| 114 | 
            +
                             before: "class ActiveSupport::TestCase\n"
         | 
| 115 | 
            +
             | 
| 112 116 | 
             
            git add:    "app/models/article.rb"
         | 
| 113 117 | 
             
            git add:    "test/**/article_test.rb"
         | 
| 118 | 
            +
            git add:    "test/test_helper.rb"
         | 
| 114 119 | 
             
            git commit: "-m 'Added an `Article.search` method'"
         | 
| 115 120 |  | 
| 116 121 | 
             
            # ----- Add loading Bootstrap assets --------------------------------------------------------------
         | 
| @@ -126,8 +131,9 @@ gsub_file 'app/views/layouts/application.html.erb', %r{<%= yield %>}, <<-CODE un | |
| 126 131 | 
             
            CODE
         | 
| 127 132 |  | 
| 128 133 | 
             
            insert_into_file 'app/views/layouts/application.html.erb', <<-CODE, before: '</head>'
         | 
| 129 | 
            -
              <link rel="stylesheet" href=" | 
| 130 | 
            -
              <script src=" | 
| 134 | 
            +
              <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
         | 
| 135 | 
            +
              <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
         | 
| 136 | 
            +
              <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
         | 
| 131 137 | 
             
            CODE
         | 
| 132 138 |  | 
| 133 139 | 
             
            git commit: "-a -m 'Added loading Bootstrap assets in the application layout'"
         | 
| @@ -142,12 +148,6 @@ gsub_file 'app/views/articles/index.html.erb', %r{<%= label_tag .* :search %>}m | |
| 142 148 | 
             
            <<-CODE
         | 
| 143 149 | 
             
            <div class="input-group">
         | 
| 144 150 | 
             
              <%= text_field_tag :q, params[:q], class: 'form-control', placeholder: 'Search...' %>
         | 
| 145 | 
            -
             | 
| 146 | 
            -
              <span class="input-group-btn">
         | 
| 147 | 
            -
                <button type="button" class="btn btn-default">
         | 
| 148 | 
            -
                  <span class="glyphicon glyphicon-search"></span>
         | 
| 149 | 
            -
                </button>
         | 
| 150 | 
            -
              </span>
         | 
| 151 151 | 
             
            </div>
         | 
| 152 152 | 
             
            CODE
         | 
| 153 153 | 
             
            end
         | 
| @@ -166,7 +166,7 @@ end | |
| 166 166 |  | 
| 167 167 | 
             
            gsub_file 'app/views/articles/index.html.erb', %r{<td><%= link_to [^%]+} do |match|
         | 
| 168 168 | 
             
              match.gsub!('<td>', '<td style="width: 50px">')
         | 
| 169 | 
            -
              match.include?("btn") ? match : (match + ", class: 'btn btn- | 
| 169 | 
            +
              match.include?("btn") ? match : (match + ", class: 'btn btn-outline-primary btn-sm'")
         | 
| 170 170 | 
             
            end
         | 
| 171 171 |  | 
| 172 172 | 
             
            gsub_file 'app/views/articles/index.html.erb', %r{<br>\s*(<\%= link_to 'New Article'.*)}m do |content|
         | 
| @@ -190,6 +190,12 @@ gsub_file 'app/views/articles/index.html.erb', %r{<%= link_to 'All Articles',\s* | |
| 190 190 | 
             
              "\n  " + match + ", class: 'btn btn-primary btn-xs', style: 'color: #fff'"
         | 
| 191 191 | 
             
            end
         | 
| 192 192 |  | 
| 193 | 
            +
            # ----- Customize the form -----------------------------------------------------------------
         | 
| 194 | 
            +
             | 
| 195 | 
            +
            gsub_file 'app/views/articles/_form.html.erb', %r{<div class="field">} do |match|
         | 
| 196 | 
            +
              %Q|<div class="form-group">|
         | 
| 197 | 
            +
            end
         | 
| 198 | 
            +
             | 
| 193 199 | 
             
            git add:    "app/views"
         | 
| 194 200 | 
             
            git commit: "-m 'Refactored the articles listing to use Bootstrap components'"
         | 
| 195 201 |  | 
| @@ -229,9 +235,9 @@ insert_into_file 'app/views/articles/index.html.erb', after: '</table>' do | |
| 229 235 | 
             
              CODE
         | 
| 230 236 | 
             
            end
         | 
| 231 237 |  | 
| 232 | 
            -
            generate "kaminari:views", " | 
| 238 | 
            +
            generate "kaminari:views", "bootstrap3", "--force"
         | 
| 233 239 |  | 
| 234 | 
            -
            gsub_file 'app/views/kaminari/_paginator.html.erb', %r{< | 
| 240 | 
            +
            gsub_file 'app/views/kaminari/_paginator.html.erb', %r{<nav>}, '<nav class="pagination">'
         | 
| 235 241 |  | 
| 236 242 | 
             
            git add:    "."
         | 
| 237 243 | 
             
            git commit: "-m 'Added pagination to articles listing'"
         | 
| @@ -246,21 +252,35 @@ append_to_file 'app/assets/stylesheets/application.css' do | |
| 246 252 | 
             
              unless File.read('app/assets/stylesheets/application.css').include?('.label-highlight')
         | 
| 247 253 | 
             
            <<-CODE
         | 
| 248 254 |  | 
| 255 | 
            +
             body * {
         | 
| 256 | 
            +
               font-size: 100% !important;
         | 
| 257 | 
            +
             }
         | 
| 258 | 
            +
             | 
| 259 | 
            +
            .table {
         | 
| 260 | 
            +
              border-bottom: 1px solid #dee2e6;
         | 
| 261 | 
            +
            }
         | 
| 262 | 
            +
             | 
| 263 | 
            +
            .table td {
         | 
| 264 | 
            +
              vertical-align: middle !important;
         | 
| 265 | 
            +
            }
         | 
| 266 | 
            +
             | 
| 249 267 | 
             
            .label-highlight {
         | 
| 250 268 | 
             
              font-size: 100% !important;
         | 
| 251 269 | 
             
              font-weight: inherit !important;
         | 
| 252 270 | 
             
              font-style: inherit !important;
         | 
| 253 271 | 
             
              color: #333 !important;
         | 
| 254 272 | 
             
              background: #fff401 !important;
         | 
| 273 | 
            +
              padding: 0.25em 0.5em
         | 
| 274 | 
            +
              border-radius: 5px;
         | 
| 255 275 | 
             
            }
         | 
| 256 276 |  | 
| 257 | 
            -
             | 
| 277 | 
            +
            nav.pagination {
         | 
| 258 278 | 
             
              text-align: center;
         | 
| 259 | 
            -
              display: block;
         | 
| 279 | 
            +
              display: inline-block;
         | 
| 260 280 | 
             
            }
         | 
| 261 281 |  | 
| 262 | 
            -
             | 
| 263 | 
            -
               | 
| 282 | 
            +
            ul.pagination {
         | 
| 283 | 
            +
              margin-bottom: 0;
         | 
| 264 284 | 
             
            }
         | 
| 265 285 |  | 
| 266 286 | 
             
            CODE
         | 
| @@ -183,7 +183,7 @@ git commit: "-m 'Refactored the Elasticsearch integration into a concern\n\nSee: | |
| 183 183 | 
             
            # ----- Add Sidekiq indexer -----------------------------------------------------------------------
         | 
| 184 184 |  | 
| 185 185 | 
             
            puts
         | 
| 186 | 
            -
            say_status  " | 
| 186 | 
            +
            say_status  "Sidekiq", "Adding Sidekiq worker for updating the index...\n", :yellow
         | 
| 187 187 | 
             
            puts        '-'*80, ''; sleep 0.25
         | 
| 188 188 |  | 
| 189 189 | 
             
            gem "sidekiq"
         | 
| @@ -241,6 +241,18 @@ git add:    "app/controllers/ test/controllers/ config/routes.rb" | |
| 241 241 | 
             
            git add:    "app/views/search/ app/assets/stylesheets/search.css"
         | 
| 242 242 | 
             
            git commit: "-m 'Added SearchController#index'"
         | 
| 243 243 |  | 
| 244 | 
            +
            # ----- Add SearchController -----------------------------------------------------------------------
         | 
| 245 | 
            +
             | 
| 246 | 
            +
            puts
         | 
| 247 | 
            +
            say_status  "Views", "Updating application layout...\n", :yellow
         | 
| 248 | 
            +
            puts        '-'*80, ''; sleep 0.25
         | 
| 249 | 
            +
             | 
| 250 | 
            +
            insert_into_file 'app/views/layouts/application.html.erb', <<-CODE, before: '</head>'
         | 
| 251 | 
            +
              <link href="https://fonts.googleapis.com/css?family=Rokkitt:400,700" rel="stylesheet">
         | 
| 252 | 
            +
            CODE
         | 
| 253 | 
            +
             | 
| 254 | 
            +
            git commit: "-a -m 'Updated application template'"
         | 
| 255 | 
            +
             | 
| 244 256 | 
             
            # ----- Add initializer ---------------------------------------------------------------------------
         | 
| 245 257 |  | 
| 246 258 | 
             
            puts
         | 
| @@ -38,7 +38,7 @@ | |
| 38 38 | 
             
                    </button>
         | 
| 39 39 | 
             
                    <ul class="dropdown-menu" role="menu">
         | 
| 40 40 | 
             
                      <li><%= link_to "Sort by published on", search_path(params.permit(:q, :a, :c, :s, :w, :comments).merge(s: 'published_on')), class: 'btn-xs' %></li>
         | 
| 41 | 
            -
                      <li><%= link_to "Sort by relevancy",    search_path(params.permit(:q, :a, :c, :s, :w, :comments).merge(s: nil)), class: 'btn-xs' %></li>
         | 
| 41 | 
            +
                      <li><%= link_to "Sort by relevancy",    search_path(params.permit(:q, :a, :c, :s, :w, :comments).merge(s: nil)), class: 'btn-xs' unless params[:q].blank?  %></li>
         | 
| 42 42 | 
             
                    </ul>
         | 
| 43 43 | 
             
                  </div>
         | 
| 44 44 | 
             
                </div>
         | 
| @@ -122,7 +122,7 @@ | |
| 122 122 | 
             
                  <div class="result">
         | 
| 123 123 | 
             
                    <h3 class="title">
         | 
| 124 124 | 
             
                      <%= (article.try(:highlight).try(:title) ? article.highlight.title.join.html_safe : article.title) %>
         | 
| 125 | 
            -
                      <small class="category" | 
| 125 | 
            +
                      <small class="category"> | <%= article.categories.to_sentence %></small>
         | 
| 126 126 | 
             
                    </h3>
         | 
| 127 127 |  | 
| 128 128 | 
             
                    <p class="body">
         | 
| @@ -38,7 +38,7 @@ | |
| 38 38 | 
             
                    </button>
         | 
| 39 39 | 
             
                    <ul class="dropdown-menu" role="menu">
         | 
| 40 40 | 
             
                      <li><%= link_to "Sort by published on", search_path(params.permit(:q, :a, :c, :s, :w, :comments).merge(s: 'published_on')), class: 'btn-xs' %></li>
         | 
| 41 | 
            -
                      <li><%= link_to "Sort by relevancy",    search_path(params.permit(:q, :a, :c, :s, :w, :comments).merge(s: nil)), class: 'btn-xs' %></li>
         | 
| 41 | 
            +
                      <li><%= link_to "Sort by relevancy",    search_path(params.permit(:q, :a, :c, :s, :w, :comments).merge(s: nil)), class: 'btn-xs' unless params[:q].blank?  %></li>
         | 
| 42 42 | 
             
                    </ul>
         | 
| 43 43 | 
             
                  </div>
         | 
| 44 44 | 
             
                </div>
         | 
| @@ -122,7 +122,7 @@ | |
| 122 122 | 
             
                  <div class="result">
         | 
| 123 123 | 
             
                    <h3 class="title">
         | 
| 124 124 | 
             
                      <%= (article.try(:highlight).try(:title) ? article.highlight.title.join.html_safe : article.title) %>
         | 
| 125 | 
            -
                      <small class="category" | 
| 125 | 
            +
                      <small class="category"> | <%= article.categories.to_sentence %></small>
         | 
| 126 126 | 
             
                    </h3>
         | 
| 127 127 |  | 
| 128 128 | 
             
                    <p class="body">
         | 
| @@ -54,9 +54,13 @@ form #form-options input { | |
| 54 54 | 
             
            }
         | 
| 55 55 |  | 
| 56 56 | 
             
            .result h3.title {
         | 
| 57 | 
            +
              font-size: 180% !important;
         | 
| 57 58 | 
             
              font-family: 'Rokkitt', sans-serif;
         | 
| 58 59 | 
             
              margin-top: 0;
         | 
| 59 60 | 
             
            }
         | 
| 61 | 
            +
            .result h3.title small {
         | 
| 62 | 
            +
              font-size: 75% !important;
         | 
| 63 | 
            +
            }
         | 
| 60 64 |  | 
| 61 65 | 
             
            .result .body {
         | 
| 62 66 | 
             
              font-family: Georgia, serif;
         | 
    
        data/test/test_helper.rb
    CHANGED
    
    | @@ -23,7 +23,7 @@ require 'shoulda-context' | |
| 23 23 | 
             
            require 'turn' unless ENV["TM_FILEPATH"] || ENV["NOTURN"] || defined?(RUBY_VERSION) && RUBY_VERSION > '2.2'
         | 
| 24 24 |  | 
| 25 25 | 
             
            require 'ansi'
         | 
| 26 | 
            -
            require 'oj'
         | 
| 26 | 
            +
            require 'oj' unless defined?(JRUBY_VERSION)
         | 
| 27 27 |  | 
| 28 28 | 
             
            require 'rails/version'
         | 
| 29 29 | 
             
            require 'active_record'
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: elasticsearch-rails
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version:  | 
| 4 | 
            +
              version: 6.0.0.pre
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Karel Minarik
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2018- | 
| 11 | 
            +
            date: 2018-08-13 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -53,21 +53,21 @@ dependencies: | |
| 53 53 | 
             
                  - !ruby/object:Gem::Version
         | 
| 54 54 | 
             
                    version: '0'
         | 
| 55 55 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            -
              name:  | 
| 56 | 
            +
              name: rails
         | 
| 57 57 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 58 | 
             
                requirements:
         | 
| 59 59 | 
             
                - - ">="
         | 
| 60 60 | 
             
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            -
                    version: ' | 
| 61 | 
            +
                    version: '3.1'
         | 
| 62 62 | 
             
              type: :development
         | 
| 63 63 | 
             
              prerelease: false
         | 
| 64 64 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 65 | 
             
                requirements:
         | 
| 66 66 | 
             
                - - ">="
         | 
| 67 67 | 
             
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            -
                    version: ' | 
| 68 | 
            +
                    version: '3.1'
         | 
| 69 69 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            -
              name:  | 
| 70 | 
            +
              name: lograge
         | 
| 71 71 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 72 | 
             
                requirements:
         | 
| 73 73 | 
             
                - - ">="
         | 
| @@ -81,21 +81,7 @@ dependencies: | |
| 81 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 82 82 | 
             
                    version: '0'
         | 
| 83 83 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 84 | 
            -
              name:  | 
| 85 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 | 
            -
                requirements:
         | 
| 87 | 
            -
                - - ">="
         | 
| 88 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 89 | 
            -
                    version: '3.1'
         | 
| 90 | 
            -
              type: :development
         | 
| 91 | 
            -
              prerelease: false
         | 
| 92 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 | 
            -
                requirements:
         | 
| 94 | 
            -
                - - ">="
         | 
| 95 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 96 | 
            -
                    version: '3.1'
         | 
| 97 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 98 | 
            -
              name: lograge
         | 
| 84 | 
            +
              name: minitest
         | 
| 99 85 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 100 86 | 
             
                requirements:
         | 
| 101 87 | 
             
                - - ">="
         | 
| @@ -109,7 +95,7 @@ dependencies: | |
| 109 95 | 
             
                  - !ruby/object:Gem::Version
         | 
| 110 96 | 
             
                    version: '0'
         | 
| 111 97 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 112 | 
            -
              name:  | 
| 98 | 
            +
              name: test-unit
         | 
| 113 99 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 114 100 | 
             
                requirements:
         | 
| 115 101 | 
             
                - - ">="
         | 
| @@ -123,7 +109,7 @@ dependencies: | |
| 123 109 | 
             
                  - !ruby/object:Gem::Version
         | 
| 124 110 | 
             
                    version: '0'
         | 
| 125 111 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 126 | 
            -
              name:  | 
| 112 | 
            +
              name: shoulda-context
         | 
| 127 113 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 128 114 | 
             
                requirements:
         | 
| 129 115 | 
             
                - - ">="
         | 
| @@ -137,7 +123,7 @@ dependencies: | |
| 137 123 | 
             
                  - !ruby/object:Gem::Version
         | 
| 138 124 | 
             
                    version: '0'
         | 
| 139 125 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 140 | 
            -
              name:  | 
| 126 | 
            +
              name: mocha
         | 
| 141 127 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 142 128 | 
             
                requirements:
         | 
| 143 129 | 
             
                - - ">="
         | 
| @@ -151,7 +137,7 @@ dependencies: | |
| 151 137 | 
             
                  - !ruby/object:Gem::Version
         | 
| 152 138 | 
             
                    version: '0'
         | 
| 153 139 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 154 | 
            -
              name:  | 
| 140 | 
            +
              name: turn
         | 
| 155 141 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 156 142 | 
             
                requirements:
         | 
| 157 143 | 
             
                - - ">="
         | 
| @@ -165,7 +151,7 @@ dependencies: | |
| 165 151 | 
             
                  - !ruby/object:Gem::Version
         | 
| 166 152 | 
             
                    version: '0'
         | 
| 167 153 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 168 | 
            -
              name:  | 
| 154 | 
            +
              name: yard
         | 
| 169 155 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 170 156 | 
             
                requirements:
         | 
| 171 157 | 
             
                - - ">="
         | 
| @@ -179,7 +165,7 @@ dependencies: | |
| 179 165 | 
             
                  - !ruby/object:Gem::Version
         | 
| 180 166 | 
             
                    version: '0'
         | 
| 181 167 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 182 | 
            -
              name:  | 
| 168 | 
            +
              name: oj
         | 
| 183 169 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 184 170 | 
             
                requirements:
         | 
| 185 171 | 
             
                - - ">="
         | 
| @@ -322,12 +308,12 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 322 308 | 
             
                  version: 1.9.3
         | 
| 323 309 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 324 310 | 
             
              requirements:
         | 
| 325 | 
            -
              - - " | 
| 311 | 
            +
              - - ">"
         | 
| 326 312 | 
             
                - !ruby/object:Gem::Version
         | 
| 327 | 
            -
                  version:  | 
| 313 | 
            +
                  version: 1.3.1
         | 
| 328 314 | 
             
            requirements: []
         | 
| 329 315 | 
             
            rubyforge_project: 
         | 
| 330 | 
            -
            rubygems_version: 2.7. | 
| 316 | 
            +
            rubygems_version: 2.7.7
         | 
| 331 317 | 
             
            signing_key: 
         | 
| 332 318 | 
             
            specification_version: 4
         | 
| 333 319 | 
             
            summary: Ruby on Rails integrations for Elasticsearch.
         |