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
@@ -0,0 +1,61 @@
1
+ module Pione
2
+ module Command
3
+ # PioneLog is a command for viewing PIONE log or converting into other formats.
4
+ class PioneLog < BasicCommand
5
+ define_info do
6
+ set_name "pione-log"
7
+ set_banner "View and convert PIONE log."
8
+ end
9
+
10
+ define_option do
11
+ default :format, :xes
12
+ default :trace_filter, []
13
+ default :output, Location["local:./output"]
14
+
15
+ option("--agent-activity[=TYPE]", "output only agent activity log") do |data, name|
16
+ data[:trace_filter] << Proc.new do |trace|
17
+ trace.attributes.include?(XES.string("pione:traceType", "agent_activity")) and
18
+ (name.nil? or trace.events.first.org_resource == name)
19
+ end
20
+ end
21
+
22
+ option("--rule-process", "generate rule process log") do |data|
23
+ data[:trace_filter] << Proc.new do |trace|
24
+ trace.attributes.include?(XES.string("pione:traceType", "rule_process"))
25
+ end
26
+ end
27
+
28
+ option("--task-process", "generate task process log") do |data|
29
+ data[:trace_filter] << Proc.new do |trace|
30
+ trace.attributes.include?(XES.string("pione:traceType", "task_process"))
31
+ end
32
+ end
33
+
34
+ option("--location=LOCATION", "set log location of PIONE process") do |data, location|
35
+ data[:output] = Location[location]
36
+ end
37
+
38
+ option("--format=(XES|JSON|HTML)", "set format type") do |data, name|
39
+ data[:format] = name.downcase.to_sym
40
+ end
41
+
42
+ validate do |data|
43
+ unless data[:output].exist?
44
+ abort("File or directory not found in the location: %s" % data[:output].uri.to_s)
45
+ end
46
+ end
47
+ end
48
+
49
+ start do
50
+ Log::ProcessLog[option[:format]].tap do |formatter|
51
+ if formatter
52
+ $stdout.puts(formatter.read(option[:output]).format(option[:trace_filter]))
53
+ $stdout.flush
54
+ else
55
+ abort("Unknown format: %s" % option[:format])
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -1,63 +1,66 @@
1
1
  module Pione
2
2
  module Command
3
+ # PioneRelayAccountDB is a command that adds, deletes, shows your accounts
4
+ # of relay servers.
3
5
  class PioneRelayAccountDB < BasicCommand
4
- set_program_name("pione-relay-account-db")
6
+ define_info do
7
+ set_name "pione-relay-account-db"
8
+ set_banner "Add, delete, or show your accounts of relay servers."
9
+ end
5
10
 
6
- set_program_message <<TXT
7
- Add, delete, or show your accounts of relay servers.
8
- TXT
11
+ define_option do
12
+ option("-a", "--add", "add an account") do |data|
13
+ data[:action] = :add
14
+ end
9
15
 
10
- define_option("-a", "--add", "add an account") do
11
- @action = :add
12
- end
16
+ option("-d", "--delete", "delete an account") do |data|
17
+ data[:action] = :delete
18
+ end
13
19
 
14
- define_option("-d", "--delete", "delete an account") do
15
- @action = :delete
16
- end
20
+ option("-l", "--list", "list accounts") do |data|
21
+ data[:action] = :list
22
+ end
17
23
 
18
- define_option("-l", "--list", "list accounts") do
19
- @action = :list
20
- end
24
+ option("-r realm", "--realm realm", "realm name") do |data, realm|
25
+ data[:realm] = realm
26
+ end
21
27
 
22
- define_option("-r realm", "--realm realm", "realm name") do |realm|
23
- @realm = realm
24
- end
28
+ option("-u name", "--user name", "user name") do |data, name|
29
+ data[:name] = name
30
+ end
25
31
 
26
- define_option("-u name", "--user name", "user name") do |name|
27
- @name = name
28
- end
32
+ option("-p password", "--password password", "password") do |data, password|
33
+ data[:password] = password
34
+ end
29
35
 
30
- define_option("-p password", "--password password", "password") do |password|
31
- @password = password
32
- end
36
+ option("-f path", "--file path", "account db path") do |data, path|
37
+ Global.relay_account_db_path = path
38
+ end
33
39
 
34
- define_option("-f path", "--file path", "account db path") do |path|
35
- Global.relay_account_db_path = path
40
+ validate do |data|
41
+ abort("error: -a, -d, or -l") unless data[:action]
42
+ end
36
43
  end
37
44
 
38
45
  def initialize
39
- @action = nil
46
+ @realm = nil
40
47
  @name = nil
