tdl-client-ruby 0.19.3 → 0.20.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.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.gitmodules +3 -0
  4. data/README.md +11 -3
  5. data/lib/tdl.rb +6 -1
  6. data/lib/tdl/audit/console_audit_stream.rb +9 -0
  7. data/lib/tdl/previous_version.rb +1 -1
  8. data/lib/tdl/{abstractions → queue/abstractions}/processing_rule.rb +0 -0
  9. data/lib/tdl/{abstractions → queue/abstractions}/request.rb +0 -0
  10. data/lib/tdl/{abstractions → queue/abstractions}/response/fatal_error_response.rb +1 -1
  11. data/lib/tdl/{abstractions → queue/abstractions}/response/valid_response.rb +0 -0
  12. data/lib/tdl/{actions → queue/actions}/client_actions.rb +3 -3
  13. data/lib/tdl/{actions → queue/actions}/publish_action.rb +0 -0
  14. data/lib/tdl/{actions → queue/actions}/publish_and_stop_action.rb +0 -0
  15. data/lib/tdl/{actions → queue/actions}/stop_action.rb +0 -0
  16. data/lib/tdl/{client.rb → queue/client.rb} +4 -4
  17. data/lib/tdl/queue/implementation_runner_config.rb +59 -0
  18. data/lib/tdl/{processing_rules.rb → queue/processing_rules.rb} +4 -4
  19. data/lib/tdl/queue/queue_based_implementation_runner.rb +75 -0
  20. data/lib/tdl/queue/queue_based_implementation_runner_builder.rb +40 -0
  21. data/lib/tdl/{serialization → queue/serialization}/deserialization_exception.rb +0 -0
  22. data/lib/tdl/{serialization → queue/serialization}/json_rpc_serialization_provider.rb +2 -2
  23. data/lib/tdl/{transport → queue/transport}/remote_broker.rb +1 -1
  24. data/lib/tdl/runner/challenge_server_client.rb +91 -0
  25. data/lib/tdl/runner/challenge_session.rb +95 -0
  26. data/lib/tdl/runner/challenge_session_config.rb +74 -0
  27. data/lib/tdl/runner/recording_system.rb +62 -0
  28. data/lib/tdl/runner/round_management.rb +43 -0
  29. data/lib/tdl/runner/runner_action.rb +28 -0
  30. data/tdl-client-ruby.gemspec +1 -1
  31. data/tdl-client-ruby.iml +17 -19
  32. metadata +41 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bfea2b9c8522c632c1575cb265fa63878c43bc58
4
- data.tar.gz: dadbb03629370a64ba8a4a4276f89e02226989ba
3
+ metadata.gz: cfff7b61ca7c2da15456e4c6d38e552c08a452c1
4
+ data.tar.gz: 05214917528db407ae73ac41a5a056fc75c84e65
5
5
  SHA512:
6
- metadata.gz: aeb4e17b7745cacf524813ffb60764420371da73130b379571bc21e4883392694a3bd9a00494207e9323aadde3b2775c9a8bc54faa281d1a7dea61b9b19ed609
7
- data.tar.gz: aa0d593c0048d922993c6296ca1c7c306a8d3eb3bf827ca0c4201414cb290913e26c389501bbd64093e945166368ff973f1701840adb97c83ce653cec0a9ddd0
6
+ metadata.gz: cf5b14b4bb3a3eacdf104e8f594cde8b5414f1842101a23a547d8d799f6ee4d0cd1c3c659254d4bfe497bb11b3cf68df508fcc489466a17333d42a139e335d67
7
+ data.tar.gz: 23beacfb8721248e08d2a771e48e8ae77feb3e50611960a80c0d0c927d788ee1e62684d0ae7660c40b745c9847165f904f39cd5300c26dec2616f73aaab527aa
data/.gitignore CHANGED
@@ -4,3 +4,4 @@ Gemfile.lock
4
4
  out
5
5
  coverage
6
6
  .DS_Store
7
+ challenges
data/.gitmodules CHANGED
@@ -4,3 +4,6 @@
4
4
  [submodule "features/spec"]
5
5
  path = features/spec
6
6
  url = git@github.com:julianghionoiu/tdl-client-spec.git
7
+ [submodule "wiremock"]
8
+ path = wiremock
9
+ url = git@github.com:julianghionoiu/tdl-client-test-wiremock.git
data/README.md CHANGED
@@ -26,11 +26,19 @@ All test require the ActiveMQ broker to be started.
26
26
  The following commands are available for the broker.
27
27
 
28
28
  ```
29
- ./broker/activemq-wrapper start
30
- ./broker/activemq-wrapper console
31
- ./broker/activemq-wrapper stop
29
+ python ./broker/activemq-wrapper.py start
30
+ python wiremock/wiremock-wrapper.py start 41375
31
+ python wiremock/wiremock-wrapper.py start 8222
32
32
  ```
33
33
 
34
34
  Run tests with `rake features`.
35
35
  To run a single scenario execute `cucumber path/to/file.feature:line_no`
36
36
  Recommendation is to use the cucumber command instead of rake always outside of CI.
37
+
38
+ # Cleanup
39
+
40
+ Stop external dependencies
41
+ ```
42
+ python ./broker/activemq-wrapper.py stop
43
+ ```
44
+
data/lib/tdl.rb CHANGED
@@ -1,4 +1,9 @@
1
- require 'tdl/client'
1
+ require 'tdl/queue/client'
2
+ require 'tdl/queue/implementation_runner_config'
3
+ require 'tdl/queue/queue_based_implementation_runner'
4
+ require 'tdl/queue/queue_based_implementation_runner_builder'
5
+ require 'tdl/runner/challenge_session'
6
+ require 'tdl/runner/challenge_session_config'
2
7
 
3
8
  module TDL
4
9
  end
@@ -0,0 +1,9 @@
1
+ module TDL
2
+ class ConsoleAuditStream
3
+
4
+ def write_line(value)
5
+ puts value
6
+ end
7
+
8
+ end
9
+ end
@@ -1,4 +1,4 @@
1
1
  module TDL
2
- PREVIOUS_VERSION = '0.19.2'
2
+ PREVIOUS_VERSION = '0.19.3'
3
3
  # the current MAJOR.MINOR version is dynamically computed from the version of the Spec
4
4
  end
@@ -1,4 +1,4 @@
1
- require 'tdl/actions/stop_action'
1
+ require 'tdl/queue/actions/stop_action'
2
2
 
3
3
  module TDL
4
4
  class FatalErrorResponse
@@ -1,6 +1,6 @@
1
- require 'tdl/actions/publish_action'
2
- require 'tdl/actions/stop_action'
3
- require 'tdl/actions/publish_and_stop_action'
1
+ require 'tdl/queue/actions/publish_action'
2
+ require 'tdl/queue/actions/stop_action'
3
+ require 'tdl/queue/actions/publish_and_stop_action'
4
4
 
5
5
  module TDL
6
6
  module ClientActions
File without changes
@@ -1,11 +1,11 @@
1
1
  require 'stomp'
2
2
  require 'logging'
3
3
 
4
- require 'tdl/transport/remote_broker'
5
- require 'tdl/processing_rules'
6
- require 'tdl/actions/stop_action'
4
+ require 'tdl/queue/transport/remote_broker'
5
+ require 'tdl/queue/processing_rules'
6
+ require 'tdl/queue/actions/stop_action'
7
7
 
8
- require 'tdl/serialization/json_rpc_serialization_provider'
8
+ require 'tdl/queue/serialization/json_rpc_serialization_provider'
9
9
 
10
10
  module TDL
11
11
 
@@ -0,0 +1,59 @@
1
+ require 'tdl/audit/console_audit_stream'
2
+
3
+ module TDL
4
+
5
+ class ImplementationRunnerConfig
6
+
7
+ def initialize
8
+ @port = 61616
9
+ @time_to_wait_for_requests = 500
10
+ @audit_stream = ConsoleAuditStream.new
11
+ end
12
+
13
+ def set_hostname(hostname)
14
+ @hostname = hostname
15
+ self
16
+ end
17
+
18
+ def set_port(port)
19
+ @port = port
20
+ self
21
+ end
22
+
23
+ def set_unique_id(unique_id)
24
+ @unique_id = unique_id
25
+ self
26
+ end
27
+
28
+ def set_time_to_wait_for_requests(time_to_wait_for_requests)
29
+ @time_to_wait_for_requests = time_to_wait_for_requests
30
+ self
31
+ end
32
+
33
+ def set_audit_stream(audit_stream)
34
+ @set_audit_stream = audit_stream
35
+ self
36
+ end
37
+
38
+ def get_hostname
39
+ @hostname
40
+ end
41
+
42
+ def get_port
43
+ @port
44
+ end
45
+
46
+ def get_unique_id
47
+ @unique_id
48
+ end
49
+
50
+ def get_time_to_wait_for_requests
51
+ @time_to_wait_for_requests
52
+ end
53
+
54
+ def get_audit_stream
55
+ @audit_stream
56
+ end
57
+ end
58
+
59
+ end
@@ -1,7 +1,7 @@
1
- require 'tdl/abstractions/processing_rule'
2
- require 'tdl/abstractions/response/fatal_error_response'
3
- require 'tdl/abstractions/response/valid_response'
4
- require 'tdl/actions/client_actions'
1
+ require 'tdl/queue/abstractions/processing_rule'
2
+ require 'tdl/queue/abstractions/response/fatal_error_response'
3
+ require 'tdl/queue/abstractions/response/valid_response'
4
+ require 'tdl/queue/actions/client_actions'
5
5
 
