Add sample script and extracted common code
This commit is contained in:
40
bin/example.rb
Normal file
40
bin/example.rb
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require_relative "./client"
|
||||
|
||||
pipeline = PipelineClient.new
|
||||
|
||||
puts "Sample for ruby:two-fer"
|
||||
|
||||
action = ARGV[0]
|
||||
lang = "ruby"
|
||||
exercise_slug = "two-fer"
|
||||
solution_slug = "soln-demo"
|
||||
|
||||
source = ARGV[1] || "s3://exercism-iterations/production/iterations/1182520"
|
||||
|
||||
r = case action
|
||||
when "test"
|
||||
pipeline.test_run(lang, exercise_slug, solution_slug, source)
|
||||
when "analyze"
|
||||
pipeline.analyze(lang, exercise_slug, solution_slug, source)
|
||||
when "represent"
|
||||
pipeline.represent(lang, exercise_slug, solution_slug, source)
|
||||
else
|
||||
raise "Command #{action} unknown.\n Usage: ./example.rb test|analyze|represent [s3_url]"
|
||||
end
|
||||
|
||||
pipeline.close_socket
|
||||
|
||||
puts " === Complete ==="
|
||||
|
||||
|
||||
if r["logs"]
|
||||
r["logs"].each do |log_line|
|
||||
puts "+ #{log_line["cmd"]}"
|
||||
puts log_line["stdout"]
|
||||
puts log_line["stderr"]
|
||||
end
|
||||
end
|
||||
|
||||
puts r["result"]
|
||||
@@ -4,11 +4,13 @@ require_relative "./client"
|
||||
|
||||
pipeline = PipelineClient.new
|
||||
|
||||
|
||||
# return
|
||||
lang = ARGV[0] || "ruby"
|
||||
lang = "ruby"
|
||||
lang = ARGV[1] || "ruby"
|
||||
|
||||
r = pipeline.represent(lang, "two-fer", "soln-42", "s3://exercism-dev/iterations/fff07700-e1c3-402d-8937-823aeefb159f")
|
||||
r = pipeline.represent(lang, "two-fer", "soln-42",
|
||||
"s3://exercism-iterations/production/iterations/1182520")
|
||||
# puts r
|
||||
if r["logs"]
|
||||
r["logs"].each do |log_line|
|
||||
|
||||
Reference in New Issue
Block a user