kabutops 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 321de7144e42cfc9cba6d6e6675eac975a2981a5
4
- data.tar.gz: 39e39c701812ff208f6131e5caa31438c3268ed5
3
+ metadata.gz: 1312dd77260f2a2f113ba6e757e9da4491caf282
4
+ data.tar.gz: 031d23cf3833bda39fdabe6759d22acf377ac7c3
5
5
  SHA512:
6
- metadata.gz: cbb53e66f5b2be03d080728ee7be1c4c9c40210796f7ab851d87e94af7519ef54c13e46c60e7a4770d5ec89a0c3c0043d60995ccc7508d43f07fd1918957161d
7
- data.tar.gz: 0f3ae02d465fb1a056018bc7db0d1e47a01df19d4c6ce5ec54855fa4774edf497c1c359e5b8eb3dfc2d592e67c3b983ca06f0a21b740c8d97c6b2b38e9f8bbc2
6
+ metadata.gz: 313a091b905a439d0b194f1b468fdccc188a99ff43b40b470bf135e58880c787bf723b70930285f05dac043d5c2a37247ec4a2f494ed098eb11b072fa24ce4c6
7
+ data.tar.gz: f8a3e80823d52b7e234625327d4522fd700e1296d52c699da072f31a0943c3ccbfa0f8bdaefbf40460e2bd434f7ea307ce891d4213660a5f18067a2899cf0d33
data/README.md CHANGED
@@ -13,7 +13,7 @@ gem install kabutops
13
13
  Or you can put it in your Gemfile
14
14
 
15
15
  ```ruby
16
- gem 'kabutops', '~> 0.0.6'
16
+ gem 'kabutops', '~> 0.0.7'
17
17
  ```
18
18
 
19
19
  Basic example
data/lib/kabutops.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
+ require 'json'
3
4
  require 'hashie'
4
5
  require 'sidekiq'
5
6
  require 'cachy'
@@ -7,6 +8,8 @@ require 'moneta'
7
8
  require 'pstore'
8
9
  require 'mechanize'
9
10
  require 'elasticsearch'
11
+ require 'redis'
12
+ require 'redis-namespace'
10
13
 
11
14
  Cachy.cache_store = Moneta.new(:File, dir: 'cache') # temporary
12
15
 
@@ -17,7 +20,9 @@ require 'kabutops/recipe_item'
17
20
  require 'kabutops/adapters/base'
18
21
  require 'kabutops/adapters/database_adapter'
19
22
  require 'kabutops/adapters/elastic_search'
23
+ require 'kabutops/adapters/redis'
20
24
  require 'kabutops/crawler_extensions/elastic_search'
25
+ require 'kabutops/crawler_extensions/redis'
21
26
  require 'kabutops/crawler_extensions/pstore_storage'
22
27
  require 'kabutops/crawler_extensions/debugging'
23
28
  require 'kabutops/crawler'
@@ -0,0 +1,37 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ module Kabutops
4
+
5
+ module Adapters
6
+
7
+ class Redis < DatabaseAdapter
8
+ include Extensions::Parameterable
9
+
10
+ params :host, :port, :namespace, :db, :password
11
+
12
+ def store result
13
+ client[result[:id]] = JSON.dump(result.to_hash)
14
+ end
15
+
16
+ def nested?
17
+ true
18
+ end
19
+
20
+ protected
21
+
22
+ def client
23
+ @@client ||= ::Redis::Namespace.new(
24
+ params[:namespace] || 'kabutops',
25
+ redis: ::Redis.new(
26
+ host: params[:host],
27
+ port: params[:port],
28
+ db: params[:db],
29
+ password: params[:password],
30
+ )
31
+ )
32
+ end
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -6,6 +6,7 @@ module Kabutops
6
6
  include CrawlerExtensions::Debugging
7
7
  include CrawlerExtensions::PStoreStorage
8
8
  include CrawlerExtensions::ElasticSearch
9
+ include CrawlerExtensions::Redis
9
10
  include Sidekiq::Worker
10
11
 
11
12
  class << self
@@ -0,0 +1,27 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ module Kabutops
4
+
5
+ module CrawlerExtensions
6
+
7
+ module Redis
8
+
9
+ def self.included base
10
+ base.extend(ClassMethods)
11
+ end
12
+
13
+ module ClassMethods
14
+ def redis &block
15
+ adapter = Adapters::Redis.new
16
+ adapter.instance_eval &block
17
+
18
+ @adapters ||= []
19
+ @adapters << adapter
20
+ end
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  module Kabutops
4
- VERSION = '0.0.6'
4
+ VERSION = '0.0.7'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kabutops
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rene Klacan
@@ -94,6 +94,48 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: redis
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: redis-namespace
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.4'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.4'
125
+ - !ruby/object:Gem::Dependency
126
+ name: json
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.8'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.8'
97
139
  - !ruby/object:Gem::Dependency
98
140
  name: rspec
99
141
  requirement: !ruby/object:Gem::Requirement
@@ -135,10 +177,12 @@ files:
135
177
  - lib/kabutops/adapters/base.rb
136
178
  - lib/kabutops/adapters/database_adapter.rb
137
179
  - lib/kabutops/adapters/elastic_search.rb
180
+ - lib/kabutops/adapters/redis.rb
138
181
  - lib/kabutops/crawler.rb
139
182
  - lib/kabutops/crawler_extensions/debugging.rb
140
183
  - lib/kabutops/crawler_extensions/elastic_search.rb
141
184
  - lib/kabutops/crawler_extensions/pstore_storage.rb
185
+ - lib/kabutops/crawler_extensions/redis.rb
142
186
  - lib/kabutops/extensions/callback_support.rb
143
187
  - lib/kabutops/extensions/parameterable.rb
144
188
  - lib/kabutops/recipe.rb