6
6
  module TDL
7
7
  class ProcessingRules
@@ -0,0 +1,75 @@
1
+ require 'logging'
2
+
3
+ require 'tdl/queue/processing_rules'
4
+
5
+ module TDL
6
+ class QueueBasedImplementationRunner
7
+
8
+ def initialize(config, deploy_processing_rules)
9
+ @config = config
10
+ @deploy_processing_rules = deploy_processing_rules
11
+ @logger = Logging.logger[self]
12
+ @total_processing_time = nil
13
+ end
14
+
15
+ def run
16
+ time1 = Time.now.to_f
17
+ begin
18
+ @logger.info 'Starting client'
19
+ remote_broker = RemoteBroker.new(
20
+ @config.get_hostname,
21
+ @config.get_port,
22
+ @config.get_unique_id,
23
+ @config.get_time_to_wait_for_requests)
24
+ remote_broker.subscribe(ApplyProcessingRules.new(@deploy_processing_rules))
25
+ @logger.info 'Waiting for requests.'
26
+ remote_broker.join
27
+ @logger.info 'Stopping client'
28
+
29
+ rescue Exception => e
30
+ # raise e if ENV['TDL_ENV'] == 'test'
31
+ @logger.error "There was a problem processing messages. #{e.message}"
32
+ @logger.error e.backtrace.join("\n")
33
+ end
34
+
35
+ time2 = Time.now.to_f
36
+ @total_processing_time = (time2 - time1) * 1000.00
37
+ end
38
+
39
+ def get_request_timeout_millis
40
+ @config.get_time_to_wait_for_requests
41
+ end
42
+
43
+ def total_processing_time
44
+ @total_processing_time
45
+ end
46
+
47
+ class ApplyProcessingRules
48
+
49
+ def initialize(processing_rules)
50
+ @processing_rules = processing_rules
51
+ @logger = Logging.logger[self]
52
+ @audit = AuditStream.new
53
+ end
54
+
55
+ def process_next_request_from(remote_broker, request)
56
+ @audit.start_line
57
+ @audit.log(request)
58
+
59
+ # Obtain response from user
60
+ response = @processing_rules.get_response_for(request)
61
+ @audit.log(response)
62
+
63
+ # Obtain action
64
+ client_action = response.client_action
65
+
66
+ # Act
67
+ client_action.after_response(remote_broker, request, response)
68
+ @audit.log(client_action)
69
+ @audit.end_line
70
+ client_action.prepare_for_next_request(remote_broker)
71
+ end
72
+
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,40 @@
1
+ require 'tdl/queue/queue_based_implementation_runner'
2
+ require 'tdl/queue/actions/client_actions'
3
+
4
+ module TDL
5
+
6
+ class QueueBasedImplementationRunnerBuilder
7
+
8
+ def initialize
9
+ @deploy_processing_rules = create_deploy_processing_rules()
10
+ end
11
+
12
+ def set_config(config)
13
+ @config = config
14
+ self
15
+ end
16
+
17
+ def with_solution_for(method_name, user_implementation, action = ClientActions.publish)
18
+ @deploy_processing_rules
19
+ .on(method_name)
20
+ .call(user_implementation)
21
+ .then(action)
22
+ self
23
+ end
24
+
25
+ def create
26
+ QueueBasedImplementationRunner.new(@config, @deploy_processing_rules)
27
+ end
28
+
29
+ private def create_deploy_processing_rules
30
+ deploy_processing_rules = ProcessingRules.new()
31
+ deploy_processing_rules
32
+ .on('display_description')
33
+ .call(-> (params) {'OK'})
34
+ .then(ClientActions.publish)
35
+ deploy_processing_rules
36
+ end
37
+
38
+ end
39
+
40
+ end
@@ -1,6 +1,6 @@
1
1
  require 'json'
2
- require 'tdl/abstractions/request'
3
- require 'tdl/serialization/deserialization_exception'
2
+ require 'tdl/queue/abstractions/request'
3
+ require 'tdl/queue/serialization/deserialization_exception'
4
4
 
5
5
  module TDL
6
6
  class JSONRPCSerializationProvider
@@ -1,4 +1,4 @@
1
- require_relative '../thread_timer'
1
+ require 'tdl/thread_timer'
2
2
 
3
3
  module TDL
4
4
  class RemoteBroker
