pione 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/.gitignore +2 -1
  2. data/History.txt +11 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +1 -1
  5. data/bin/pione-log +5 -0
  6. data/example/CountChar/CountChar.pione +1 -1
  7. data/example/SieveOfEratosthenes/SieveOfEratosthenes.pione +39 -38
  8. data/lib/pione.rb +14 -35
  9. data/lib/pione/agent/input-generator.rb +38 -40
  10. data/lib/pione/agent/logger.rb +52 -19
  11. data/lib/pione/agent/rule-provider.rb +5 -8
  12. data/lib/pione/agent/task-worker.rb +25 -32
  13. data/lib/pione/agent/tuple-space-client.rb +22 -14
  14. data/lib/pione/command.rb +21 -0
  15. data/lib/pione/command/basic-command.rb +267 -84
  16. data/lib/pione/command/child-process.rb +21 -18
  17. data/lib/pione/command/daemon-process.rb +9 -8
  18. data/lib/pione/command/front-owner-command.rb +8 -25
  19. data/lib/pione/command/pione-broker.rb +27 -24
  20. data/lib/pione/command/pione-clean.rb +6 -6
  21. data/lib/pione/command/pione-client.rb +143 -128
  22. data/lib/pione/command/pione-log.rb +61 -0
  23. data/lib/pione/command/pione-relay-account-db.rb +40 -38
  24. data/lib/pione/command/pione-relay-client-db.rb +38 -42
  25. data/lib/pione/command/pione-relay.rb +19 -20
  26. data/lib/pione/command/pione-syntax-checker.rb +70 -45
  27. data/lib/pione/command/pione-task-worker.rb +56 -66
  28. data/lib/pione/command/pione-tuple-space-provider.rb +36 -45
  29. data/lib/pione/command/pione-tuple-space-receiver.rb +34 -32
  30. data/lib/pione/command/pione-tuple-space-viewer.rb +63 -47
  31. data/lib/pione/location.rb +10 -0
  32. data/lib/pione/location/basic-location.rb +272 -0
  33. data/lib/pione/location/dropbox-location.rb +139 -0
  34. data/lib/pione/location/ftp-location.rb +156 -0
  35. data/lib/pione/location/local-location.rb +116 -0
  36. data/lib/pione/log.rb +10 -0
  37. data/lib/pione/log/domain-info.rb +72 -0
  38. data/lib/pione/log/process-log.rb +176 -0
  39. data/lib/pione/log/process-record.rb +189 -0
  40. data/lib/pione/log/xes-log.rb +105 -0
  41. data/lib/pione/model/assignment.rb +88 -80
  42. data/lib/pione/model/binary-operator.rb +74 -68
  43. data/lib/pione/model/block.rb +218 -207
  44. data/lib/pione/model/boolean.rb +123 -112
  45. data/lib/pione/model/call-rule.rb +72 -65
  46. data/lib/pione/model/data-expr.rb +596 -290
  47. data/lib/pione/model/float.rb +108 -103
  48. data/lib/pione/model/integer.rb +133 -129
  49. data/lib/pione/model/message.rb +79 -72
  50. data/lib/pione/model/package.rb +42 -38
  51. data/lib/pione/model/parameters.rb +265 -236
  52. data/lib/pione/model/rule-expr.rb +247 -242
  53. data/lib/pione/model/rule-io.rb +137 -133
  54. data/lib/pione/model/rule.rb +307 -292
  55. data/lib/pione/model/string.rb +110 -99
  56. data/lib/pione/model/variable-table.rb +300 -271
  57. data/lib/pione/model/variable.rb +88 -83
  58. data/lib/pione/option.rb +13 -0
  59. data/lib/pione/option/child-process-option.rb +19 -0
  60. data/lib/pione/{command-option → option}/common-option.rb +6 -5
  61. data/lib/pione/option/option-interface.rb +73 -0
  62. data/lib/pione/{command-option → option}/presence-notifier-option.rb +4 -3
  63. data/lib/pione/option/task-worker-owner-option.rb +24 -0
  64. data/lib/pione/{command-option → option}/tuple-space-provider-option.rb +6 -4
  65. data/lib/pione/option/tuple-space-provider-owner-option.rb +18 -0
  66. data/lib/pione/option/tuple-space-receiver-option.rb +8 -0
  67. data/lib/pione/parser/common-parser.rb +3 -2
  68. data/lib/pione/parser/expr-parser.rb +6 -1
  69. data/lib/pione/patch/em-ftpd-patch.rb +21 -0
  70. data/lib/pione/patch/rinda-patch.rb +31 -23
  71. data/lib/pione/rule-handler/action-handler.rb +35 -25
  72. data/lib/pione/rule-handler/basic-handler.rb +92 -18
  73. data/lib/pione/rule-handler/flow-handler.rb +104 -98
  74. data/lib/pione/rule-handler/root-handler.rb +11 -0
  75. data/lib/pione/system/common.rb +10 -0
  76. data/lib/pione/system/file-cache.rb +103 -84
  77. data/lib/pione/system/global.rb +67 -12
  78. data/lib/pione/system/init.rb +20 -0
  79. data/lib/pione/transformer/expr-transformer.rb +6 -1
  80. data/lib/pione/tuple-space/data-finder.rb +33 -6
  81. data/lib/pione/tuple-space/tuple-space-receiver.rb +4 -3
  82. data/lib/pione/tuple-space/tuple-space-server-interface.rb +58 -13
  83. data/lib/pione/tuple-space/tuple-space-server.rb +13 -11
  84. data/lib/pione/tuple-space/update-criteria.rb +8 -7
  85. data/lib/pione/tuple/base-location-tuple.rb +9 -0
  86. data/lib/pione/tuple/basic-tuple.rb +7 -7
  87. data/lib/pione/tuple/data-tuple.rb +5 -2
  88. data/lib/pione/tuple/lift-tuple.rb +14 -0
  89. data/lib/pione/tuple/rule-tuple.rb +1 -1
  90. data/lib/pione/tuple/task-tuple.rb +5 -1
  91. data/lib/pione/version.rb +1 -1
  92. data/pione.gemspec +5 -1
  93. data/test/location/spec_basic-location.rb +35 -0
  94. data/test/location/spec_ftp-location.rb +100 -0
  95. data/test/location/spec_local-location.rb +99 -0
  96. data/test/log/data/sample.log +1003 -0
  97. data/test/log/spec_xes-log.rb +11 -0
  98. data/test/model/spec_data-expr.rb +249 -6
  99. data/test/model/spec_data-expr.yml +45 -0
  100. data/test/parser/spec_expr-parser.yml +4 -0
  101. data/test/spec_data-finder.rb +13 -7
  102. data/test/spec_data-finder.yml +42 -13
  103. data/test/system/spec_file-cache.rb +39 -0
  104. data/test/test-util.rb +226 -1
  105. data/test/transformer/spec_expr-transformer.rb +12 -1
  106. metadata +107 -24
  107. data/bin/pione-search-log +0 -30
  108. data/lib/pione/command-option/basic-option.rb +0 -42
  109. data/lib/pione/command-option/child-process-option.rb +0 -17
  110. data/lib/pione/command-option/daemon-option.rb +0 -12
  111. data/lib/pione/command-option/task-worker-owner-option.rb +0 -17
  112. data/lib/pione/command-option/tuple-space-provider-owner-option.rb +0 -16
  113. data/lib/pione/command-option/tuple-space-receiver-option.rb +0 -12
  114. data/lib/pione/command/tuple-space-provider-owner.rb +0 -6
  115. data/lib/pione/resource/basic-resource.rb +0 -92
  116. data/lib/pione/resource/dropbox-resource.rb +0 -106
  117. data/lib/pione/resource/ftp.rb +0 -84
  118. data/lib/pione/resource/local.rb +0 -113
  119. data/lib/pione/tuple/base-uri-tuple.rb +0 -9
  120. data/lib/pione/tuple/shift-tuple.rb +0 -13
  121. data/lib/pione/util/log.rb +0 -79
  122. data/test/spec_resource.rb +0 -73