41
48
  @password = nil
42
49
  end
43
50
 
44
- def validate_options
45
- abort("error: -a, -d, or -l") unless @action
46
- end
47
-
48
- def prepare
51
+ prepare do
49
52
  # set account db
50
53
  Global.relay_account_db = RelayAccountDB.new(Global.relay_account_db_path)
51
54
 
52
55
  # set realm
53
- if [:add, :delete].include?(@action)
54
- @realm = HighLine.new.ask("Realm: ") unless @realm
56
+ if [:add, :delete].include?(option[:action])
57
+ @realm = option[:realm] || HighLine.new.ask("Realm: ") unless @realm
55
58
  end
56
59
 
57
60
  # set name and password
58
- if @action == :add
59
- @name = HighLine.new.ask("Name: ") unless @name
60
- unless @password
61
+ if option[:action] == :add
62
+ @name = option[:name] || HighLine.new.ask("Name: ")
63
+ unless @password = option[:password]
61
64
  @password = HighLine.new.ask("Password: "){|q| q.echo = "*"}
62
65
  password = HighLine.new.ask("Re-enter password: "){|q| q.echo = "*"}
63
66
  abort("error: password mismatch") unless @password == password
@@ -65,9 +68,9 @@ TXT
65
68
  end
66
69
  end
67
70
 
68
- def start
71
+ start do
69
72
  db = Global.relay_account_db
70
- case @action
73
+ case option[:action]
71
74
  when :add
72
75
  db.add(@realm, @name, @password)
73
76
  db.save
@@ -78,7 +81,6 @@ TXT
78
81
  puts "%s accounts in %s" % [db.realms.size, Global.relay_account_db_path]
79
82
  db.realms.each {|realm| puts "%s:%s" % [realm, db[realm].name]}
80
83
  end
81
- terminate
82
84
  end
83
85
  end
84
86
  end
@@ -1,79 +1,75 @@
1
1
  module Pione
2
2
  module Command
3
+ # PioneRelayClientDB is a command that adds, deletes, or shows clients in
4
+ # relay server.
3
5
  class PioneRelayClientDB < BasicCommand
4
- set_program_name("pione-relay-client-db")
5
-
6
- set_program_message <<TXT
7
- Add, delete, or show clients in this relay server.
8
- TXT
9
-
10
- define_option("-a", "--add", "add a client") do
11
- @action = :add
6
+ define_info do
7
+ set_name "pione-relay-client-db"
8
+ set_banner "Add, delete, or show clients in this relay server."
12
9
  end
13
10
 
14
- define_option("-d", "--delete", "delete a client") do
15
- @action = :delete
16
- end
11
+ define_option do
12
+ option("-a", "--add", "add a client") do |data|
13
+ data[:action] = :add
14
+ end
17
15
 
18
- define_option("-l", "--list", "list clients") do
19
- @action = :list
20
- end
16
+ option("-d", "--delete", "delete a client") do |data|
17
+ data[:action] = :delete
18
+ end
21
19
 
22
- define_option("-u name", "--user name", "user name") do |name|
23
- @name = name
24
- end
20
+ option("-l", "--list", "list clients") do |data|
21
+ data[:action] = :list
22
+ end
25
23
 
26
- define_option("-p password", "--password password", "password") do |password|
27
- @password = password
28
- end
24
+ option("-u name", "--user name", "user name") do |data, name|
25
+ data[:name] = name
26
+ end
29
27
 
30
- define_option("-f path", "--file path", "client db path") do |path|
31
- Global.relay_client_db_path = path
32
- end
28
+ option("-p password", "--password password", "password") do |data, password|
29
+ data[:password] = password
30
+ end
33
31
 
34
- def initialize
35
- @action = nil
36
- @name = nil
37
- @password = nil
38
- end
32
+ option("-f path", "--file path", "client db path") do |data, path|
33
+ Global.relay_client_db_path = path
34
+ end
39
35
 
40
- def validate_options
41
- abort("error: -a, -d, or -l") unless @action
36
+ validate do |data|
37
+ abort("error: -a, -d, or -l") unless data[:action]
38
+ end
42
39
  end
43
40
 
44
- def prepare
41
+ prepare do
45
42
  # set client db
46
43
  Global.relay_client_db = RelayClientDB.new(Global.relay_client_db_path)
47
44
 
48
45
  # set name
49
- if [:add, :delete].include?(@action)
50
- @name = HighLine.new.ask("Name: ") unless @name
46
+ if [:add, :delete].include?(option[:action])
47
+ option[:name] = HighLine.new.ask("Name: ") unless option[:name]
51
48
  end
