pione 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. data/.gitignore +3 -2
  2. data/History.txt +6 -0
  3. data/Rakefile +1 -1
  4. data/bin/pione-broker +1 -1
  5. data/bin/pione-clean +1 -1
  6. data/bin/pione-client +1 -1
  7. data/bin/pione-log +1 -1
  8. data/bin/pione-relay +1 -1
  9. data/bin/pione-relay-account-db +1 -1
  10. data/bin/pione-relay-client-db +1 -1
  11. data/bin/pione-syntax-checker +1 -1
  12. data/bin/pione-task-worker +1 -1
  13. data/bin/pione-tuple-space-provider +1 -1
  14. data/bin/pione-tuple-space-receiver +1 -1
  15. data/bin/pione-tuple-space-viewer +1 -1
  16. data/bin/pione-val +1 -1
  17. data/example/CTFCorrection/CTFCorrection.pione +78 -0
  18. data/example/CTFCorrection/package.yml +1 -0
  19. data/example/HelloWorld/scenario/output/message.txt +1 -0
  20. data/example/LoopByTouch/LoopByTouch.pione +10 -18
  21. data/example/LoopByTouch/PairLoop.pione +18 -0
  22. data/example/LoopByTouch/SingleLoop.pione +5 -0
  23. data/example/LoopByTouch/TripletLoop.pione +24 -0
  24. data/example/MakePair/scenario/output/comb-1-2.pair +0 -0
  25. data/example/MakePair/scenario/output/comb-1-3.pair +0 -0
  26. data/example/MakePair/scenario/output/comb-1-4.pair +0 -0
  27. data/example/MakePair/scenario/output/comb-1-5.pair +0 -0
  28. data/example/MakePair/scenario/output/comb-2-3.pair +0 -0
  29. data/example/MakePair/scenario/output/comb-2-4.pair +0 -0
  30. data/example/MakePair/scenario/output/comb-2-5.pair +0 -0
  31. data/example/MakePair/scenario/output/comb-3-4.pair +0 -0
  32. data/example/MakePair/scenario/output/comb-3-5.pair +0 -0
  33. data/example/MakePair/scenario/output/comb-4-5.pair +0 -0
  34. data/example/MakePair/scenario/output/perm-1-2.pair +0 -0
  35. data/example/MakePair/scenario/output/perm-1-3.pair +0 -0
  36. data/example/MakePair/scenario/output/perm-1-4.pair +0 -0
  37. data/example/MakePair/scenario/output/perm-1-5.pair +0 -0
  38. data/example/MakePair/scenario/output/perm-2-1.pair +0 -0
  39. data/example/MakePair/scenario/output/perm-2-3.pair +0 -0
  40. data/example/MakePair/scenario/output/perm-2-4.pair +0 -0
  41. data/example/MakePair/scenario/output/perm-2-5.pair +0 -0
  42. data/example/MakePair/scenario/output/perm-3-1.pair +0 -0
  43. data/example/MakePair/scenario/output/perm-3-2.pair +0 -0
  44. data/example/MakePair/scenario/output/perm-3-4.pair +0 -0
  45. data/example/MakePair/scenario/output/perm-3-5.pair +0 -0
  46. data/example/MakePair/scenario/output/perm-4-1.pair +0 -0
  47. data/example/MakePair/scenario/output/perm-4-2.pair +0 -0
  48. data/example/MakePair/scenario/output/perm-4-3.pair +0 -0
  49. data/example/MakePair/scenario/output/perm-4-5.pair +0 -0
  50. data/example/MakePair/scenario/output/perm-5-1.pair +0 -0
  51. data/example/MakePair/scenario/output/perm-5-2.pair +0 -0
  52. data/example/MakePair/scenario/output/perm-5-3.pair +0 -0
  53. data/example/MakePair/scenario/output/perm-5-4.pair +0 -0
  54. data/example/MakePair/scenario/output/succ-1-2.pair +0 -0
  55. data/example/MakePair/scenario/output/succ-2-3.pair +0 -0
  56. data/example/MakePair/scenario/output/succ-3-4.pair +0 -0
  57. data/example/MakePair/scenario/output/succ-4-5.pair +0 -0
  58. data/example/SyntaxError/output_line_error.pione +6 -0
  59. data/example/WorkflowPatterns/38_GeneralSynchronizingMerge/GeneralSynchronizingMerge.pione +94 -0
  60. data/lib/pione.rb +1 -10
  61. data/lib/pione/agent/process-manager.rb +6 -5
  62. data/lib/pione/agent/rule-provider.rb +7 -9
  63. data/lib/pione/agent/task-worker.rb +1 -1
  64. data/lib/pione/command.rb +1 -0
  65. data/lib/pione/command/basic-command.rb +12 -77
  66. data/lib/pione/command/child-process.rb +19 -13
  67. data/lib/pione/command/daemon-process.rb +0 -9
  68. data/lib/pione/command/front-owner-command.rb +0 -6
  69. data/lib/pione/command/option.rb +243 -0
  70. data/lib/pione/command/pione-broker.rb +10 -5
  71. data/lib/pione/command/pione-clean.rb +4 -0
  72. data/lib/pione/command/pione-client.rb +257 -210
  73. data/lib/pione/command/pione-log.rb +38 -19
  74. data/lib/pione/command/pione-relay-account-db.rb +42 -17
  75. data/lib/pione/command/pione-relay-client-db.rb +35 -14
  76. data/lib/pione/command/pione-relay.rb +16 -8
  77. data/lib/pione/command/pione-syntax-checker.rb +33 -13
  78. data/lib/pione/command/pione-task-worker.rb +26 -23
  79. data/lib/pione/command/pione-tuple-space-provider.rb +8 -17
  80. data/lib/pione/command/pione-tuple-space-receiver.rb +13 -3
  81. data/lib/pione/command/pione-tuple-space-viewer.rb +42 -23
  82. data/lib/pione/command/pione-val.rb +15 -7
  83. data/lib/pione/component/document.rb +49 -70
  84. data/lib/pione/component/package.rb +125 -83
  85. data/lib/pione/location/basic-location.rb +1 -0
  86. data/lib/pione/model/assignment.rb +11 -0
  87. data/lib/pione/model/parameters.rb +10 -0
  88. data/lib/pione/model/variable.rb +14 -0
  89. data/lib/pione/parser/common-parser.rb +4 -0
  90. data/lib/pione/parser/document-parser.rb +4 -3
  91. data/lib/pione/parser/rule-definition-parser.rb +2 -1
  92. data/lib/pione/patch/rinda-patch.rb +1 -1
  93. data/lib/pione/rule-handler/action-handler.rb +6 -1
  94. data/lib/pione/rule-handler/basic-handler.rb +0 -6
  95. data/lib/pione/rule-handler/flow-handler.rb +14 -9
  96. data/lib/pione/system/global.rb +3 -0
  97. data/lib/pione/system/package-cache.rb +18 -0
  98. data/lib/pione/transformer/document-transformer.rb +26 -3
  99. data/lib/pione/transformer/rule-definition-transformer.rb +10 -2
  100. data/lib/pione/tuple-space/presence-notifier.rb +4 -3
  101. data/lib/pione/uri-scheme.rb +11 -0
  102. data/lib/pione/uri-scheme/git-scheme.rb +12 -0
  103. data/lib/pione/util.rb +2 -0
  104. data/lib/pione/util/package-parameters-list.rb +32 -0
  105. data/lib/pione/util/process-info.rb +21 -0
  106. data/lib/pione/version.rb +1 -1
  107. data/pione.gemspec +1 -1
  108. data/test/agent/spec_rule-provider.rb +57 -44
  109. data/test/command/command-behavior.rb +15 -0
  110. data/test/command/spec_pione-client.rb +56 -0
  111. data/test/command/spec_pione-val.domain.dump +0 -0
  112. data/test/command/spec_pione-val.rb +22 -0
  113. data/test/component/spec_document.pione +51 -0
  114. data/test/component/spec_document.rb +41 -70
  115. data/test/component/spec_package.rb +18 -3
  116. data/test/parser/spec_document-parser.yml +15 -0
  117. data/test/parser/spec_rule-definition-parser.yml +7 -2
  118. data/test/rule-handler/spec_action-handler.rb +6 -6
  119. data/test/rule-handler/spec_flow-handler.pione +25 -0
  120. data/test/rule-handler/spec_flow-handler.rb +35 -95
  121. data/test/rule-handler/spec_update-criteria.rb +2 -2
  122. data/test/test-util.rb +68 -4
  123. data/test/transformer/spec_block-transformer.rb +1 -1
  124. data/test/transformer/spec_document-transformer.rb +50 -0
  125. data/test/transformer/spec_expr-transformer.rb +1 -1
  126. data/test/transformer/spec_flow-element-transformer.rb +13 -13
  127. data/test/transformer/spec_literal-transformer.rb +1 -1
  128. data/test/transformer/spec_rule-definition-transformer.rb +31 -19
  129. data/test/uri-scheme/spec_git-scheme.rb +20 -0
  130. data/test/util/spec_id.rb +6 -6
  131. data/test/util/spec_package-parameters-list.rb +59 -0
  132. data/test/util/spec_package-parameters-list_1.pione +17 -0
  133. data/test/util/spec_package-parameters-list_2.pione +13 -0
  134. data/test/util/spec_package-parameters-list_3.pione +12 -0
  135. data/test/util/spec_package-parameters-list_4.pione +6 -0
  136. data/test/util/spec_process-info.rb +56 -0
  137. metadata +79 -16
  138. data/lib/pione/option.rb +0 -13
  139. data/lib/pione/option/child-process-option.rb +0 -19
  140. data/lib/pione/option/common-option.rb +0 -31
  141. data/lib/pione/option/option-interface.rb +0 -73
  142. data/lib/pione/option/presence-notifier-option.rb +0 -16
  143. data/lib/pione/option/task-worker-owner-option.rb +0 -24
  144. data/lib/pione/option/tuple-space-provider-option.rb +0 -28
  145. data/lib/pione/option/tuple-space-provider-owner-option.rb +0 -18
  146. data/lib/pione/option/tuple-space-receiver-option.rb +0 -8
