abid 0.2.0 → 0.2.1

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: 7cc7876b6fa9c07f29b893a57ffca6222569385c
4
- data.tar.gz: fabd1296f57c4ad14b58564882250b71a917fe68
3
+ metadata.gz: d16caf9273d7d1b98230b9a43390e392656481b1
4
+ data.tar.gz: f7ee5b5dc8d9d852d2339b0c49e4deb4bb7e66f6
5
5
  SHA512:
6
- metadata.gz: 1fcf95c39e0b23ee3bb8116d5e227d27ff9439fc83bbcbd2cbff7bd86b0f8a4ec837d430af09b6dd0e71643328367a7daee483157bfdc53cc868dc2050876190
7
- data.tar.gz: 57b0276deeaef0a06f3e35aa57674f2cc7d8eb15494e9b14b2fab717b9397e23bd74f460854779beba8afe48e397fc64a0104c414740cf5d6331a59f78340acd
6
+ metadata.gz: cc7a6b194b6106cee0f1cb4638108ca8cce56e20e42eb100c6d38763355ac015c1255de677eeb4255fa6bcc1ad01bf15c537fcf773e0bdf686a8b6e9354a93af
7
+ data.tar.gz: a47e90c5529cfadd1dd4df78afc9ccea44879594e234996628c2f33b2f1b8c9500d681b0d9378a774991b145ac15a9e48afd6275632f4f027714a7f30177e866
data/lib/abid.rb CHANGED
@@ -15,6 +15,7 @@ require 'sequel'
15
15
  require 'abid/rake_extensions'
16
16
  require 'abid/concurrent_extention'
17
17
  require 'abid/version'
18
+ require 'abid/abid_module'
18
19
  require 'abid/waiter'
19
20
  require 'abid/worker'
20
21
  require 'abid/params_parser'
@@ -0,0 +1,15 @@
1
+ module Abid
2
+ extend Rake
3
+
4
+ class << self
5
+ def application
6
+ return @application if @application
7
+ self.application = Abid::Application.new
8
+ end
9
+
10
+ def application=(app)
11
+ @application = app
12
+ Rake.application = app
13
+ end
14
+ end
15
+ end
@@ -9,22 +9,16 @@ module Abid
9
9
  super
10
10
  @rakefiles = %w(abidfile Abidfile abidfile.rb Abidfile.rb) << abidfile
11
11
  @worker = Worker.new(self)
12
+
13
+ @config = IniFile.new(content: default_config)
14
+ @config.merge!(IniFile.load('config/abid.conf'))
12
15
  end
13
16
 
14
17
  def run
15
- Rake.application = self
18
+ Abid.application = self
16
19
  super
17
20
  end
18
21
 
19
- def init(app_name = 'abid')
20
- standard_exception_handling do
21
- @config = IniFile.new(content: default_config)
22
- @config.merge!(IniFile.load('config/abid.conf'))
23
- end
24
-
25
- super(app_name)
26
- end
27
-
28
22
  # allows the built-in tasks to load without a abidfile
29
23
  def abidfile
30
24
  File.expand_path(File.join(File.dirname(__FILE__), '..', 'Abidfile.rb'))
@@ -15,6 +15,10 @@ module Abid
15
15
  def helpers(*extensions, &block)
16
16
  Abid::Play.helpers(*extensions, &block)
17
17
  end
18
+
19
+ def invoke(task, *args, **params)
20
+ Rake.application[task, **params].async_invoke(*args).wait!
21
+ end
18
22
  end
19
23
  end
20
24
 
data/lib/abid/play.rb CHANGED
@@ -15,9 +15,8 @@ module Abid
15
15
  end
16
16
 
17
17
  def param(name, **param_spec)
18
- params_spec[name] = { significant: true }.merge(param_spec)
19
-
20
18
  define_method(name) { task.params[name] }
19
+ params_spec[name] = { significant: true }.merge(param_spec)
21
20
  end
22
21
 
23
22
  def undef_param(name)
@@ -36,6 +35,7 @@ module Abid
36
35
 
37
36
  def set(name, value = nil, &block)
38
37
  var = :"@#{name}"
38
+
39
39
  define_method(name) do
40
40
  unless instance_variable_defined?(var)
41
41
  if !value.nil?
@@ -68,6 +68,10 @@ module Abid
68
68
  def around(&block)
69
69
  hooks[:around] << block
70
70
  end
71
+
72
+ def method_added(name)
73
+ params_spec.delete(name) # undef param
74
+ end
71
75
  end
72
76
 
73
77
  set :worker, :default
data/lib/abid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Abid
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/abid/worker.rb CHANGED
@@ -5,9 +5,6 @@ module Abid
5
5
  @pools = {}
6
6
  @pool_definitions = {}
7
7
 
8
- @pool_definitions[:waiter] = nil
9
- @pools[:waiter] = Concurrent::SimpleExecutorService.new
10
-
11
8
  if application.options.always_multitask
12
9
  default_thread_num = @application.options.thread_pool_size || \
13
10
  Rake.suggested_thread_count - 1
@@ -15,6 +12,8 @@ module Abid
15
12
  default_thread_num = 1
16
13
  end
17
14
  define(:default, default_thread_num)
15
+
16
+ define(:fresh, -1)
18
17
  end
19
18
 
20
19
  def define(name, thread_count)
@@ -24,15 +23,23 @@ module Abid
24
23
  end
25
24
 
26
25
  def [](name)
26
+ return @pools[name] if @pools.include?(name)
27
+ return self[:fresh] if name == :waiter # alias
28
+
27
29
  unless @pool_definitions.include?(name)
28
30
  fail "worker #{name} is not defined"
29
31
  end
30
32
 
31
- @pools[name] ||= Concurrent::FixedThreadPool.new(
32
- @pool_definitions[name],
33
- idletime: FIXNUM_MAX
34
- )
33
+ if @pool_definitions[name] > 0
34
+ @pools[name] = Concurrent::FixedThreadPool.new(
35
+ @pool_definitions[name],
36
+ idletime: FIXNUM_MAX
37
+ )
38
+ else
39
+ @pools[name] = Concurrent::SimpleExecutorService.new
40
+ end
35
41
  end
42
+
36
43
  def shutdown
37
44
  @pools.each do |_, pool|
38
45
  pool.shutdown
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hikaru Ojima
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-07 00:00:00.000000000 Z
11
+ date: 2016-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -157,6 +157,7 @@ files:
157
157
  - exe/abid
158
158
  - lib/Abidfile.rb
159
159
  - lib/abid.rb
160
+ - lib/abid/abid_module.rb
160
161
  - lib/abid/application.rb
161
162
  - lib/abid/concurrent_extention.rb
162
163
  - lib/abid/concurrent_extention/ivar.rb
@@ -198,3 +199,4 @@ signing_key:
198
199
  specification_version: 4
199
200
  summary: Abid is a simple Workflow Engine based on Rake.
200
201
  test_files: []
202
+ has_rdoc: