relaxo-query-server 0.1.4 → 0.1.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78944e73c0640d81426a896195caf1dac016cccf
4
- data.tar.gz: 32d6f60802a40842fbea80820c1914f06e6409cf
3
+ metadata.gz: 1bce12878810ea52b4511ded70da309034ae22ca
4
+ data.tar.gz: dc5c2821f3fbb7eed5bb48cbd2853028aee2863b
5
5
  SHA512:
6
- metadata.gz: 5df2161444eee230a5eff87830986c5b060ea38d53e3823c48bc94c3a54969760c6ba91bd7bcb23a30673afafe654901305476efa7aec2c956b3e8c58a941f32
7
- data.tar.gz: 403b146fb25f50a0dfc71b6d8cc845159c86d0491954d505af9f08419f64db569d0598ca68386c526779a1a0a96bdd0f887b4d42fa65492c728406f110038728
6
+ metadata.gz: 2671ca62a2ded30c04ca9012a4dc7f30a6fa0ce0e4abffee32a761b3081fe255ff4699023a73cf7b086cc84695850720cced0cca85d6a8d91abdc510671bdcfb
7
+ data.tar.gz: 8b08db83690523700b7a99ab36ab58a54a8b7f38aaf25b074fa142dbe7e2f5b7a05a3eb5405fb46834ad020deae70f89657ab8a850c5d83e03a919dd1d98fdde
@@ -4,7 +4,8 @@ require 'relaxo/query_server'
4
4
  require 'optparse'
5
5
 
6
6
  OPTIONS = {
7
- :safe => 2
7
+ # Don't do completely unsafe operations, but most things continue to work correctly.
8
+ :safe => 1
8
9
  }
9
10
 
10
11
  ARGV.options do |o|
@@ -20,6 +21,10 @@ ARGV.options do |o|
20
21
  o.on("--safe [level]", "Set the ruby $SAFE level to protect the execution environment.") do |level|
21
22
  OPTIONS[:safe] = level.to_i
22
23
  end
24
+
25
+ o.on("--debug path", "Log all requests to the given log file") do |path|
26
+ OPTIONS[:debug] = path
27
+ end
23
28
 
24
29
  o.separator ""
25
30
 
@@ -28,6 +28,11 @@ module Relaxo
28
28
  shell = Shell.new($stdin, $stdout)
29
29
  context = Context.new(shell, options)
30
30
 
31
+ if options[:debug]
32
+ log = File.open(options[:debug], 'a')
33
+ shell = DebugShell.new(log, shell)
34
+ end
35
+
31
36
  shell.run do |command|
32
37
  context.run(command)
33
38
  end
@@ -49,9 +49,9 @@ module Relaxo
49
49
  begin
50
50
  while true
51
51
  command = read_object
52
-
52
+
53
53
  result = yield command
54
-
54
+
55
55
  write_object(result)
56
56
  end
57
57
  rescue EOFError
@@ -60,6 +60,26 @@ module Relaxo
60
60
  end
61
61
  end
62
62
 
63
+ class DebugShell
64
+ def initialize(log, wrapper)
65
+ @log = log
66
+ @wrapper = wrapper
67
+ end
68
+
69
+ # Read commands from `input`, execute them and then write out the results.
70
+ def run
71
+ @wrapper.run do |command|
72
+ @log.puts "-> #{command.inspect}"
73
+
74
+ result = yield command
75
+
76
+ @log.puts "<- #{result.inspect}"
77
+
78
+ next result
79
+ end
80
+ end
81
+ end
82
+
63
83
  # Used primarily for testing, allows the input and output of the server to be provided directly.
64
84
  class MockShell < Shell
65
85
  def initialize
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Relaxo
22
22
  module QueryServer
23
- VERSION = "0.1.4"
23
+ VERSION = "0.1.5"
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaxo-query-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-08 00:00:00.000000000 Z
11
+ date: 2015-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: relaxo