data/lib/pione/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Pione
2
2
  # version of pione
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
data/pione.gemspec CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |gem|
30
30
  gem.add_dependency "uuidtools", "~> 2.1.4"
31
31
  gem.add_dependency "highline", "~> 1.6.15"
32
32
  gem.add_dependency "hamster", "~> 0.4.3"
33
- gem.add_dependency "naming", "~> 0.0.2"
33
+ gem.add_dependency "naming", "~> 0.1.0"
34
34
  gem.add_dependency "forwardablex", "~> 0.1.4"
35
35
  gem.add_dependency "temppath", "~> 0.1.1"
36
36
  gem.add_dependency "ruby-xes", "~> 0.1.0"
@@ -1,65 +1,78 @@
1
1
  require_relative '../test-util'
2
- require 'pione/agent/rule-provider'
3
2
 
4
- describe "Agent::RuleProvider" do
3
+ describe "Pione::Agent::RuleProvider" do
5
4
  before do
6
- create_remote_tuple_space_server
7
- @provider = Agent[:rule_provider].start(tuple_space_server)
8
- doc = Component::Document.parse(<<-DOCUMENT)
9
- Rule abc
5
+ @ts = create_tuple_space_server
6
+ @agent = Agent[:rule_provider].new(@ts)
7
+ doc = Component::Document.load(<<-DOCUMENT)
8
+ Rule A
10
9
  input '*.a'