@@ -1,84 +1,91 @@
1
- module Pione::Model
2
- # Message represents method callers for PIONE model objects.
3
- # @example
4
- # 1.as_string()
5
- # @example
6
- # '*.txt'.except('a*')
7
- class Message < BasicModel
8
- attr_reader :name
9
- attr_reader :receiver
10
- attr_reader :arguments
11
-
12
- # Creates a message.
13
- # @param [String] name
14
- # message name
15
- # @param [BasicModel] receiver
16
- # message receiver
17
- # @param [BasicModel] arguments
18
- # message arguments
19
- def initialize(name, receiver, *arguments)
20
- @name = name
21
- @receiver = receiver.to_pione
22
- @arguments = arguments.map{|arg| arg.to_pione}
23
- super()
24
- end
1
+ module Pione
2
+ module Model
3
+ # Message represents method callers for PIONE model objects.
4
+ #
5
+ # @example
6
+ # 1.as_string()
7
+ # @example
8
+ # '*.txt'.except('a*')
9
+ class Message < BasicModel
10
+ attr_reader :name
11
+ attr_reader :receiver
12
+ attr_reader :arguments
25
13
 
26
- # Returns false because Message is a complex form.
27
- # @return [Boolean]
28
- # false
29
- def atomic?
30
- false
31
- end
14
+ # Create a message.
15
+ #
16
+ # @param name [String]
17
+ # message name
18
+ # @param receiver [BasicModel]
19
+ # message receiver
20
+ # @param arguments [BasicModel]
21
+ # message arguments
22
+ def initialize(name, receiver, *arguments)
23
+ @name = name
24
+ @receiver = receiver.to_pione
25
+ @arguments = arguments.map{|arg| arg.to_pione}
26
+ super()
27
+ end
32
28
 