@@ -0,0 +1,91 @@
1
+ class ChallengeServerClient
2
+
3
+ def initialize(hostname, port, journey_id, use_colours)
4
+ @base_url = "http://#{hostname}:#{port}"
5
+ @journey_id = journey_id
6
+ use_colours ? @accept_header = 'text/coloured' : @accept_header = 'text/not-coloured'
7
+ end
8
+
9
+ def get_journey_progress
10
+ get('journeyProgress')
11
+ end
12
+
13
+ def get_available_actions
14
+ get('availableActions')
15
+ end
16
+
17
+ def get_round_description
18
+ get('roundDescription')
19
+ end
20
+
21
+ def send_action(action)
22
+ encoded_path = @journey_id.encode('utf-8')
23
+ url = "#{@base_url}/action/#{action}/#{encoded_path}"
24
+ response = Unirest.post(url, headers: {'Accept'=> @accept_header, 'Accept-Charset'=> 'UTF-8'})
25
+ ensure_status_ok(response)
26
+ response.body
27
+ end
28
+
29
+ private
30
+
31
+ def get(name)
32
+ journey_id_utf8 = @journey_id.encode('utf-8')
33
+ url = "#{@base_url}/#{name}/#{journey_id_utf8}"
34
+ response = Unirest.get(url, headers: {'Accept'=> @accept_header, 'Accept-Charset'=> 'UTF-8'})
35
+ ensure_status_ok(response)
36
+ response.body
37
+ end
38
+
39
+ def ensure_status_ok(response)
40
+ if client_error?(response.code)
41
+ raise ClientErrorException, response.body
42
+ elsif server_error?(response.code)
43
+ raise ServerErrorException, response.body
44
+ elsif other_error_response?(response.code)
45
+ raise OtherCommunicationException, response.body
46
+ end
47
+ end
48
+
49
+ def client_error?(response_status)
50
+ response_status >= 400 && response_status < 500
51
+ end
52
+
53
+ def server_error?(response_status)
54
+ response_status >= 500 && response_status < 600
55
+ end
56
+
57
+ def other_error_response?(response_status)
58
+ response_status < 200 || response_status > 300
59
+ end
60
+
61
+ class ClientErrorException < RuntimeError
62
+ # def initialise(message)
63
+ # @response_message = message
64
+ # end
65
+ #
66
+ # def get_response_message
67
+ # @response_message
68
+ # end
69
+ end
70
+
71
+ class ServerErrorException < RuntimeError
72
+ # def initialise(message)
73
+ # @response_message = message
74
+ # end
75
+ #
76
+ # def get_response_message
77
+ # @response_message
78
+ # end
79
+ end
80
+
81
+ class OtherCommunicationException < RuntimeError
82
+ # def initialise(message)
83
+ # @response_message = message
84
+ # end
85
+ #
86
+ # def get_response_message
87
+ # @response_message
88
+ # end
89
+ end
90
+ end
91
+
@@ -0,0 +1,95 @@
1
+ require 'tdl/runner/challenge_server_client'
2
+ require 'tdl/runner/round_management'
3
+ require 'tdl/runner/recording_system'
4
+
5
+ include RoundManagement
6
+
7
+ module TDL
8
+
9
+ class ChallengeSession
10
+ def self.for_runner(runner)
11
+ ChallengeSession.new(runner)
12
+ end
13
+
14
+ def initialize(runner)
15
+ @runner = runner
16
+ end
17
+
18
+ def with_config(config)
19
+ @config = config
20
+ @audit_stream = config.get_audit_stream
21
+ self
22
+ end
23
+
24
+ def with_action_provider(callback)
25
+ @user_input_callback = callback
26
+ self
27
+ end
28
+
29
+ def start
30
+ @recording_system = RecordingSystem.new(@config.get_recording_system_should_be_on)
31
+
32
+ unless @recording_system.is_recording_system_ok
33
+ @audit_stream.write_line 'Please run `record_screen_and_upload` before continuing.'
34
+ return
35
+ end
36
+
37
+ @audit_stream.write_line "Connecting to #{@config.get_hostname}"
38
+ run_app
39
+ end
40
+
41
+ def run_app
42
+ @challenge_server_client = ChallengeServerClient.new(
43
+ @config.get_hostname,
44
+ @config.get_port,
45
+ @config.get_journey_id,
46
+ @config.get_use_colours)
47
+
48
+ begin
49
+ should_continue = check_status_of_challenge
50
+ if should_continue
51
+ user_input = @user_input_callback.call
52
+ @audit_stream.write_line "Selected action is: #{user_input}"
53
+ round_description = execute_user_action(user_input)
54
+ RoundManagement.save_description(@recording_system, round_description, @audit_stream, @config.get_working_directory)
55
+ end
56
+ rescue ChallengeServerClient::ClientErrorException => e
57
+ @audit_stream.write_line e.message
58
+ rescue ChallengeServerClient::ServerErrorException => e
59
+ @audit_stream.write_line 'Server experienced an error. Try again in a few minutes.'
60
+ rescue ChallengeServerClient::OtherCommunicationException => e
61
+ @audit_stream.write_line 'Client threw an unexpected error. Try again.'
62
+ end
63
+ end
64
+
65
+ def check_status_of_challenge
66
+ @audit_stream = @config.get_audit_stream
67
+
68
+ journey_progress = @challenge_server_client.get_journey_progress
69
+ @audit_stream.write_line(journey_progress)
70
+
71
+ available_actions = @challenge_server_client.get_available_actions
72
+ @audit_stream.write_line(available_actions)
73
+
74
+ not(available_actions.include?('No actions available.'))
75
+ end
76
+
77
+ def execute_user_action(user_input)
78
+ if user_input == 'deploy'
79
+ @runner.run
80
+ last_fetched_round = RoundManagement.get_last_fetched_round(@config.get_working_directory)
81
+ @recording_system.deploy_notify_event last_fetched_round
82
+ end
83
+
84
+ execute_action user_input
85
+ end
86
+
87
+ def execute_action(user_input)
88
+ action_feedback = @challenge_server_client.send_action user_input
89
+ @audit_stream.write_line action_feedback
90
+ @challenge_server_client.get_round_description
91
+ end
92
+
93
+ end
94
+
95
+ end
@@ -0,0 +1,74 @@
1
+ module TDL
2
+
3
+ class ChallengeSessionConfig
4
+ def self.for_journey_id(journey_id)
5
+ ChallengeSessionConfig.new(journey_id)
6
+ end
7
+
8
+ def initialize(journey_id)
9
+ @port = 8222
10
+ @use_colours = true
11
+ @recording_system_should_be_on = true
12
+ @journey_id = journey_id
13
+ end
14
+
15
+ def with_server_hostname(hostname)
16
+ @hostname = hostname
17
+ self
18
+ end
19
+
20
+ def with_port(port)
21
+ @port = port
22
+ self
23
+ end
24
+
25
+ def with_colours(use_colours)
26
+ @use_colours = use_colours
27
+ self
28
+ end
29
+
30
+ def with_recording_system_should_be_on(recording_system_should_be_on)
31
+ @recording_system_should_be_on = recording_system_should_be_on
32
+ self
33
+ end
34
+
35
+ def with_audit_stream(audit_stream)
36
+ @audit_stream = audit_stream
37
+ self
38
+ end
39
+
40
+ def with_working_directory(working_directory)
41
+ @working_directory = working_directory
42
+ self
43
+ end
44
+
45
+ def get_recording_system_should_be_on
46
+ @recording_system_should_be_on
47
+ end
48
+
49
+ def get_hostname
50
+ @hostname
51
+ end
52
+
53
+ def get_port
54
+ @port
55
+ end
56
+
57
+ def get_journey_id
58
+ @journey_id
59
+ end
60
+
61
+ def get_use_colours
62
+ @use_colours
63
+ end
64
+
65
+ def get_audit_stream
66
+ @audit_stream
67
+ end
68
+
69
+ def get_working_directory
70
+ @working_directory
71
+ end
72
+ end
73
+
74
+ end
@@ -0,0 +1,62 @@
1
+ require 'unirest'
2
+ require 'tdl/runner/runner_action'
3
+
4
+ RECORDING_SYSTEM_ENDPOINT = 'http://localhost:41375'
5
+
6
+ class RecordingSystem
7
+
8
+ def initialize(recording_required)
9
+ @recording_required = recording_required
10
+ end
11
+
12
+ def is_recording_required
13
+ @recording_required
14
+ end
15
+
16
+ def is_recording_system_ok
17
+ return is_recording_required ? is_running : true
18
+ end
19
+
20
+ def is_running
21
+ begin
22
+ response = Unirest.get "#{RECORDING_SYSTEM_ENDPOINT}/status"
23
+ if response.code == 200 and response.body.start_with?('OK')
24
+ return true
25
+ end
26
+ rescue StandardError => e
27
+ puts "Could not reach recording system: #{e.message}"
28
+ end
29
+ false
30
+ end
31
+
32
+ def deploy_notify_event(last_fetched_round)
33
+ notify_event(last_fetched_round, RunnerActions.deploy_to_production.short_name)
34
+ end
35
+
36
+ def on_new_round(round_id, short_name)
37
+ notify_event(round_id, short_name)
38
+ end
39
+
40
+ def notify_event(last_fetched_round, short_name)
41
+ if not @recording_required
42
+ return
43
+ end
44
+
45
+ begin
46
+ response = Unirest.post "#{RECORDING_SYSTEM_ENDPOINT}/notify",
47
+ parameters:"#{last_fetched_round}/#{short_name}"
48
+
49
+ unless response.code == 200
50
+ puts "Recording system returned code: #{response.code}"
51
+ return
52
+ end
53
+
54
+ unless response.body.start_with?('ACK')
55
+ puts "Recording system returned body: #{response.body}"
56
+ end
57
+ rescue StandardError => e
58
+ puts "Could not reach recording system: #{e.message}"
59
+ end
60
+ end
61
+
62
+ end
@@ -0,0 +1,43 @@
1
+ CHALLENGES_FOLDER = 'challenges'
2
+ LAST_FETCHED_ROUND_PATH = "#{CHALLENGES_FOLDER}/XR.txt"
3
+
4
+ require 'tdl/runner/runner_action'
5
+
6
+ include RunnerActions
7
+
8
+ module RoundManagement
9
+
10
+ def save_description(listener, raw_description, audit_stream, working_directory)
11
+ return unless raw_description.include? "\n"
12
+
13
+ newline_index = raw_description.index("\n")
14
+ round_id = raw_description[0..newline_index - 1]
15
+ listener.on_new_round(round_id, RunnerActions.get_new_round_description.short_name) if round_id != get_last_fetched_round(working_directory)
16
+
17
+ display_and_save_description(round_id, raw_description, audit_stream, working_directory)
18
+ end
19
+
20
+ def display_and_save_description(label, description, audit_stream, working_directory)
21
+ Dir.mkdir(File.join(working_directory, CHALLENGES_FOLDER)) unless File.exists?(File.join(working_directory, CHALLENGES_FOLDER))
22
+
23
+ output_description = File.open("#{working_directory}/#{CHALLENGES_FOLDER}/#{label}.txt", 'w')
24
+ output_description << description
25
+ output_description.close
26
+ audit_stream.write_line("Challenge description saved to file: #{CHALLENGES_FOLDER}/#{label}.txt.")
27
+
28
+ output_last_round = File.open(File.join(working_directory, LAST_FETCHED_ROUND_PATH), 'w')
29
+ output_last_round << label
30
+ output_last_round.close
31
+
32
+ 'OK'
33
+ end
34
+
35
+ def get_last_fetched_round(working_directory)
36
+ begin
37
+ File.read(File.join(working_directory, LAST_FETCHED_ROUND_PATH))
38
+ rescue StandardError => _
39
+ 'noRound'
40
+ end
41
+ end
42
+
43
+ end
@@ -0,0 +1,28 @@
1
+ require 'tdl/queue/actions/client_actions'
2
+
3
+ include TDL::ClientActions
4
+
5
+ class RunnerAction
6
+ attr_reader :short_name, :name, :client_action
7
+
8
+ def initialize(short_name, name, client_action)
9
+ @short_name = short_name
10
+ @name = name
11
+ @client_action = client_action
12
+ end
13
+
14
+ end
15
+
16
+ module RunnerActions
17
+ def get_new_round_description
18
+ RunnerAction.new('new', 'get_new_round_description', TDL::ClientActions.stop)
19
+ end
20
+
21
+ def deploy_to_production
22
+ RunnerAction.new('deploy', 'deploy_to_production', TDL::ClientActions.publish)
23
+ end
24
+
25
+ def all
26
+ [get_new_round_description, deploy_to_production]
27
+ end
28
+ end
@@ -52,7 +52,7 @@ Gem::Specification.new do |spec|
52
52
 