11
- output '{$INPUT[1].MATCH[1]}.b'
12
- Action---
13
- content "echo 'abc' > {$OUTPUT[1]}"
14
- ---End
10
+ output '{$I[1]}.result'
11
+ Action
12
+ echo A > {$O[1]}
13
+ End
15
14
 
16
- Rule xyz
17
- input '*.a'
18
- output '{$INPUT[1].MATCH[1]}.b'
19
- Action---
20
- content "echo 'xyz' > {$OUTPUT[1]}"
21
- ---End
15
+ Rule B
16
+ input '*.b'
17
+ output '{$I[1]}.result'
18
+ Action
19
+ echo B > {$[1]}
20
+ End
21
+ DOCUMENT
22
+ @rule_a = doc.find('A')
23
+ @rule_b = doc.find('B')
24
+ @agent.read_rules(doc)
25
+ end
26
+
27
+ after do
28
+ @agent.terminate
29
+ @ts.terminate
30
+ end
31
+
32
+ it "should have rules" do
33
+ @agent.known_rules.should.include "&Main:A"
34
+ @agent.known_rules.should.include "&Main:B"
35
+ end
36
+
37
+ it "should add a rule" do
38
+ doc = Component::Document.load(<<-DOCUMENT)
39
+ Rule C
40
+ input '*.c'
41
+ output '{$I[1]}.result'
42
+ Action
43
+ echo C > {$O[1]}
44
+ End
22
45
  DOCUMENT
