deps_grapher 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 (60) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +3 -0
  3. data/Gemfile +16 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +327 -0
  6. data/Rakefile +12 -0
  7. data/bin/console +15 -0
  8. data/bin/deps_grapher +96 -0
  9. data/bin/setup +8 -0
  10. data/deps_grapher.gemspec +34 -0
  11. data/lefthook.yml +14 -0
  12. data/lib/deps_grapher/ast_processor.rb +211 -0
  13. data/lib/deps_grapher/ast_processor_policy.rb +45 -0
  14. data/lib/deps_grapher/cache_file.rb +48 -0
  15. data/lib/deps_grapher/cli.rb +29 -0
  16. data/lib/deps_grapher/command/analyzer.rb +89 -0
  17. data/lib/deps_grapher/command/init.rb +49 -0
  18. data/lib/deps_grapher/configuration.rb +99 -0
  19. data/lib/deps_grapher/context.rb +48 -0
  20. data/lib/deps_grapher/cytoscape/cose.rb +36 -0
  21. data/lib/deps_grapher/cytoscape/fcose.rb +36 -0
  22. data/lib/deps_grapher/cytoscape/klay.rb +27 -0
  23. data/lib/deps_grapher/cytoscape/template.erb +61 -0
  24. data/lib/deps_grapher/cytoscape.rb +88 -0
  25. data/lib/deps_grapher/dsl.rb +50 -0
  26. data/lib/deps_grapher/edge.rb +58 -0
  27. data/lib/deps_grapher/errors.rb +8 -0
  28. data/lib/deps_grapher/event.rb +63 -0
  29. data/lib/deps_grapher/graph.rb +71 -0
  30. data/lib/deps_grapher/graphile/generator.rb +42 -0
  31. data/lib/deps_grapher/graphile/graphile.erb +119 -0
  32. data/lib/deps_grapher/graphile/graphile.temp.erb +23 -0
  33. data/lib/deps_grapher/html_writer.rb +16 -0
  34. data/lib/deps_grapher/input.rb +40 -0
  35. data/lib/deps_grapher/layer/registry.rb +32 -0
  36. data/lib/deps_grapher/layer.rb +75 -0
  37. data/lib/deps_grapher/logging.rb +21 -0
  38. data/lib/deps_grapher/matcher.rb +28 -0
  39. data/lib/deps_grapher/node.rb +65 -0
  40. data/lib/deps_grapher/plugin_dsl.rb +12 -0
  41. data/lib/deps_grapher/plugin_loader.rb +29 -0
  42. data/lib/deps_grapher/source.rb +51 -0
  43. data/lib/deps_grapher/source_cache/class_name_extractor.rb +60 -0
  44. data/lib/deps_grapher/source_cache/registry.rb +64 -0
  45. data/lib/deps_grapher/source_cache.rb +49 -0
  46. data/lib/deps_grapher/version.rb +5 -0
  47. data/lib/deps_grapher/vis/box.rb +21 -0
  48. data/lib/deps_grapher/vis/dot.rb +17 -0
  49. data/lib/deps_grapher/vis/template.erb +36 -0
  50. data/lib/deps_grapher/vis.rb +69 -0
  51. data/lib/deps_grapher/visualizer/base.rb +74 -0
  52. data/lib/deps_grapher/visualizer/color/registry.rb +30 -0
  53. data/lib/deps_grapher/visualizer/color.rb +62 -0
  54. data/lib/deps_grapher/visualizer/command_option.rb +22 -0
  55. data/lib/deps_grapher/visualizer/downloader.rb +42 -0
  56. data/lib/deps_grapher/visualizer/js_option.rb +39 -0
  57. data/lib/deps_grapher/visualizer/registry.rb +37 -0
  58. data/lib/deps_grapher/visualizer.rb +11 -0
  59. data/lib/deps_grapher.rb +42 -0
  60. metadata +135 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 31d04a84f91bd795f6c19d70a9de853963cd02d298cadb8cceaf68fae288e10e
