society 1.6 → 1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d5405b409b32bc4c1fbcdcd16045f6e89f914dc0
4
- data.tar.gz: 37a9b9232cb5ad32076b44b93a79d23d8dfbecaf
2
+ SHA256:
3
+ metadata.gz: 528e86c646a2d410350036ae115b42446814588b8db6f0ed5213a9c4aa06f6b9
4
+ data.tar.gz: 3a909c1be6b6f52d753ed2ca4f7e566bc3873a7bb6f6b50b548033ac411b9828
5
5
  SHA512:
6
- metadata.gz: 16e7aa59852b0fc41fe030d3d65794cb9db6d9f1ff14897ea6f2e2cc08402456c30921b99acaf7931f978eba1d5427d79d3585724455fda8d184722a3a343109
7
- data.tar.gz: fbb2a78386bbc8642fdc036e6a216430814c3df7052afb9ab8e5b6042224d58153737ed04e3f02eb449f55a474f2822e5e46cde94140d14e107619b9ff8c0179
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
- gem 'society'
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
@@ -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
-
@@ -5,7 +5,7 @@ module Society
5
5
 
6
6
  class CLI < Thor
7
7
 
8
- desc_text = "Formats are html (default) and json."
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)
@@ -0,0 +1,4 @@
1
+ Model, Coupled Model, Weight
2
+ - JSON.parse(json_data).sort{|a,b| a[0] <=> b[0]}.each do |node, edges|
3
+ - edges.each do |edge|
4
+ #{node},#{edge[0]},#{edge[1]}
@@ -476,7 +476,7 @@ module Society
476
476
 
477
477
  FORMATTERS = {
478
478
  html: Society::Formatter::Report::HTML,
479
- json: Society::Formatter::Report::Json
479
+ json: Society::Formatter::Report::Json,
480
480
  }
481
481
 
482
482
  # Internal: List known output formatters.
@@ -1,3 +1,3 @@
1
1
  module Society
2
- VERSION = "1.6"
2
+ VERSION = "1.7"
3
3
  end
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.6'
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: 2016-06-17 00:00:00.000000000 Z
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.4.5.1
246
+ rubygems_version: 2.7.6
245
247
  signing_key:
246
248
  specification_version: 4
247
249
  summary: Social graph for Ruby objects