cloudbuildviz 0.1.0
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 +7 -0
 - data/.gitignore +11 -0
 - data/.rspec +3 -0
 - data/.travis.yml +5 -0
 - data/Gemfile +6 -0
 - data/Gemfile.lock +39 -0
 - data/LICENSE.txt +21 -0
 - data/README.md +61 -0
 - data/Rakefile +10 -0
 - data/bin/console +14 -0
 - data/bin/graph +5 -0
 - data/bin/setup +8 -0
 - data/cloudbuildviz.gemspec +30 -0
 - data/lib/cloudbuildviz/cli.rb +9 -0
 - data/lib/cloudbuildviz/errors/cloudbuild_step_errors.rb +5 -0
 - data/lib/cloudbuildviz/errors/loader_errors.rb +9 -0
 - data/lib/cloudbuildviz/loader.rb +46 -0
 - data/lib/cloudbuildviz/models/cloudbuild_step.rb +19 -0
 - data/lib/cloudbuildviz/version.rb +3 -0
 - data/lib/cloudbuildviz/visualizer.rb +30 -0
 - data/lib/cloudbuildviz.rb +14 -0
 - metadata +134 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 006f2ef426833f0bd4c684a39ab71668d9ffab5e
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 0fb45a6bb67f03164110f4d386fe7b3799f58f16
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 913af8fd1a884352d52a78f7904276075f9609386153ff6ff2529680847d8a962711db02289c3ece0e7e8e18e105ce19379ea264ff5a27009441f2275cdc2345
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 5097d21bdef9da6b1a93f662dfdbcc440298bbe9fa84c433ebc289cab5c7df69ff47875826896bddde3a3083896b141f2743dfd099f82fc09388b36a0924d9ff
         
     | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/Gemfile.lock
    ADDED
    
    | 
         @@ -0,0 +1,39 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            PATH
         
     | 
| 
      
 2 
     | 
    
         
            +
              remote: .
         
     | 
| 
      
 3 
     | 
    
         
            +
              specs:
         
     | 
| 
      
 4 
     | 
    
         
            +
                cloudbuildviz (0.1.0)
         
     | 
| 
      
 5 
     | 
    
         
            +
                  ruby-graphviz (~> 1.2)
         
     | 
| 
      
 6 
     | 
    
         
            +
                  thor (~> 0.20)
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            GEM
         
     | 
| 
      
 9 
     | 
    
         
            +
              remote: https://rubygems.org/
         
     | 
| 
      
 10 
     | 
    
         
            +
              specs:
         
     | 
| 
      
 11 
     | 
    
         
            +
                diff-lcs (1.3)
         
     | 
| 
      
 12 
     | 
    
         
            +
                rake (10.5.0)
         
     | 
| 
      
 13 
     | 
    
         
            +
                rspec (3.8.0)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  rspec-core (~> 3.8.0)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  rspec-expectations (~> 3.8.0)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  rspec-mocks (~> 3.8.0)
         
     | 
| 
      
 17 
     | 
    
         
            +
                rspec-core (3.8.0)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  rspec-support (~> 3.8.0)
         
     | 
| 
      
 19 
     | 
    
         
            +
                rspec-expectations (3.8.2)
         
     | 
| 
      
 20 
     | 
    
         
            +
                  diff-lcs (>= 1.2.0, < 2.0)
         
     | 
| 
      
 21 
     | 
    
         
            +
                  rspec-support (~> 3.8.0)
         
     | 
| 
      
 22 
     | 
    
         
            +
                rspec-mocks (3.8.0)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  diff-lcs (>= 1.2.0, < 2.0)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  rspec-support (~> 3.8.0)
         
     | 
| 
      
 25 
     | 
    
         
            +
                rspec-support (3.8.0)
         
     | 
| 
      
 26 
     | 
    
         
            +
                ruby-graphviz (1.2.4)
         
     | 
| 
      
 27 
     | 
    
         
            +
                thor (0.20.3)
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            PLATFORMS
         
     | 
| 
      
 30 
     | 
    
         
            +
              ruby
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            DEPENDENCIES
         
     | 
| 
      
 33 
     | 
    
         
            +
              bundler (~> 1.16)
         
     | 
| 
      
 34 
     | 
    
         
            +
              cloudbuildviz!
         
     | 
| 
      
 35 
     | 
    
         
            +
              rake (~> 10.0)
         
     | 