23
- @rule_abc = doc['&main:abc']
24
- @rule_xyz = doc['&main:xyz']
25
- @provider.read_document(doc)
46
+ @agent.read_rules(doc)
47
+ @agent.known_rules.should.include "&Main:C"
26
48
  end
27
49
 
28
- it "should provide known rule information" do
50
+ it "should provide requested rule" do
51
+ @agent.start
52
+
29
53
  # wait provider's setup
30
- @provider.wait_till(:request_waiting)
54
+ @agent.wait_till(:request_waiting)
55
+
31
56
  # write a request
32
- write_and_wait_to_be_taken(Tuple[:request_rule].new(rule_path: '&main:abc'))
57
+ write_and_wait_to_be_taken(Tuple[:request_rule].new(rule_path: '&Main:A'))
33
58
  check_exceptions
59
+
34
60
  # check rule tuple
35
61
  should.not.raise(Rinda::RequestExpiredError) do
36
- rule = read(Tuple[:rule].new(rule_path: '&main:abc'))
37
- rule.status.should == :known
38
- rule.content.class.should == Rule::ActionRule
39
- rule.content.should == @rule_abc
62
+ tuple = read!(Tuple[:rule].new(rule_path: '&Main:A'))
63
+ tuple.content.class.should == Component::ActionRule
64
+ tuple.content.should == @rule_a
40
65
  end
66
+
41
67
  # write another request
42
- write_and_wait_to_be_taken(Tuple[:request_rule].new(rule_path: '&main:xyz'))
68
+ write_and_wait_to_be_taken(Tuple[:request_rule].new(rule_path: '&Main:B'))
43
69
  check_exceptions
44
- # check rule tuple
45
- should.not.raise(Rinda::RequestExpiredError) do
46
- rule = read(Tuple[:rule].new(rule_path: '&main:xyz'))
47
- rule.status.should == :known
48
- rule.content.class.should == Rule::ActionRule
49
- rule.content.should == @rule_xyz
50
- end
51
- end
52
70
 
53
- it "should provide unknown rule information" do
54
- # wait provider's setup
55
- @provider.wait_till(:request_waiting)
56
- # write a request
57
- write_and_wait_to_be_taken(Tuple[:request_rule].new(rule_path: "aaa"))
58
- check_exceptions
59
- # check unknown rule tuple
71
+ # check rule tuple
60
72
  should.not.raise(Rinda::RequestExpiredError) do
61
- rule = read(Tuple[:rule].new(rule_path: "aaa"))
62
- rule.status.should == :unknown
73
+ tuple = read!(Tuple[:rule].new(rule_path: '&Main:B'))
74
+ tuple.content.class.should == Component::ActionRule
75
+ tuple.content.should == @rule_b
63
76
  end
64
77
  end
65
78
  end