52
49
 
53
50
  # set password
54
- if @action == :add
55
- unless @password
56
- @password = HighLine.new.ask("Password: "){|q| q.echo = "*"}
51
+ if option[:action] == :add
52
+ unless option[:password]
53
+ option[:password] = HighLine.new.ask("Password: "){|q| q.echo = "*"}
57
54
  password = HighLine.new.ask("Re-enter password: "){|q| q.echo = "*"}
58
- abort("error: password mismatch") unless @password == password
55
+ abort("error: password mismatch") unless option[:password] == password
59
56
  end
60
57
  end
61
58
  end
62
59
 
63
- def start
64
- case @action
60
+ start do
61
+ case option[:action]
65
62
  when :add
66
- Global.relay_client_db.add(@name, @password)
63
+ Global.relay_client_db.add(option[:name], option[:password])
67
64
  Global.relay_client_db.save
68
65
  when :delete
69
- Global.relay_client_db.delete(@name)
66
+ Global.relay_client_db.delete(option[:name])
70
67
  Global.relay_client_db.save
71
68
  when :list
72
69
  names = Global.relay_client_db.names
73
70
  puts "%s clients in %s" % [names.size, Global.relay_client_db_path]
74
71
  names.each {|user| puts user}
75
72
  end
76
- terminate
77
73
  end
78
74
  end
79
75
  end
@@ -1,42 +1,41 @@
1
1
  module Pione
2
2
  module Command
3
+ # PioneRelay is a command for connecting relay server.
3
4
  class PioneRelay < FrontOwnerCommand
4
- set_program_name("pione-relay") do
5
- "--relay-port %s" % [@relay_port]
5
+ define_info do
6
+ set_name "pione-relay"
7
+ set_tail {|cmd| "--relay-port %s" % cmd.option[:relay_port]}
8
+ set_banner "Run relay process for connecting between clients and brokers."
6
9
  end
7
10
 
8
- set_program_message <<TXT
9
- Runs relay process for connecting between clients and brokers.
10
- TXT
11
+ define_option do
12
+ default :relay_port, Global.relay_port
11
13
 
12
- define_option("--realm name", "set relay realm name for client authentification") do |name|
13
- Global.relay_realm = name
14
- end
15
-
16
- define_option("--relay-port port", "set relay port") do |port|
17
- @relay_port = port
18
- end
14
+ option("--realm name", "set relay realm name for client authentification") do |data, name|
15
+ Global.relay_realm = name
16
+ end
19
17
 
20
- def initialize
21
- @relay_port = Global.relay_port
22
- end
18
+ option("--relay-port port", "set relay port") do |data, port|
19
+ data[:relay_port] = port
20
+ end
23
21
 
24
- def validate_options
25
- abort("error: no realm name") if Global.relay_realm.nil? or Global.relay_realm.empty?
26
- abort("error: no relay port") unless @relay_port
22
+ validate do |data|
23
+ abort("error: no realm name") if Global.relay_realm.nil? or Global.relay_realm.empty?
24
+ abort("error: no relay port") unless data[:relay_port]
25
+ end
27
26
  end
28
27
 
29
28
  def create_front
30
29
  Front::RelayFront.new(self)
31
30
  end
32
31
 
33
- def start
32
+ start do
34
33
  # wake up tuple space provider process
35
34
  Pione::TupleSpaceProvider.instance
36
35
 
37
36
  puts DRb.front.uri
38
37
  DRb::DRbServer.new(
39
- "relay://:%s" % @relay_port,
38
+ "relay://:%s" % data[:relay_port],
40
39
  nil,
41
40
  {:SSLCertName => Global.relay_ssl_certname}
42
41
  )
@@ -1,52 +1,79 @@
1
1
  module Pione
2
2
  module Command
3
+ # PioneSyntaxChecker is a command for checking syntax tree and model of the
4
+ # PIONE document.
3
5
  class PioneSyntaxChecker < BasicCommand
4
- set_program_name("pione-syntax-checker")
6
+ define_info do
7
+ set_name "pione-syntax-checker"
8
+ set_banner "Print syntax tree of PIONE notation."
9
+ end
5
10
 
6
- set_program_message <<TXT
7
- Prints syntax tree of PIONE notation.
8
- TXT
11
+ define_option do
12
+ default :readline_mode, true
13
+ default :transform, false
9
14
 
10
- define_option('-e', '--expr=expr', 'expression string') do |e|
11
- @expr = e
12
- @readline_mode = false
13
- end
15
+ option('-e', '--expr=EXPR', 'check the expression string and exit') do |data, e|
16
+ data[:expr] = e
17
+ data[:readline_mode] = false
18
+ end
14
19
 