53
53
  spec.add_runtime_dependency 'stomp', '1.3.4'
54
54
  spec.add_runtime_dependency 'logging', '2.0.0'
55
-
55
+ spec.add_runtime_dependency 'unirest', '1.1.2'
56
56
 
57
57
  spec.add_development_dependency 'bundler', '~> 1.9'
58
58
  spec.add_development_dependency 'rake', '~> 10.0'
data/tdl-client-ruby.iml CHANGED
@@ -17,38 +17,36 @@
17
17
  </content>
18
18
  <orderEntry type="jdk" jdkName="rbenv: 2.2.2" jdkType="RUBY_SDK" />
19
19
  <orderEntry type="sourceFolder" forTests="false" />
20
+ <orderEntry type="library" scope="PROVIDED" name="addressable (v2.3.8, rbenv: 2.2.2) [gem]" level="application" />
20
21
  <orderEntry type="library" scope="PROVIDED" name="ansi (v1.5.0, rbenv: 2.2.2) [gem]" level="application" />
21
- <orderEntry type="library" scope="PROVIDED" name="builder (v3.2.2, rbenv: 2.2.2) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="builder (v3.2.3, rbenv: 2.2.2) [gem]" level="application" />
22
23
  <orderEntry type="library" scope="PROVIDED" name="bundler (v1.12.5, rbenv: 2.2.2) [gem]" level="application" />