@@ -0,0 +1,15 @@
1
+ shared "command" do
2
+ it "should show a help message" do
3
+ res = TestUtil::Command.succeed do
4
+ Command::PioneVal.run ["--help"]
5
+ end
6
+ res.stdout.string.should.start_with "Usage"
7
+ end
8
+
9
+ it "should show a version message" do
10
+ res = TestUtil::Command.succeed do
11
+ Command::PioneVal.run ["--version"]
12
+ end
13
+ res.stdout.string.should.include Pione::VERSION
14
+ end
15
+ end
@@ -0,0 +1,56 @@
1
+ require_relative '../test-util'
2
+ require_relative 'command-behavior'
3
+
4
+ describe "Pione::Command::PioneClient" do
5
+ behaves_like "command"
6
+
7
+ ### is this wrong?
8
+ # it "should execute a PIONE document" do
9
+ # path = Temppath.create
10
+ # args = ["example/HelloWorld/HelloWorld.pione", "-o", path.to_s]
11
+ # res = TestUtil::Command.succeed do
12
+ # Pione::Command::PioneClient.run args
13
+ # end
14
+ # Location[path + "message.txt"].should.exist
15
+ # Location[path + "message.txt"].read.should.start_with "Hello, world!"
16
+ # end
17
+
18
+ it "should execute a PIONE document with stand alone mode" do
19
+ path = Temppath.create
20
+ args = ["example/HelloWorld/HelloWorld.pione", "-o", path.to_s, "--stand-alone"]
21
+ res = TestUtil::Command.succeed do
22
+ Pione::Command::PioneClient.run args
23
+ end
24
+ Location[path + "message.txt"].should.exist
25
+ Location[path + "message.txt"].read.should.start_with "Hello, world!"
26
+ end
27
+
28
+ # it "should execute a PIONE package" do
29
+ # path = Temppath.create
30
+ # args = ["example/HelloWorld/", "-o", path.to_s]
31
+ # res = TestUtil::Command.succeed do
32
+ # Pione::Command::PioneClient.run args
33
+ # end
34
+ # Location[path + "message.txt"].should.exist
35
+ # Location[path + "message.txt"].read.should.start_with "Hello, world!"
36
+ # end
37
+
38
+ it "should execute a PIONE package with stand alone mode" do
39
+ path = Temppath.create
40
+ args = ["example/HelloWorld/", "-o", path.to_s, "--stand-alone"]
41
+ res = TestUtil::Command.succeed do
42
+ Pione::Command::PioneClient.run args
43
+ end
44
+ Location[path + "message.txt"].should.exist
45
+ Location[path + "message.txt"].read.should.start_with "Hello, world!"
46
+ end
47
+
48
+ it "should show parameters list of package" do
49
+ args = ["example/HelloWorld/HelloWorld.pione", "--list-params"]
50
+ res = TestUtil::Command.succeed do
51
+ Pione::Command::PioneClient.run args
52
+ end
53
+ res.stdout.string.size.should > 0
54
+ end
55
+ end
56
+
@@ -0,0 +1,22 @@
1
+ require_relative '../test-util'
2
+ require_relative 'command-behavior'
3
+
4
+ describe "Pione::Command::PioneVal" do
5
+ behaves_like "command"
6
+
7
+ it "should get value" do
8
+ res = TestUtil::Command.succeed do
9
+ Command::PioneVal.run ["1 + 1"]
10
+ end
11
+ res.stdout.string.chomp.should == "2"
12
+ end
13
+
14
+ it "should get variable from domain info" do
15
+ domain_info = TestUtil::DIR + "command" + "spec_pione-val.domain.dump"
16
+ res = TestUtil::Command.succeed do
17
+ Command::PioneVal.run ["$O[1]", "--domain-info", domain_info.path.to_s]
18
+ end
19
+ res.stdout.string.chomp.should == "message.txt"
20
+ end
21
+ end
22
+
@@ -0,0 +1,51 @@
1
+ Param
2
+ $P1 := "a"
3
+ $P2 := "b"
4
+ $P3 := "c"
5
+ End
6
+
7
+ param $P4 := "d"
8
+ param $P5 := "e"
9
+
10
+ $P6 := "f"
11
+
12
+ $X := 1
13
+
14
+ Rule Main
15
+ input '*.txt'
16
+ output '*.result'
17
+ Flow
18
+ rule RuleA
19
+ rule RuleB
20
+ rule RuleC
21
+ End
22
+
23
+ Rule RuleA
24
+ input '*.txt'
25
+ output '{$I[1,1]}.a'
26
+ Action
27
+ command_a {$I[1]} > {$O[1]}
28
+ End
29
+
30
+ Rule RuleB
31
+ input '*.a'
32
+ output '{$I[1,1]}.b'
33
+ Action
34
+ command_b {$I[1]} > {$O[1]}
35
+ End
36
+
37
+ Rule RuleC
38
+ input '*.b'
39
+ output '{$I[1,1]}.result'
40
+ Action
41
+ command_c {$I[1]} > {$O[1]}
42
+ End
43
+
44
+ Rule TestParams
45
+ input '*.input'
46
+ output '{$*}.output'
47
+ param $P1
48
+ Action
49
+ echo `echo {$I[1]}` {$P1} > {$O[1]}
50
+ End
51
+
@@ -1,93 +1,64 @@
1
1
  require_relative '../test-util'
