makasi 0.1.3 → 0.1.4
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/.gitignore +4 -0
- data/Rakefile +0 -1
- data/lib/makasi.rb +2 -0
- data/lib/makasi/asari_client.rb +2 -1
- data/lib/makasi/config.rb +8 -0
- data/lib/makasi/railtie.rb +7 -0
- data/lib/makasi/search_index.rb +6 -5
- data/lib/makasi/version.rb +1 -1
- data/lib/tasks/search_reindex.rake +2 -0
- data/makasi.gemspec +1 -1
- metadata +2 -4
- data/.DS_Store +0 -0
- data/lib/.DS_Store +0 -0
- data/lib/makasi/.DS_Store +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23dc8d1fc9c43883c42dedad1f34a810aa8aa03b
|
4
|
+
data.tar.gz: b20ce7337a730d5a4f0dcc6191956c3e22f81f22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0175a4a58df67675e03934803b2d8ac0384ee2013ebaab4b211ea2662f523e24f94ebba7ff81cde10fccd2653b9b5f5f1bb6c24cd989544eb15191d281bfd90d
|
7
|
+
data.tar.gz: cb968a176a61acabc9f58b5d7dcce0ca5a701168948dfa49a872770f6ef1ac37d3ae2d3f61bb04a0256d6913151760cc18d1ddecde65a424260b714860b79ad3
|
data/Rakefile
CHANGED
data/lib/makasi.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
require "asari"
|
2
|
+
require_relative "../app/models/cloud_search_document"
|
2
3
|
require "makasi/asari_client"
|
3
4
|
require "makasi/asari_result"
|
4
5
|
require "makasi/config"
|
5
6
|
require "makasi/search_index"
|
6
7
|
require "makasi/version"
|
8
|
+
require 'makasi/railtie' if defined?(Rails)
|
7
9
|
|
8
10
|
module Makasi
|
9
11
|
end
|
data/lib/makasi/asari_client.rb
CHANGED
@@ -9,7 +9,8 @@ module Makasi
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def search(query, params={})
|
12
|
-
|
12
|
+
default_params = { return_fields: Makasi::Config.asari_return_fields }
|
13
|
+
asari.search(query, default_params.merge(params))
|
13
14
|
end
|
14
15
|
|
15
16
|
def search_resource_ids(query, resource_type)
|
data/lib/makasi/config.rb
CHANGED
@@ -20,6 +20,14 @@ module Makasi
|
|
20
20
|
rails_config.website_url
|
21
21
|
end
|
22
22
|
|
23
|
+
def self.content_selector
|
24
|
+
rails_config.content_selector || "[data-indexable]"
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.resource_name_selector
|
28
|
+
rails_config.resource_name_selector || "[data-title]"
|
29
|
+
end
|
30
|
+
|
23
31
|
def self.cloudsearch_api_version
|
24
32
|
rails_config.cloudsearch_api_version.presence || "2013-01-01"
|
25
33
|
end
|
data/lib/makasi/search_index.rb
CHANGED
@@ -7,7 +7,8 @@ module Makasi
|
|
7
7
|
sync_db_with_sitemap
|
8
8
|
|
9
9
|
CloudSearchDocument.desc(:reindexed_at).each do |cloudsearch_doc|
|
10
|
-
|
10
|
+
html_content = load_page(cloudsearch_doc.url)
|
11
|
+
html_doc = Nokogiri::HTML(html_content)
|
11
12
|
|
12
13
|
if Rails.logger.debug?
|
13
14
|
Rails.logger.debug ">>> URL: " + cloudsearch_doc.url +
|
@@ -49,7 +50,7 @@ module Makasi
|
|
49
50
|
url_nodes = Nokogiri::XML(read_sitemap).css('url loc')
|
50
51
|
|
51
52
|
url_nodes.each do |url_node|
|
52
|
-
cloudsearch_doc = CloudSearchDocument.find_or_initialize_by(url: url_node.text)
|
53
|
+
cloudsearch_doc = CloudSearchDocument.find_or_initialize_by(url: url_node.text.strip)
|
53
54
|
cloudsearch_doc.update_attributes(present_in_sitemap: true)
|
54
55
|
end
|
55
56
|
|
@@ -70,7 +71,7 @@ module Makasi
|
|
70
71
|
## Patch for indexing from localhost
|
71
72
|
if Rails.env.development?
|
72
73
|
url += "/" unless url.ends_with?("/")
|
73
|
-
url.gsub! Makasi::Config.website_url, "localhost:3000"
|
74
|
+
url.gsub! Makasi::Config.website_url, "http://localhost:3000/"
|
74
75
|
end
|
75
76
|
|
76
77
|
parsed_url = URI.parse(url)
|
@@ -105,7 +106,7 @@ module Makasi
|
|
105
106
|
end
|
106
107
|
|
107
108
|
def content_of(doc)
|
108
|
-
content_nodes = doc.css(
|
109
|
+
content_nodes = doc.css(Makasi::Config.content_selector)
|
109
110
|
if content_nodes.present?
|
110
111
|
extract_text(content_nodes)
|
111
112
|
else
|
@@ -134,7 +135,7 @@ module Makasi
|
|
134
135
|
end
|
135
136
|
|
136
137
|
def resource_name_of(doc)
|
137
|
-
content_nodes = doc.css(
|
138
|
+
content_nodes = doc.css(Makasi::Config.resource_name_selector)
|
138
139
|
if content_nodes.present?
|
139
140
|
HTMLEntities.new.decode content_nodes.map(&:text).join(" ")
|
140
141
|
else
|
data/lib/makasi/version.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
namespace :makasi do
|
2
|
+
desc "Refresh sitemap and update indices on Amazon CloudSearch"
|
2
3
|
task :search_reindex => [:environment, "sitemap:refresh"] do
|
3
4
|
Makasi::SearchIndex.new.reindex
|
4
5
|
end
|
5
6
|
|
7
|
+
desc "Delete all indices from Amazon CloudSearch and cleanup CloudSearchDocument model"
|
6
8
|
task :search_truncate_index => :environment do
|
7
9
|
Makasi::AsariClient.new.remove_all
|
8
10
|
CloudSearchDocument.delete_all
|
data/makasi.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "http://slatestudio.com"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
-
spec.files = `git ls-files
|
16
|
+
spec.files = `git ls-files`.split("\n")
|
17
17
|
spec.bindir = "exe"
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: makasi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nataliia Kumeiko
|
@@ -73,7 +73,6 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
- ".DS_Store"
|
77
76
|
- ".gitignore"
|
78
77
|
- Gemfile
|
79
78
|
- Gemfile.lock
|
@@ -83,12 +82,11 @@ files:
|
|
83
82
|
- app/models/cloud_search_document.rb
|
84
83
|
- bin/console
|
85
84
|
- bin/setup
|
86
|
-
- lib/.DS_Store
|
87
85
|
- lib/makasi.rb
|
88
|
-
- lib/makasi/.DS_Store
|
89
86
|
- lib/makasi/asari_client.rb
|
90
87
|
- lib/makasi/asari_result.rb
|
91
88
|
- lib/makasi/config.rb
|
89
|
+
- lib/makasi/railtie.rb
|
92
90
|
- lib/makasi/search_index.rb
|
93
91
|
- lib/makasi/version.rb
|
94
92
|
- lib/tasks/search_reindex.rake
|
data/.DS_Store
DELETED
Binary file
|
data/lib/.DS_Store
DELETED
Binary file
|
data/lib/makasi/.DS_Store
DELETED
Binary file
|