behave_fun 0.1.1 → 0.1.2

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
  SHA256:
3
- metadata.gz: fa6285d17ba7200bca3e11fb9cdb7c6fb538a7461f8cb2d9c4496e5a1f885a90
4
- data.tar.gz: 196808930dec23a365d3825da90c20e85e3a4f780a3857b67f768f718595a4fb
3
+ metadata.gz: 935e48b4d598edb584ef80612774fec7028552597b1a6e56b4d2ec4b6283f616
4
+ data.tar.gz: 9a51961b11ec757601e3912eee99918a4ec9b39b7913d7dc95aaae25218bc627
5
5
  SHA512:
6
- metadata.gz: f1cd5d323dfd2db92b4d9ac41b12cabf14ac9a56a14a317db64f32b23513f92ce0ce31285881d3e2feb0560603627891d392534ffec63ba378303eae244738fc
7
- data.tar.gz: '01139c43255bb5130e327d2152b42964266adac83752314de0923898f2eb543b438e306a0027321b0139b120c2ac06fb6f0aa17138e8f2957df0b70fc36001f8'
6
+ metadata.gz: e2a1e6a8aa77715d47b2238920626da6b232e75e4fd92cc22b525c88d7de1036c54d1c704aa29dc5276fce1573876b164b48e6492102288a5168e0c1ccb3d41f
7
+ data.tar.gz: 5592475d04f9fb7198f4d6222673a98ebe6dbeec7ecd80e22fcf580022f4a8b7ced2901dfda2e8da887b5ca432fd1a48164ebdc5b6f89914405e14d77da69fe0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- behave_fun (0.1.1)
4
+ behave_fun (0.1.2)
5
5
  activesupport (~> 6.0.0)
6
6
  zeitwerk (~> 2.3.0)
7
7
 
@@ -18,7 +18,7 @@ GEM
18
18
  diff-lcs (1.3)
19
19
  i18n (1.8.2)
20
20
  concurrent-ruby (~> 1.0)
21
- minitest (5.14.0)
21
+ minitest (5.14.1)
22
22
  rake (12.3.3)
23
23
  rspec (3.9.0)
24
24
  rspec-core (~> 3.9.0)
@@ -10,6 +10,11 @@ module BehaveFun
10
10
  @current_child.run
11
11
  end
12
12
 
13
+ def start
14
+ super
15
+ @current_child = nil
16
+ end
17
+
13
18
  def child_running
14
19
  running
15
20
  end
@@ -2,7 +2,7 @@ module BehaveFun
2
2
  class Decorators::Repeat < Decorator
3
3
  attr_accessor :counter
4
4
 
5
- def initialize(times: )
5
+ def initialize(times: -1)
6
6
  super
7
7
  @times = times
8
8
  end
@@ -13,6 +13,8 @@ module BehaveFun
13
13
  end
14
14
 
15
15
  def child_success
16
+ return @children[0].reset if @times == -1
17
+
16
18
  @counter += 1
17
19
  if @counter < @times
18
20
  @children[0].reset
@@ -22,6 +22,11 @@ module BehaveFun
22
22
  control.guard = builder.control.root
23
23
  end
24
24
 
25
+ def include(task)
26
+ cloned_task = BehaveFun.build_task { build_from_hash(task.as_json) }
27
+ @control.add_child(cloned_task)
28
+ end
29
+
25
30
  def build_from_hash(task_hash)
26
31
  type_name, params, guard_with, children =
27
32
  task_hash.values_at(:type, :params, :guard_with, :children)
@@ -1,6 +1,6 @@
1
1
  module BehaveFun
2
2
  class Tree < Task
3
- attr_accessor :root
3
+ attr_reader :root
4
4
 
5
5
  def root=(root)
6
6
  @root = root
@@ -1,3 +1,3 @@
1
1
  module BehaveFun
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
data/lib/behave_fun.rb CHANGED
@@ -9,6 +9,12 @@ loader.setup
9
9
  module BehaveFun
10
10
  module_function
11
11
 
12
+ def build_task(&block)
13
+ task = build_tree(&block).root
14
+ task.control = nil
15
+ task
16
+ end
17
+
12
18
  def build_tree(&block)
13
19
  builder = TaskBuilder.new(Tree.new)
14
20
  builder.instance_eval(&block)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: behave_fun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ayaya zhao