33
- # Return PIONE model type of the message result according to type interface.
34
- #
35
- # @return [Symbol]
36
- # PIONE model type
37
- def pione_model_type
38
- if interface = @receiver.pione_model_type.method_interface[@name.to_s]
39
- interface.output
40
- else
41
- raise MethodNotFound.new(@name.to_s, self)
29
+ # Return false because Message is a complex form.
30
+ #
31
+ # @return [Boolean]
32
+ # false
33
+ def atomic?
34
+ false
42
35
  end
43
- end
44
36
 
45
- # Evaluates the application expression and returns application result.
46
- # @param [VariableTable] vtable variable table for the evaluation
47
- # @return [BasicModel]
48
- # evaluation result
49
- def eval(vtable)
50
- receiver = @receiver.eval(vtable)
51
- arguments = @arguments.map{|arg| arg.eval(vtable)}
52
- receiver.call_pione_method(@name, *arguments)
53
- end
37
+ # Return PIONE model type of the message result according to type interface.
38
+ #
39
+ # @return [Symbol]
40
+ # PIONE model type
41
+ def pione_model_type
42
+ if interface = @receiver.pione_model_type.method_interface[@name.to_s]
43
+ interface.output
44
+ else
45
+ raise MethodNotFound.new(@name.to_s, self)
46
+ end
47
+ end
54
48
 
55
- # Returns true if the receiver or arguments include variables.
56
- # @return [Boolean]
57
- # true if the receiver or arguments include variables
58
- def include_variable?
59
- @receiver.include_variable? or @arguments.any?{|arg| arg.include_variable?}
60
- end
49
+ # Evaluate the application expression and returns application result.
50
+ #
51
+ # @param vtable [VariableTable]
52
+ # variable table for the evaluation
53
+ # @return [BasicModel]
54
+ # evaluation result
55
+ def eval(vtable)
56
+ receiver = @receiver.eval(vtable)
57
+ arguments = @arguments.map{|arg| arg.eval(vtable)}
58
+ receiver.call_pione_method(@name, *arguments)
59
+ end
61
60
 
62
- # @api private
63
- def textize
64
- args = [@name, @receiver.textize, @arguments.textize]
65
- "message(\"%s\",%s,[%s])" % args
66
- end
61
+ # Return true if the receiver or arguments include variables.
62
+ #
63
+ # @return [Boolean]
64
+ # true if the receiver or arguments include variables
65
+ def include_variable?
66
+ @receiver.include_variable? or @arguments.any?{|arg| arg.include_variable?}
67
+ end
67
68
 
68
- # @api private
69
- def ==(other)
70
- return false unless other.kind_of?(self.class)
71
- return false unless @name == other.name
72
- return false unless @receiver == other.receiver
73
- return false unless @arguments == other.arguments
74
- return true
75
- end
69
+ # @api private
70
+ def textize
71
+ args = [@name, @receiver.textize, @arguments.textize]
72
+ "message(\"%s\",%s,[%s])" % args
73
+ end
76
74
 
