society 0.13.2 → 1.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.
- checksums.yaml +4 -4
- data/.bowerrc +3 -0
- data/.gitignore +2 -14
- data/README.md +18 -17
- data/bower.json +6 -0
- data/lib/society.rb +16 -6
- data/lib/society/association_processor.rb +206 -0
- data/lib/society/cli.rb +12 -9
- data/lib/society/edge.rb +15 -0
- data/lib/society/formatter/graph/json.rb +44 -0
- data/lib/society/formatter/report/html.rb +73 -0
- data/lib/society/formatter/report/json.rb +39 -0
- data/lib/society/formatter/report/templates/components/.gitignore +7 -0
- data/lib/society/formatter/report/templates/components/d3/d3.min.js +5 -0
- data/lib/society/formatter/report/templates/components/society-assets/society.css +70 -0
- data/lib/society/formatter/report/templates/components/society-assets/society.js +420 -0
- data/lib/society/formatter/report/templates/index.htm.haml +48 -0
- data/lib/society/object_graph.rb +3 -2
- data/lib/society/parser.rb +49 -32
- data/lib/society/reference_processor.rb +60 -0
- data/lib/society/version.rb +1 -1
- data/society.gemspec +4 -1
- data/society_graph.json +1 -0
- data/spec/association_processor_spec.rb +174 -0
- data/spec/cli_spec.rb +25 -0
- data/spec/fixtures/foo.rb +6 -18
- data/spec/formatter/graph/json_spec.rb +52 -0
- data/spec/formatter/report/html_spec.rb +75 -0
- data/spec/formatter/report/json_spec.rb +70 -0
- data/spec/object_graph_spec.rb +30 -0
- data/spec/parser_spec.rb +61 -0
- data/spec/reference_processor_spec.rb +18 -0
- data/spec/spec_helper.rb +3 -0
- metadata +77 -13
- data/lib/society/matrix.rb +0 -36
- data/lib/society/node.rb +0 -19
- data/spec/fixtures/bar.rb +0 -6
- data/spec/matrix_spec.rb +0 -27
- data/spec/node_spec.rb +0 -30
data/lib/society/matrix.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module Society
|
4
|
-
|
5
|
-
class Matrix
|
6
|
-
|
7
|
-
attr_reader :nodes
|
8
|
-
|
9
|
-
def initialize(nodes)
|
10
|
-
@nodes = nodes
|
11
|
-
end
|
12
|
-
|
13
|
-
def to_json
|
14
|
-
{ names: node_names, matrix: matrix }.to_json
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def node_names
|
20
|
-
self.nodes.map(&:name)
|
21
|
-
end
|
22
|
-
|
23
|
-
def matrix
|
24
|
-
reference_matrix = [[]]
|
25
|
-
nodes.each_with_index do |node, i|
|
26
|
-
references = node_names.map do |name|
|
27
|
-
node.edges.include?(name) ? 1 : 0
|
28
|
-
end
|
29
|
-
reference_matrix.push(references)
|
30
|
-
end
|
31
|
-
reference_matrix
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
data/lib/society/node.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Society
|
2
|
-
class Node
|
3
|
-
|
4
|
-
attr_reader :name # method or class name
|
5
|
-
attr_reader :address # file name or file name + loc
|
6
|
-
attr_accessor :edges # relation between nodes
|
7
|
-
|
8
|
-
def initialize(name: name, address: address, edges: edges=[])
|
9
|
-
@name = name
|
10
|
-
@address = address
|
11
|
-
@edges = edges
|
12
|
-
end
|
13
|
-
|
14
|
-
def edge_count
|
15
|
-
edges.count
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
data/spec/fixtures/bar.rb
DELETED
data/spec/matrix_spec.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Society::Matrix do
|
4
|
-
|
5
|
-
let(:node) { Struct.new(:name, :edges) }
|
6
|
-
let(:nodes) {
|
7
|
-
[
|
8
|
-
node.new("foo", %w{bar bat baz}),
|
9
|
-
node.new("bar", %w{foo bat baz})
|
10
|
-
]
|
11
|
-
}
|
12
|
-
let(:matrix) { Society::Matrix.new(nodes) }
|
13
|
-
|
14
|
-
describe "#initialize" do
|
15
|
-
it "assigns its nodes" do
|
16
|
-
expect(matrix.nodes).to eq(nodes)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "#to_json" do
|
21
|
-
it "generates a json representation" do
|
22
|
-
expected = "{\"names\":[\"foo\",\"bar\"],\"matrix\":[[],[0,1],[1,0]]}"
|
23
|
-
expect(matrix.to_json).to eq(expected)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
data/spec/node_spec.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Society::Node do
|
4
|
-
|
5
|
-
let(:node) { Society::Node.new(
|
6
|
-
name: "Foo",
|
7
|
-
address: "./foo.rb",
|
8
|
-
edges: %w{Bar Bat}
|
9
|
-
)
|
10
|
-
}
|
11
|
-
|
12
|
-
describe "#initialize" do
|
13
|
-
it "assigns its name" do
|
14
|
-
expect(node.name).to eq("Foo")
|
15
|
-
end
|
16
|
-
it "assigns its address" do
|
17
|
-
expect(node.address).to eq("./foo.rb")
|
18
|
-
end
|
19
|
-
it "assigns its edges" do
|
20
|
-
expect(node.edges).to eq(["Bar", "Bat"])
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "#edge_count" do
|
25
|
-
it "returns a count of its edges" do
|
26
|
-
expect(node.edge_count).to eq 2
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|