abid 0.2.4 → 0.2.5

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: 7c41573b12be68e4e74a00c7d8014e7f2d3cc435
4
- data.tar.gz: b9e43e1b4d742c798972984090eab802245db56f
3
+ metadata.gz: fc06867a8a623282880bbcad00cec48c90e82b6b
4
+ data.tar.gz: b833ae4472677b2f4f68dd6b8ecfefe022995354
5
5
  SHA512:
6
- metadata.gz: 8ea210978f2e500611a2ccee925413d8e1e85dcb54cc770ca626622ca588c52650324925c00aa5a47178e732cdf0adaa88fe0a7c79436fd399785d888426ff38
7
- data.tar.gz: f5fd045370053a9fd27e88d007a071bb888f4b658082ed331d1b81aff6ee303fa040705908f64be6d3af21b3ea2f2dfd9ee80dff2597e4c13d3084cc97a20cca
6
+ metadata.gz: f87dbbe6e1e99afd8a7c0f420371e65cdff0ad6f988cc14f3be05a11e7d4355fd3f9b3b0c8d02541f862770356e3bcc77fa1524b13b75b793cecc0a709a486e2
7
+ data.tar.gz: d4566051016776a2b9bf7567b739c1110dd6f3eb20426a103bb1da4993098195f1604f959cde02fd88ad653a5eae1b6791b80b3471df08ce4c020542e478498e
@@ -19,6 +19,10 @@ module Abid
19
19
  def invoke(task, *args, **params)
20
20
  Rake.application[task, **params].async_invoke(*args).wait!
21
21
  end
22
+
23
+ def mixin(*args, &block)
24
+ Abid::MixinTask.define_mixin(*args, &block)
25
+ end
22
26
  end
23
27
  end
24
28
 
@@ -0,0 +1,23 @@
1
+ module Abid
2
+ class MixinTask < Rake::Task
3
+ class Mixin < Module
4
+ include PlayCore
5
+ end
6
+
7
+ attr_accessor :mixin_definition
8
+
9
+ def mixin
10
+ @mixin ||= Mixin.new(&mixin_definition)
11
+ end
12
+
13
+ def execute(_args = nil)
14
+ fail 'mixin is not executable'
15
+ end
16
+
17
+ class <<self
18
+ def define_mixin(*args, &block) # :nodoc:
19
+ Rake.application.define_mixin(self, *args, &block)
20
+ end
21
+ end
22
+ end
23
+ end
data/lib/abid/play.rb CHANGED
@@ -2,6 +2,8 @@ require 'forwardable'
2
2
 
3
3
  module Abid
4
4
  class Play
5
+ extend PlayCore
6
+
5
7
  class << self
6
8
  attr_accessor :task
7
9
 
@@ -28,21 +30,6 @@ module Abid
28
30
  @hooks ||= Hash.new { |h, k| h[k] = [] }
29
31
  end
30
32
 
31
- def set(name, value = nil, &block)
32
- var = :"@#{name}"
33
-
34
- define_method(name) do
35
- unless instance_variable_defined?(var)
36
- if !value.nil?
37
- instance_variable_set(var, value)
38
- elsif block_given?
39
- instance_variable_set(var, instance_eval(&block))
40
- end
41
- end
42
- instance_variable_get(var)
43
- end
44
- end
45
-
46
33
  def helpers(*extensions, &block)
47
34
  class_eval(&block) if block_given?
48
35
  include(*extensions) if extensions.any?
@@ -0,0 +1,34 @@
1
+ module Abid
2
+ module PlayCore
3
+ def set(name, value = nil, &block)
4
+ var = :"@#{name}"
5
+
6
+ define_method(name) do
7
+ unless instance_variable_defined?(var)
8
+ if !value.nil?
9
+ instance_variable_set(var, value)
10
+ elsif block_given?
11
+ instance_variable_set(var, instance_eval(&block))
12
+ end
13
+ end
14
+ instance_variable_get(var)
15
+ end
16
+ end
17
+
18
+ def include(*mod)
19
+ ms = mod.map do |m|
20
+ if m.is_a? Module
21
+ m
22
+ else
23
+ mixin_task = Rake.application[m, @scope]
24
+
25
+ fail "#{m} is not a mixin" unless mixin_task.is_a? MixinTask
26
+
27
+ mixin_task.mixin
28
+ end
29
+ end
30
+
31
+ super(*ms)
32
+ end
33
+ end
34
+ end
@@ -11,6 +11,12 @@ module Abid
11
11
  end
12
12
  end
13
13
 
14
+ def define_mixin(task_class, mixin_name, &block)
15
+ define_task(task_class, mixin_name).tap do |task|
16
+ task.mixin_definition = block
17
+ end
18
+ end
19
+
14
20
  def [](task_name, scopes = nil, **params)
15
21
  task = super(task_name, scopes)
16
22
 
data/lib/abid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Abid
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
data/lib/abid.rb CHANGED
@@ -18,10 +18,12 @@ require 'abid/abid_module'
18
18
  require 'abid/waiter'
19
19
  require 'abid/worker'
20
20
  require 'abid/params_parser'
21
+ require 'abid/play_core'
21
22
  require 'abid/play'
22
23
  require 'abid/session'
23
24
  require 'abid/state'
24
25
  require 'abid/task'
26
+ require 'abid/mixin_task'
25
27
  require 'abid/task_manager'
26
28
  require 'abid/dsl_definition'
27
29
  require 'abid/application'
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.4
4
+ version: 0.2.5
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-28 00:00:00.000000000 Z
11
+ date: 2016-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -160,8 +160,10 @@ files:
160
160
  - lib/abid/abid_module.rb
161
161
  - lib/abid/application.rb
162
162
  - lib/abid/dsl_definition.rb
163
+ - lib/abid/mixin_task.rb
163
164
  - lib/abid/params_parser.rb
164
165
  - lib/abid/play.rb
166
+ - lib/abid/play_core.rb
165
167
  - lib/abid/rake_extensions.rb
166
168
  - lib/abid/rake_extensions/task.rb
167
169
  - lib/abid/session.rb
@@ -193,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
195
  version: '0'
194
196
  requirements: []
195
197
  rubyforge_project:
196
- rubygems_version: 2.5.2
198
+ rubygems_version: 2.2.2
197
199
  signing_key:
198
200
  specification_version: 4
199
201
  summary: Abid is a simple Workflow Engine based on Rake.