torigoya_kit 0.0.11 → 0.2.0

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.
@@ -1,7 +1,8 @@
1
- # Copyright (c) 2014 yutopp
1
+ # Copyright (c) 2014 - 2015 yutopp
2
2
  # Licenced under the MIT License (http://www.opensource.org/licenses/mit-license.php)
3
3
 
4
4
  require 'msgpack'
5
+ require_relative 'typeutil'
5
6
 
6
7
  module TorigoyaKit
7
8
  # contains source codes / inputs data
@@ -12,7 +13,8 @@ module TorigoyaKit
12
13
 
13
14
  def initialize(name, code, is_compressed = false)
14
15
  @name = name
15
- @code = if is_compressed then
16
+ @data = if is_compressed then
17
+ # NOT: implemented
16
18
  else
17
19
  code
18
20
  end
@@ -20,22 +22,23 @@ module TorigoyaKit
20
22
 
21
23
  validate
22
24
  end
23
- attr_reader :name, :code, :is_compressed
25
+ attr_reader :name, :data, :is_compressed
24
26
 
25
- def to_tuple
26
- return [@name,
27
- @code,
28
- @is_compressed
29
- ]
27
+ def to_hash
28
+ return {
29
+ name: @name,
30
+ data: @data,
31
+ is_compressed: @is_compressed,
32
+ }
30
33
  end
31
34
 
32
35
  def to_msgpack(out = '')
33
- return to_tuple.to_msgpack(out)
36
+ return to_hash.to_msgpack(out)
34
37
  end
35
38
 
36
39
  def ==(rhs)
37
40
  return @name == rhs.name &&
38
- @code == rhs.code
41
+ @data == rhs.data
39
42
  @is_compressed == rhs.is_compressed
40
43
  end
41
44
 
@@ -44,116 +47,51 @@ module TorigoyaKit
44
47
  if @name.nil?
45
48
  @name = "*default*"
46
49
  else
47
- raise InvalidFormatError.new("#{self.class}: name must be String (but #{@name.class})") unless @name.is_a?(String)
50
+ TypeUtil.nonnull_type_check(self, "name", @name, String)
48
51
  end
49
- raise InvalidFormatError.new("#{self.class}: code must be String (but #{@code.class})") unless @code.is_a?(String)
50
- raise InvalidFormatError.new("#{self.class}: is_compressed must be Boolean (but #{@is_compressed.class})") unless @is_compressed.is_a?(TrueClass) || @is_compressed.is_a?(FalseClass)
51
- end
52
- end
53
-
54
- #
55
- class Command
56
- def initialize(key_or_value, value=nil)
57
- unless value.nil?
58
- @key = key_or_value
59
- @value = value
60
- else
61
- @value = key_or_value
62
- end
63
-
64
- validate
65
- end
66
- attr_reader :key, :value
67
-
68
- def to_tuple
69
- unless @key.nil?
70
- return [@key, @value]
71
- else
72
- return [@value]
73
- end
74
- end
75
-
76
- def ==(rhs)
77
- return @key == rhs.key && @value == rhs.value
78
- end
79
-
80
- private
81
- def validate
82
- unless @key.nil?
83
- raise InvalidFormatError.new("#{self.class}: key must be String (but #{@key.class})") unless @key.is_a?(String)
84
- end
85
- raise InvalidFormatError.new("#{self.class}: value must be String (but #{@value.class})") unless @value.is_a?(String)
52
+ TypeUtil.nonnull_type_check(self, "data", @data, String)
53
+ TypeUtil.nonnull_boolean_type_check(self, "is_compressed", @is_compressed)
86
54
  end
87
55
  end
88
56
 
89
57
  #
90
58
  class ExecutionSetting
91
- def initialize(command_line, structured_command, cpu_limit, memory_limit)
92
- @command_line = command_line # String
93
- @structured_command = structured_command # Array!Command
94
- @cpu_limit = cpu_limit # uint64 / sec
95
- @memory_limit = memory_limit # uint64 / bytes
59
+ def initialize(args, envs, cpu_limit, memory_limit)
60
+ @args = args # Array!String
61
+ @envs = envs # Array!String
62
+ @cpu_limit = cpu_limit # uint64 / sec
63
+ @memory_limit = memory_limit # uint64 / bytes
96
64
 
