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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.bowerrc +3 -0
  3. data/.gitignore +2 -14
  4. data/README.md +18 -17
  5. data/bower.json +6 -0
  6. data/lib/society.rb +16 -6
  7. data/lib/society/association_processor.rb +206 -0
  8. data/lib/society/cli.rb +12 -9
  9. data/lib/society/edge.rb +15 -0
  10. data/lib/society/formatter/graph/json.rb +44 -0
  11. data/lib/society/formatter/report/html.rb +73 -0
  12. data/lib/society/formatter/report/json.rb +39 -0
  13. data/lib/society/formatter/report/templates/components/.gitignore +7 -0
  14. data/lib/society/formatter/report/templates/components/d3/d3.min.js +5 -0
  15. data/lib/society/formatter/report/templates/components/society-assets/society.css +70 -0
  16. data/lib/society/formatter/report/templates/components/society-assets/society.js +420 -0
  17. data/lib/society/formatter/report/templates/index.htm.haml +48 -0
  18. data/lib/society/object_graph.rb +3 -2
  19. data/lib/society/parser.rb +49 -32
  20. data/lib/society/reference_processor.rb +60 -0
  21. data/lib/society/version.rb +1 -1
  22. data/society.gemspec +4 -1
  23. data/society_graph.json +1 -0
  24. data/spec/association_processor_spec.rb +174 -0
  25. data/spec/cli_spec.rb +25 -0
  26. data/spec/fixtures/foo.rb +6 -18
  27. data/spec/formatter/graph/json_spec.rb +52 -0
  28. data/spec/formatter/report/html_spec.rb +75 -0
  29. data/spec/formatter/report/json_spec.rb +70 -0
  30. data/spec/object_graph_spec.rb +30 -0
  31. data/spec/parser_spec.rb +61 -0
  32. data/spec/reference_processor_spec.rb +18 -0
  33. data/spec/spec_helper.rb +3 -0
  34. metadata +77 -13
  35. data/lib/society/matrix.rb +0 -36
  36. data/lib/society/node.rb +0 -19
  37. data/spec/fixtures/bar.rb +0 -6
  38. data/spec/matrix_spec.rb +0 -27
  39. data/spec/node_spec.rb +0 -30
@@ -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
@@ -1,6 +0,0 @@
1
- class Bar
2
-
3
- def say_hello
4
- end
5
-
6
- end
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