77
- alias :eql? :"=="
75
+ # @api private
76
+ def ==(other)
77
+ return false unless other.kind_of?(self.class)
78
+ return false unless @name == other.name
79
+ return false unless @receiver == other.receiver
80
+ return false unless @arguments == other.arguments
81
+ return true
82
+ end
83
+ alias :eql? :"=="
78
84
 
79
- # @api private
80
- def hash
81
- @name.hash + @receiver.hash + @arguments.hash
85
+ # @api private
86
+ def hash
87
+ @name.hash + @receiver.hash + @arguments.hash
88
+ end
82
89
  end
83
90
  end
84
91
  end
@@ -1,48 +1,52 @@
1
- module Pione::Model
2
- # Package is a PIONE model class for rule package.
3
- class Package < BasicModel
4
- attr_reader :name
5
- set_pione_model_type TypePackage
1
+ module Pione
2
+ module Model
3
+ # Package is a PIONE model class for rule package.
4
+ class Package < BasicModel
5
+ attr_reader :name
6
+ set_pione_model_type TypePackage
6
7
 
7
- # Creates a package with name.
8
- # @param [String] name
9
- # package name
10
- def initialize(name)
11
- @name = name
12
- super()
13
- end
8
+ # Create a package with name.
9
+ #
10
+ # @param name [String]
11
+ # package name
12
+ def initialize(name)
13
+ @name = name
14
+ super()
15
+ end
14
16
 
15
- # @api private
16
- def task_id_string
17
- "Package<#{@name}>"
18
- end
17
+ # @api private
18
+ def task_id_string
19
+ "Package<#{@name}>"
20
+ end
19
21
 
20
- # @api private
21
- def textize
22
- "package(\"%s\")" % [@name]
23
- end
22
+ # @api private
23
+ def textize
24
+ "package(\"%s\")" % [@name]
25
+ end
24
26
 
25
- # Return a rule path.
26
- # @param [RuleExpr] other
27
- # rule expression
28
- # @return [String]
29
- # rule path string
30
- def +(other)
31
- raise ArgumentError.new(other) unless other.kind_of?(RuleExpr)
32
- "#{@name}:#{other.name}"
33
- end
27
+ # Return a rule path.
28
+ #
29
+ # @param other [RuleExpr]
30
+ # rule expression
31
+ # @return [String]
32
+ # rule path string
33
+ def +(other)
34
+ raise ArgumentError.new(other) unless other.kind_of?(RuleExpr)
35
+ "#{@name}:#{other.name}"
36
+ end
34
37
 
35
- # @api private
36
- def ==(other)
37
- return false unless other.kind_of?(self.class)
38
- @name == other.name
39
- end
38
+ # @api private
39
+ def ==(other)
40
+ return false unless other.kind_of?(self.class)
41
+ @name == other.name
42
+ end
40
43
 
41
- alias :eql? :"=="
44
+ alias :eql? :"=="
42
45
 
43
- # @api private
44
- def hash
45
- @value.hash
46
+ # @api private
47
+ def hash
48
+ @value.hash
49
+ end
46
50
  end
47
51
  end
48
52
  end
@@ -1,282 +1,311 @@
1
- module Pione::Model
2
- # Parameters is a PIONE mode class for parameters.
3
- class Parameters < BasicModel
4
- # InvalidParameter is raised when you specify invalid parameter.
5
- class InvalidParameter < TypeError
6
- # Creates a error.
7
- # @param [Object] key
8
- # specified key
9
- def initialize(key)
10
- @key = key
11
- end
1
+ module Pione
2
+ module Model
3
+ # Parameters is a PIONE mode class for parameters.
4
+ class Parameters < BasicModel
5
+ # InvalidParameter is raised when you specify invalid parameter.
6
+ class InvalidParameter < TypeError
7
+ # Create a error.
8
+ #
9
+ # @param [Object] key
10
+ # specified key
11
+ def initialize(key)
12
+ @key = key
13
+ end
12
14
 
13
- # @api private
14
- def message
15
- "invalid parameter key: %s" % [@key.inspect]
15
+ # @api private
16
+ def message
17
+ "invalid parameter key: %s" % [@key.inspect]
18
+ end
16
19
  end
17
- end
18
20
 
