rake_flow_visualizer 0.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 53f922771c055c9f50eb66026b8b99acab6248e1e378d6d6b2cfdbc6bd6b651b
4
+ data.tar.gz: eef431d8e8b2acbada404357dcfa9e312a6d22f991e982fc4b80c49f6d337fe1
5
+ SHA512:
6
+ metadata.gz: e56a87866e2c648abe4f66fdb636b09a51ce9117362b1afff2eda9a58a66d4233f5a922c9b1b0ba90fe475ec49a95250805ccb1a47f4c7eca2a783be8ad42fc7
7
+ data.tar.gz: a38fde8fa89eb5e76fb1906b08414b587dd9c928275c4787324b0fdaba8c60fb6f3e20f439af5f5cd0d654ccdcac852714dc99dd01452bdada48ca9f08426726
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Rob Fors
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 all
13
+ 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 THE
21
+ SOFTWARE.
@@ -0,0 +1,8 @@
1
+ # Rake Flow Visualizer
2
+ This Ruby Gem will help you determine the order of task execution of an existing project using Rake. I wrote it to help reverse engineer a complex project I found and wanted to clean up.'
3
+
4
+ # Install
5
+ `gem install rake_flow_visualizer`
6
+
7
+ # Run
8
+ When you are in your project's root directory simply run `rake_flow_visualizer`.
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # %% -*- ruby -*-
3
+
4
+ require 'rake_flow_visualizer'
5
+
6
+ RakeFlowVisualizer.run
@@ -0,0 +1,52 @@
1
+ require 'open3'
2
+
3
+ require 'rake_flow_visualizer/task'
4
+
5
+
6
+ module RakeFlowVisualizer
7
+
8
+ def self.parse(text)
9
+ lines = text.split("\n").map(&:strip)
10
+ parent = nil
11
+ lines.each do |line|
12
+ if line[0..4] == 'rake '
13
+ parent_name = line[5..-1]
14
+ parent = Task.find_or_create(parent_name)
15
+ next
16
+ end
17
+ raise unless parent
18
+ dependency_name = line
19
+ dependency = Task.find_or_create(dependency_name)
20
+ parent.dependencies << dependency
21
+ end
22
+ Task.all.each do |task|
23
+ print_task(0, task, [])
24
+ puts
25
+ end
26
+ end
27
+
28
+ def self.print_task(depth, task, ignore)
29
+ return if ignore.include?(task)
30
+ ignore << task
31
+ print "|" * depth
32
+ puts task
33
+ task.dependencies.each { |dependency| print_task(depth + 1, dependency, ignore) }
34
+ end
35
+
36
+ def self.run
37
+ _stdout, status = Open3.capture2('rake --help')
38
+ raise 'can not find rake, is it installed?' unless status.success?
39
+ stdout, status = Open3.capture2('rake -P')
40
+ unless status.success?
41
+ puts stdout
42
+ raise "executing 'rake -P' resulted in an exception"
43
+ end
44
+ puts "--- Rake Flow Visualizer ---"
45
+ puts "The following shows a list for every task that can be run."
46
+ puts "Each list will have the requisites for the task and the order that they will be executed."
47
+ puts
48
+ puts
49
+ parse(stdout)
50
+ end
51
+
52
+ end
@@ -0,0 +1,32 @@
1
+ module RakeFlowVisualizer
2
+ class Task
3
+
4
+ def self.find_or_create(name)
5
+ @tasks ||= []
6
+ existing_task = @tasks.find { |task| task.name == name }
7
+ if existing_task
8
+ existing_task
9
+ else
10
+ new_task = new(name)
11
+ @tasks << new_task
12
+ new_task
13
+ end
14
+ end
15
+
16
+ def self.all
17
+ @tasks ||= []
18
+ end
19
+
20
+ attr_reader :name, :dependencies
21
+
22
+ def initialize(name)
23
+ @name = name
24
+ @dependencies = []
25
+ end
26
+
27
+ def to_s
28
+ @name
29
+ end
30
+
31
+ end
32
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rake_flow_visualizer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Rob Fors
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-05-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: This gem will help you determine the order of task execution of an existing
28
+ project using Rake. It may help you reverse engineer a complex project.
29
+ email: mail@robfors.com
30
+ executables:
31
+ - rake_flow_visualizer
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - LICENSE
36
+ - README.md
37
+ - bin/rake_flow_visualizer
38
+ - lib/rake_flow_visualizer.rb
39
+ - lib/rake_flow_visualizer/task.rb
40
+ homepage: https://github.com/robfors/quack_concurrency
41
+ licenses:
42
+ - MIT
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 2.7.6
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: A simple tool to visualize the order of Rake tasks of an existing project.
64
+ test_files: []