97
65
  validate
98
66
  end
99
- attr_reader :command_line, :structured_command, :cpu_limit, :memory_limit
67
+ attr_reader :args, :envs, :cpu_limit, :memory_limit
100
68
 
101
- def to_tuple
102
- return [@command_line,
103
- @structured_command.map {|x| x.to_tuple},
104
- @cpu_limit,
105
- @memory_limit
106
- ]
69
+ def to_hash
70
+ return {
71
+ args: @args,
72
+ envs: @envs,
73
+ cpu_time_limit: @cpu_limit,
74
+ memory_bytes_limit: @memory_limit
75
+ }
107
76
  end
108
77
 
109
78
  def to_msgpack(out = '')
110
- return to_tuple.to_msgpack(out)
79
+ return to_hash.to_msgpack(out)
111
80
  end
112
81
 
113
82
  def ==(rhs)
114
- return @command_line == rhs.command_line &&
115
- @structured_command == rhs.structured_command &&
83
+ return @args == rhs.args &&
84
+ @envs == rhs.envs &&
116
85
  @cpu_limit == rhs.cpu_limit &&
117
86
  @memory_limit == rhs.memory_limit
118
87
  end
119
88
 
120
89
  private
121
90
  def validate
122
- unless @command_line.nil?
123
- raise InvalidFormatError.new("#{self.class}: type of command_line must be String (but #{@command_line.class})") unless @command_line.is_a?(String)
124
- else
125
- @command_line = ""
126
- end
127
-
128
- unless @structured_command.nil?
129
- raise InvalidFormatError.new("#{self.class}: type of structured_command must be Array (but #{@structured_command.class})") unless @structured_command.is_a?(Array)
130
- @structured_command.map! do |e|
131
- if e.is_a?(Hash)
132
- raise InvalidFormatError.new("#{self.class}: couln't convert type of element of structured_command (Hash: size is not 1)") unless e.size == 1
133
- fl = e.flatten
134
- if fl[1].nil?
135
- Command.new(fl[0])
136
- else
137
- Command.new(fl[0], fl[1])
138
- end
139
- elsif e.is_a?(Array)
140
- raise InvalidFormatError.new("#{self.class}: couln't convert type of element of structured_command (Array: length is not 1 or 2)") unless e.length == 1 || e.length == 2
141
- if e.length == 1
142
- Command.new(e[0])
143
- elsif e.length == 2
144
- Command.new(e[0], e[1])
145
- end
146
- else
147
- raise InvalidFormatError.new("#{self.class}: type of element of structured_command must be Command (but #{e.class})") unless e.is_a?(Command)
148
- e
149
- end
150
- end
151
- else
152
- @structured_command = []
153
- end
154
-
155
- raise InvalidFormatError.new("#{self.class}: type of cpu_limit must be Integer (but #{@cpu_limit.class})") unless @cpu_limit.is_a?(Integer)
156
- raise InvalidFormatError.new("#{self.class}: type of memory_limit must be Integer (but #{@memory_limit.class})") unless @memory_limit.is_a?(Integer)
91
+ TypeUtil.nonnull_array_type_check(self, "args", @args, String)
92
+ TypeUtil.nonnull_array_type_check(self, "envs", @envs, String)
93
+ TypeUtil.nonnull_type_check(self, "cpu_limit", @cpu_limit, Integer)
94
+ TypeUtil.nonnull_type_check(self, "memory_limit", @memory_limit, Integer)
157
95
  end
158
96
  end
159
97
 
@@ -161,20 +99,21 @@ module TorigoyaKit
161
99
  class BuildInstruction
162
100
  def initialize(compile_setting, link_setting)
163
101
  @compile_setting = compile_setting # ExecutionSetting
164
- @link_setting = link_setting # ExecutionSetting
102
+ @link_setting = link_setting # ExecutionSetting?
165
103
 
166
104
  validate
167
105
  end
168
106
  attr_reader :compile_setting, :link_setting
169
107
 