19
- # InvalidArgument is raised when you specify invalid argument.
20
- class InvalidArgument < TypeError
21
- # Creates a error.
22
- # @param [Object] val
23
- # specified value
24
- def initialize(val)
25
- @val = val
26
- end
21
+ # InvalidArgument is raised when you specify invalid argument.
22
+ class InvalidArgument < TypeError
23
+ # Create a error.
24
+ #
25
+ # @param [Object] val
26
+ # specified value
27
+ def initialize(val)
28
+ @val = val
29
+ end
27
30
 
28
- # @api private
29
- def message
30
- "invalid argument value: %s" % [@val.inspect]
31
+ # @api private
32
+ def message
33
+ "invalid argument value: %s" % [@val.inspect]
34
+ end
31
35
  end
32
- end
33
36
 
34
- class << self
35
- # Creates a empty parameters object.
36
- # @return [Parameters]
37
- # empty parameters
38
- def empty
39
- self.new({})
40
- end
37
+ class << self
38
+ # Create a empty parameters object.
39
+ #
40
+ # @return [Parameters]
41
+ # empty parameters
42
+ def empty
43
+ self.new({})
44
+ end
41
45
 
42
- # Merges arguments' parameters.
43
- # @param [Array<Parameters>] list
44
- # merge target elements
45
- # @return [Parameters]
46
- # merged result
47
- def merge(*list)
48
- new_params = empty
49
- list.each do |params|
50
- new_params = new_params.merge(params)
46
+ # Merge arguments' parameters.
47
+ #
48
+ # @param list [Array<Parameters>]
49
+ # merge target elements
50
+ # @return [Parameters]
51
+ # merged result
52
+ def merge(*list)
53
+ new_params = empty
54
+ list.each do |params|
55
+ new_params = new_params.merge(params)
56
+ end
57
+ return new_params
51
58
  end
52
- return new_params
53
59
  end
54
- end
55
60
 
56
- attr_reader :data
57
- set_pione_model_type TypeParameters
58
-
59
- # Creates a parameters object.
60
- # @param [Hash{Variable => BasicModel}] data
61
- # parameters data table
62
- def initialize(data)
63
- raise TypeError.new(data) unless data.kind_of?(Hash)
64
- data.each do |key, val|
65
- raise InvalidParameter.new(key) unless key.kind_of?(Variable)
66
- raise InvalidArgument.new(val) unless val.kind_of?(BasicModel)
61
+ attr_reader :data
62
+ set_pione_model_type TypeParameters
63
+
64
+ # Create a parameters object.
65
+ #
66
+ # @param [Hash{Variable => BasicModel}] data
67
+ # parameters data table
68
+ def initialize(data)
69
+ raise TypeError.new(data) unless data.kind_of?(Hash)
70
+ data.each do |key, val|
71
+ raise InvalidParameter.new(key) unless key.kind_of?(Variable)
72
+ raise InvalidArgument.new(val) unless val.kind_of?(BasicModel)
73
+ end
74
+ @data = data
75
+ super()
67
76
  end
68
- @data = data
69
- super()
70
- end
71
77
 
72
- # Evaluates the object with variable table.
73
- # @param [VariableTable] vtable
74
- # variable tabale for evaluation
75
- # @return [BasicModel]
76
- # evaluated result
77
- def eval(vtable)
78
- return self.class.empty if empty?
79
- data = @data.map{|key, val| [key, val.eval(vtable)]}.flatten(1)
80
- self.class.new(Hash[*data])
81
- end
78
+ # Evaluate the object with variable table.
79
+ #
80
+ # @param vtable [VariableTable]
81
+ # variable tabale for evaluation
82
+ # @return [BasicModel]
83
+ # evaluated result
84
+ def eval(vtable)
85
+ return self.class.empty if empty?
86
+ data = @data.map{|key, val| [key, val.eval(vtable)]}.flatten(1)
87
+ self.class.new(Hash[*data])
88
+ end
82
89
 
83
- # Returns true if parameters include variables.
84
- # @return [Boolean]
85
- # true if parameters include variables
86
- def include_variable?
87
- @data.any? {|_, val| val.include_variable?}
88
- end
90
+ # Return true if parameters include variables.
91
+ #
92
+ # @return [Boolean]
93
+ # true if parameters include variables
94
+ def include_variable?
95
+ @data.any? {|_, val| val.include_variable?}
96
+ end
89
97
 
