aranha-rails 0.7.2 → 0.8.0

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
  SHA256:
3
- metadata.gz: a2f81d25c96765dabe391eba3b55e7e41ba034f7e0c513f9c3e3d41e324b6a84
4
- data.tar.gz: 1b17888a4c5ba75da243691599f99c48c1fcd403922650af9402770854e48df4
3
+ metadata.gz: 7549d708d366c904799577c0b0d51b9f0e1b4050595ec4e052c4b61ab89da1ba
4
+ data.tar.gz: a4091a00af110da068186784c650a5a6dedf1f711f7a619ec188b76a6b53dd85
5
5
  SHA512:
6
- metadata.gz: b50cda8b00fdd6408787ec8c115de71b202751aaa472d005711b2c4f47f52851a9711a87db4d60afcf584438132b98073b15b3958e82fcad0dfe73e343b0f579
7
- data.tar.gz: 82640e9f247086ff8c47c66c68cdc90629e76dbbadeb828829da43531f845f985bca13f1427c708db0aa763ee85892e5ce94a5e503bc37c25cc740535faa5b4e
6
+ metadata.gz: dfdc5d97e55f0d322a7b5a6df6e520eae8c33887f3c49e67244d7180180d99c1b0b7d7a138b0813817d3fb882f9cefb36eac46cf1b6305f2d7d6788ae4e330ac
7
+ data.tar.gz: 020607c3cba7ed60abc415d4cbd423cb6a9db6314ff2414389512d00bc9a8960caa61cb3770598c013af7cb6041b972afdb64c5c6a2852900bca7ed8420d22de
@@ -2,7 +2,8 @@
2
2
 
3
3
  module Aranha
4
4
  class AddressesController < ::ApplicationController
5
- active_scaffold :'aranha/address' do |_conf|
5
+ active_scaffold :'aranha/address' do |conf|
6
+ conf.actions.exclude :create, :update
6
7
  end
7
8
  end
8
9
  end
@@ -8,6 +8,7 @@ module Aranha
8
8
  common_constructor :address_id
9
9
 
10
10
  def perform
11
+ ::Rails.logger.info("Processing \"#{address.url}\"")
11
12
  address_processor.successful? ? perform_on_success : perform_on_error
12
13
  end
13
14
 
@@ -6,17 +6,28 @@ module Aranha
6
6
  QUEUE = 'aranha'
7
7
  QUEUES = [QUEUE].freeze
8
8
 
9
+ enable_listable
10
+ lists.add_symbol :option, :limit
11
+
12
+ common_constructor :options, default: [{}] do
13
+ self.options = self.class.lists.option.hash_keys_validate!(options)
14
+ end
15
+
9
16
  def run
10
17
  run_init
11
18
  run_jobs_workoff
12
19
  run_close
13
20
  end
14
21
 
22
+ def limit
23
+ options[OPTION_LIMIT].if_present(-1, &:to_i)
24
+ end
25
+
15
26
  private
16
27
 
17
28
  def run_close
18
- ::Aranha::Address.failed do |a|
19
- ::Rails.logger.info "Failed \"#{a.url}\": #{a.last_error}"
29
+ ::Aranha::Address.failed.each do |a|
30
+ ::Rails.logger.warn "Failed \"#{a.url}\": #{a.last_error}"
20
31
  end
21
32
  raise 'Some address failed' if ::Aranha::Address.failed.any?
22
33
  end
@@ -27,7 +38,8 @@ module Aranha
27
38
  end
28
39
 
29
40
  def run_jobs_workoff
30
- ::Delayed::Worker.new(exit_on_complete: true, queues: QUEUES).start
41
+ worker = ::Delayed::Worker.new(exit_on_complete: true, queues: QUEUES)
42
+ limit.negative? ? worker.start : worker.work_off(limit)
31
43
  end
32
44
  end
33
45
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Aranha
4
4
  module Rails
5
- VERSION = '0.7.2'
5
+ VERSION = '0.8.0'
6
6
  end
7
7
  end
@@ -2,8 +2,8 @@
2
2
 
3
3
  namespace(:aranha) do
4
4
  desc 'Process Aranha\'s addresses.'
5
- task process: :environment do
6
- ::Aranha::Rails::Process.new.run
5
+ task :process, %i[limit] => :environment do |_t, args|
6
+ ::Aranha::Rails::Process.new(limit: args.limit).run
7
7
  end
8
8
 
9
9
  desc 'Remove all registered Aranha\'s addresses.'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aranha-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Put here the authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-04 00:00:00.000000000 Z
11
+ date: 2021-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha
@@ -126,20 +126,14 @@ dependencies:
126
126
  requirements:
127
127
  - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: '0.3'
130
- - - ">="
131
- - !ruby/object:Gem::Version
132
- version: 0.3.1
129
+ version: '0.4'
133
130
  type: :development
134
131
  prerelease: false
135
132
  version_requirements: !ruby/object:Gem::Requirement
136
133
  requirements:
137
134
  - - "~>"
138
135
  - !ruby/object:Gem::Version
139
- version: '0.3'
140
- - - ">="
141
- - !ruby/object:Gem::Version
142
- version: 0.3.1
136
+ version: '0.4'
143
137
  description:
144
138
  email:
145
139
  executables: []