170
- def to_tuple
171
- return [@compile_setting.to_tuple,
172
- unless @link_setting.nil? then @link_setting.to_tuple else nil end
173
- ]
108
+ def to_hash
109
+ return {
110
+ compile_setting: @compile_setting.to_hash,
111
+ link_setting: unless @link_setting.nil? then @link_setting.to_hash else nil end
112
+ }
174
113
  end
175
114
 
176
115
  def to_msgpack(out = '')
177
- return to_tuple.to_msgpack(out)
116
+ return to_hash.to_msgpack(out)
178
117
  end
179
118
 
180
119
  def ==(rhs)
@@ -184,29 +123,30 @@ module TorigoyaKit
184
123
 
185
124
  private
186
125
  def validate()
187
- raise InvalidFormatError.new("#{self.class}: type of compile_setting must be ExecutionSetting (but #{@compile_setting.class})") unless @compile_setting.is_a?(ExecutionSetting)
188
- unless @link_setting.nil?
189
- raise InvalidFormatError.new("#{self.class}: type of link_setting must be ExecutionSetting (but #{@link_setting.class})") unless @link_setting.is_a?(ExecutionSetting)
190
- end
126
+ TypeUtil.nonnull_type_check(self, "compile_setting", @compile_setting, ExecutionSetting)
127
+ TypeUtil.type_check(self, "link_setting", @link_setting, ExecutionSetting)
191
128
  end
192
129
  end
193
130
 
194
131
  #
195
132
  class Input
196
133
  def initialize(stdin, run_setting)
197
- @stdin = stdin # SourceData
134
+ @stdin = stdin # SourceData?
198
135
  @run_setting = run_setting # ExecutionSetting
199
136
 
200
137
  validate
201
138
  end
202
139
  attr_reader :stdin, :run_setting
203
140
 
204
- def to_tuple
205
- return [@stdin, @run_setting]
141
+ def to_hash
142
+ return {
143
+ stdin: @stdin,
144
+ run_setting: @run_setting.to_hash
145
+ }
206
146
  end
207
147
 
208
148
  def to_msgpack(out = '')
209
- return to_tuple.to_msgpack(out)
149
+ return to_hash.to_msgpack(out)
210
150
  end
211
151
 
212
152
  def ==(rhs)
@@ -216,10 +156,8 @@ module TorigoyaKit
216
156
 
217
157
  private
218
158
  def validate()
219
- unless @stdin.nil?
220
- raise InvalidFormatError.new("#{self.class}: type of stdin must be SourceData (but #{@stdin.class})") unless @stdin.is_a?(SourceData)
221
- end
222
- raise InvalidFormatError.new("#{self.class}: type of run_setting must be ExecutionSetting (but #{@run_setting.class})") unless @run_setting.is_a?(ExecutionSetting)
159
+ TypeUtil.type_check(self, "stdin", @stdin, SourceData)
160
+ TypeUtil.nonnull_type_check(self, "run_setting", @run_setting, ExecutionSetting)
223
161
  end
224
162
  end
225
163
 
@@ -232,12 +170,12 @@ module TorigoyaKit
232
170
  end
233
171
  attr_reader :inputs
234
172
 
235
- def to_tuple
236
- return [@inputs.map {|x| x.to_tuple}]
173
+ def to_hash
174
+ return [@inputs.map {|x| x.to_hash}]
237
175
  end
238
176
 
239
177
  def to_msgpack(out = '')
240
- return to_tuple.to_msgpack(out)
178
+ return to_hash.to_msgpack(out)
241
179
  end
242
180
 
243
181
  def ==(rhs)
@@ -246,45 +184,37 @@ module TorigoyaKit
246
184
 
247
185
  private
248
186
  def validate()
249
- raise InvalidFormatError.new("#{self.class}: type of inputs must be Array (but #{@inputs.class})") unless @inputs.is_a?(Array)
250
- @inputs.each do |e|
251
- raise InvalidFormatError.new("#{self.class}: type of element of inputs must be Input (but #{e.class})") unless e.is_a?(Input)
252
- end
187
+ TypeUtil.nonnull_array_type_check(self, "inputs", @inputs, Input)
253
188
  end
254
189
  end
255
190
 
256
191
  #
257
192
  class Ticket