23
- <orderEntry type="library" scope="PROVIDED" name="coveralls (v0.8.2, rbenv: 2.2.2) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="coveralls (v0.8.9, rbenv: 2.2.2) [gem]" level="application" />
24
25
  <orderEntry type="library" scope="PROVIDED" name="cucumber (v2.0.2, rbenv: 2.2.2) [gem]" level="application" />
25
26
  <orderEntry type="library" scope="PROVIDED" name="cucumber-core (v1.2.0, rbenv: 2.2.2) [gem]" level="application" />
26
- <orderEntry type="library" scope="PROVIDED" name="debase (v0.1.4, rbenv: 2.2.2) [gem]" level="application" />
27
- <orderEntry type="library" scope="PROVIDED" name="debase-ruby_core_source (v0.8.0, rbenv: 2.2.2) [gem]" level="application" />
28
- <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, rbenv: 2.2.2) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="debase (v0.1.8, rbenv: 2.2.2) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="debase-ruby_core_source (v0.10.2, rbenv: 2.2.2) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.3, rbenv: 2.2.2) [gem]" level="application" />
29
30
  <orderEntry type="library" scope="PROVIDED" name="docile (v1.1.5, rbenv: 2.2.2) [gem]" level="application" />
30
- <orderEntry type="library" scope="PROVIDED" name="domain_name (v0.5.24, rbenv: 2.2.2) [gem]" level="application" />
31
31
  <orderEntry type="library" scope="PROVIDED" name="gherkin (v2.12.2, rbenv: 2.2.2) [gem]" level="application" />