15
- define_option('-t', '--transformer', 'show transformer result') do
16
- @transform = true
17
- end
20
+ option('-t', '--transformer', 'show transformer result') do |data|
21
+ data[:transform] = true
22
+ end
18
23
 
19
- define_option('-f', '--file=PATH', 'check syntax of the document') do |path|
20
- @document = path
21
- @readline_mode = false
24
+ option('-f', '--file=PATH', 'check syntax of the document') do |data, path|
25
+ data[:document] = path
26
+ data[:readline_mode] = false
27
+ end
22
28
  end
23
29
 
24
30
  def initialize
25
- @readline_mode = true
31
+ @history = File.join(Global.dot_pione_dir, "pione-history")
26
32
  end
27
33
 
28
- def prepare
34
+ prepare do
29
35
  require 'pp'
30
- @history = File.join(Global.dot_pione_dir, "pione-history")
31
- trap_int
32
36
  end
33
37
 
34
- def start
35
- if @readline_mode
36
- start_readline_mode
37
- else
38
- if @document
39
- print_result(Pathname.new(@document).read)
40
- else
41
- # print parsing result
42
- print_result(@expr)
43
- end
38
+ start do
39
+ case action_mode
40
+ when :readline
41
+ action_readline_mode
42
+ when :file
43
+ print_result(Pathname.new(option[:document]).read)
44
+ when :expr
45
+ print_result(option[:expr])
44
46
  end
45
47
  end
46
48
 
49
+ terminate(:pre) do
50
+ save_history if readline_mode?
51
+ end
52
+
47
53
  private
48
54
 
49
- def start_readline_mode
55
+ # Return action mode.
56
+ #
57
+ # @return [Symbol]
58
+ # action mode
59
+ def action_mode
60
+ return :readline if readline_mode?
61
+ return :file if option[:document]
62
+ return :expr if option[:expr]
63
+ end
64
+
65
+ # Return true if readline mode is enabled.
66
+ #
67
+ # @return [Boolean]
68
+ # true if readline mode is enabled
69
+ def readline_mode?
70
+ option[:readline_mode]
71
+ end
72
+
73
+ # Action readline mode.
74
+ #
75
+ # @return [void]
76
+ def action_readline_mode
50
77
  require 'readline'
51
78
  restore_history
52
79
  buf = ""
@@ -74,40 +101,36 @@ TXT
74
101
  # don't record if it is an empty line
75
102
  Readline::HISTORY.pop
76
103
  end
77
- # print parsing result
78
- print_result(buf)
79
104
  end
80
105
  end
81
106
 
82
- # Prints parsing result of the string
107
+ # Print parsing result of the string.
108
+ #
109
+ # @param str [String]
110
+ # PIONE expression
111
+ # @return [void]
83
112
  def print_result(str)
84
113
  begin
85
114
  puts Terminal.green("syntax:")
86
115
  stree = DocumentParser.new.parse(str)
87
116
  pp stree
88
- if @transform
117
+ if option[:transform]
89
118
  puts Terminal.green("model:")
90
119
  pp DocumentTransformer.new.apply(stree)
91
120
  end
92
121
  rescue Pione::Parser::ParserError, Parslet::ParseFailed => e
93
122
  msg = "Pione syntax error: %s (%s)" % [e.message, e.class.name]
94
- @readline_mode ? puts(msg) : abort(msg)
123
+ readline_mode? ? puts(msg) : abort(msg)
95
124
  rescue Pione::Model::PioneModelTypeError,
96
125
  Pione::Model::VariableBindingError => e
97
126
  msg = "Pione model error: %s (%s)" % [e.message, e.class.name]
98
- @readline_mode ? puts(msg) : abort(msg)
99
- end
100
- end
101
-
102
- # Makes trap Ctr+C
103
- def trap_int
104
- trap("INT") do
105
- save_history
106
- exit
127
+ readline_mode? ? puts(msg) : abort(msg)
107
128
  end
108
129
  end
109
130
 
110
- # Restores history.
131
+ # Restore readline's history.
132
+ #
133
+ # @return [void]
111
134
  def restore_history
112
135
  if File.exist?(@history)
113
136
  File.readlines(@history).reverse.each do |line|
@@ -116,7 +139,9 @@ TXT
116
139
  end
117
140
  end
118
141
 
119
- # Saves history.
142
+ # Save history to file.
143
+ #
144
+ # @return [void]
120
145
  def save_history
121
146
  File.open(@history, "w+") do |file|
122
147
  Readline::HISTORY.to_a.reverse[0..100].each do |line|