258
- def initialize(base_name, proc_id, proc_version, source_codes, build_inst, run_inst)
259
- @base_name = base_name
260
- @proc_id = proc_id
261
- @proc_version = proc_version
193
+ def initialize(base_name, source_codes, build_inst, run_inst)
194
+ @base_name = base_name # String
262
195
  @source_codes = source_codes # Array!SourceData
263
- @build_inst = build_inst # BuildInstruction
264
- @run_inst = run_inst # RunInstruction
196
+ @build_inst = build_inst # BuildInstruction?
197
+ @run_inst = run_inst # RunInstruction?
265
198
 
266
199
  validate
267
200
  end
268
- attr_reader :base_name, :proc_id, :proc_version, :source_codes, :build_inst, :run_inst
201
+ attr_reader :base_name, :source_codes, :build_inst, :run_inst
269
202
 
270
- def to_tuple
271
- return [@base_name,
272
- @proc_id,
273
- @proc_version,
274
- @source_codes.map {|x| x.to_tuple},
275
- unless @build_inst.nil? then @build_inst.to_tuple else nil end,
276
- unless @run_inst.nil? then @run_inst.to_tuple else nil end
277
- ]
203
+ def to_hash
204
+ return {
205
+ base_inst: @base_name,
206
+ sources: @source_codes.map {|x| x.to_hash},
207
+ build_inst: unless @build_inst.nil? then @build_inst.to_hash else nil end,
208
+ run_inst: unless @run_inst.nil? then @run_inst.to_hash else nil end,
209
+ }
278
210
  end
279
211
 
280
212
  def to_msgpack
281
- return to_tuple.to_msgpack()
213
+ return to_hash.to_msgpack()
282
214
  end
283
215
 
284
216
  def ==(rhs)
285
217
  return @base_name == rhs.base_name &&
286
- @proc_id == rhs.proc_id &&
287
- @proc_version == rhs.proc_version &&
288
218
  @source_codes == rhs.source_codes &&
289
219
  @build_inst == rhs.build_inst &&
290
220
  @run_inst == rhs.run_inst
@@ -292,19 +222,10 @@ module TorigoyaKit
292
222
 
293
223
  private
294
224
  def validate()
295
- raise InvalidFormatError.new("#{self.class}: type of base_name must be String (but #{@base_name.class})") unless @base_name.is_a?(String)
296
- raise InvalidFormatError.new("#{self.class}: type of proc_id must be Integer (but #{@proc_id.class})") unless @proc_id.is_a?(Integer)
297
- raise InvalidFormatError.new("#{self.class}: type of proc_version must be String (but #{@proc_version.class})") unless @proc_version.is_a?(String)
298
- raise InvalidFormatError.new("#{self.class}: type of source_codes must be Array (but #{@source_codes.class})") unless @source_codes.is_a?(Array)
299
- @source_codes.each do |e|
300
- raise InvalidFormatError.new("#{self.class}: type of element of source_codes must be SourceData (but #{e.class})") unless e.is_a?(SourceData)
301
- end
302
- unless @build_inst.nil?
303
- raise InvalidFormatError.new("#{self.class}: type of build_inst must be BuildInstruction (but #{@build_inst.class})") unless @build_inst.is_a?(BuildInstruction)
304
- end
305
- unless @run_inst.nil?
306
- raise InvalidFormatError.new("#{self.class}: type of run_inst must be RunInstruction (but #{@run_inst.class})") unless @run_inst.is_a?(RunInstruction)
307
- end
225
+ TypeUtil.nonnull_type_check(self, "base_name", @base_name, String)
226
+ TypeUtil.nonnull_array_type_check(self, "source_codes", @source_codes, SourceData)
227
+ TypeUtil.type_check(self, "build_inst", @build_inst, BuildInstruction)
228
+ TypeUtil.type_check(self, "run_inst", @run_inst, RunInstruction)
308
229
  end
309
230
  end
310
231
 
@@ -314,4 +235,5 @@ module TorigoyaKit
314
235
  super(*args)
315
236
  end
316
237
  end
238
+
317
239
  end # module TorigoyaKit
