rfilma 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rfilma.rb +2 -0
- data/lib/rfilma/crawlerdb.rb +3 -3
- data/lib/rfilma/pelicula.rb +27 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6153d836bf46417ea1746f1a00e7e307f3254c64
|
4
|
+
data.tar.gz: e34f132b4c10af1853efeef1ec5e7c504fd14769
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8dff72e1cb07394faec6f0510243ea802c2811fd4112a210d8a0c10d377a9647d41157c987726e82445ba9fb95fef55c64d965a0328c6f6c43b82966e5d05eb0
|
7
|
+
data.tar.gz: 6fc49a649e801c2e328fb632a19d7b785c783525f1bd8068e5e81964416a91e6f63800f327312188e9f4a5f44f8f2bdf890c15c77055d6dcbac5f364bb345790
|
data/lib/rfilma.rb
CHANGED
data/lib/rfilma/crawlerdb.rb
CHANGED
@@ -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
|
-
Pelicula.where(titulo: /#{titulo
|
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)
|
data/lib/rfilma/pelicula.rb
CHANGED
@@ -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
|
-
|
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
|
+
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-
|
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
|