tdl-client-ruby 0.6.2 → 0.8.1

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: 6976b1c83ffdf765e109612d09f91463491fb61c
4
- data.tar.gz: 2db01aa3f6d57408913c4ae43aa4379f0b3cd944
3
+ metadata.gz: 692ce8021fc9ee93c4beb5d2ccf53702b357a852
4
+ data.tar.gz: bd4c39075d37f2585f9e2d08283094b074b59a42
5
5
  SHA512:
6
- metadata.gz: d929ce2e05e339eb28ecb2e4220962c8f064a8a95958aa9a957b19e8e69738c9a6279c7934d884b8267836e4fccaed910bbada9c790df6f68614b4cf12056498
7
- data.tar.gz: d70bd8203c405476d9b6b7ca745abda763e1bb211a16b8c456712ca795602973f0cce87a5da4ba4f952aef5f7dfd16f95e14dbf7efb058f4cacce5b19162ea96
6
+ metadata.gz: c5390ada98e61d5d533525df561e00f26379c9ced6d966f794beb861532f2176d8dc7ae7a906aa5da0786b2c16675736bba3de07ee807b843fbe8c93b343e689
7
+ data.tar.gz: 6ecb31247e27e216db9d5dbc5a747e5ea298a69b0ec6e1008c0af3d9d846d4f3f50ea7b8ec520c8b315a52f44b35eb493301416a6ec6a8d1d1dc2e739aed0bb8
data/lib/tdl.rb CHANGED
@@ -1,5 +1,4 @@
1
-
2
1
  require 'tdl/client'
3
2
 
4
3
  module TDL
5
- end
4
+ end
@@ -1,16 +1,20 @@
1
+ require 'tdl/util'
2
+
1
3
  module TDL
2
4
  class Request
3
5
  attr_reader :original_message, :id, :method, :params
4
6
 
5
7
  def initialize(original_message, request_data)
6
8
  @original_message = original_message
7
- @id = request_data['id']
8
- @method = request_data['method']
9
- @params = request_data['params']
9
+ @id = request_data.fetch('id')
10
+ @method = request_data.fetch('method')
11
+ @params = request_data.fetch('params')
10
12
  end
11
13
 
12
14
  def audit_text
13
- "id = #{@id}, req = #{@method}(#{@params.join(', ')})"
15
+ "id = #{id}, req = #{method}(#{params.map{ |param|
16
+ TDL::Util.compress_data(param)
17
+ }.join(', ')})"
14
18
  end
15
19
  end
16
20
  end
@@ -1,3 +1,5 @@
1
+ require 'tdl/util'
2
+
1
3
  module TDL
2
4
  class ValidResponse
3
5
  attr_reader :result, :id, :client_action
@@ -17,7 +19,7 @@ module TDL
17
19
  end
18
20
 
19
21
  def audit_text
20
- "resp = #{@result}"
22
+ "resp = #{TDL::Util.compress_data(@result)}"
21
23
  end
22
24
  end
23
25
  end
data/lib/tdl/client.rb CHANGED
@@ -6,7 +6,6 @@ require 'tdl/processing_rules'
6
6
  require 'tdl/actions/stop_action'
7
7
 
8
8
  require 'tdl/serialization/json_rpc_serialization_provider'
9
-
10
9
  module TDL
11
10
 
12
11
  class Client
@@ -29,6 +28,7 @@ module TDL
29
28
  @logger.info 'Stopping client.'
30
29
  remote_broker.close
31
30
  rescue Exception => e
31
+ # raise e if ENV['TDL_ENV'] == 'test'
32
32
  @logger.error "There was a problem processing messages. #{e.message}"
33
33
  @logger.error e.backtrace.join("\n")
34
34
  end
@@ -45,7 +45,7 @@ module TDL
45
45
  if @rules.has_key?(request.method)
46
46
  processing_rule = @rules[request.method]
47
47
  else
48
- message = "method \"#{request.method}\" did not match any processing rule"
48
+ message = "\"method '#{request.method}' did not match any processing rule\""
49
49
  @logger.warn(message)
50
50
  return FatalErrorResponse.new(message)
51
51
  end
@@ -56,7 +56,7 @@ module TDL
56
56
 
57
57
  return ValidResponse.new(request.id, result, processing_rule.client_action)
58
58
  rescue Exception => e
59
- message = 'user implementation raised exception'
59
+ message = '"user implementation raised exception"'
60
60
  @logger.warn("#{message}, #{e.message}")
61
61
  @logger.warn e.backtrace.join("\n")
62
62
  return FatalErrorResponse.new(message)
@@ -10,9 +10,10 @@ module TDL
10
10
 
11
11
  def deserialize(msg)
12
12
  begin
13
- request_data = JSON.parse(msg.body)
13
+ request_data = JSON.parse(msg.body.gsub("\n", '\n'))
14
14
  Request.new(msg, request_data)
15
15
  rescue Exception => e
16
+ raise e if ENV['TDL_ENV'] == 'test'
16
17
  raise DeserializationException,'Invalid message format', e.backtrace
17
18
  end
18
19
  end
data/lib/tdl/util.rb ADDED
@@ -0,0 +1,22 @@
1
+ module TDL
2
+ module Util
3
+ def self.compress_text(text)
4
+ # DEBT compress text should not add quotes
5
+ top_line, *remaing_content = text.split("\n")
6
+ if remaing_content
7
+ lines_remaining = remaing_content.size
8
+ "\"#{top_line} .. ( #{lines_remaining} more line#{ 's' if lines_remaining != 1 } )\""
9
+ else
10
+ "\"#{top_line}\""
11
+ end
12
+ end
13
+
14
+ def self.compress_data(data)
15
+ if data.respond_to?(:split)
16
+ "#{TDL::Util.compress_text(data)}"
17
+ else
18
+ "#{data}"
19
+ end
20
+ end
21
+ end
22
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tdl-client-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Ghionoiu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-22 00:00:00.000000000 Z
11
+ date: 2016-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: stomp
@@ -212,6 +212,7 @@ files:
212
212
  - lib/tdl/serialization/deserialization_exception.rb
213
213
  - lib/tdl/serialization/json_rpc_serialization_provider.rb
214
214
  - lib/tdl/transport/remote_broker.rb
215
+ - lib/tdl/util.rb
215
216
  - release.sh
216
217
  - tdl-client-ruby.gemspec
217
218
  - tdl-client-ruby.iml