rfilma 0.1.4 → 0.1.5

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: de84e2f9b00f19be16c16a790ff9ab84d415a427
4
- data.tar.gz: cd60a64ea4ec5410eac547fdc0d39b6401d1caab
3
+ metadata.gz: 6153d836bf46417ea1746f1a00e7e307f3254c64
4
+ data.tar.gz: e34f132b4c10af1853efeef1ec5e7c504fd14769
5
5
  SHA512:
6
- metadata.gz: 033b13fdd52a1fbbb229742825cab0a435eff0067e0ec4723a28ea5eb1f35bca18a3c6a97b06c2ea346c37dd6c8487329d13d78e4adfd3d4fb81bac05fcbcbfc
7
- data.tar.gz: 5b7f55118f5d60e4c45aa1362d535522e4dc8eb46508966eb8d9883243dc33d770eb07dd27e8be7728afca720c096f408b59e26d5f273343237276defa38096f
6
+ metadata.gz: 8dff72e1cb07394faec6f0510243ea802c2811fd4112a210d8a0c10d377a9647d41157c987726e82445ba9fb95fef55c64d965a0328c6f6c43b82966e5d05eb0
7
+ data.tar.gz: 6fc49a649e801c2e328fb632a19d7b785c783525f1bd8068e5e81964416a91e6f63800f327312188e9f4a5f44f8f2bdf890c15c77055d6dcbac5f364bb345790
@@ -36,4 +36,6 @@ class RFilma
36
36
  def actualizar_todo
37
37
  @crawlerdb.procesar_todo
38
38
  end
39
+
40
+
39
41
  end
@@ -11,14 +11,14 @@ class CrawlerDB < Crawler
11
11
  Pelicula.where(id: id).as_json
12
12
  end
13
13
 
14
- def buscar_por_titulo(titulo,nlim=15)
15
- Pelicula.where(titulo: /#{titulo.split(" ").join(".*")}/i).limit(nlim).as_json
14
+ def buscar_por_titulo(titulo,nlim=30)
15
+ Pelicula.where(titulo: /#{titulo}/i).limit(nlim).as_json
16
16
  end
17
17
 
18
18
  def guardar_pelicula(id)
19
19
  p = Crawler.new.obtener_pelicula(id)
20
20
  m = Pelicula.new(p)
21
- m.upsert
21
+ m.upsert
22
22
  end
23
23
 
24
24
  def guardar_peliculas(ids,nthread=5)
@@ -1,8 +1,27 @@
1
1
  require "mongoid"
2
+ require "elasticsearch"
3
+ require "singleton"
4
+ require "pp"
5
+
2
6
 
3
7
  mongoidyml = File.join(File.dirname(__FILE__),"..","config","mongoid.yml")
8
+
4
9
  Mongoid.load!(mongoidyml,:production)
5
10
 
11
+ class Elastic
12
+ include Singleton
13
+
14
+ def initialize
15
+ url_elastic = ENV["RFILMA_ELASTICSEARCH_URL"] ? ENV["RFILMA_ELASTICSEARCH_URL"] : "http://localhost:9200"
16
+ @c = Elasticsearch::Client.new url: url_elastic, log: false
17
+ end
18
+
19
+ def client
20
+ @c
21
+ end
22
+
23
+ end
24
+
6
25
  class Pelicula
7
26
 
8
27
  include Mongoid::Document
@@ -24,5 +43,11 @@ class Pelicula
24
43
  field :puntuacion, type: Float
25
44
  field :web, type: String
26
45
  field :portada, type: String
27
- field :_id, type: Integer, overwrite: true, default: ->{ id }
28
- end
46
+ field :_id, type: Integer, overwrite: true, default: -> { id }
47
+
48
+ after_upsert do |document|
49
+ database = Mongoid.session(:default).options[:database]
50
+ client = Elastic.instance.client
51
+ client.index index: "#{database}", type: "peliculas", id: document.id, body: document
52
+ end
53
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rfilma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jose Antonio PB
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-10 00:00:00.000000000 Z
11
+ date: 2014-11-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: RFilma is a Ruby library for crawl data from FilmAffinity website
14
14
  email: aztuzeca@gmail.com