32
- <orderEntry type="library" scope="PROVIDED" name="http-cookie (v1.0.2, rbenv: 2.2.2) [gem]" level="application" />
33
32
  <orderEntry type="library" scope="PROVIDED" name="json (v1.8.6, rbenv: 2.2.2) [gem]" level="application" />
34
33
  <orderEntry type="library" scope="PROVIDED" name="little-plugger (v1.1.4, rbenv: 2.2.2) [gem]" level="application" />
35
34
  <orderEntry type="library" scope="PROVIDED" name="logging (v2.0.0, rbenv: 2.2.2) [gem]" level="application" />
36
- <orderEntry type="library" scope="PROVIDED" name="mime-types (v2.6.1, rbenv: 2.2.2) [gem]" level="application" />
35
+ <orderEntry type="library" scope="PROVIDED" name="mime-types (v1.25.1, rbenv: 2.2.2) [gem]" level="application" />
37
36
  <orderEntry type="library" scope="PROVIDED" name="minitest (v5.4.1, rbenv: 2.2.2) [gem]" level="application" />
38
- <orderEntry type="library" scope="PROVIDED" name="minitest-reporters (v1.0.19, rbenv: 2.2.2) [gem]" level="application" />
39
- <orderEntry type="library" scope="PROVIDED" name="multi_json (v1.11.2, rbenv: 2.2.2) [gem]" level="application" />
37
+ <orderEntry type="library" scope="PROVIDED" name="minitest-reporters (v1.1.19, rbenv: 2.2.2) [gem]" level="application" />
38
+ <orderEntry type="library" scope="PROVIDED" name="multi_json (v1.13.1, rbenv: 2.2.2) [gem]" level="application" />
40
39
  <orderEntry type="library" scope="PROVIDED" name="multi_test (v0.1.2, rbenv: 2.2.2) [gem]" level="application" />
41
- <orderEntry type="library" scope="PROVIDED" name="netrc (v0.10.3, rbenv: 2.2.2) [gem]" level="application" />
42
- <orderEntry type="library" scope="PROVIDED" name="rest-client (v1.8.0, rbenv: 2.2.2) [gem]" level="application" />
43
- <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.7.5, rbenv: 2.2.2) [gem]" level="application" />
40
+ <orderEntry type="library" scope="PROVIDED" name="rake (v10.5.0, rbenv: 2.2.2) [gem]" level="application" />
41
+ <orderEntry type="library" scope="PROVIDED" name="rest-client (v1.6.9, rbenv: 2.2.2) [gem]" level="application" />
42
+ <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.9.0, rbenv: 2.2.2) [gem]" level="application" />
44
43
  <orderEntry type="library" scope="PROVIDED" name="simplecov (v0.10.0, rbenv: 2.2.2) [gem]" level="application" />
45
- <orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.10.0, rbenv: 2.2.2) [gem]" level="application" />
44
+ <orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.10.2, rbenv: 2.2.2) [gem]" level="application" />
46
45
  <orderEntry type="library" scope="PROVIDED" name="stomp (v1.3.4, rbenv: 2.2.2) [gem]" level="application" />