90
- # @api private
91
- def textize
92
- "{" + @data.map{|k,v| "%s:%s" % [k.textize[1..-1], v.textize]}.join(", ") + "}"
93
- end
98
+ # @api private
99
+ def textize
100
+ "{" + @data.map{|k,v| "%s:%s" % [k.textize[1..-1], v.textize]}.join(", ") + "}"
101
+ end
94
102
 
95
- # Returns value of parameter name.
96
- # @param [String] name
97
- # parameter name to get the value
98
- # @return [BasicModel]
99
- # the value
100
- def [](name)
101
- @data[Variable.new(name)]
102
- end
103
+ # Return value of parameter name.
104
+ #
105
+ # @param name [String]
106
+ # parameter name to get the value
107
+ # @return [BasicModel]
108
+ # the value
109
+ def [](name)
110
+ @data[Variable.new(name)]
111
+ end
103
112
 
104
- # Returns the value corresponding to the parameter name. Raises an error
105
- # when the parameter name is kind of a variable.
106
- # @param [Variable] name
107
- # variable to get the value
108
- # @return [BasicModel]
109
- # the value
110
- def get(name)
111
- raise InvalidParameter.new(name) unless name.kind_of?(Variable)
112
- @data[name]
113
- end
113
+ # Return the value corresponding to the parameter name. Raises an error
114
+ # when the parameter name is kind of a variable.
115
+ #
116
+ # @param name [Variable]
117
+ # variable to get the value
118
+ # @return [BasicModel]
119
+ # the value
120
+ def get(name)
121
+ raise InvalidParameter.new(name) unless name.kind_of?(Variable)
122
+ @data[name]
123
+ end
114
124
 
115
- # Adds the parameter value and return new parameters.
116
- # @param [Variable] name
117
- # @param [BasicModel] value
118
- # @return [Parameters]
119
- # new parameters with the parameter
120
- def set(name, value)
121
- raise InvalidParameter.new(name) unless name.kind_of?(Variable)
122
- raise InvalidArgument.new(value) unless value.kind_of?(BasicModel)
123
- self.class.new(@data.merge({name => value}))
124
- end
125
+ # Add the parameter value and return new parameters.
126
+ #
127
+ # @param name [Variable]
128
+ # variable
129
+ # @param value [BasicModel]
130
+ # value
131
+ # @return [Parameters]
132
+ # new parameters with the parameter
133
+ def set(name, value)
134
+ raise InvalidParameter.new(name) unless name.kind_of?(Variable)
135
+ raise InvalidArgument.new(value) unless value.kind_of?(BasicModel)
136
+ self.class.new(@data.merge({name => value}))
137
+ end
125
138
 
126
- # Adds the parameter value.
127
- # @param [Variable] name
128
- # @param [BasicModel] value
129
- # @return [void]
130
- def set!(name, value)
131
- raise InvalidParameter.new(name) unless name.kind_of?(Variable)
132
- raise InvalidArgument.new(value) unless value.kind_of?(BasicModel)
133
- @data.merge!({name => value})
134
- end
139
+ # Add the parameter value.
140
+ #
141
+ # @param name [Variable]
142
+ # variable
143
+ # @param value [BasicModel]
144
+ # value
145
+ # @return [void]
146
+ def set!(name, value)
147
+ raise InvalidParameter.new(name) unless name.kind_of?(Variable)
148
+ raise InvalidArgument.new(value) unless value.kind_of?(BasicModel)
149
+ @data.merge!({name => value})
150
+ end
135
151
 
136
- # Adds the parameter value safety and return new parameters.
137
- # @param [Variable] name
138
- # @param [BasicModel] value
139
- # @return [Parameters]
140
- # new parameters with the parameter
141
- def set_safety(name, value)
142
- if not(@data.has_key?(name)) or @data[name].kind_of?(UndefinedValue)
143
- set(name, value)
152
+ # Add the parameter value safety and return new parameters.
153
+ #
154
+ # @param name [Variable]
155
+ # variable
156
+ # @param value [BasicModel]
157
+ # vlaue
158
+ # @return [Parameters]
159
+ # new parameters with the parameter
160
+ def set_safety(name, value)
161
+ if not(@data.has_key?(name)) or @data[name].kind_of?(UndefinedValue)
162
+ set(name, value)
163
+ end
144
164
  end