@@ -0,0 +1,46 @@
1
+ # Copyright (c) 2015 - yutopp
2
+ # Licenced under the MIT License (http://www.opensource.org/licenses/mit-license.php)
3
+
4
+ module TorigoyaKit
5
+ class TypeUtil
6
+ def self.nil_check(tag, name, elem)
7
+ raise InvalidFormatError.new("#{tag.class}: type of `#{name}` must NOT be nil") if elem.nil?
8
+ end
9
+
10
+ def self.type_check(tag, name, elem, expect)
11
+ return if elem.nil?
12
+ raise InvalidFormatError.new("#{tag.class}: type of `#{name}` must be #{expect} (but #{elem.class})") unless elem.is_a?(expect)
13
+ end
14
+
15
+ def self.nonnull_type_check(tag, name, elem, expect)
16
+ nil_check(tag, name, elem)
17
+ type_check(tag, name, elem, expect)
18
+ end
19
+
20
+ def self.boolean_type_check(tag, name, elem)
21
+ return if elem.nil?
22
+ raise InvalidFormatError.new("#{tag.class}: type of `#{name}` must be Boolean (but #{elem.class})") unless elem.is_a?(TrueClass) || elem.is_a?(FalseClass)
23
+ end
24
+
25
+ def self.nonnull_boolean_type_check(tag, name, elem)
26
+ nil_check(tag, name, elem)
27
+ boolean_type_check(tag, name, elem)
28
+ end
29
+
30
+ def self.array_type_check(tag, name, elem, expect)
31
+ return if elem.nil?
32
+ type_check(tag, name, elem, Array)
33
+ elem.each do |e|
34
+ type_check(tag, "element of #{name}", e, expect)
35
+ end
36
+ end
37
+
38
+ def self.nonnull_array_type_check(tag, name, elem, expect)
39
+ nonnull_type_check(tag, name, elem, Array)
40
+ elem.each do |e|
41
+ nonnull_type_check(tag, "element of #{name}", e, expect)
42
+ end
43
+ end
44
+ end
45
+
46
+ end # module TorigoyaKit
@@ -1,3 +1,3 @@
1
1
  module TorigoyaKit
2
- VERSION = "0.0.11"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -3,29 +3,41 @@
3
3
  require_relative '../spec_helper'
4
4
 
5
5
  describe :request_protocol do
6
- b = TorigoyaKit::Protocol::Packet.new(TorigoyaKit::Protocol::MessageKindAcceptRequest, 12345)
6
+ b = TorigoyaKit::Protocol::Packet.new(
7
+ TorigoyaKit::Protocol::MessageKindTicketRequest, # kind
8
+ 42, # version
9
+ {"test": 42} # data
10
+ )
7
11
 
8
- it "size of kind should be 1" do
12
+ it "size of @kind should be 1" do
9
13
  expect(b.kind.size).to eq 1
10
14
  end
11
15
 
12
- it "kind should be TorigoyaKit::Protocol::MessageKindAcceptRequest" do
13
- expect(b.kind.bytes).to eq [0x00]
16
+ it "@kind should be TorigoyaKit::Protocol::MessageKindAcceptRequest" do
17
+ expect(b.kind.bytes).to eq [0x01]
14
18
  end
15
19
 
16
- it "size of size should be 3" do
17
- expect(b.size.size).to eq 4
20
+ it "size of @version should be 4" do
21
+ expect(b.version.size).to eq 4
18
22
  end
19
23
 
20
- it "size should be [0x03, 0x00, 0x00, 0x00]" do
21
- expect(b.size.bytes).to eq [0x03, 0x00, 0x00, 0x00]
24
+ it "@version should be 42" do
25
+ expect(b.version.bytes).to eq [0x2a, 0x00, 0x00, 0x00]
22
26
  end
23
27
 
24
- it "size of encoded_data should be 3" do
25
- expect(b.encoded_data.size).to eq 3
28
+ it "size of @length should be 4" do
29
+ expect(b.length.size).to eq 4
26
30
  end
27
31
 
