pocky 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +38 -0
- data/LICENSE.txt +21 -0
- data/README.md +47 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/pocky.rb +7 -0
- data/lib/pocky/graph.rb +90 -0
- data/lib/pocky/version.rb +5 -0
- data/pocky.gemspec +30 -0
- metadata +73 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f4c00f616a39cb65bc9c21cc400499fc9342ac9eba29717662410c5b1cabbbd9
|
4
|
+
data.tar.gz: 8beb8794798ebf9e5bc31fc154a0a82602debe9f101d09a6d48b11cfd9e30ea1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: de3d8cadae4b6167c2963d1960781236229b1cefdf3dc4ac8bf4a3942843f1926689e60a51a2c68d2d85dbf4efc7c54d9cd0422e86a9aa689167acadd99ca0fc
|
7
|
+
data.tar.gz: d75db5ddda124dc0d27409339a70bd5287f1c7b2710be9097cc5ebd5d835fa5f89891ec288b929315222d3884dea18fea49c3010d2941a8ec302de199809c540
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
pocky (1.0.0)
|
5
|
+
ruby-graphviz (~> 1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.4.4)
|
11
|
+
rake (13.0.3)
|
12
|
+
rexml (3.2.4)
|
13
|
+
rspec (3.10.0)
|
14
|
+
rspec-core (~> 3.10.0)
|
15
|
+
rspec-expectations (~> 3.10.0)
|
16
|
+
rspec-mocks (~> 3.10.0)
|
17
|
+
rspec-core (3.10.1)
|
18
|
+
rspec-support (~> 3.10.0)
|
19
|
+
rspec-expectations (3.10.1)
|
20
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
21
|
+
rspec-support (~> 3.10.0)
|
22
|
+
rspec-mocks (3.10.1)
|
23
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
+
rspec-support (~> 3.10.0)
|
25
|
+
rspec-support (3.10.1)
|
26
|
+
ruby-graphviz (1.2.5)
|
27
|
+
rexml
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
x86_64-darwin-18
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
pocky!
|
34
|
+
rake (~> 13.0)
|
35
|
+
rspec (~> 3.0)
|
36
|
+
|
37
|
+
BUNDLED WITH
|
38
|
+
2.2.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Quan Nguyen
|
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,47 @@
|
|
1
|
+
# Pocky
|
2
|
+
|
3
|
+
Pocky is used to generate dependency graphs for your packwerk packages. The gem is named after pocky, a beloved Japanese snack that comes in small packages.
|
4
|
+
|
5
|
+
![Pocky](https://user-images.githubusercontent.com/138784/103248942-c141de80-4921-11eb-99bd-3744816abc37.png)
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
Pocky::Graph.generate(
|
11
|
+
root_path: 'path/to/app/packages',
|
12
|
+
default_package: 'The Monolith', # The default package listed as "." in deprecated_references.yml
|
13
|
+
package_prefix: 'app/packages', # this is for matching package names listed in deprecated_references.yml
|
14
|
+
output_filename: 'pocky-graph.png'
|
15
|
+
)
|
16
|
+
```
|
17
|
+
|
18
|
+
|
19
|
+
## Installation
|
20
|
+
|
21
|
+
Add this line to your application's Gemfile:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
gem 'pocky'
|
25
|
+
```
|
26
|
+
|
27
|
+
And then execute:
|
28
|
+
|
29
|
+
$ bundle install
|
30
|
+
|
31
|
+
Or install it yourself as:
|
32
|
+
|
33
|
+
$ gem install pocky
|
34
|
+
|
35
|
+
## Development
|
36
|
+
|
37
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
38
|
+
|
39
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pocky.
|
44
|
+
|
45
|
+
## License
|
46
|
+
|
47
|
+
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,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "pocky"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/pocky.rb
ADDED
data/lib/pocky/graph.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'ruby-graphviz'
|
5
|
+
|
6
|
+
module Pocky
|
7
|
+
class Graph
|
8
|
+
def self.generate(params)
|
9
|
+
new(**params).generate
|
10
|
+
end
|
11
|
+
|
12
|
+
private_class_method :new
|
13
|
+
def initialize(
|
14
|
+
root_path:,
|
15
|
+
default_package: 'Default',
|
16
|
+
package_prefix: '',
|
17
|
+
image_filename: 'pocky-graph.png'
|
18
|
+
)
|
19
|
+
@root_path = root_path
|
20
|
+
@default_package = default_package
|
21
|
+
@package_prefix = package_prefix
|
22
|
+
@output_filename = image_filename
|
23
|
+
|
24
|
+
@deprecated_references = {}
|
25
|
+
@nodes = {}
|
26
|
+
end
|
27
|
+
|
28
|
+
def generate
|
29
|
+
load_package_dependencies
|
30
|
+
build_directed_graph
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def build_directed_graph
|
36
|
+
graph = GraphViz.new(:G, type: :digraph, dpi: 300)
|
37
|
+
@deprecated_references.each do |package, references|
|
38
|
+
@nodes[package] ||= graph.add_nodes(package)
|
39
|
+
references.each do |provider, dependencies|
|
40
|
+
provider_package = package_name_for_dependency(provider)
|
41
|
+
@nodes[provider_package] ||= graph.add_nodes(provider_package)
|
42
|
+
|
43
|
+
graph.add_edges(
|
44
|
+
@nodes[package],
|
45
|
+
@nodes[provider_package],
|
46
|
+
penwidth: edge_width(dependencies.length)
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
graph.output(png: )
|
52
|
+
end
|
53
|
+
|
54
|
+
def edge_width(count)
|
55
|
+
[
|
56
|
+
[(count / 5).to_i, 1].max,
|
57
|
+
5
|
58
|
+
].min
|
59
|
+
end
|
60
|
+
|
61
|
+
def load_dependencies
|
62
|
+
Dir.each_child(@root_path) do |elem|
|
63
|
+
if Dir.exist?(File.join(@root_path, elem))
|
64
|
+
load_deprecated_references_for_package(elem)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def load_deprecated_references_for_package(package)
|
70
|
+
@deprecated_references[package] ||= begin
|
71
|
+
filename = deprecated_references_file_for(package)
|
72
|
+
if File.exist?(filename)
|
73
|
+
YAML.load_file(filename) || {}
|
74
|
+
else
|
75
|
+
{}
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def deprecated_references_file_for(package)
|
81
|
+
File.join(@root_path, package, 'deprecated_references.yml')
|
82
|
+
end
|
83
|
+
|
84
|
+
def package_name_for_dependency(name)
|
85
|
+
return @default_package if name == '.'
|
86
|
+
|
87
|
+
name.gsub(@package_prefix, '').gsub(/^\//, '')
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
data/pocky.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/pocky/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "pocky"
|
7
|
+
spec.version = Pocky::VERSION
|
8
|
+
spec.authors = ["Quan Nguyen"]
|
9
|
+
spec.email = ["mquannie@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "A ruby gem that generates dependency graph for your packwerk packages"
|
12
|
+
spec.description = "A ruby gem that generates dependency graph for your packwerk packages"
|
13
|
+
spec.homepage = "https://github.com/mquan/pocky"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
16
|
+
|
17
|
+
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
spec.metadata["source_code_uri"] = "https://github.com/mquan/pocky"
|
20
|
+
spec.metadata["changelog_uri"] = "https://github.com/mquan/pocky"
|
21
|
+
|
22
|
+
spec.files = Dir.chdir(__dir__) do
|
23
|
+
%x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^(test|spec|features|static)/}) }
|
24
|
+
end
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = %w(lib)
|
28
|
+
|
29
|
+
spec.add_dependency "ruby-graphviz", "~> 1"
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pocky
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Quan Nguyen
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-12-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ruby-graphviz
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1'
|
27
|
+
description: A ruby gem that generates dependency graph for your packwerk packages
|
28
|
+
email:
|
29
|
+
- mquannie@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- ".rspec"
|
36
|
+
- Gemfile
|
37
|
+
- Gemfile.lock
|
38
|
+
- LICENSE.txt
|
39
|
+
- README.md
|
40
|
+
- Rakefile
|
41
|
+
- bin/console
|
42
|
+
- bin/setup
|
43
|
+
- lib/pocky.rb
|
44
|
+
- lib/pocky/graph.rb
|
45
|
+
- lib/pocky/version.rb
|
46
|
+
- pocky.gemspec
|
47
|
+
homepage: https://github.com/mquan/pocky
|
48
|
+
licenses:
|
49
|
+
- MIT
|
50
|
+
metadata:
|
51
|
+
homepage_uri: https://github.com/mquan/pocky
|
52
|
+
source_code_uri: https://github.com/mquan/pocky
|
53
|
+
changelog_uri: https://github.com/mquan/pocky
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 2.3.0
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubygems_version: 3.1.4
|
70
|
+
signing_key:
|
71
|
+
specification_version: 4
|
72
|
+
summary: A ruby gem that generates dependency graph for your packwerk packages
|
73
|
+
test_files: []
|