145
- end
146
165
 
147
- # Adds the parameter value safety.
148
- # @param [Variable] name
149
- # @param [BasicModel] value
150
- # @return [void]
151
- def set_safety!(name, value)
152
- if not(@data.has_key?(name)) or @data[name].kind_of?(UndefinedValue)
153
- set!(name, value)
166
+ # Add the parameter value safety.
167
+ #
168
+ # @param name [Variable]
169
+ # variable
170
+ # @param value [BasicModel]
171
+ # value
172
+ # @return [void]
173
+ def set_safety!(name, value)
174
+ if not(@data.has_key?(name)) or @data[name].kind_of?(UndefinedValue)
175
+ set!(name, value)
176
+ end
154
177
  end
155
- end
156
178
 
157
- # Deletes the parameter by name.
158
- # @param [Variable] name
159
- # target's name
160
- # @return [Parameters]
161
- # new parameters that deleted the target
162
- def delete(name)
163
- raise InvalidParameter.new(name) unless name.kind_of?(Variable)
164
- new_data = @data.clone
165
- new_data.delete(name)
166
- self.class.new(new_data)
167
- end
179
+ # Delete the parameter by name.
180
+ #
181
+ # @param name [Variable]
182
+ # target's name
183
+ # @return [Parameters]
184
+ # new parameters that deleted the target
185
+ def delete(name)
186
+ raise InvalidParameter.new(name) unless name.kind_of?(Variable)
187
+ new_data = @data.clone
188
+ new_data.delete(name)
189
+ self.class.new(new_data)
190
+ end
168
191
 
169
- # Returns true if the parameters is empty.
170
- # @return [Boolean]
171
- # true if the parameters is empty
172
- def empty?
173
- @data.empty?
174
- end
192
+ # Return true if the parameters is empty.
193
+ #
194
+ # @return [Boolean]
195
+ # true if the parameters is empty
196
+ def empty?
197
+ @data.empty?
198
+ end
175
199
 
176
- # Updates parameters with the argument and return new parameters with it.
177
- # @param [BasicModel] other
178
- # merge target
179
- # @return [Parameters]
180
- # new parameters that merged the target
181
- def merge(other)
182
- case other
183
- when Parameters
184
- self.class.new(@data.merge(other.data))
185
- when Variable
186
- self.class.new(@data.merge({other => UndefinedValue.new}))
187
- when Assignment
188
- self.class.new(@data.merge({other.variable => other.expr}))
189
- else
190
- raise TypeError.new(other)
200
+ # Update parameters with the argument and return new parameters with it.
201
+ #
202
+ # @param other [BasicModel]
203
+ # merge target
204
+ # @return [Parameters]
205
+ # new parameters that merged the target
206
+ def merge(other)
207
+ case other
208
+ when Parameters
209
+ self.class.new(@data.merge(other.data))
210
+ when Variable
211
+ self.class.new(@data.merge({other => UndefinedValue.new}))
212
+ when Assignment
213
+ self.class.new(@data.merge({other.variable => other.expr}))
214
+ else
215
+ raise TypeError.new(other)
216
+ end
191
217
  end
192
- end
193
218
 
194
- # Updates parameters with the argument destructively.
195
- # @param [BasicModel] other
196
- # merge target
197
- # @return [void]
198
- def merge!(other)
199
- case other
200
- when Parameters
201
- @data.merge!(other.data)
202
- when Variable
203
- @data.merge!({other => UndefinedValue.new})
204
- when Assignment
205
- @data.merge!({other.variable => other.expr})
206
- else
207
- raise TypeError.new(other)
219
+ # Update parameters with the argument destructively.
220
+ #
221
+ # @param [BasicModel] other
222
+ # merge target
223
+ # @return [void]
224
+ def merge!(other)
225
+ case other
226
+ when Parameters
227
+ @data.merge!(other.data)
228
+ when Variable
229
+ @data.merge!({other => UndefinedValue.new})
230
+ when Assignment
231
+ @data.merge!({other.variable => other.expr})
232
+ else
233
+ raise TypeError.new(other)
234
+ end
208
235
  end
209
- end
210
236
 
