attractor 2.0.0 → 2.0.1
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/CHANGELOG.md +4 -0
- data/README.md +150 -67
- data/bin/test +6 -0
- data/lib/attractor/cli.rb +8 -0
- data/lib/attractor/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87ed2febd5e08be404f8589b1f6da07779ce7cef6730395df2bc6940f6b60864
|
4
|
+
data.tar.gz: ac539bf8bab537ae633934f985b1df1223e8a4b3ee783a08c21cd609086d1448
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c46f972f805ed3a86da19a5fbccadd774d65b50f919f1d31d48ac5b0b2393282e332cb513d9c451c61f5e12c962d8923f2ab5133e43706a93811e2ada47dfecd
|
7
|
+
data.tar.gz: 00ca0589082b0ffd7a094beca428d7129cfc05f12b6fd988c013279f3bc7a43d1345c154d5ebc77d4de503481d46c0f0d7e042e1bed84998c6bf5a4b1855c563
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,77 +1,157 @@
|
|
1
|
-
|
1
|
+
<!-- MARKDOWN LINKS & IMAGES -->
|
2
|
+
<!-- Shields -->
|
3
|
+
[forks-shield]: https://img.shields.io/github/forks/julianrubisch/attractor.svg?style=flat-square
|
4
|
+
[forks-url]: https://github.com/julianrubisch/attractor/network/members
|
5
|
+
[stars-shield]: https://img.shields.io/github/stars/julianrubisch/attractor.svg?style=flat-square
|
6
|
+
[stars-url]: https://github.com/julianrubisch/attractor/stargazers
|
7
|
+
[issues-shield]: https://img.shields.io/github/issues/julianrubisch/attractor.svg?style=flat-square
|
8
|
+
[issues-url]: https://github.com/julianrubisch/attractor/issues
|
9
|
+
[license-shield]: https://img.shields.io/github/license/julianrubisch/attractor.svg?style=flat-square
|
10
|
+
[license-url]: https://github.com/julianrubisch/attractor/blob/master/LICENSE
|
11
|
+
[build-status]: https://travis-ci.org/julianrubisch/attractor.svg?branch=master
|
12
|
+
[twitter-shield]: https://img.shields.io/twitter/follow/AttractorGem?style=social
|
13
|
+
[ruby-tests-action-shield]: https://github.com/julianrubisch/attractor/workflows/Ruby%20Tests/badge.svg
|
14
|
+
<!-- Media -->
|
15
|
+
[demo-gif]: https://user-images.githubusercontent.com/4352208/67033292-b41e4280-f115-11e9-8c91-81b3bea4451c.gif
|
16
|
+
[logo-source]: https://thenounproject.com/term/black-hole/1043893
|
17
|
+
<!-- References -->
|
18
|
+
[medium-article]: https://medium.com/better-programming/why-i-made-my-own-code-quality-tool-c44b40ceaafd
|
19
|
+
[sandi-metz-article]: https://www.sandimetz.com/blog/2017/9/13/breaking-up-the-behemoth
|
20
|
+
[michael-feathers-article]: https://www.agileconnection.com/article/getting-empirical-about-refactoring
|
21
|
+
[bundler]: https://bundler.io
|
22
|
+
[rack-livereload]: https://github.com/johnbintz/rack-livereload
|
23
|
+
[guard-livereload]: https://github.com/guard/guard-livereload
|
24
|
+
[attractor-action]: https://github.com/julianrubisch/attractor-action
|
25
|
+
[attractor-action-marketplace]: https://github.com/marketplace/actions/attractor-action
|
26
|
+
[repo]: https://github.com/julianrubisch/attractor
|
27
|
+
|
28
|
+
<!-- PROJECT LOGO -->
|
29
|
+
<br />
|
30
|
+
<div align="center">
|
31
|
+
<a href="https://github.com/julianrubisch/attractor">
|
32
|
+
<img src="https://user-images.githubusercontent.com/4352208/65411858-3dc84200-ddee-11e9-99b6-c9cdbeb533c5.png" alt="Logo" width="80" height="80">
|
33
|
+
</a>
|
34
|
+
<h2 align="center">Attractor</h2>
|
35
|
+
<p align="center">A code complexity metrics visualization and exploration tool for Ruby and JavaScript</p>
|
36
|
+
|
37
|
+
---
|
38
|
+
|
39
|
+
<!-- PROJECT SHIELDS -->
|
40
|
+
![Build Status][build-status]
|
41
|
+
![Ruby Tests Action Status][ruby-tests-action-shield]
|
42
|
+
[![Forks][forks-shield]][forks-url]
|
43
|
+
[![Stargazers][stars-shield]][stars-url]
|
44
|
+
[![Issues][issues-shield]][issues-url]
|
45
|
+
[![MIT License][license-shield]][license-url]
|
2
46
|
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
3
47
|
[](#contributors-)
|
4
48
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
49
|
+
<a href="https://www.patreon.com/user?u=24747270"><img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" alt="Become a Patron!" width="160" /></a>
|
50
|
+
</div>
|
5
51
|
|
6
|
-
|
52
|
+
<!-- GIF -->
|
53
|
+
![attractor_v0 6 1][demo-gif]
|
7
54
|
|
8
|
-
|
55
|
+
## Table of Contents
|
9
56
|
|
10
|
-
|
57
|
+
- [Table of Contents](#table-of-contents)
|
58
|
+
- [Introduction](#introduction)
|
59
|
+
- [Installation](#installation)
|
60
|
+
- [Usage](#usage)
|
61
|
+
- [Live Reloading](#live-reloading)
|
62
|
+
- [CI Usage](#ci-usage)
|
63
|
+
- [Github Action](#github-action)
|
64
|
+
- [Gitlab Example](#gitlab-example)
|
65
|
+
- [CLI Commands and Options](#cli-commands-and-options)
|
66
|
+
- [Development](#development)
|
67
|
+
- [Contributing](#contributing)
|
68
|
+
- [Logo Attribution](#logo-attribution)
|
69
|
+
- [Contributors ✨](#contributors-%e2%9c%a8)
|
11
70
|
|
12
|
-
##
|
71
|
+
## Introduction
|
13
72
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
* [CI Usage](#ci-usage)
|
18
|
-
+ [Github Action](#github-action)
|
19
|
-
+ [Gitlab Example](#gitlab-example)
|
20
|
-
* [CLI Commands and Options](#cli-commands-and-options)
|
21
|
-
* [Development](#development)
|
22
|
-
* [Contributing](#contributing)
|
23
|
-
* [Social](#social)
|
24
|
-
* [Logo Attribution](#logo-attribution)
|
73
|
+
Many authors ([Michael Feathers][michael-feathers-article], [Sandi Metz][sandi-metz-article] have shown that an evaluation of churn vs complexity of files in software projects provide a valuable metric towards code quality. This is another take on the matter, for ruby code, using the `churn` and `flog` projects.
|
74
|
+
|
75
|
+
Here's an [article on medium][medium-article] explaining the approach in greater detail.
|
25
76
|
|
26
77
|
## Installation
|
27
78
|
|
28
|
-
|
79
|
+
Attractor's installation is standard for a Ruby gem:
|
80
|
+
|
81
|
+
```sh
|
82
|
+
gem install attractor
|
83
|
+
```
|
84
|
+
|
85
|
+
You'll also want to install some plugins to go along with the main gem:
|
86
|
+
|
87
|
+
```sh
|
88
|
+
gem install attractor-ruby # https://github.com/julianrubisch/attractor-ruby
|
89
|
+
gem install attractor-javascript # https://github.com/julianrubisch/attractor-javascript
|
90
|
+
```
|
91
|
+
|
92
|
+
You will most likely want to install Attractor using [Bundler][bundler]:
|
29
93
|
|
30
94
|
```ruby
|
31
95
|
gem 'attractor'
|
96
|
+
gem 'attractor-ruby'
|
97
|
+
gem 'attractor-javascript'
|
32
98
|
```
|
33
99
|
|
34
100
|
And then execute:
|
35
101
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
$ gem install attractor
|
102
|
+
```sh
|
103
|
+
bundle
|
104
|
+
```
|
41
105
|
|
42
106
|
## Usage
|
43
107
|
|
44
|
-
To create a HTML report in `attractor_output/index.html
|
45
|
-
|
46
|
-
|
108
|
+
To create a HTML report in `attractor_output/index.html`:
|
109
|
+
|
110
|
+
```sh
|
111
|
+
attractor report
|
112
|
+
```
|
47
113
|
|
48
114
|
If you'd like to specify a directory, use the file prefix option:
|
49
115
|
|
50
|
-
|
116
|
+
```sh
|
117
|
+
attractor report --file_prefix app/models
|
118
|
+
```
|
51
119
|
|
52
120
|
Or shorter:
|
53
121
|
|
54
|
-
|
122
|
+
```sh
|
123
|
+
attractor report -p app/models
|
124
|
+
```
|
55
125
|
|
56
|
-
Check
|
126
|
+
Check JavaScript:
|
57
127
|
|
58
|
-
|
128
|
+
```sh
|
129
|
+
attractor report -p app/javascript -t js
|
130
|
+
```
|
59
131
|
|
60
132
|
Watch for file changes:
|
61
133
|
|
62
|
-
|
134
|
+
```sh
|
135
|
+
attractor report -p app/models --watch
|
136
|
+
```
|
137
|
+
|
138
|
+
Serve at `http://localhost:7890`:
|
63
139
|
|
64
|
-
|
140
|
+
```sh
|
141
|
+
attractor serve -p app/models
|
142
|
+
```
|
65
143
|
|
66
|
-
|
144
|
+
Enable [rack-livereload][rack-livereload]:
|
67
145
|
|
68
|
-
|
146
|
+
```sh
|
147
|
+
attractor serve -p app/models --watch
|
148
|
+
```
|
69
149
|
|
70
|
-
|
150
|
+
_Make sure you prefix these commands with `bundle exec` if you are using Bundler._
|
71
151
|
|
72
152
|
### Live Reloading
|
73
153
|
|
74
|
-
If you have
|
154
|
+
If you have [guard-livereload][guard-livereload] (or a similar service) running on your project, you can leverage the hot reloading functionality by specifying `--watch|-w`. Attractor will then live-reload the browser window when a file watched by `guard-livereload` changes.
|
75
155
|
|
76
156
|
## CI Usage
|
77
157
|
|
@@ -79,7 +159,9 @@ To use this CLI in a CI environment, use the `--ci` option, which will suppress
|
|
79
159
|
|
80
160
|
### Github Action
|
81
161
|
|
82
|
-
There is a dedicated [Github Action]
|
162
|
+
There is a dedicated [Github Action][attractor-action] that will compile Attractor's output.
|
163
|
+
|
164
|
+
You can quickly integrate it into your action's workflow by grabbing it on the [Marketplace][attractor-action-marketplace].
|
83
165
|
|
84
166
|
### Gitlab Example
|
85
167
|
|
@@ -98,56 +180,57 @@ attractor:
|
|
98
180
|
- attractor_output
|
99
181
|
```
|
100
182
|
|
101
|
-
Alternatively,
|
102
|
-
|
103
183
|
## CLI Commands and Options
|
104
184
|
|
105
185
|
Print a simple output to console:
|
106
186
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
187
|
+
```sh
|
188
|
+
attractor calc
|
189
|
+
--file_prefix|-p app/models
|
190
|
+
--type|-t rb|js
|
191
|
+
--watch|-w
|
192
|
+
--start_ago|-s (e.g. 5y, 3m, 7w)
|
193
|
+
--minimum_churn|-c (minimum times a file must have changed to be processed)
|
194
|
+
```
|
113
195
|
|
114
196
|
Generate a full report
|
115
197
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
198
|
+
```sh
|
199
|
+
attractor report
|
200
|
+
--file_prefix|-p app/models
|
201
|
+
--type|-t rb|js
|
202
|
+
--watch|-w
|
203
|
+
--no-open-browser|--ci
|
204
|
+
--start_ago|-s (e.g. 5y, 3m, 7w)
|
205
|
+
--minimum_churn|-c (minimum times a file must have changed to be processed)
|
206
|
+
```
|
123
207
|
|
124
|
-
Serve the output on http://localhost:7890
|
208
|
+
Serve the output on `http://localhost:7890`
|
125
209
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
210
|
+
```sh
|
211
|
+
attractor serve
|
212
|
+
--file_prefix|-p app/models
|
213
|
+
--watch|-w
|
214
|
+
--no-open-browser|--ci
|
215
|
+
--start_ago|-s (e.g. 5y, 3m, 7w)
|
216
|
+
--minimum_churn|-c (minimum times a file must have changed to be processed)
|
217
|
+
```
|
132
218
|
|
133
219
|
## Development
|
134
220
|
|
135
|
-
After checking out the repo, run `bin/setup` to install dependencies.
|
221
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
222
|
+
|
223
|
+
To run all tests, run `bin/test`. You can run the specs by themselves with `bundle exec rspec`, and the cucumber features with `bundle exec cucumber`.
|
136
224
|
|
137
225
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
138
226
|
|
139
227
|
## Contributing
|
140
228
|
|
141
|
-
Bug reports and pull requests are welcome on GitHub
|
142
|
-
|
143
|
-
## Social
|
144
|
-
|
145
|
-
[Twitter](https://twitter.com/AttractorGem)
|
146
|
-
|
147
|
-
[Patreon](https://www.patreon.com/user?u=24747270)
|
229
|
+
Bug reports and pull requests are welcome on [GitHub][repo].
|
148
230
|
|
149
231
|
## Logo Attribution
|
150
|
-
|
232
|
+
|
233
|
+
[Black Hole by Eynav Raphael from the Noun Project][logo-source]
|
151
234
|
|
152
235
|
## Contributors ✨
|
153
236
|
|
data/bin/test
ADDED
data/lib/attractor/cli.rb
CHANGED
@@ -17,6 +17,14 @@ module Attractor
|
|
17
17
|
[:no_open_browser, type: :boolean],
|
18
18
|
[:ci, type: :boolean]]
|
19
19
|
|
20
|
+
desc "version", "Prints Attractor's version information"
|
21
|
+
map %w(-v --version) => :version
|
22
|
+
def version
|
23
|
+
puts "Attractor version #{Attractor::VERSION}"
|
24
|
+
rescue RuntimeError => e
|
25
|
+
puts "Runtime error: #{e.message}"
|
26
|
+
end
|
27
|
+
|
20
28
|
desc 'calc', 'Calculates churn and complexity for all ruby files in current directory'
|
21
29
|
shared_options.each do |shared_option|
|
22
30
|
option(*shared_option)
|
data/lib/attractor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attractor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Rubisch
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: churn
|
@@ -379,6 +379,7 @@ files:
|
|
379
379
|
- attractor.gemspec
|
380
380
|
- bin/console
|
381
381
|
- bin/setup
|
382
|
+
- bin/test
|
382
383
|
- dist/calculator.bundle.js
|
383
384
|
- exe/attractor
|
384
385
|
- lib/attractor.rb
|