Class: Kontrast::GlobalRunner
- Inherits:
-
Object
- Object
- Kontrast::GlobalRunner
- Defined in:
- lib/kontrast/global_runner.rb
Instance Method Summary collapse
-
#create_manifest ⇒ Object
The manifest is a per-node .json file that is used to create the gallery without having to download all assets from S3 to the test environment.
-
#initialize ⇒ GlobalRunner
constructor
A new instance of GlobalRunner.
- #run ⇒ Object
Constructor Details
#initialize ⇒ GlobalRunner
Returns a new instance of GlobalRunner.
7 8 9 10 11 12 |
# File 'lib/kontrast/global_runner.rb', line 7 def initialize @page_runner = PageRunner.new @api_endpont_runner = ApiEndpointRunner.new @path = Kontrast.path @current_node = 0 end |
Instance Method Details
#create_manifest ⇒ Object
The manifest is a per-node .json file that is used to create the gallery without having to download all assets from S3 to the test environment
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/kontrast/global_runner.rb', line 37 def create_manifest # Create manifest puts "Creating manifest..." if Kontrast.configuration.run_parallel build = Kontrast.configuration.remote_path else build = nil end diffs = {} diffs.merge!(@page_runner.diffs) diffs.merge!(@api_endpont_runner.diffs) # Set up structure manifest = { diffs: diffs, files: [] } # Dump directories Dir.foreach(@path) do |subdir| next if ['.', '..'].include?(subdir) next if subdir.index('manifest_') Dir.foreach("#{@path}/#{subdir}") do |img| next if ['.', '..'].include?(img) manifest[:files] << "#{subdir}/#{img}" end end if Kontrast.configuration.run_parallel # Upload manifest Kontrast.fog.directories.get(Kontrast.configuration.aws_bucket).files.create( key: "#{build}/manifest_#{@current_node}.json", body: manifest.to_json ) else # Write manifest File.open("#{@path}/manifest_#{@current_node}.json", 'w') do |outf| outf.write(manifest.to_json) end end return manifest end |
#run ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/kontrast/global_runner.rb', line 14 def run # Make sure the local server is running wait_for_server # Assign nodes if Kontrast.configuration.run_parallel total_nodes = Kontrast.configuration.total_nodes @current_node = Kontrast.configuration.current_node else # Override the config for local use total_nodes = 1 end # Run both runners @page_runner.run(total_nodes, @current_node) @api_endpont_runner.run(total_nodes, @current_node) # Create manifest create_manifest end |