| 
      
 36 
     | 
    
         
            +
              rspec (~> 3.0)
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            BUNDLED WITH
         
     | 
| 
      
 39 
     | 
    
         
            +
               1.16.1
         
     | 
    
        data/LICENSE.txt
    ADDED
    
    | 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            The MIT License (MIT)
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Copyright (c) 2018 Weiyuan
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy
         
     | 
| 
      
 6 
     | 
    
         
            +
            of this software and associated documentation files (the "Software"), to deal
         
     | 
| 
      
 7 
     | 
    
         
            +
            in the Software without restriction, including without limitation the rights
         
     | 
| 
      
 8 
     | 
    
         
            +
            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         
     | 
| 
      
 9 
     | 
    
         
            +
            copies of the Software, and to permit persons to whom the Software is
         
     | 
| 
      
 10 
     | 
    
         
            +
            furnished to do so, subject to the following conditions:
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be included in
         
     | 
| 
      
 13 
     | 
    
         
            +
            all copies or substantial portions of the Software.
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         
     | 
| 
      
 16 
     | 
    
         
            +
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         
     | 
| 
      
 17 
     | 
    
         
            +
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         
     | 
| 
      
 18 
     | 
    
         
            +
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         
     | 
| 
      
 19 
     | 
    
         
            +
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         
     | 
| 
      
 20 
     | 
    
         
            +
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
         
     | 
| 
      
 21 
     | 
    
         
            +
            THE SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,61 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Cloudbuildviz
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Add this line to your application's Gemfile:
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 9 
     | 
    
         
            +
            gem 'cloudbuildviz'
         
     | 
| 
      
 10 
     | 
    
         
            +
            ```
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            And then execute:
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                $ bundle
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            Or install it yourself as:
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                $ gem install cloudbuildviz
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            ### Side dependency
         
     | 
| 
      
 21 
     | 
    
         
            +
            `graphviz` should also be installed
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            For Mac
         
     | 
| 
      
 24 
     | 
    
         
            +
            ```
         
     | 
| 
      
 25 
     | 
    
         
            +
            brew install graphviz
         
     | 
| 
      
 26 
     | 
    
         
            +
            ```
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            From CLI
         
     | 
| 
      
 31 
     | 
    
         
            +
            ```
         
     | 
| 
      
 32 
     | 
    
         
            +
            bundle exec graph cloudbuildfile.yaml render_image.png
         
     | 
| 
      
 33 
     | 
    
         
            +
            ```
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            For a Ruby or Rails application
         
     | 
| 
      
 36 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 37 
     | 
    
         
            +
            require 'cloudbuildviz'
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            class ApplicationController < ActionController::Base
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            .
         
     | 
| 
      
 42 
     | 
    
         
            +
            .
         
     | 
| 
      
 43 
     | 
    
         
            +
            .
         
     | 
| 
      
 44 
     | 
    
         
            +
            	
         
     | 
| 
      
 45 
     | 
    
         
            +
                def make_build_graph
         
     | 
| 
      
 46 
     | 
    
         
            +
                    Cloudbuildviz.make('cloudbuildfile.yaml', '/tmp/images/render_image.png')
         
     | 
| 
      
 47 
     | 
    
         
            +
                end
         
     | 
| 
      
 48 
     | 
    
         
            +
            .
         
     | 
| 
      
 49 
     | 
    
         
            +
            .
         
     | 
| 
      
 50 
     | 
    
         
            +
            .
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            end
         
     | 
| 
      
 53 
     | 
    
         
            +
            ```
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            Bug reports and pull requests are welcome on GitHub at https://github.com/weiyuan-lane/cloudbuildviz.
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
            ## License
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
            The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
         
     | 
    
        data/Rakefile
    ADDED
    
    
    
        data/bin/console
    ADDED
    
    | 
         @@ -0,0 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #!/usr/bin/env ruby
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "bundler/setup"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "cloudbuildviz"
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            # You can add fixtures and/or initialization code here to make experimenting
         
     | 
| 
      
 7 
     | 
    
         
            +
            # with your gem easier. You can also use a different console, if you like.
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            # (If you use this, don't forget to add pry to your Gemfile!)
         
     | 
| 
      
 10 
     | 
    
         
            +
            # require "pry"
         
     | 
| 
      
 11 
     | 
    
         
            +
            # Pry.start
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            require "irb"
         
     | 