28
- it "encoded_data should be [205, 48, 57]" do
29
- expect(b.encoded_data.bytes).to eq [205, 48, 57]
32
+ it "@length should be 3" do
33
+ expect(b.length.bytes).to eq [0x07, 0x00, 0x00, 0x00]
34
+ end
35
+
36
+ it "size of @message should be 7" do
37
+ expect(b.message.size).to eq 7
38
+ end
39
+
40
+ it "@message should be [129, 164, 116, 101, 115, 116, 42]" do
41
+ expect(b.message.bytes).to eq [129, 164, 116, 101, 115, 116, 42]
30
42
  end
31
43
  end
@@ -3,16 +3,27 @@
3
3
  require_relative '../spec_helper'
4
4
 
5
5
  describe :session do
6
+ port = 23432
7
+
6
8
  it "session proc exec_ticket" do
7
- s = TorigoyaKit::Session.new("localhost", 49800)
8
- # p s.exec_ticket(make_ticket())
9
+ s = TorigoyaKit::Session.new("localhost", port)
10
+ t = s.exec_ticket(make_ticket())
11
+ p t
12
+ expect(t.compile.result.system_error_status).to eq 0
13
+ expect(t.compile.result.exited).to eq true
14
+ expect(t.compile.result.exit_status).to eq 0
15
+
16
+ expect(t.link.result.system_error_status).to eq 0
17
+ expect(t.link.result.exited).to eq true
18
+ expect(t.link.result.exit_status).to eq 0
19
+
20
+ expect(t.run[0].result.system_error_status).to eq 0
21
+ expect(t.run[0].result.exited).to eq true
22
+ expect(t.run[0].result.exit_status).to eq 0
9
23
  end
10
24
 
11
- it "session proc update_proc_table" do
12
- #s = TorigoyaKit::Session.new("localhost", 22222)
13
- #s.update_packages()
14
- #s.exec_ticket(make_ticket())
15
- #s.update_proc_table()
16
- #p s.get_proc_table()
25
+ it "session proc update_packages" do
26
+ s = TorigoyaKit::Session.new("localhost", port)
27
+ expect(s.update_packages()).to eq 0
17
28
  end
18
29
  end
@@ -14,73 +14,67 @@ describe :ticket do
14
14
  end
15
15
 
16
16
  #
17
- dummy_es = TorigoyaKit::ExecutionSetting.new("", [], 0, 0)
17
+ dummy_es = TorigoyaKit::ExecutionSetting.new([], [], 0, 0)
18
18
  dummy_bi = TorigoyaKit::BuildInstruction.new(dummy_es, dummy_es)
19
19
  dummy_ri = TorigoyaKit::RunInstruction.new([])
20
20
 
21
21
  it "construct ticket" do
22
22
  expect do
23
- TorigoyaKit::Ticket.new(nil, nil, nil, nil, nil, nil)
23
+ TorigoyaKit::Ticket.new(nil, nil, nil, nil)
24
24
  end.to raise_error(TorigoyaKit::InvalidFormatError)
25
25
 
26
26
  expect do
27
- TorigoyaKit::Ticket.new("", nil, nil, nil, nil, nil)
27
+ TorigoyaKit::Ticket.new("", nil, nil, nil)
28
28
  end.to raise_error(TorigoyaKit::InvalidFormatError)
29
29
 
30
30
  expect do
31
- TorigoyaKit::Ticket.new("", 0, nil, nil, nil, nil)
31
+ TorigoyaKit::Ticket.new("", [], "", nil)
32
32
  end.to raise_error(TorigoyaKit::InvalidFormatError)
33
33
 
34
34
  expect do
35
- TorigoyaKit::Ticket.new("", 0, "", nil, nil, nil)
35
+ TorigoyaKit::Ticket.new("", [], "", "")
36
36
  end.to raise_error(TorigoyaKit::InvalidFormatError)
37
37
 
38
38
  expect do
39
- TorigoyaKit::Ticket.new("", 0, "", [], nil, 2)
39
+ TorigoyaKit::Ticket.new(0, [], "", "")
40
40
  end.to raise_error(TorigoyaKit::InvalidFormatError)
41
41
 
42
42
  expect do
43
- TorigoyaKit::Ticket.new("", 0, "", [], dummy_bi, 2)
43
+ TorigoyaKit::Ticket.new("", 0, "", "")
44
44
  end.to raise_error(TorigoyaKit::InvalidFormatError)