47
- <orderEntry type="library" scope="PROVIDED" name="term-ansicolor (v1.3.2, rbenv: 2.2.2) [gem]" level="application" />
48
- <orderEntry type="library" scope="PROVIDED" name="thor (v0.19.1, rbenv: 2.2.2) [gem]" level="application" />
49
- <orderEntry type="library" scope="PROVIDED" name="tins (v1.5.4, rbenv: 2.2.2) [gem]" level="application" />
50
- <orderEntry type="library" scope="PROVIDED" name="unf (v0.1.4, rbenv: 2.2.2) [gem]" level="application" />
51
- <orderEntry type="library" scope="PROVIDED" name="unf_ext (v0.0.7.1, rbenv: 2.2.2) [gem]" level="application" />
46
+ <orderEntry type="library" scope="PROVIDED" name="term-ansicolor (v1.6.0, rbenv: 2.2.2) [gem]" level="application" />
47
+ <orderEntry type="library" scope="PROVIDED" name="thor (v0.19.4, rbenv: 2.2.2) [gem]" level="application" />
48
+ <orderEntry type="library" scope="PROVIDED" name="tins (v1.6.0, rbenv: 2.2.2) [gem]" level="application" />
49
+ <orderEntry type="library" scope="PROVIDED" name="unirest (v1.1.2, rbenv: 2.2.2) [gem]" level="application" />
52
50
  </component>
53
51
  <component name="RModuleSettingsStorage">
54
52
  <LOAD_PATH number="1" string0="$MODULE_DIR$/../../tdl-warmup/ruby/lib" />
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.19.3
4
+ version: 0.20.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: 2017-11-30 00:00:00.000000000 Z
11
+ date: 2018-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: stomp
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: unirest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 1.1.2
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.1.2
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -198,21 +212,31 @@ files:
198
212
  - Rakefile
199
213
  - examples/add_numbers.rb
200
214
  - lib/tdl.rb
201
- - lib/tdl/abstractions/processing_rule.rb
202
- - lib/tdl/abstractions/request.rb
203
- - lib/tdl/abstractions/response/fatal_error_response.rb
204
- - lib/tdl/abstractions/response/valid_response.rb
205
- - lib/tdl/actions/client_actions.rb
206
- - lib/tdl/actions/publish_action.rb
207
- - lib/tdl/actions/publish_and_stop_action.rb
208
- - lib/tdl/actions/stop_action.rb
209
- - lib/tdl/client.rb
215
+ - lib/tdl/audit/console_audit_stream.rb
210
216
  - lib/tdl/previous_version.rb
211
- - lib/tdl/processing_rules.rb
212
- - lib/tdl/serialization/deserialization_exception.rb
213
- - lib/tdl/serialization/json_rpc_serialization_provider.rb
217
+ - lib/tdl/queue/abstractions/processing_rule.rb
218
+ - lib/tdl/queue/abstractions/request.rb
219
+ - lib/tdl/queue/abstractions/response/fatal_error_response.rb
220
+ - lib/tdl/queue/abstractions/response/valid_response.rb
221
+ - lib/tdl/queue/actions/client_actions.rb
222
+ - lib/tdl/queue/actions/publish_action.rb
223
+ - lib/tdl/queue/actions/publish_and_stop_action.rb
224
+ - lib/tdl/queue/actions/stop_action.rb
225
+ - lib/tdl/queue/client.rb
226
+ - lib/tdl/queue/implementation_runner_config.rb
227
+ - lib/tdl/queue/processing_rules.rb
228
+ - lib/tdl/queue/queue_based_implementation_runner.rb
229
+ - lib/tdl/queue/queue_based_implementation_runner_builder.rb
230
+ - lib/tdl/queue/serialization/deserialization_exception.rb
231
+ - lib/tdl/queue/serialization/json_rpc_serialization_provider.rb
232
+ - lib/tdl/queue/transport/remote_broker.rb
233
+ - lib/tdl/runner/challenge_server_client.rb
234
+ - lib/tdl/runner/challenge_session.rb
235
+ - lib/tdl/runner/challenge_session_config.rb
236
+ - lib/tdl/runner/recording_system.rb
237
+ - lib/tdl/runner/round_management.rb
238
+ - lib/tdl/runner/runner_action.rb
214
239
  - lib/tdl/thread_timer.rb
215
- - lib/tdl/transport/remote_broker.rb
216
240
  - lib/tdl/util.rb
217
241
  - release.sh
218
242
  - tdl-client-ruby.gemspec
@@ -221,7 +245,7 @@ homepage: https://github.com/julianghionoiu/tdl-client-ruby
221
245
  licenses:
222
246
  - GPL-3.0
223
247
  metadata:
224
- previous_version: 0.19.2
248
+ previous_version: 0.19.3
225
249
  post_install_message:
226
250
  rdoc_options: []
227
251
  require_paths:
@@ -238,7 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
238
262
  version: '0'
239
263
  requirements: []
240
264
  rubyforge_project:
241
- rubygems_version: 2.6.13
265
+ rubygems_version: 2.6.14
242
266
  signing_key:
243
267
  specification_version: 4
244
268
  summary: A client to connect to the central kata server.