cobradeps 0.1.1 → 0.2.1
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 +4 -4
- data/README.md +31 -1
- data/cobradeps.gemspec +1 -1
- data/lib/cobradeps.rb +26 -12
- data/lib/cobradeps/gemfile_scraper.rb +17 -7
- metadata +18 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a9c8b4c793f5ec42669a805a30f7009afe7b21d
|
4
|
+
data.tar.gz: e1a3483db3d315cf506d9f8f8e4bcda2c2ddcc62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c409d6abcc223fb5ac10b74bc034a2c73d3b7e7b4509bc8f513bae0c9a333fbc6bcdcb044c682099e5ef7d7cde1b143e3f9d835c0d3fcb7f053c1fdf73522e4f
|
7
|
+
data.tar.gz: d488aa0db1af3ac1a164eec3b675fa1d21d2eeb0d5a80c30bb92c7d723482999e1a31eae33bbd1d4c2a6dbd648cce05ac89c3bf3b19312a3590a72f33401e8e1
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# cobradeps [](https://travis-ci.org/shageman/cobradeps) [](http://badge.fury.io/rb/cobradeps) [](https://codeclimate.com/github/shageman/cobradeps) [](https://gemnasium.com/shageman/cobradeps)
|
2
2
|
|
3
|
-
Prints and exports the dependencies within component-based Ruby/Rails applications (#
|
3
|
+
Prints and exports the dependencies within component-based Ruby/Rails applications (#cbra)
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -15,6 +15,22 @@ And then execute:
|
|
15
15
|
Or install it yourself as:
|
16
16
|
|
17
17
|
$ gem install cobradeps
|
18
|
+
|
19
|
+
### Dependencies
|
20
|
+
|
21
|
+
You need [Graphviz](http://graphviz.org/) to generate the graph.png
|
22
|
+
|
23
|
+
#### OS X
|
24
|
+
|
25
|
+
If you're using OS X and homebrew, you just need to:
|
26
|
+
|
27
|
+
```bash
|
28
|
+
brew install graphviz
|
29
|
+
```
|
30
|
+
|
31
|
+
#### Other Operating Systems
|
32
|
+
|
33
|
+
For more information about installation on other operating systems, just check [Graphviz Download Page](http://graphviz.org/Download..php)
|
18
34
|
|
19
35
|
## Usage
|
20
36
|
|
@@ -35,6 +51,20 @@ There are sample #cobra folder structures in `spec/examples`. Here is the graph
|
|
35
51
|
|
36
52
|

|
37
53
|
|
54
|
+
## Using `path "..." do` blocks
|
55
|
+
The preferred method of referencing #cbra dependencies is via the path block syntax supported by bundler(http://teotti.com/gemfiles-hierarchy-in-ruby-on-rails-component-based-architecture/):
|
56
|
+
|
57
|
+
path "../" do
|
58
|
+
gem "B"
|
59
|
+
gem "C"
|
60
|
+
gem "D"
|
61
|
+
gem "E1"
|
62
|
+
gem "E2"
|
63
|
+
gem "F"
|
64
|
+
end
|
65
|
+
|
66
|
+
Note, that you only need to add direct dependencies when using the block syntax (and not transitive dependencies as discussed below).
|
67
|
+
|
38
68
|
## #cobra extension to Gemfile
|
39
69
|
|
40
70
|
The :path option used for #cobras is typically a relative path. Because of that all gems and apps transitively including a
|
data/cobradeps.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'cobradeps'
|
7
|
-
spec.version = '0.
|
7
|
+
spec.version = '0.2.1'
|
8
8
|
spec.authors = ['Stephan Hagemann']
|
9
9
|
spec.email = ['stephan.hagemann@gmail.com']
|
10
10
|
spec.summary = %q{Prints and exports the dependencies within component-based Ruby/Rails applications}
|
data/lib/cobradeps.rb
CHANGED
@@ -13,14 +13,17 @@ module Cbradeps
|
|
13
13
|
outputs app.to_s
|
14
14
|
|
15
15
|
outputs "\n\nDEPENDENCIES"
|
16
|
-
cobra_deps = app.
|
16
|
+
cobra_deps = app.cobra_dependencies.to_a
|
17
17
|
|
18
|
-
|
18
|
+
i = 0
|
19
|
+
while (i < cobra_deps.size) do
|
20
|
+
dep = cobra_deps[i]
|
19
21
|
outputs "\n#{dep[:options][:path]}"
|
20
22
|
gem = GemfileScraper.new(dep[:options][:path])
|
21
23
|
outputs gem.to_s
|
22
24
|
|
23
|
-
cobra_deps
|
25
|
+
cobra_deps += gem.cobra_dependencies
|
26
|
+
i+=1
|
24
27
|
end
|
25
28
|
|
26
29
|
outputs "\n\n ALL PARTS"
|
@@ -45,36 +48,47 @@ module Cbradeps
|
|
45
48
|
|
46
49
|
def self.graph(path)
|
47
50
|
g = GraphViz.new(:G, :type => :digraph, concentrate: true)
|
51
|
+
gem_nodes = {}
|
48
52
|
|
49
53
|
app = GemfileScraper.new(path)
|
50
54
|
|
51
55
|
app_node = g.add_nodes(app.name)
|
52
|
-
|
56
|
+
gem_nodes[app.name] = app_node
|
57
|
+
outputs "Added #{app.name} app"
|
53
58
|
|
54
|
-
cobra_deps = app.
|
55
|
-
gem_nodes = {}
|
59
|
+
cobra_deps = app.cobra_dependencies.to_a
|
56
60
|
|
57
61
|
cobra_deps.each do |dep|
|
58
62
|
gem = GemfileScraper.new(dep[:options][:path])
|
59
|
-
|
60
|
-
gem_nodes[gem.name] = gem_node
|
63
|
+
gem_nodes[gem.name] = g.add_nodes(gem.name)
|
61
64
|
outputs "Added #{gem.name} node"
|
62
65
|
if dep[:options][:direct]
|
63
66
|
outputs "Added edge from #{app.name} to #{gem.name}"
|
64
|
-
g.add_edges(app_node,
|
67
|
+
g.add_edges(app_node, gem_nodes[gem.name])
|
65
68
|
end
|
66
69
|
end
|
67
70
|
|
68
|
-
|
71
|
+
i = 0
|
72
|
+
while (i < cobra_deps.size) do
|
73
|
+
dep = cobra_deps[i]
|
69
74
|
gem = GemfileScraper.new(dep[:options][:path])
|
70
|
-
|
75
|
+
if !gem_nodes.has_key? gem.name
|
76
|
+
gem_nodes[gem.name] = g.add_nodes(gem.name)
|
77
|
+
outputs "Added #{gem.name} node"
|
78
|
+
end
|
71
79
|
|
72
80
|
gem_cobra_deps = gem.cobra_dependencies
|
73
81
|
gem_cobra_deps.each do |nest_dep|
|
74
82
|
nest_gem = GemfileScraper.new(nest_dep[:options][:path])
|
75
|
-
|
83
|
+
if !gem_nodes.has_key? nest_gem.name
|
84
|
+
gem_nodes[nest_gem.name] = g.add_nodes(nest_gem.name)
|
85
|
+
outputs "Added to #{nest_gem.name} node"
|
86
|
+
end
|
87
|
+
g.add_edges(gem_nodes[gem.name], gem_nodes[nest_gem.name])
|
76
88
|
outputs "Added edge from #{gem.name} to #{nest_gem.name}"
|
77
89
|
end
|
90
|
+
cobra_deps += gem.cobra_dependencies
|
91
|
+
i+=1
|
78
92
|
end
|
79
93
|
g
|
80
94
|
end
|
@@ -19,6 +19,8 @@ module Cbradeps
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
private
|
23
|
+
|
22
24
|
def transitive_cobra_dependencies
|
23
25
|
gem_dependencies.inject([]) do |memo, dep|
|
24
26
|
if !!dep[:options][:path]
|
@@ -30,8 +32,6 @@ module Cbradeps
|
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
33
|
-
private
|
34
|
-
|
35
35
|
def raw_gemspec
|
36
36
|
path = File.expand_path(File.join(@root_path, "#{underscore(name)}.gemspec"))
|
37
37
|
File.exist?(path) ? File.read(path) : ""
|
@@ -51,10 +51,20 @@ module Cbradeps
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def gem_dependencies
|
54
|
+
in_path_block_dir = nil
|
54
55
|
raw_gemfile.split("\n").inject([]) do |memo, line|
|
55
|
-
|
56
|
-
|
57
|
-
|
56
|
+
if in_path_block_dir
|
57
|
+
if match = line.match(/gem\s+["']([^'"]+)["'](.*)/)
|
58
|
+
memo << {name: match[1], options: {path: "#{in_path_block_dir}/#{match[1]}", direct: true}}
|
59
|
+
elsif line.match(/end/)
|
60
|
+
in_path_block_dir = nil
|
61
|
+
end
|
62
|
+
else
|
63
|
+
if match = line.match(/gem\s+["']([^'"]+)["'](.*)/)
|
64
|
+
memo << {name: match[1], options: NonBlockOptionParser.new(match[2]).parse}
|
65
|
+
elsif match = line.match(/path\s+[\"\'\:]?([^\"\']*)[\"\']?\s+do/)
|
66
|
+
in_path_block_dir = match[1]
|
67
|
+
end
|
58
68
|
end
|
59
69
|
memo
|
60
70
|
end
|
@@ -68,7 +78,7 @@ module Cbradeps
|
|
68
78
|
downcase
|
69
79
|
end
|
70
80
|
|
71
|
-
class
|
81
|
+
class NonBlockOptionParser
|
72
82
|
def initialize(options)
|
73
83
|
@options = options
|
74
84
|
end
|
@@ -85,7 +95,7 @@ module Cbradeps
|
|
85
95
|
end
|
86
96
|
|
87
97
|
def direct
|
88
|
-
match = @options.match(/
|
98
|
+
match = @options.match(/group(?:\s*=>|:)\s+:direct/)
|
89
99
|
match ? {direct: true} : {}
|
90
100
|
end
|
91
101
|
end
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cobradeps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephan Hagemann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-graphviz
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.5'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.5'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: |
|
@@ -76,14 +76,14 @@ executables:
|
|
76
76
|
extensions: []
|
77
77
|
extra_rdoc_files: []
|
78
78
|
files:
|
79
|
-
- bin/cobradeps
|
80
|
-
- cobradeps.gemspec
|
81
79
|
- Gemfile
|
82
|
-
- lib/cobradeps/gemfile_scraper.rb
|
83
|
-
- lib/cobradeps.rb
|
84
80
|
- LICENSE
|
85
|
-
- Rakefile
|
86
81
|
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/cobradeps
|
84
|
+
- cobradeps.gemspec
|
85
|
+
- lib/cobradeps.rb
|
86
|
+
- lib/cobradeps/gemfile_scraper.rb
|
87
87
|
homepage: https://github.com/shageman/cobradeps
|
88
88
|
licenses:
|
89
89
|
- MIT
|
@@ -94,17 +94,17 @@ require_paths:
|
|
94
94
|
- lib
|
95
95
|
required_ruby_version: !ruby/object:Gem::Requirement
|
96
96
|
requirements:
|
97
|
-
- -
|
97
|
+
- - ">="
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: '0'
|
100
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- -
|
102
|
+
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
106
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.
|
107
|
+
rubygems_version: 2.4.6
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: Prints and exports the dependencies within component-based Ruby/Rails applications
|