2
2
 
3
- src = <<DOCUMENT
4
- Param
5
- $P1 := "a"
6
- $P2 := "b"
7
- $P3 := "c"
8
- End
3
+ document_location = Location[File.dirname(__FILE__)] + "spec_document.pione"
9
4
 
10
- param $P4 := "d"
11
- param $P5 := "e"
12
-
13
- $X := 1
14
-
15
- Rule Main
16
- input '*.txt'
17
- output '*.result'
18
- Flow
19
- rule RuleA
20
- rule RuleB
21
- rule RuleC
22
- End
23
-
24
- Rule RuleA
25
- input '*.txt'
26
- output '{$I[1,1]}.a'
27
- Action
28
- command_a {$I[1]} > {$O[1]}
29
- End
30
-
31
- Rule RuleB
32
- input '*.a'
33
- output '{$I[1,1]}.b'
34
- Action
35
- command_b {$I[1]} > {$O[1]}
36
- End
5
+ describe 'Pione::Component::Document' do
6
+ before do
7
+ @document = Component::Document.load(document_location)
8
+ end
37
9
 
38
- Rule RuleC
39
- input '*.b'
40
- output '{$I[1,1]}.result'
41
- Action
42
- command_c {$I[1]} > {$O[1]}
43
- End
44
- DOCUMENT
10
+ it 'should load a document from a file' do
11
+ @document.rules.map{|rule| rule.name}.tap do |x|
12
+ x.should.include "Main"
13
+ x.should.include "RuleA"
14
+ x.should.include "RuleB"
15
+ x.should.include "RuleC"
16
+ end
17
+ end
45
18
 
46
- describe 'Pione::Component::Document' do
47
- it 'should read a document from a string' do
48
- doc = Component::Document.parse(src)
49
- doc.rules.size.should == 4
19
+ it 'should load a document from a string' do
20
+ Component::Document.load(document_location.read).should == @document
50
21
  end
51
22
 
52
- it 'should read a document from a file' do
53
- temp = Tempfile.new("spec_document")
54
- temp.write(src)
55
- path = temp.path
56
- temp.close(false)
57
- doc = Component::Document.load(path)
58
- doc.rules.size.should == 4
23
+ it 'should load a document with package name' do
24
+ document = Component::Document.load(document_location, "Test")
25
+ document.package_name.should == "Test"
26
+ document.find("Main").package_name == "Test"
59
27
  end
60
28
 
61
- it 'should get rules by rule path' do
62
- doc = Component::Document.parse(src)
63
- doc["&main:Main"].should.kind_of(Component::Rule)
64
- doc["&main:RuleA"].should.kind_of(Component::Rule)
65
- doc["&main:RuleB"].should.kind_of(Component::Rule)
66
- doc["&main:RuleC"].should.kind_of(Component::Rule)
29
+ it 'should get rule by name' do
30
+ @document.find("Main").should.kind_of(Component::FlowRule)
31
+ @document.find("RuleA").should.kind_of(Component::ActionRule)
32
+ @document.find("RuleB").should.kind_of(Component::ActionRule)
33
+ @document.find("RuleC").should.kind_of(Component::ActionRule)
67
34
  end