45
45
 
46
46
  expect do
47
- TorigoyaKit::Ticket.new("", 0, "", [], dummy_bi, dummy_ri)
47
+ TorigoyaKit::Ticket.new("", [], dummy_bi, dummy_ri)
48
48
  end.to_not raise_error
49
49
 
50
50
  expect do
51
- TorigoyaKit::Ticket.new("", 0, "", [], dummy_bi, dummy_ri).to_msgpack
51
+ TorigoyaKit::Ticket.new("", [], dummy_bi, dummy_ri).to_msgpack
52
52
  end.to_not raise_error
53
53
 
54
54
  expect do
55
- TorigoyaKit::Ticket.new("", 0, "", [], nil, dummy_ri)
55
+ TorigoyaKit::Ticket.new("", [], nil, dummy_ri)
56
56
  end.to_not raise_error
57
57
 
58
58
  expect do
59
- TorigoyaKit::Ticket.new("", 0, "", [], nil, dummy_ri).to_msgpack
59
+ TorigoyaKit::Ticket.new("", [], nil, dummy_ri).to_msgpack
60
60
  end.to_not raise_error
61
- end
62
-
63
- it "construct execution setting" do
64
- commands = [TorigoyaKit::Command.new("A=", "B"),
65
- TorigoyaKit::Command.new("unit")
66
- ]
67
- expected = TorigoyaKit::ExecutionSetting.new("test command", commands, 100, 200)
68
61
 
69
- cloned_commands = [TorigoyaKit::Command.new("A=", "B"),
70
- TorigoyaKit::Command.new("unit")
71
- ]
72
- cloned_dummy = TorigoyaKit::ExecutionSetting.new("test command", cloned_commands, 100, 200)
62
+ expect do
63
+ TorigoyaKit::Ticket.new("", [], dummy_bi, nil)
64
+ end.to_not raise_error
73
65
 
74
- expect(cloned_dummy).to eq expected
66
+ expect do
67
+ TorigoyaKit::Ticket.new("", [], dummy_bi, nil).to_msgpack
68
+ end.to_not raise_error
75
69
  end
76
70
 
77
71
  it "setting" do
78
- cloned_es = TorigoyaKit::ExecutionSetting.new("", [], 0, 0)
72
+ cloned_es = TorigoyaKit::ExecutionSetting.new([], [], 0, 0)
79
73
  expect(cloned_es).to eq dummy_es
80
74
  end
81
75
 
82
76
  it "build inst" do
83
- cloned_es = TorigoyaKit::ExecutionSetting.new("", [], 0, 0)
77
+ cloned_es = TorigoyaKit::ExecutionSetting.new([], [], 0, 0)
84
78
  cloned_bi = TorigoyaKit::BuildInstruction.new(cloned_es, cloned_es)
85
79
 
86
80
  expect(cloned_bi).to eq dummy_bi
@@ -91,24 +85,6 @@ describe :ticket do
91
85
  expect(cloned_ri).to eq dummy_ri
92
86
  end
93
87
 
94
- it "setting conversion list" do
95
- commands = [TorigoyaKit::Command.new("A=", "B"),
96
- TorigoyaKit::Command.new("unit")
97
- ]
98
- expected = TorigoyaKit::ExecutionSetting.new("test command", commands, 100, 200)
99
-
100
- expect(TorigoyaKit::ExecutionSetting.new("test command", [["A=", "B"], ["unit"]], 100, 200)).to eq expected
101
- end
102
-
103
- it "setting conversion list" do
104
- commands = [TorigoyaKit::Command.new("A=", "B"),
105
- TorigoyaKit::Command.new("unit")
106
- ]
107
- expected = TorigoyaKit::ExecutionSetting.new("test command", commands, 100, 200)
108
-
109
- expect(TorigoyaKit::ExecutionSetting.new("test command", [{"A=" => "B"}, {"unit"=>nil}], 100, 200)).to eq expected
110
- end
111
-
112
88
  it "source default" do
113
89
  expected = TorigoyaKit::SourceData.new("*default*", "hoge")
114
90
  expect(TorigoyaKit::SourceData.new(nil, "hoge")).to eq expected