211
- # Converts into variable table.
212
- # @return [VariableTable]
213
- # variable table which values are same as the parameters.
214
- def as_variable_table
215
- VariableTable.new(@data)
216
- end
237
+ # Convert into variable table.
238
+ #
239
+ # @return [VariableTable]
240
+ # variable table which values are same as the parameters.
241
+ def as_variable_table
242
+ VariableTable.new(@data)
243
+ end
217
244
 
218
- # Returns key list.
219
- # @return [Array<Variable>]
220
- # parameter key list
221
- def keys
222
- @data.keys.sort
223
- end
245
+ # Return key list.
246
+ #
247
+ # @return [Array<Variable>]
248
+ # parameter key list
249
+ def keys
250
+ @data.keys.sort
251
+ end
224
252
 
225
- # @api private
226
- def string_form
227
- "{" + @data.map{|k,v| "#{k}: #{v}"}.join(", ") + "}"
228
- end
253
+ # @api private
254
+ def string_form
255
+ "{" + @data.map{|k,v| "#{k}: #{v}"}.join(", ") + "}"
256
+ end
229
257
 
230
- # @api private
231
- def to_json(*args)
232
- @data.to_json(*args)
233
- end
258
+ # @api private
259
+ def to_json(*args)
260
+ @data.to_json(*args)
261
+ end
234
262
 
235
- # @api private
236
- def ==(other)
237
- return false unless other.kind_of?(self.class)
238
- @data == other.data
239
- end
263
+ # @api private
264
+ def ==(other)
265
+ return false unless other.kind_of?(self.class)
266
+ @data == other.data
267
+ end
240
268
 
241
- alias :eql? :"=="
269
+ alias :eql? :"=="
242
270
 
243
- # @api private
244
- def hash
245
- @data.hash
271
+ # @api private
272
+ def hash
273
+ @data.hash
274
+ end
246
275
  end
247
- end
248
276
 
249
- TypeParameters.instance_eval do
250
- define_pione_method('==', [TypeParameters], TypeBoolean) do |rec, other|
251
- PioneBoolean.new(rec.data == other.data)
252
- end
277
+ TypeParameters.instance_eval do
278
+ define_pione_method('==', [TypeParameters], TypeBoolean) do |rec, other|
279
+ PioneBoolean.new(rec.data == other.data)
280
+ end
253
281
 
254
- define_pione_method("!=", [TypeParameters], TypeBoolean) do |rec, other|
255
- PioneBoolean.not(rec.call_pione_method("==", other))
256
- end
282
+ define_pione_method("!=", [TypeParameters], TypeBoolean) do |rec, other|
283
+ PioneBoolean.not(rec.call_pione_method("==", other))
284
+ end
257
285
 
258
- define_pione_method("[]", [TypeString], TypeAny) do |rec, name|
259
- rec.get(Variable.new(name.value))
260
- end
286
+ define_pione_method("[]", [TypeString], TypeAny) do |rec, name|
287
+ rec.get(Variable.new(name.value))
288
+ end
261
289
 
262
- define_pione_method("get", [TypeString], TypeAny) do |rec, name|
263
- rec.get(Variable.new(name.value))
264
- end
290
+ define_pione_method("get", [TypeString], TypeAny) do |rec, name|
291
+ rec.get(Variable.new(name.value))
292
+ end
265
293
 
266
- define_pione_method(
267
- "set",
268
- [TypeString, TypeAny],
269
- TypeParameters
270
- ) do |rec, name, val|
271
- rec.set(Variable.new(name.value), val)
272
- end
294
+ define_pione_method(
295
+ "set",
296
+ [TypeString, TypeAny],
297
+ TypeParameters
298
+ ) do |rec, name, val|
299
+ rec.set(Variable.new(name.value), val)
300
+ end
273
301
 
274
- define_pione_method("empty?", [], TypeBoolean) do |rec|
275
- PioneBoolean.new(rec.empty?)
276
- end
302
+ define_pione_method("empty?", [], TypeBoolean) do |rec|
303
+ PioneBoolean.new(rec.empty?)
304
+ end
277
305
 
278
- define_pione_method("as_string", [], TypeString) do |rec|
279
- PioneString.new(rec.string_form)
306
+ define_pione_method("as_string", [], TypeString) do |rec|
307
+ PioneString.new(rec.string_form)
308
+ end
280
309
  end
281
310
  end
282
311
  end