| 
      
 14 
     | 
    
         
            +
            IRB.start(__FILE__)
         
     | 
    
        data/bin/graph
    ADDED
    
    
    
        data/bin/setup
    ADDED
    
    
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
             
     | 
| 
      
 2 
     | 
    
         
            +
            lib = File.expand_path("../lib", __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "cloudbuildviz/version"
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Gem::Specification.new do |spec|
         
     | 
| 
      
 7 
     | 
    
         
            +
              spec.name          = "cloudbuildviz"
         
     | 
| 
      
 8 
     | 
    
         
            +
              spec.version       = Cloudbuildviz::VERSION
         
     | 
| 
      
 9 
     | 
    
         
            +
              spec.authors       = ["Weiyuan"]
         
     | 
| 
      
 10 
     | 
    
         
            +
              spec.email         = ["weiyuan.lane@gmail.com"]
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              spec.summary       = %q{ Summary }
         
     | 
| 
      
 13 
     | 
    
         
            +
              spec.description   = %q{ Description }
         
     | 
| 
      
 14 
     | 
    
         
            +
              spec.homepage      = "https://github.com/weiyuan-lane/cloudbuildviz"
         
     | 
| 
      
 15 
     | 
    
         
            +
              spec.license       = "MIT"
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              spec.files         = `git ls-files -z`.split("\x0").reject do |f|
         
     | 
| 
      
 18 
     | 
    
         
            +
                f.match(%r{^(test|spec|features)/})
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
              spec.bindir        = "exe"
         
     | 
| 
      
 21 
     | 
    
         
            +
              spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
         
     | 
| 
      
 22 
     | 
    
         
            +
              spec.require_paths = ["lib"]
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              spec.add_development_dependency "bundler", "~> 1.16"
         
     | 
| 
      
 25 
     | 
    
         
            +
              spec.add_development_dependency "rake", "~> 10.0"
         
     | 
| 
      
 26 
     | 
    
         
            +
              spec.add_development_dependency "rspec", "~> 3.0"
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              spec.add_dependency 'ruby-graphviz', '~> 1.2'
         
     | 
| 
      
 29 
     | 
    
         
            +
              spec.add_dependency 'thor', '~> 0.20'
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,46 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'yaml'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class Cloudbuildviz::Loader
         
     | 
| 
      
 4 
     | 
    
         
            +
              ORIGIN_ID = '-'.freeze
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              def initialize(filename = '')
         
     | 
| 
      
 7 
     | 
    
         
            +
                if filename.class != String
         
     | 
| 
      
 8 
     | 
    
         
            +
                  raise Cloudbuildviz::LoaderInitError.new('invalid filename')
         
     | 
| 
      
 9 
     | 
    
         
            +
                end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                cloudbuild = YAML::load_file(filename)
         
     | 
| 
      
 12 
     | 
    
         
            +
                if !cloudbuild.key?('steps') or cloudbuild['steps'].size == 0
         
     | 
| 
      
 13 
     | 
    
         
            +
                  raise Cloudbuildviz::LoaderInitError.new('cloudbuild missing valid \'steps\' key at root')
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                @cloudbuild_steps = cloudbuild['steps']
         
     | 
| 
      
 17 
     | 
    
         
            +
                
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              def parse_cloudbuild_steps
         
     | 
| 
      
 21 
     | 
    
         
            +
                parsed_ids = []
         
     | 
| 
      
 22 
     | 
    
         
            +
                @cloudbuild_steps.map do |s| 
         
     | 
| 
      
 23 
     | 
    
         
            +
                  result = if implicit_next_step?(s)
         
     | 
| 
      
 24 
     | 
    
         
            +
                              Cloudbuildviz::Models::CloudbuildStep.new(id: s['id'], prev_ids: parsed_ids.dup)
         
     | 
| 
      
 25 
     | 
    
         
            +
                            elsif origin_step?(s)
         
     | 
| 
      
 26 
     | 
    
         
            +
                              Cloudbuildviz::Models::CloudbuildStep.new(id: s['id'])
         
     | 
| 
      
 27 
     | 
    
         
            +
                            else
         
     | 
| 
      
 28 
     | 
    
         
            +
                              Cloudbuildviz::Models::CloudbuildStep.new(id: s['id'], prev_ids: s['waitFor'])
         
     | 
| 
      
 29 
     | 
    
         
            +
                            end
         
     | 
| 
      
 30 
     | 
    
         
            +
                  
         
     | 
| 
      
 31 
     | 
    
         
            +
                  parsed_ids << s['id']
         
     | 
| 
      
 32 
     | 
    
         
            +
                  result
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
              private
         
     | 
| 
      
 37 
     | 
    
         
            +
              def origin_step?(cloudbuild_step)
         
     | 
| 
      
 38 
     | 
    
         
            +
                cloudbuild_step['waitFor'].size == 1 && 
         
     | 
| 
      
 39 
     | 
    
         
            +
                cloudbuild_step['waitFor'][0].strip == ORIGIN_ID
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
              def implicit_next_step?(cloudbuild_step)
         
     | 
| 
      
 43 
     | 
    
         
            +
                !cloudbuild_step.key?('waitFor') ||
         
     | 
| 
      
 44 
     | 
    
         
            +
                cloudbuild_step['waitFor'].size == 0
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
             
     | 
| 
      
 2 
     | 
    
         
            +
            module Cloudbuildviz::Models
         
     | 
| 
      
 3 
     | 
    
         
            +
              class CloudbuildStep
         
     | 
| 
      
 4 
     | 
    
         
            +
                attr_reader :id, :prev_ids
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                def initialize(id: nil, prev_ids: [])
         
     | 
| 
      
 7 
     | 
    
         
            +
                  if id == nil
         
     | 
| 
      
 8 
     | 
    
         
            +
                    raise Cloudbuildviz::CloudbuildStepInitError.new
         
     | 
| 
      
 9 
     | 
    
         
            +
                  end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  @id = id
         
     | 
| 
      
 12 
     | 
    
         
            +
                  @prev_ids = prev_ids
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                def origin_step?
         
     | 
| 
      
 16 
     | 
    
         
            +
                  @prev_ids.length == 0
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class Cloudbuildviz::Visualizer
         
     | 
| 
      
 2 
     | 
    
         
            +
              def initialize(parsed_cloudbuild_steps)
         
     | 
| 
      
 3 
     | 
    
         
            +
                @parsed_cloudbuild_steps = parsed_cloudbuild_steps
         
     | 
| 
      
 4 
     | 
    
         
            +
              end
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              def visualize_normal_build(filename)
         
     | 
| 
      
 7 
     | 
    
         
            +
                g = GraphViz.new( :G, type: :digraph )
         
     | 
| 
      
 8 
     | 
    
         
            +
                node_hash = Hash.new(nil)
         
     | 
| 
      
 9 
     | 
    
         
            +
                origin_node = g.add_nodes('Start')
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                # Create all nodes
         
     | 
| 
      
 12 
     | 
    
         
            +
                @parsed_cloudbuild_steps.each do |s|
         
     | 
| 
      
 13 
     | 
    
         
            +
                  node_hash[s.id] = g.add_nodes(s.id)
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                # Draw the edges
         
     | 
| 
      
 17 
     | 
    
         
            +
                @parsed_cloudbuild_steps.each do |s|
         
     | 
| 
      
 18 
     | 
    
         
            +
                  if s.origin_step?
         
     | 
| 
      
 19 
     | 
    
         
            +
                    g.add_edges(origin_node, node_hash[s.id])
         
     | 
| 
      
 20 
     | 
    
         
            +
                  else
         
     | 
| 
      
 21 
     | 
    
         
            +
                    s.prev_ids.each do |prev_id|
         
     | 
| 
      
 22 
     | 
    
         
            +
                      g.add_edges(node_hash[prev_id], node_hash[s.id])
         
     | 
| 
      
 23 
     | 
    
         
            +
                    end
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
                
         
     | 
| 
      
 27 
     | 
    
         
            +
                # Generate output image
         
     | 
| 
      
 28 
     | 
    
         
            +
                g.output( png: filename )
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'cloudbuildviz/loader'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'cloudbuildviz/visualizer'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'ruby-graphviz'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            module Cloudbuildviz
         
     | 
| 
      
 6 
     | 
    
         
            +
              def self.make(inputfile, outputfile)
         
     | 
| 
      
 7 
     | 
    
         
            +
                loader = Cloudbuildviz::Loader.new(inputfile)
         
     | 
| 
      
 8 
     | 
    
         
            +
                parsed_steps = loader.parse_cloudbuild_steps
         
     | 
| 
      
 9 
     | 
    
         
            +
                visualizer = Cloudbuildviz::Visualizer.new(parsed_steps)
         
     | 
| 
      
 10 
     | 
    
         
            +
                visualizer.visualize_normal_build(outputfile)
         
     | 
| 
      
 11 
     | 
    
         
            +
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
            end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            Dir[File.dirname(__FILE__) + '/**/*.rb'].each {|file| require file }
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,134 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: cloudbuildviz
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Weiyuan
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: exe
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2018-11-15 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: bundler
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '1.16'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '1.16'
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '10.0'
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '10.0'
         
     | 
| 
      
 41 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 42 
     | 
    
         
            +
              name: rspec
         
     | 
| 
      
 43 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 44 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 45 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 46 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 47 
     | 
    
         
            +
                    version: '3.0'
         
     | 
| 
      
 48 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 49 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 50 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 51 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 52 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 53 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 54 
     | 
    
         
            +
                    version: '3.0'
         
     | 
| 
      
 55 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 56 
     | 
    
         
            +
              name: ruby-graphviz
         
     | 
| 
      
 57 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 58 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 59 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 60 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 61 
     | 
    
         
            +
                    version: '1.2'
         
     | 
| 
      
 62 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 63 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 64 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 65 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 66 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 67 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 68 
     | 
    
         
            +
                    version: '1.2'
         
     | 
| 
      
 69 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 70 
     | 
    
         
            +
              name: thor
         
     | 
| 
      
 71 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 72 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 73 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 74 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 75 
     | 
    
         
            +
                    version: '0.20'
         
     | 
| 
      
 76 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 77 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 78 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 79 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 80 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 81 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 82 
     | 
    
         
            +
                    version: '0.20'
         
     | 
| 
      
 83 
     | 
    
         
            +
            description: " Description "
         
     | 
| 
      
 84 
     | 
    
         
            +
            email:
         
     | 
| 
      
 85 
     | 
    
         
            +
            - weiyuan.lane@gmail.com
         
     | 
| 
      
 86 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 87 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 88 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 89 
     | 
    
         
            +
            files:
         
     | 
| 
      
 90 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
      
 91 
     | 
    
         
            +
            - ".rspec"
         
     | 
| 
      
 92 
     | 
    
         
            +
            - ".travis.yml"
         
     | 
| 
      
 93 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 94 
     | 
    
         
            +
            - Gemfile.lock
         
     | 
| 
      
 95 
     | 
    
         
            +
            - LICENSE.txt
         
     | 
| 
      
 96 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 97 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 98 
     | 
    
         
            +
            - bin/console
         
     | 
| 
      
 99 
     | 
    
         
            +
            - bin/graph
         
     | 
| 
      
 100 
     | 
    
         
            +
            - bin/setup
         
     | 
| 
      
 101 
     | 
    
         
            +
            - cloudbuildviz.gemspec
         
     | 
| 
      
 102 
     | 
    
         
            +
            - lib/cloudbuildviz.rb
         
     | 
| 
      
 103 
     | 
    
         
            +
            - lib/cloudbuildviz/cli.rb
         
     | 
| 
      
 104 
     | 
    
         
            +
            - lib/cloudbuildviz/errors/cloudbuild_step_errors.rb
         
     | 
| 
      
 105 
     | 
    
         
            +
            - lib/cloudbuildviz/errors/loader_errors.rb
         
     | 
| 
      
 106 
     | 
    
         
            +
            - lib/cloudbuildviz/loader.rb
         
     | 
| 
      
 107 
     | 
    
         
            +
            - lib/cloudbuildviz/models/cloudbuild_step.rb
         
     | 
| 
      
 108 
     | 
    
         
            +
            - lib/cloudbuildviz/version.rb
         
     | 
| 
      
 109 
     | 
    
         
            +
            - lib/cloudbuildviz/visualizer.rb
         
     | 
| 
      
 110 
     | 
    
         
            +
            homepage: https://github.com/weiyuan-lane/cloudbuildviz
         
     | 
| 
      
 111 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 112 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 113 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 114 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 115 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 116 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 117 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 118 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 119 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 120 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 121 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 122 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 123 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 124 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 125 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 126 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 127 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 128 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 129 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 130 
     | 
    
         
            +
            rubygems_version: 2.6.14
         
     | 
| 
      
 131 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 132 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 133 
     | 
    
         
            +
            summary: Summary
         
     | 
| 
      
 134 
     | 
    
         
            +
            test_files: []
         
     |