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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d0ca62cb4cd0c89f424818acd9744b33bc6dcf2c
4
- data.tar.gz: 789692ee0f6e269dac5e024c647b6fe39b921b66
3
+ metadata.gz: 23dc8d1fc9c43883c42dedad1f34a810aa8aa03b
4
+ data.tar.gz: b20ce7337a730d5a4f0dcc6191956c3e22f81f22
5
5
  SHA512:
6
- metadata.gz: 9a23e8f8e8fc26017d3c813b285a3451a3ddeb4f2cd8526da210101517be7807662094ff7160109a4db4e11cc6325c43a5e8708c8c4b218f3318d4a46b2bd28f
7
- data.tar.gz: d411bd8acee5ad6e1b96f170e306da08d70c65485a4a4ba27aca8d1769c5c6c3378c09facf7eb579c9953c5e5047a619afe8423a72b1c0927d66eba8b960e7dc
6
+ metadata.gz: 0175a4a58df67675e03934803b2d8ac0384ee2013ebaab4b211ea2662f523e24f94ebba7ff81cde10fccd2653b9b5f5f1bb6c24cd989544eb15191d281bfd90d
7
+ data.tar.gz: cb968a176a61acabc9f58b5d7dcce0ca5a701168948dfa49a872770f6ef1ac37d3ae2d3f61bb04a0256d6913151760cc18d1ddecde65a424260b714860b79ad3
data/.gitignore CHANGED
@@ -1 +1,5 @@
1
1
  /pkg
2
+ .DS_Store
3
+ .idea
4
+ /*.tmproj
5
+ **.swp
data/Rakefile CHANGED
@@ -1,2 +1 @@
1
1
  require "bundler/gem_tasks"
2
-
@@ -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
@@ -9,7 +9,8 @@ module Makasi
9
9
  end
10
10
 
11
11
  def search(query, params={})
12
- asari.search(query, params)
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)
@@ -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
@@ -0,0 +1,7 @@
1
+ module Makasi
2
+ class Railtie < Rails::Railtie
3
+ rake_tasks do
4
+ Dir["#{File.dirname(__FILE__)}/../tasks/*.rake"].sort.each { |ext| load ext }
5
+ end
6
+ end
7
+ end
@@ -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
- html_doc = Nokogiri::HTML(load_page(cloudsearch_doc.url))
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("[data-indexable]")
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("[data-title]")
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
@@ -1,3 +1,3 @@
1
1
  module Makasi
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -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
@@ -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 -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
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.3
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
Binary file
Binary file