pione 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/History.txt +11 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/bin/pione-log +5 -0
- data/example/CountChar/CountChar.pione +1 -1
- data/example/SieveOfEratosthenes/SieveOfEratosthenes.pione +39 -38
- data/lib/pione.rb +14 -35
- data/lib/pione/agent/input-generator.rb +38 -40
- data/lib/pione/agent/logger.rb +52 -19
- data/lib/pione/agent/rule-provider.rb +5 -8
- data/lib/pione/agent/task-worker.rb +25 -32
- data/lib/pione/agent/tuple-space-client.rb +22 -14
- data/lib/pione/command.rb +21 -0
- data/lib/pione/command/basic-command.rb +267 -84
- data/lib/pione/command/child-process.rb +21 -18
- data/lib/pione/command/daemon-process.rb +9 -8
- data/lib/pione/command/front-owner-command.rb +8 -25
- data/lib/pione/command/pione-broker.rb +27 -24
- data/lib/pione/command/pione-clean.rb +6 -6
- data/lib/pione/command/pione-client.rb +143 -128
- data/lib/pione/command/pione-log.rb +61 -0
- data/lib/pione/command/pione-relay-account-db.rb +40 -38
- data/lib/pione/command/pione-relay-client-db.rb +38 -42
- data/lib/pione/command/pione-relay.rb +19 -20
- data/lib/pione/command/pione-syntax-checker.rb +70 -45
- data/lib/pione/command/pione-task-worker.rb +56 -66
- data/lib/pione/command/pione-tuple-space-provider.rb +36 -45
- data/lib/pione/command/pione-tuple-space-receiver.rb +34 -32
- data/lib/pione/command/pione-tuple-space-viewer.rb +63 -47
- data/lib/pione/location.rb +10 -0
- data/lib/pione/location/basic-location.rb +272 -0
- data/lib/pione/location/dropbox-location.rb +139 -0
- data/lib/pione/location/ftp-location.rb +156 -0
- data/lib/pione/location/local-location.rb +116 -0
- data/lib/pione/log.rb +10 -0
- data/lib/pione/log/domain-info.rb +72 -0
- data/lib/pione/log/process-log.rb +176 -0
- data/lib/pione/log/process-record.rb +189 -0
- data/lib/pione/log/xes-log.rb +105 -0
- data/lib/pione/model/assignment.rb +88 -80
- data/lib/pione/model/binary-operator.rb +74 -68
- data/lib/pione/model/block.rb +218 -207
- data/lib/pione/model/boolean.rb +123 -112
- data/lib/pione/model/call-rule.rb +72 -65
- data/lib/pione/model/data-expr.rb +596 -290
- data/lib/pione/model/float.rb +108 -103
- data/lib/pione/model/integer.rb +133 -129
- data/lib/pione/model/message.rb +79 -72
- data/lib/pione/model/package.rb +42 -38
- data/lib/pione/model/parameters.rb +265 -236
- data/lib/pione/model/rule-expr.rb +247 -242
- data/lib/pione/model/rule-io.rb +137 -133
- data/lib/pione/model/rule.rb +307 -292
- data/lib/pione/model/string.rb +110 -99
- data/lib/pione/model/variable-table.rb +300 -271
- data/lib/pione/model/variable.rb +88 -83
- data/lib/pione/option.rb +13 -0
- data/lib/pione/option/child-process-option.rb +19 -0
- data/lib/pione/{command-option → option}/common-option.rb +6 -5
- data/lib/pione/option/option-interface.rb +73 -0
- data/lib/pione/{command-option → option}/presence-notifier-option.rb +4 -3
- data/lib/pione/option/task-worker-owner-option.rb +24 -0
- data/lib/pione/{command-option → option}/tuple-space-provider-option.rb +6 -4
- data/lib/pione/option/tuple-space-provider-owner-option.rb +18 -0
- data/lib/pione/option/tuple-space-receiver-option.rb +8 -0
- data/lib/pione/parser/common-parser.rb +3 -2
- data/lib/pione/parser/expr-parser.rb +6 -1
- data/lib/pione/patch/em-ftpd-patch.rb +21 -0
- data/lib/pione/patch/rinda-patch.rb +31 -23
- data/lib/pione/rule-handler/action-handler.rb +35 -25
- data/lib/pione/rule-handler/basic-handler.rb +92 -18
- data/lib/pione/rule-handler/flow-handler.rb +104 -98
- data/lib/pione/rule-handler/root-handler.rb +11 -0
- data/lib/pione/system/common.rb +10 -0
- data/lib/pione/system/file-cache.rb +103 -84
- data/lib/pione/system/global.rb +67 -12
- data/lib/pione/system/init.rb +20 -0
- data/lib/pione/transformer/expr-transformer.rb +6 -1
- data/lib/pione/tuple-space/data-finder.rb +33 -6
- data/lib/pione/tuple-space/tuple-space-receiver.rb +4 -3
- data/lib/pione/tuple-space/tuple-space-server-interface.rb +58 -13
- data/lib/pione/tuple-space/tuple-space-server.rb +13 -11
- data/lib/pione/tuple-space/update-criteria.rb +8 -7
- data/lib/pione/tuple/base-location-tuple.rb +9 -0
- data/lib/pione/tuple/basic-tuple.rb +7 -7
- data/lib/pione/tuple/data-tuple.rb +5 -2
- data/lib/pione/tuple/lift-tuple.rb +14 -0
- data/lib/pione/tuple/rule-tuple.rb +1 -1
- data/lib/pione/tuple/task-tuple.rb +5 -1
- data/lib/pione/version.rb +1 -1
- data/pione.gemspec +5 -1
- data/test/location/spec_basic-location.rb +35 -0
- data/test/location/spec_ftp-location.rb +100 -0
- data/test/location/spec_local-location.rb +99 -0
- data/test/log/data/sample.log +1003 -0
- data/test/log/spec_xes-log.rb +11 -0
- data/test/model/spec_data-expr.rb +249 -6
- data/test/model/spec_data-expr.yml +45 -0
- data/test/parser/spec_expr-parser.yml +4 -0
- data/test/spec_data-finder.rb +13 -7
- data/test/spec_data-finder.yml +42 -13
- data/test/system/spec_file-cache.rb +39 -0
- data/test/test-util.rb +226 -1
- data/test/transformer/spec_expr-transformer.rb +12 -1
- metadata +107 -24
- data/bin/pione-search-log +0 -30
- data/lib/pione/command-option/basic-option.rb +0 -42
- data/lib/pione/command-option/child-process-option.rb +0 -17
- data/lib/pione/command-option/daemon-option.rb +0 -12
- data/lib/pione/command-option/task-worker-owner-option.rb +0 -17
- data/lib/pione/command-option/tuple-space-provider-owner-option.rb +0 -16
- data/lib/pione/command-option/tuple-space-receiver-option.rb +0 -12
- data/lib/pione/command/tuple-space-provider-owner.rb +0 -6
- data/lib/pione/resource/basic-resource.rb +0 -92
- data/lib/pione/resource/dropbox-resource.rb +0 -106
- data/lib/pione/resource/ftp.rb +0 -84
- data/lib/pione/resource/local.rb +0 -113
- data/lib/pione/tuple/base-uri-tuple.rb +0 -9
- data/lib/pione/tuple/shift-tuple.rb +0 -13
- data/lib/pione/util/log.rb +0 -79
- data/test/spec_resource.rb +0 -73
data/lib/pione/model/variable.rb
CHANGED
@@ -1,98 +1,103 @@
|
|
1
|
-
module Pione
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
# the variable name is unbound in the table.
|
24
|
-
# @param [VariableTable] vtable
|
25
|
-
# variable table for evaluation
|
26
|
-
# @return [BasicModel]
|
27
|
-
# evaluation result
|
28
|
-
def eval(vtable)
|
29
|
-
val = vtable.get(self)
|
30
|
-
raise UnboundVariableError.new(self) if val.nil?
|
31
|
-
return val
|
32
|
-
end
|
1
|
+
module Pione
|
2
|
+
module Model
|
3
|
+
# Variable represent variable name objects. A variable object can evaluates
|
4
|
+
# its value with the variable table.
|
5
|
+
class Variable < BasicModel
|
6
|
+
set_pione_model_type TypeAny
|
7
|
+
|
8
|
+
attr_reader :name
|
9
|
+
|
10
|
+
# true if the variable is user parameter
|
11
|
+
attr_reader :user_param
|
12
|
+
|
13
|
+
# Create a variable with name.
|
14
|
+
#
|
15
|
+
# @param name [String]
|
16
|
+
# variable name
|
17
|
+
def initialize(name)
|
18
|
+
@name = name.to_s
|
19
|
+
@toplevel = nil
|
20
|
+
@user_param = nil
|
21
|
+
super()
|
22
|
+
end
|
33
23
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
24
|
+
# Evaluate self variable name in the table and returns it. Return self if
|
25
|
+
# the variable name is unbound in the table.
|
26
|
+
#
|
27
|
+
# @param vtable [VariableTable]
|
28
|
+
# variable table for evaluation
|
29
|
+
# @return [BasicModel]
|
30
|
+
# evaluation result
|
31
|
+
def eval(vtable)
|
32
|
+
val = vtable.get(self)
|
33
|
+
raise UnboundVariableError.new(self) if val.nil?
|
34
|
+
return val
|
35
|
+
end
|
40
36
|
|
41
|
-
|
42
|
-
|
43
|
-
@
|
44
|
-
|
37
|
+
# Return true because variable is a variable.
|
38
|
+
#
|
39
|
+
# @return [Boolean]
|
40
|
+
# true
|
41
|
+
def include_variable?
|
42
|
+
true
|
43
|
+
end
|
45
44
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
# Set truth of toplevel variable.
|
46
|
+
def set_toplevel(b)
|
47
|
+
@toplevel = b
|
48
|
+
end
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
@toplevel
|
56
|
-
end
|
50
|
+
# Set truth of user parameter.
|
51
|
+
def set_user_param(b)
|
52
|
+
@user_param = b
|
53
|
+
end
|
57
54
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
55
|
+
# Return true if the variable is defined in toplevel.
|
56
|
+
#
|
57
|
+
# @return [Boolean]
|
58
|
+
# true if the variable is defined in toplevel
|
59
|
+
def toplevel?
|
60
|
+
@toplevel
|
61
|
+
end
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
63
|
+
# @api private
|
64
|
+
def task_id_string
|
65
|
+
"Variable<#{@name}>"
|
66
|
+
end
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
unless other.kind_of?(self.class)
|
72
|
-
raise ArgumentError.new(other)
|
68
|
+
# @api private
|
69
|
+
def textize
|
70
|
+
"$%s" % @name
|
73
71
|
end
|
74
|
-
@name <=> other.name
|
75
|
-
end
|
76
72
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
other
|
81
|
-
|
73
|
+
# Compare with other variable.
|
74
|
+
#
|
75
|
+
# @api private
|
76
|
+
def <=>(other)
|
77
|
+
unless other.kind_of?(self.class)
|
78
|
+
raise ArgumentError.new(other)
|
79
|
+
end
|
80
|
+
@name <=> other.name
|
81
|
+
end
|
82
82
|
|
83
|
-
|
83
|
+
# Return true if other is a variable object which name is same as myself.
|
84
|
+
#
|
85
|
+
# @api private
|
86
|
+
def ==(other)
|
87
|
+
other.kind_of?(self.class) && @name == other.name
|
88
|
+
end
|
89
|
+
alias :eql? :"=="
|
84
90
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
91
|
+
# @api private
|
92
|
+
def hash
|
93
|
+
@name.hash
|
94
|
+
end
|
89
95
|
|
90
|
-
|
91
|
-
|
92
|
-
|
96
|
+
# @api private
|
97
|
+
def inspect
|
98
|
+
"#<Pione::Model::Variable @name=%s>" % @name.inspect
|
99
|
+
end
|
100
|
+
alias :to_s :inspect
|
93
101
|
end
|
94
|
-
|
95
|
-
# @api private
|
96
|
-
alias :to_s :inspect
|
97
102
|
end
|
98
103
|
end
|
data/lib/pione/option.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
module Pione
|
2
|
+
# Option is a name space for command option set modules.
|
3
|
+
module Option; end
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'pione/option/option-interface'
|
7
|
+
require 'pione/option/common-option'
|
8
|
+
require 'pione/option/child-process-option'
|
9
|
+
require 'pione/option/presence-notifier-option'
|
10
|
+
require 'pione/option/tuple-space-provider-option'
|
11
|
+
require 'pione/option/tuple-space-provider-owner-option'
|
12
|
+
require 'pione/option/tuple-space-receiver-option'
|
13
|
+
require 'pione/option/task-worker-owner-option'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Pione
|
2
|
+
module Option
|
3
|
+
# ChildProcessOption provides options for child process like
|
4
|
+
# pione-task-worker or pione-tuple-space-receiver.
|
5
|
+
module ChildProcessOption
|
6
|
+
extend OptionInterface
|
7
|
+
|
8
|
+
# --parent-front
|
9
|
+
option('--parent-front=URI', 'set parent front URI') do |data, uri|
|
10
|
+
data[:parent_front] = DRbObject.new_with_uri(uri)
|
11
|
+
end
|
12
|
+
|
13
|
+
# --no-parent
|
14
|
+
option('--no-parent', 'turn on no parent mode') do
|
15
|
+
data[:no_parent_mode] = true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,26 +1,27 @@
|
|
1
1
|
module Pione
|
2
|
-
module
|
2
|
+
module Option
|
3
|
+
# CommonOption provides common options for pione commands.
|
3
4
|
module CommonOption
|
4
5
|
extend OptionInterface
|
5
6
|
|
6
7
|
# --debug
|
7
|
-
|
8
|
+
option('-d', '--debug', "turn on debug mode") do |data, name|
|
8
9
|
Pione.debug_mode = true
|
9
10
|
end
|
10
11
|
|
11
12
|
# --show-communication
|
12
|
-
|
13
|
+
option('--show-communication', "show object communication") do |data, show|
|
13
14
|
Global.show_communication = true
|
14
15
|
end
|
15
16
|
|
16
17
|
# --color
|
17
|
-
|
18
|
+
option('--[no-]color', 'turn on/off color mode') do |data, str|
|
18
19
|
bool = nil
|
19
20
|
bool = true if str == "true"
|
20
21
|
bool = false if str == "false"
|
21
22
|
if bool.nil?
|
22
23
|
puts "invalid color option: %s" % bool
|
23
|
-
exit
|
24
|
+
exit!
|
24
25
|
end
|
25
26
|
Terminal.color_mode = bool
|
26
27
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Pione
|
2
|
+
module Option
|
3
|
+
# OptionInterface provides basic methods for option modules. All option
|
4
|
+
# modules should be extended by this.
|
5
|
+
module OptionInterface
|
6
|
+
# Make an array of definitions.
|
7
|
+
#
|
8
|
+
# @api private
|
9
|
+
def self.extended(obj)
|
10
|
+
obj.instance_variable_set(:@definitions, [])
|
11
|
+
obj.instance_variable_set(:@default_table, {})
|
12
|
+
obj.instance_variable_set(:@validators, [])
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :definitions
|
16
|
+
attr_reader :default_table
|
17
|
+
attr_reader :validators
|
18
|
+
|
19
|
+
# Define default value of the option data set.
|
20
|
+
#
|
21
|
+
# @param name [Symbol]
|
22
|
+
# option data key
|
23
|
+
# @param value [Object]
|
24
|
+
# option data value
|
25
|
+
# @return [void]
|
26
|
+
def default(name, value)
|
27
|
+
@default_table[name] = value
|
28
|
+
end
|
29
|
+
|
30
|
+
# Define a new option for the command.
|
31
|
+
#
|
32
|
+
# @param args [Array]
|
33
|
+
# OptionParser arguments
|
34
|
+
# @param b [Proc]
|
35
|
+
# option action
|
36
|
+
# @return [void]
|
37
|
+
def option(*args, &b)
|
38
|
+
@definitions << [args, b]
|
39
|
+
end
|
40
|
+
|
41
|
+
# Remove the option.
|
42
|
+
#
|
43
|
+
# @param b [Proc]
|
44
|
+
# remove options that match proc's result
|
45
|
+
# @return [void]
|
46
|
+
def remove_option(&b)
|
47
|
+
@definitions.select! do |definition|
|
48
|
+
not(b.call(definition))
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Install the option module.
|
53
|
+
#
|
54
|
+
# @param mod [Module]
|
55
|
+
# PIONE's option set modules
|
56
|
+
# @return [void]
|
57
|
+
def use(mod)
|
58
|
+
@definitions += mod.definitions
|
59
|
+
@default_table.merge!(mod.default_table)
|
60
|
+
@validators += mod.validators
|
61
|
+
end
|
62
|
+
|
63
|
+
# Define validation of the option set.
|
64
|
+
#
|
65
|
+
# @param b [Proc]
|
66
|
+
# validation content
|
67
|
+
# @return [void]
|
68
|
+
def validate(&b)
|
69
|
+
@validators << b
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -1,13 +1,14 @@
|
|
1
1
|
module Pione
|
2
|
-
module
|
2
|
+
module Option
|
3
|
+
# PresenceNotifierOption provides options for presence notifiers.
|
3
4
|
module PresenceNotifierOption
|
4
5
|
extend OptionInterface
|
5
6
|
|
6
7
|
# --show-presence-notifier
|
7
|
-
|
8
|
+
option(
|
8
9
|
"--show-presence-notifier",
|
9
10
|
"show presence notifier informations"
|
10
|
-
) do
|
11
|
+
) do |data|
|
11
12
|
Global.show_presence_notifier = true
|
12
13
|
end
|
13
14
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Pione
|
2
|
+
module Option
|
3
|
+
# TaskWorkerOwnerOption provides options for commands that make task
|
4
|
+
# workers. Options are:
|
5
|
+
#
|
6
|
+
# - task-worker
|
7
|
+
# - features
|
8
|
+
module TaskWorkerOwnerOption
|
9
|
+
extend OptionInterface
|
10
|
+
|
11
|
+
default :task_worker, [Util.core_number - 1, 1].max
|
12
|
+
|
13
|
+
# --task-worker
|
14
|
+
option('-t N', '--task-worker=N', 'set task worker number that this process creates') do |data, n|
|
15
|
+
data[:task_worker] = n.to_i
|
16
|
+
end
|
17
|
+
|
18
|
+
# --features
|
19
|
+
option('--features=FEATURES', 'set features') do |data, features|
|
20
|
+
data[:features] = features
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,14 +1,16 @@
|
|
1
1
|
module Pione
|
2
|
-
module
|
2
|
+
module Option
|
3
|
+
# TupleSpaceProviderOption provides options for commands that make tuple
|
4
|
+
# space provider agent.
|
3
5
|
module TupleSpaceProviderOption
|
4
6
|
extend OptionInterface
|
5
|
-
|
7
|
+
use PresenceNotifierOption
|
6
8
|
|
7
9
|
# --presence-notification-address
|
8
|
-
|
10
|
+
option(
|
9
11
|
"--presence-notification-address=255.255.255.255:%s" % Global.presence_port,
|
10
12
|
"set the address for sending presence notifier"
|
11
|
-
) do |address|
|
13
|
+
) do |data, address|
|
12
14
|
# clear addresses at first time
|
13
15
|
unless @__option_notifier_address__
|
14
16
|
@__option_notifier_address__ = true
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Pione
|
2
|
+
module Option
|
3
|
+
# TupleSpaceProviderOption provides options for commands that make tuple
|
4
|
+
# space provider agent.
|
5
|
+
module TupleSpaceProviderOwnerOption
|
6
|
+
extend OptionInterface
|
7
|
+
use TupleSpaceProviderOption
|
8
|
+
|
9
|
+
# --without-tuple-space-provider
|
10
|
+
option(
|
11
|
+
'--without-tuple-space-provider',
|
12
|
+
'process without tuple space provider'
|
13
|
+
) do |data|
|
14
|
+
data[:without_tuple_space_provider] = true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -78,7 +78,8 @@ module Pione
|
|
78
78
|
:keyword_true => 'true',
|
79
79
|
:keyword_false => 'false',
|
80
80
|
:keyword_and => 'and',
|
81
|
-
:keyword_or => 'or'
|
81
|
+
:keyword_or => 'or',
|
82
|
+
:keyword_null => 'null'
|
82
83
|
}
|
83
84
|
|
84
85
|
# make keywords
|
@@ -95,7 +96,7 @@ module Pione
|
|
95
96
|
# line end.
|
96
97
|
# @return [Parslet::Atoms::Entity] +identifier+ atom
|
97
98
|
rule(:identifier) {
|
98
|
-
((space | symbols | line_end).absent? >> any).repeat(1)
|
99
|
+
((space | symbols | line_end).absent? >> any).repeat(1) >> question.maybe
|
99
100
|
}
|
100
101
|
|
101
102
|
# @!attribute [r] digit
|