68
35
 
69
36
  it 'should have document parameters' do
70
- doc = Component::Document.parse(src)
71
- doc.params["P1"].should == PioneString.new("a").to_seq
72
- doc.params["P2"].should == PioneString.new("b").to_seq
73
- doc.params["P3"].should == PioneString.new("c").to_seq
74
- doc.params["P4"].should == PioneString.new("d").to_seq
75
- doc.params["P5"].should == PioneString.new("e").to_seq
76
- user_params = doc.params.data.select{|var, val| var.user_param}.map{|var, val| var.name}
37
+ @document.params["P1"].should == PioneString.new("a").to_seq
38
+ @document.params["P2"].should == PioneString.new("b").to_seq
39
+ @document.params["P3"].should == PioneString.new("c").to_seq
40
+ @document.params["P4"].should == PioneString.new("d").to_seq
41
+ @document.params["P5"].should == PioneString.new("e").to_seq
42
+ @document.params["P6"].should == PioneString.new("f").to_seq
43
+ user_params = @document.params.data.select{|var, val| var.user_param}.map{|var, val| var.name}
77
44
  user_params.sort.should == ["P1", "P2", "P3", "P4", "P5"]
78
45
  end
79
46
 
80
47
  it 'should have document variable bindings' do
81
- doc = Component::Document.parse(src)
82
- doc["&main:Main"].condition.params["X"].should == 1.to_pione.to_seq
83
- doc["&main:RuleA"].condition.params["X"].should == 1.to_pione.to_seq
84
- doc["&main:RuleB"].condition.params["X"].should == 1.to_pione.to_seq
85
- doc["&main:RuleC"].condition.params["X"].should == 1.to_pione.to_seq
48
+ @document.find("Main").condition.params["X"].should == 1.to_pione.to_seq
49
+ @document.find("RuleA").condition.params["X"].should == 1.to_pione.to_seq
50
+ @document.find("RuleB").condition.params["X"].should == 1.to_pione.to_seq
51
+ @document.find("RuleC").condition.params["X"].should == 1.to_pione.to_seq
52
+ end
53
+
54
+ it 'should create root rule' do
55
+ root = @document.create_root_rule(@document.find("Main"), Model::Parameters.empty)
56
+ root.should.kind_of(Component::RootRule)
86
57
  end
87
58
 
88
59
  it 'should raise variable binding error' do
89
60
  should.raise(VariableBindingError) do
90
- Component::Document.parse <<-PIONE
61
+ Component::Document.load <<-PIONE
91
62
  $X := 1
92
63
  $X := 2
93
64
  PIONE
@@ -34,12 +34,14 @@ describe "Pione::Component::Package" do
34
34
  end
35
35
 
36
36
  it "should get rules" do
37
- @package.rules.keys.should.include("&TestPackage:Main")
38
- @package.rules.keys.should.include("&TestPackage:Count")
37
+ @package.rules.map{|rule| rule.path}.tap do |x|
38
+ x.should.include("&TestPackage:Main")
39
+ x.should.include("&TestPackage:Count")
40
+ end
39
41
  end
40
42
 
41
43
  it "should get a main rule" do
42
- @package.main.path.should == "&TestPackage:Main"
44
+ @package.find_rule("Main").path.should == "&TestPackage:Main"
43
45
  end
44
46
 
45
47
  it "should upload package files" do
@@ -75,3 +77,16 @@ describe "Pione::Component::PackageScenario" do
75
77
  @scenario.name.should == "TestCase1"
76
78
  end
77
79
  end
80
+
81
+ describe "Pione::Component::PackageReader" do
82
+ it "should read package directory" do
83
+ path = Location[File.expand_path("../spec_package", __FILE__)] + "TestPackage"
84
+ Component::PackageReader.new(path).type.should == :directory
85
+ end
86
+
87
+ it "should read the package and return it" do
88
+ path = Location[File.expand_path("../spec_package", __FILE__)] + "TestPackage"
89
+ Component::PackageReader.read(path).should.kind_of Component::Package
90
+ end
91
+ end
92
+