4
+ data.tar.gz: 284e8006b5cd05e76e8446ca6732048267ee7e234d13d3320589c7e2bb79b38c
5
+ SHA512:
6
+ metadata.gz: 261f74611a3ac886afd45c7ec1487dcd4db6bb83ede88f6aadf70b1f338725b989bf546b6f0476cffb35251791ebc426c57ab5e887e2b129a82fe8511b625566
7
+ data.tar.gz: 752589ecdbc90718919f0fcdeefe18e75aa0cced56532aa7ed01f2bf220e4cfc26f0f79d0b3051d6d4016f9f5893a049518b3fe955eb77157c4acbffaa22aa7f
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## [1.0.0] - 2024-03-22
2
+
3
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in deps_grapher.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
13
+
14
+ gem "simplecov", require: false, group: :test
15
+
16
+ gem "webmock", "~> 3.0"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 jk-es335
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,327 @@
1
+ Deps Grapher
2
+ ====
3
+
4
+ A Tool to visualize Ruby class dependencies
5
+
6
+ ## Description
7
+
8
+ Deps Grapher is intended for a general understanding of class dependencies through static analysis. It uses `parser` gem.
9
+
10
+ Please note the following:
11
+
12
+ - Information determined at runtime cannot be analyzed
13
+ - Dependencies of classes and methods that are likely to change dynamically cannot be analyzed
14
+ - Method arguments that are variables cannot be analyzed
15
+
16
+ Therefore, it may not be accurate and should be used as a reference only.
17
+
18
+ ## Installation
19
+
20
+ Please add this line to your application's Gemfile:
21
+
22
+ ```ruby
23
+ gem "deps_grapher"
24
+ ```
25
+
26
+ And then run the following command:
27
+
28
+ ```shell
29
+ bundle install
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ ### Generate a configuration file
35
+
36
+ ```shell
37
+ cd ${your directory}
38
+ bundle exec deps_grapher init
39
+ ```
40
+
41
+ The following message will be displayed.
42
+
43
+ ```shell
44
+ `${your directory}/graphile.rb` was created.
45
+ Please edit the configuration file.
46
+ Run `bundle exec deps_grapher -c graphile.rb`.
47
+ ```
48
+
49
+ Please try to run the following command.
50
+
51
+ ```shell
52
+ bundle exec deps_grapher -c graphile.rb
53
+ ```
54
+
55
+ The visualized graph will be output to the tmp directory.
56
+
57
+ Please open the index.html in the graph directory with your browser.
58
+
59
+ > ${your directory}/tmp/deps_grapher/graph/index.html
60
+
61
+ ### Customize the configuration file for your project
62
+
63
+ DSL is used to define the configuration file.
64
+
65
+ The DSL provides the following methods.
66
+
67
+ - `output_dir` - Specify the output directory where the graph html is output
68
+ - `cache_dir` - Specify the cache directory where the analysis result is stored
69
+ - `plugin_dir` - Specify the plugin directory. Plugins allow you to use customized visualizations and will be loaded by `Configuration#load_plugin!` method.
70
+ - `visualizer` - Specify the default graph type (default: "cy:klay")
71
+ - `ast_processor_policy` - Specify the policy for processing the AST
72
+ - `include_const` - Specify the constant or regular expression to be included in the analysis
73
+ - `exclude_const` - Specify the constant or regular expression to be excluded from the analysis
74
+ - `include_location` - Specify the location or regular expression to be included in the analysis
75
+ - `exclude_location` - Specify the location or regular expression to be excluded from the analysis
76
+ - `advanced_const_resolver` - Specify the object that has `call` method to resolve the constant. You can write a custom logic to resolve the constant using ast_node of parser gem. The block should return a string of const name or nil. If return nil, the const name will be resolved by default logic.
77
+ - `layer` - Specify the layer to be displayed in the graph
78
+ - `name` - Specify the layer name (required)
79
+ - `visible` - Specify whether the layer is visible (default: true)
80
+ - `source` - Specify the source directory of the layer (required)
81
+ - `root` - Specify the root directory of the layer (required)
82
+ - `include_pattern` - Specify the pattern to include in the analysis (default: nil)
83
+ - `exclude_pattern` - Specify the pattern to exclude from the analysis (default: nil)
84
+ - `glob_pattern` - Specify the glob pattern to include in the analysis (default: ["**/*.rb"])
85
+ - `color` - Specify the color of the layer (required)
86
+ - `background` - Specify the background color of the node and the edge (required)
87
+ - `arrow` - Specify the arrow color of the edge (default: same as `background`)
88
+ - `border` - Specify the border color of the node and the edge (required)
89
+ - `font` - Specify the font color of the the node and the edge (required)
90
+ - `with_plugin` - Specify the extension plugin directory. Plugins allow you to use customized visualizations.
91
+
92
+ ### Configuration example
93
+
94
+ ```ruby
95
+ # frozen_string_literal: true
96
+
97
+ # directory settings
98
+ # customize for your project
99
+ output_dir File.expand_path "tmp/deps_grapher/graph"
100
+ cache_dir File.expand_path "tmp/deps_grapher/cache"
101
+
102
+ root_dir = "<%= root_dir %>"
103
+ lib_root_dir = File.join(root_dir, "lib")
104
+ layer_root_dir = File.join(lib_root_dir, "deps_grapher")
105
+
106
+ # default visualizer setting
107
+ visualizer "<%= visualizer %>"
108
+
109
+ ast_processor_policy do
110
+ exclude_const /\ADepsGrapher\z/
111
+
112
+ # advanced_const_resolver do |ast_node|
113
+ # # some advanced logic using ast_node of parser gem
114
+ # # this block should return a string of const name or nil
115
+ # # if return nil, the const name will be resolved by default logic
116
+ # end
117
+ end
118
+
119
+ layer do
120
+ name :deps_grapher
121
+ visible true
122
+
123
+ source do
124
+ root lib_root_dir
125
+ exclude_pattern %r{/(command|cytoscape|vis|visualizer)}
126
+ end
127
+
128
+ color do
129
+ background "#FF5252"
130
+ border "#EF5350"
131
+ font "#FF5252"
132
+ end
133
+ end
134
+
135
+ layer do
136
+ name :command
137
+ visible true
138
+
139
+ source do
140
+ root File.join(layer_root_dir, "command")
141
+ end
142
+
143
+ color do
144
+ background "#512DA8"
145
+ border "#673AB7"
146
+ font "#512DA8"
147
+ end
148
+ end
149
+
150
+ layer do
151
+ name :cytoscape
152
+ visible true
153
+
154
+ source do
155
+ root layer_root_dir
156
+ glob_pattern ["cytoscape.rb", "cytoscape/**/*.rb"]
157
+ end
158
+
159
+ color do
160
+ background "#448AFF"
161
+ border "#42A5F5"
162
+ font "#448AFF"
163
+ end
164
+ end
165
+
166
+ layer do
167
+ name :vis
168
+ visible true
169
+
170
+ source do
171
+ root layer_root_dir
172
+ glob_pattern ["vis.rb", "vis/**/*.rb"]
173
+ end
174
+
175
+ color do
176
+ background "#00B8D4"
177
+ border "#00ACC1"
178
+ font "#00B8D4"
179
+ end
180
+ end
181
+
182
+ layer do
183
+ name :visualizer
184
+ visible true
185
+
186
+ source do
187
+ root layer_root_dir
188
+ glob_pattern ["visualizer.rb", "visualizer/**/*.rb"]
189
+ end
190
+
191
+ color do
192
+ background "#00C853"
193
+ border "#4CAF50"
194
+ font "#00C853"
195
+ end
196
+ end
197
+
198
+ with_plugin do |plugin_dir|
199
+ layer do
200
+ name :plugin
201
+ visible true
202
+
203
+ source do
204
+ root plugin_dir
205
+ end
206
+
207
+ color do
208
+ background "#607D8B"
209
+ border "#78909C"
210
+ font "#607D8B"
211
+ end
212
+ end
213
+ end
214
+ ```
215
+
216
+
217
+ ### Run deps_grapher
218
+
219
+ ```shell
220
+ cd ${your directory}
221
+ bundle exec deps_grapher -c graphile.rb [options]
222
+ ```
223
+
224
+ If `-c` is omitted, will find the configuration file `./graphile.rb` from the current directory and use it if found
225
+
226
+ ```shell
227
+ bundle exec deps_grapher --source "*Controller" --target "*Service"
228
+ ```
229
+
230
+ #### Command line options
231
+
232
+ | Option | Short Form | Description |
233
+ |-----------------------|-------------|---------------------------------------------------------------------------------------------------------------|
234
+ | `--config CONFIG` | `-c CONFIG` | Specify the path to the configuration file |
235
+ | `--dump` | | Dump the configuration |
236
+ | `--root ROOT_DIR` | | Specify a directory path you want to check without configuration |
237
+ | `--graph GRAPH` | `-g GRAPH` | Specify the type of graph |
238
+ | `--layer LAYER` | | Specify the visible layer name (comma-separated is okay, also "all" means that displays all layers) |
239
+ | `--source CLASS_NAME` | | Specify the source class on the graph (wildcards can be used, also `--target` is required if use this option) |
240
+ | `--target CLASS_NAME` | | Specify the target class on the graph (wildcards can be used) |
241
+ | `--clean` | | Clear the cache and output directory |
242
+ | `--ignore-errors` | | Ignore errors |
243
+ | `--verbose` | | Display verbose log |
244
+
245
+
246
+ #### Without the configuration file
247
+
248
+ The `root` option allows you to run it without configuration.
249
+
250
+ ```shell
251
+ bundle exec deps_grapher --root ${your directory} --source "*Controller" --target "*Service"
252
+ ```
253
+
254
+ This is generating a temporary configuration file internally.
255
+
256
+ ### Visualize the graph
257
+
258
+ #### cy:klay (default)
259
+
260
+
261
+ ```shell
262
+ bundle exec deps_grapher -g cy:klay
263
+ ```
264
+
265
+ ![cy:klay](./docs/cytoscape:klay.png)
266
+
267
+ #### cy:cose
268
+
269
+ ```shell
270
+ bundle exec deps_grapher -g cy:cose
271
+ ```
272
+
273
+ ![cy:cose](./docs/cytoscape:cose.png)
274
+
275
+ #### cy:fcose
276
+
277
+ ```shell
278
+ bundle exec deps_grapher -g cy:fcose
279
+ ```
280
+
281
+ ![cy:fcose](./docs/cytoscape:fcose.png)
282
+
283
+ #### vis:box
284
+
285
+ ```shell
286
+ bundle exec deps_grapher -g vis:box
287
+ ```
288
+
289
+ ![vis:box](./docs/vis:box.png)
290
+
291
+ #### vis:dot
292
+
293
+ ```shell
294
+ bundle exec deps_grapher -g vis:dot
295
+ ```
296
+
297
+ ![vis:dot](./docs/vis:dot.png)
298
+
299
+ ### Specify the layer to be displayed in the graph
300
+
301
+ ```shell
302
+ bundle exec deps_grapher --layer your_layer,another_layer...
303
+ ```
304
+
305
+ If no layer is specified, layers with "visible" set to "true" will be displayed.
306
+
307
+ Also if you want to display all layers, specify as follows.
308
+
309
+ ```shell
310
+ bundle exec deps_grapher --layer all --source "*Controller" --target "*Service"
311
+ ```
312
+
313
+ However, be careful as having too many dependencies can greatly reduce readability and performance.
314
+
315
+ It is recommended to use both the `source` and `target` options.
316
+
317
+ ## License
318
+ [The MIT License](./LICENSE.txt)
319
+
320
+ ## Acknowledgement
321
+
322
+ This tool is using the following open-source software.
323
+
324
+ - cytoscape.js (https://github.com/cytoscape/cytoscape.js) - Licensed under MIT License (https://opensource.org/licenses/MIT)
325
+ - vis-network (https://github.com/visjs/vis-network) - Licensed under Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0) and MIT License (https://opensource.org/licenses/MIT)
326
+
327
+ We thank the contributors of these software for their great work.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "deps_grapher"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/deps_grapher ADDED
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path(File.join("..", "Gemfile"), __dir__)
5
+ require "bundler/setup"
6
+ require_relative "../lib/deps_grapher"
7
+
8
+ options = {
9
+ config: ENV.fetch("DEPS_GRAPHILE", nil),
10
+ visualizer: nil,
11
+ visualizer_options: {
12
+ layers: []
13
+ }
14
+ }
15
+
16
+ config = DepsGrapher.config
17
+ context = config.context
18
+
19
+ if ARGV[0] == "init"
20
+ command = DepsGrapher::Command::Init.new context
21
+ else
22
+ opts = OptionParser.new
23
+ opts.on("-c CONFIG", "--config CONFIG", "specify config path") { |v| options[:config] = File.expand_path v }
24
+ opts.on("--dump", "dump configuration", TrueClass) { |v| config.dump = v }
25
+ opts.on("--root ROOT_DIR", "specify a directory path you want to check without configuration") do |v|
26
+ config.root_dir = File.expand_path v
27
+ options[:config] = context.generate_temp_graphile
28
+ end
29
+ opts.on("-g GRAPH", "--graph GRAPH", "specify graph") { |v| options[:visualizer] = v }
30
+ opts.on("--layer LAYER", "visible layer name (comma separated is okay)") do |v|
31
+ options[:visualizer_options][:layers] = v.split(/,+/).to_set do
32
+ _1.downcase.to_sym
33
+ end
34
+ end
35
+ opts.on("--source CLASS_NAME", "source class on graph, wildcards can be used, also `--target` is required if use this option") { |v| config.source_path = v }
36
+ opts.on("--target CLASS_NAME", "target class on graph, wildcards can be used") { |v| config.target_path = v }
37
+ opts.on("--clean", "clear cache", TrueClass) { |v| config.clean = v }
38
+ opts.on("--ignore-errors", "ignore errors", TrueClass) { |v| config.ignore_errors = v }
39
+ opts.on("--verbose", "display verbose log", TrueClass) { |v| config.verbose = v }
40
+
41
+ begin
42
+ opts.parse! ARGV
43
+ rescue OptionParser::InvalidOption, OptionParser::MissingArgument, ArgumentError => e
44
+ config.logger.warn e.message
45
+ config.logger.warn ""
46
+ config.logger.warn opts
47
+ exit 1
48
+ end
49
+
50
+ config_path = options.delete(:config)
51
+
52
+ if config_path.blank?
53
+ config_path = Dir.glob("graphile.rb").first
54
+
55
+ if config_path.blank?
56
+ config.logger.warn "Run `bundle exec deps_grapher init` to create a configuration file"
57
+ exit 0
58
+ end
59
+ config.logger.info "Detected `#{File.expand_path(config_path)}` and will use it as a configuration file"
60
+ end
61
+
62
+ config.load! config_path
63
+ config.load_plugin!
64
+
65
+ visualizer = options.delete(:visualizer)
66
+ if visualizer.present?
67
+ available_visualizers = config.available_visualizers
68
+
69
+ if available_visualizers.include?(visualizer)
70
+ config.visualizer = visualizer
71
+ else
72
+ graph_banner = available_visualizers.map do |v|
73
+ "`#{v}`"
74
+ end.join(" or ")
75
+ config.logger.warn "Invalid visualizer: #{visualizer}"
76
+ config.logger.warn "Available visualizers: #{graph_banner}"
77
+ exit 1
78
+ end
79
+ end
80
+
81
+ options[:visualizer_options][:layers] = if options[:visualizer_options][:layers].present?
82
+ if options[:visualizer_options][:layers].include?(:all)
83
+ DepsGrapher::Layer.names
84
+ else
85
+ DepsGrapher::Layer.names & options[:visualizer_options][:layers]
86
+ end
87
+ else
88
+ DepsGrapher::Layer.visible_names
89
+ end
90
+
91
+ config.merge! options
92
+
93
+ command = DepsGrapher::Command::Analyzer.new config.input.files, context
94
+ end
95
+
96
+ exit DepsGrapher::Cli.run!(command)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/deps_grapher/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "deps_grapher"
7
+ spec.version = DepsGrapher::VERSION
8
+ spec.authors = ["jk-es335"]
9
+ spec.email = ["dev@hacomono.co.jp", "soultraingang.dev@gmail.com"]
10
+
11
+ spec.summary = "Tool to visualize Ruby class dependencies"
12
+ spec.homepage = "https://github.com/hacomono-lib/deps_grapher"
13
+ spec.license = "MIT"
14
+ spec.required_ruby_version = ">= 2.7"
15
+ spec.metadata["rubygems_mfa_required"] = "true"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/hacomono-lib/deps_grapher"
19
+ spec.metadata["changelog_uri"] = "https://github.com/hacomono-lib/deps_grapher"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features|docs)/|\.(?:git|travis|circleci|rspec|rubocop)|appveyor)})
26
+ end
27
+ end
28
+ spec.bindir = "bin"
29
+ spec.executables << "deps_grapher"
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_dependency "activesupport"
33
+ spec.add_dependency "parser"
34
+ end
data/lefthook.yml ADDED
@@ -0,0 +1,14 @@
1
+ # Refer for explanation to following link:
2
+ # https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md
3
+ pre-push:
4
+ commands:
5
+ test:
6
+ tags: run rspec
7
+ run: bundle exec rspec
8
+
9
+ pre-commit:
10
+ commands:
11
+ rubocop:
12
+ tags: check style
13
+ glob: "*.rb"
14
+ run: bundle exec rubocop --force-exclusion {staged_files}