society 1.6 → 1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +7 -5
- data/lib/society.rb +1 -1
- data/lib/society/cli.rb +1 -1
- data/lib/society/formatter/report/csv.rb +40 -0
- data/lib/society/formatter/report/html.rb +16 -0
- data/lib/society/formatter/report/templates/society.csv.haml +4 -0
- data/lib/society/parser.rb +1 -1
- data/lib/society/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 528e86c646a2d410350036ae115b42446814588b8db6f0ed5213a9c4aa06f6b9
|
4
|
+
data.tar.gz: 3a909c1be6b6f52d753ed2ca4f7e566bc3873a7bb6f6b50b548033ac411b9828
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 410d5b6562be164fda0b715d6de2ace7d1c6eac2dd83be2e76545e1c0a3ff31bfc6171f19ea9b44f1d2fa195fb3dda1e82284c79cf42e4658d85ac0048ba9d2c
|
7
|
+
data.tar.gz: 1cd4bb7ea504a6610ce84984f37a995f4ee09637265a29f68384d5e7ee61ed0a66dafeff18c0dcbcdc7657a097728654033f3bf08e7be22c5abeda7c511c0f9e
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Society
|
2
2
|
|
3
|
-
Society analyzes and presents social graphs of relationships between classes in a Ruby or Rails project. It displays relationships that are either explicitly declared (e.g. in an ActiveRecord relation) or defined by calls between classes (e.g. in the source of ClassA there is a call to ClassB).
|
3
|
+
Society analyzes and presents social graphs of relationships between classes in a Ruby or Rails project. It displays relationships that are either explicitly declared (e.g. in an ActiveRecord relation) or defined by calls between classes (e.g. in the source of ClassA there is a call to ClassB).
|
4
4
|
|
5
5
|
Please note that Society requires Ruby 2.1 or later.
|
6
6
|
|
@@ -18,7 +18,9 @@ Please note that Society requires Ruby 2.1 or later.
|
|
18
18
|
|
19
19
|
Add this line to your application's Gemfile:
|
20
20
|
|
21
|
-
|
21
|
+
```ruby
|
22
|
+
gem 'society'
|
23
|
+
```
|
22
24
|
|
23
25
|
And then execute:
|
24
26
|
|
@@ -32,15 +34,15 @@ Or install it yourself as:
|
|
32
34
|
|
33
35
|
From your terminal:
|
34
36
|
|
35
|
-
society from path/to/models [more/paths/if/applicable]
|
37
|
+
$ society from path/to/models [more/paths/if/applicable]
|
36
38
|
|
37
|
-
and then open `doc/society/index.htm` in your browser.
|
39
|
+
and then open `doc/society/index.htm` or `doc/society/society.csv` in your browser.
|
38
40
|
|
39
41
|
For more complex applications, society also supports file globbing:
|
40
42
|
|
41
43
|
society from ../path/to/models/*user*
|
42
44
|
|
43
|
-
The default format is HTML; you can skip the HTML interface and just get the
|
45
|
+
The default format is HTML and CSV; you can skip the HTML interface and just get the
|
44
46
|
JSON by passing `--format json`
|
45
47
|
|
46
48
|
Note that all JSON data is timestamped (regardless of output format) to store
|
data/lib/society.rb
CHANGED
@@ -9,6 +9,7 @@ require_relative "society/node"
|
|
9
9
|
require_relative "society/object_graph"
|
10
10
|
require_relative "society/formatter/report/html"
|
11
11
|
require_relative "society/formatter/report/json"
|
12
|
+
require_relative "society/formatter/report/csv"
|
12
13
|
require_relative "society/parser"
|
13
14
|
require_relative "society/version"
|
14
15
|
|
@@ -19,4 +20,3 @@ module Society
|
|
19
20
|
end
|
20
21
|
|
21
22
|
end
|
22
|
-
|
data/lib/society/cli.rb
CHANGED
@@ -5,7 +5,7 @@ module Society
|
|
5
5
|
|
6
6
|
class CLI < Thor
|
7
7
|
|
8
|
-
desc_text = "Formats are html (default) and
|
8
|
+
desc_text = "Formats are html (default), json, and csv."
|
9
9
|
desc_text << "Example: society from foo/ -f json -o ./society_data.json"
|
10
10
|
|
11
11
|
desc "from PATH_TO_FILE [-f FORMAT] [-o OUTPUT_PATH]", desc_text
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Society
|
2
|
+
module Formatter
|
3
|
+
module Report
|
4
|
+
class CSV
|
5
|
+
|
6
|
+
attr_reader :csv_data, :output_path
|
7
|
+
|
8
|
+
def initialize(csv_data:, output_path: nil)
|
9
|
+
@csv_data = csv_data
|
10
|
+
@output_path = output_path
|
11
|
+
end
|
12
|
+
|
13
|
+
def write
|
14
|
+
if output_path
|
15
|
+
prepare_output_directory
|
16
|
+
write_csv_data
|
17
|
+
else
|
18
|
+
puts csv_data
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def timestamp
|
25
|
+
@timestamp ||= Time.now.strftime("%Y_%m_%d_%H_%M_%S")
|
26
|
+
end
|
27
|
+
|
28
|
+
def prepare_output_directory
|
29
|
+
raise "No output path was specified" if output_path.nil?
|
30
|
+
directory_path = File.split(output_path).first
|
31
|
+
FileUtils.mkpath directory_path
|
32
|
+
end
|
33
|
+
|
34
|
+
def write_csv_data
|
35
|
+
File.open(output_path, 'w') { |file| file.write csv_data }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -13,6 +13,7 @@ module Society
|
|
13
13
|
def write
|
14
14
|
prepare_output_directory
|
15
15
|
write_html
|
16
|
+
write_csv
|
16
17
|
copy_assets
|
17
18
|
write_json_data
|
18
19
|
puts "Results written to #{self.output_path}." unless self.output_path.nil?
|
@@ -28,6 +29,10 @@ module Society
|
|
28
29
|
File.open(File.join(output_path, 'index.htm'), 'w') {|outfile| outfile.write(index)}
|
29
30
|
end
|
30
31
|
|
32
|
+
def write_csv
|
33
|
+
File.open(File.join(output_path, 'society.csv'), 'w') {|outfile| outfile.write(csv)}
|
34
|
+
end
|
35
|
+
|
31
36
|
def copy_assets
|
32
37
|
bower_dir = File.join(File.dirname(__FILE__), 'templates', 'components')
|
33
38
|
FileUtils.cp(
|
@@ -50,6 +55,17 @@ module Society
|
|
50
55
|
)
|
51
56
|
end
|
52
57
|
|
58
|
+
def csv
|
59
|
+
Haml::Engine.new(csv_template).render(
|
60
|
+
Object.new, json_data: json_data
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
def csv_template
|
65
|
+
path = File.join(File.dirname(__FILE__), 'templates', 'society.csv.haml')
|
66
|
+
File.read(path)
|
67
|
+
end
|
68
|
+
|
53
69
|
def template
|
54
70
|
path = File.join(File.dirname(__FILE__), 'templates', 'index.htm.haml')
|
55
71
|
File.read(path)
|
data/lib/society/parser.rb
CHANGED
data/lib/society/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: society
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.7'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Coraline Ada Ehmke
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-07-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -201,6 +201,7 @@ files:
|
|
201
201
|
- lib/society.rb
|
202
202
|
- lib/society/cli.rb
|
203
203
|
- lib/society/edge.rb
|
204
|
+
- lib/society/formatter/report/csv.rb
|
204
205
|
- lib/society/formatter/report/html.rb
|
205
206
|
- lib/society/formatter/report/json.rb
|
206
207
|
- lib/society/formatter/report/templates/components/.gitignore
|
@@ -208,6 +209,7 @@ files:
|
|
208
209
|
- lib/society/formatter/report/templates/components/society-assets/society.css
|
209
210
|
- lib/society/formatter/report/templates/components/society-assets/society.js
|
210
211
|
- lib/society/formatter/report/templates/index.htm.haml
|
212
|
+
- lib/society/formatter/report/templates/society.csv.haml
|
211
213
|
- lib/society/node.rb
|
212
214
|
- lib/society/object_graph.rb
|
213
215
|
- lib/society/parser.rb
|
@@ -241,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
241
243
|
version: '0'
|
242
244
|
requirements: []
|
243
245
|
rubyforge_project:
|
244
|
-
rubygems_version: 2.
|
246
|
+
rubygems_version: 2.7.6
|
245
247
|
signing_key:
|
246
248
|
specification_version: 4
|
247
249
|
summary: Social graph for Ruby objects
|