attractor-ruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/Gemfile +4 -0
- data/README.md +138 -0
- data/Rakefile +6 -0
- data/attractor-ruby.gemspec +47 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/attractor/calculators/ruby_calculator.rb +22 -0
- data/lib/attractor/detectors/ruby_detector.rb +11 -0
- data/lib/attractor/ruby.rb +16 -0
- data/lib/attractor/ruby/version.rb +5 -0
- metadata +184 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f49f91fe9ce4ac23462d87c370dc81c9d566df19c9c830e0b5d0718eb7e88be1
|
4
|
+
data.tar.gz: d1203212d502ff645aebde5652f3bfc906db3270429cb74e3eb271283a7358a1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 34dc390b7985db69ef4d8fd0f7e2dc015a84f469c5e87ac71862d4ee280514827c02728e93e4e802a91c64ac8d1168e965c5f5cc94071688947c5a36af43a241
|
7
|
+
data.tar.gz: a1c62f7ad1d10bf0a8750e8b4d9a4ed09b3d58dfcf57e685fd8a2978850586e00be9dea006d4d966697042d0d319e45c35773a6791030f7cc571810a4472a5eb
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
<!-- MARKDOWN LINKS & IMAGES -->
|
2
|
+
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
3
|
+
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)
|
4
|
+
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
5
|
+
[attractor]: https://github.com/julianrubisch/attractor-ruby
|
6
|
+
[forks-shield]: https://img.shields.io/github/forks/julianrubisch/attractor-ruby.svg?style=flat-square
|
7
|
+
[forks-url]: https://github.com/julianrubisch/attractor-ruby/network/members
|
8
|
+
[stars-shield]: https://img.shields.io/github/stars/julianrubisch/attractor-ruby.svg?style=flat-square
|
9
|
+
[stars-url]: https://github.com/julianrubisch/attractor-ruby/stargazers
|
10
|
+
[issues-shield]: https://img.shields.io/github/issues/julianrubisch/attractor-ruby.svg?style=flat-square
|
11
|
+
[issues-url]: https://github.com/julianrubisch/attractor-ruby/issues
|
12
|
+
<!-- [license-shield]: https://img.shields.io/github/license/julianrubisch/attractor-ruby.svg?style=flat-square -->
|
13
|
+
<!-- [license-url]: https://github.com/julianrubisch/attractor-ruby/blob/master/LICENSE.txt -->
|
14
|
+
|
15
|
+
<!-- PROJECT SHIELDS -->
|
16
|
+
|
17
|
+
[![Forks][forks-shield]][forks-url]
|
18
|
+
[![Stargazers][stars-shield]][stars-url]
|
19
|
+
[![Issues][issues-shield]][issues-url]
|
20
|
+
<!--[![MIT License][license-shield]][license-url]-->
|
21
|
+
|
22
|
+
|
23
|
+
<!-- PROJECT LOGO -->
|
24
|
+
<br />
|
25
|
+
<p align="center">
|
26
|
+
<a href="https://github.com/julianrubisch/attractor">
|
27
|
+
<img src="https://user-images.githubusercontent.com/4352208/65411858-3dc84200-ddee-11e9-99b6-c9cdbeb533c5.png" alt="Logo" width="80" height="80">
|
28
|
+
</a>
|
29
|
+
|
30
|
+
<h2 align="center">Attractor Ruby Plugin</h2>
|
31
|
+
</p>
|
32
|
+
|
33
|
+
[Attractor][attractor] plugin for the Ruby programming language and its ecosystem
|
34
|
+
|
35
|
+
|
36
|
+
<!-- TABLE OF CONTENTS -->
|
37
|
+
## Table of Contents
|
38
|
+
|
39
|
+
- [Table of Contents](#table-of-contents)
|
40
|
+
- [Getting Started](#getting-started)
|
41
|
+
- [Installation](#installation)
|
42
|
+
- [Usage](#usage)
|
43
|
+
- [Contributing](#contributing)
|
44
|
+
|
45
|
+
<!-- GETTING STARTED -->
|
46
|
+
## Getting Started
|
47
|
+
|
48
|
+
This is a plugin to help you visualize code complexity metrics for your Ruby code. If you are not familiar with [Attractor][attractor], take a look at the main repo first.
|
49
|
+
|
50
|
+
### Installation
|
51
|
+
|
52
|
+
Add this to your application's Gemfile:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
gem 'attractor'
|
56
|
+
gem 'attractor-ruby'
|
57
|
+
```
|
58
|
+
|
59
|
+
And then execute:
|
60
|
+
|
61
|
+
```sh
|
62
|
+
bundle install
|
63
|
+
```
|
64
|
+
|
65
|
+
<!-- USAGE EXAMPLES -->
|
66
|
+
## Usage
|
67
|
+
|
68
|
+
To create a HTML report in `attractor_output/index.html`, try
|
69
|
+
|
70
|
+
```sh
|
71
|
+
bundle exec attractor report
|
72
|
+
```
|
73
|
+
|
74
|
+
If you'd like to specify a directory, use the file prefix option:
|
75
|
+
|
76
|
+
```sh
|
77
|
+
bundle exec attractor report --file_prefix app/models
|
78
|
+
```
|
79
|
+
|
80
|
+
Or shorter:
|
81
|
+
|
82
|
+
```sh
|
83
|
+
bundle exec attractor report -p app/models
|
84
|
+
```
|
85
|
+
|
86
|
+
Watch for file changes:
|
87
|
+
|
88
|
+
```sh
|
89
|
+
bundle exec attractor report -p app/models --watch
|
90
|
+
```
|
91
|
+
|
92
|
+
Serve at http://localhost:7890:
|
93
|
+
|
94
|
+
```sh
|
95
|
+
bundle exec attractor serve -p app/models
|
96
|
+
```
|
97
|
+
|
98
|
+
Enable rack-livereload:
|
99
|
+
|
100
|
+
```sh
|
101
|
+
bundle exec attractor serve -p app/models --watch
|
102
|
+
```
|
103
|
+
|
104
|
+
<!-- CONTRIBUTING -->
|
105
|
+
## Contributing
|
106
|
+
|
107
|
+
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.
|
108
|
+
|
109
|
+
1. Fork the Project
|
110
|
+
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
|
111
|
+
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
|
112
|
+
4. Push to the Branch (`git push origin feature/AmazingFeature`)
|
113
|
+
5. Open a Pull Request
|
114
|
+
|
115
|
+
<!-- LICENSE -->
|
116
|
+
<!--## License -->
|
117
|
+
|
118
|
+
<!-- Distributed under the MIT License. See `LICENSE` for more information. -->
|
119
|
+
|
120
|
+
## Contributors ✨
|
121
|
+
|
122
|
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
123
|
+
|
124
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
125
|
+
<!-- prettier-ignore-start -->
|
126
|
+
<!-- markdownlint-disable -->
|
127
|
+
<table>
|
128
|
+
<tr>
|
129
|
+
<td align="center"><a href="https://www.andrewmason.me/"><img src="https://avatars1.githubusercontent.com/u/18423853?v=4" width="100px;" alt=""/><br /><sub><b>Andrew Mason</b></sub></a><br /><a href="https://github.com/julianrubisch/attractor-ruby/commits?author=andrewmcodes" title="Documentation">📖</a> <a href="https://github.com/julianrubisch/attractor-ruby/commits?author=andrewmcodes" title="Code">💻</a></td>
|
130
|
+
<td align="center"><a href="http://www.julianrubisch.at"><img src="https://avatars0.githubusercontent.com/u/4352208?v=4" width="100px;" alt=""/><br /><sub><b>Julian Rubisch</b></sub></a><br /><a href="https://github.com/julianrubisch/attractor-ruby/commits?author=julianrubisch" title="Code">💻</a></td>
|
131
|
+
</tr>
|
132
|
+
</table>
|
133
|
+
|
134
|
+
<!-- markdownlint-enable -->
|
135
|
+
<!-- prettier-ignore-end -->
|
136
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
137
|
+
|
138
|
+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'attractor/ruby/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'attractor-ruby'
|
9
|
+
spec.version = Attractor::Ruby::VERSION
|
10
|
+
spec.authors = ['Julian Rubisch']
|
11
|
+
spec.email = ['julian@julianrubisch.at']
|
12
|
+
|
13
|
+
spec.summary = 'Attractor plugin for the Ruby programming language and its ecosystem'
|
14
|
+
spec.description = <<-DESCRIPTION
|
15
|
+
Attractor plugin for the Ruby programming language and its ecosystem
|
16
|
+
DESCRIPTION
|
17
|
+
spec.homepage = 'https://github.com/julianrubisch/attractor-ruby'
|
18
|
+
spec.licenses = ['MIT']
|
19
|
+
|
20
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
21
|
+
spec.metadata['source_code_uri'] = 'https://github.com/julianrubisch/attractor-ruby'
|
22
|
+
spec.metadata['bug_tracker_uri'] = "#{spec.homepage}/issues"
|
23
|
+
spec.metadata['changelog_uri'] = 'https://github.com/julianrubisch/attractor-ruby/CHANGELOG.md'
|
24
|
+
|
25
|
+
# Specify which files should be added to the gem when it is released.
|
26
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
27
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
28
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
29
|
+
f.match(%r{^(src|tmp|test|spec|features|\.github)/}) ||
|
30
|
+
%w[.all-contributorsrc .rspec .rspec_status .travis.yml].include?(f)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
spec.bindir = 'exe'
|
34
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
35
|
+
spec.require_paths = ['lib']
|
36
|
+
|
37
|
+
spec.add_dependency 'attractor', '~> 2.0'
|
38
|
+
|
39
|
+
spec.add_development_dependency 'aruba'
|
40
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
41
|
+
spec.add_development_dependency 'cucumber'
|
42
|
+
spec.add_development_dependency 'pry'
|
43
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
44
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
45
|
+
spec.add_development_dependency 'standard'
|
46
|
+
spec.add_development_dependency 'structured_changelog'
|
47
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "attractor/ruby"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'flog'
|
4
|
+
|
5
|
+
module Attractor
|
6
|
+
class RubyCalculator < BaseCalculator
|
7
|
+
def initialize(file_prefix: '', minimum_churn_count: 3, start_ago: 365 * 5)
|
8
|
+
super(file_prefix: file_prefix, file_extension: 'rb', minimum_churn_count: minimum_churn_count, start_ago: start_ago)
|
9
|
+
@type = "Ruby"
|
10
|
+
end
|
11
|
+
|
12
|
+
def calculate
|
13
|
+
super do |change|
|
14
|
+
flogger = Flog.new(all: true)
|
15
|
+
flogger.flog(change[:file_path])
|
16
|
+
complexity = flogger.total_score
|
17
|
+
details = flogger.totals
|
18
|
+
[complexity, details]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "attractor/ruby/version"
|
2
|
+
|
3
|
+
require "attractor"
|
4
|
+
require "attractor/registry_entry"
|
5
|
+
require "attractor/calculators/base_calculator"
|
6
|
+
require "attractor/calculators/ruby_calculator"
|
7
|
+
require "attractor/detectors/base_detector"
|
8
|
+
require "attractor/detectors/ruby_detector"
|
9
|
+
|
10
|
+
module Attractor
|
11
|
+
module Ruby
|
12
|
+
class Error < StandardError; end
|
13
|
+
|
14
|
+
Attractor.register(Attractor::RegistryEntry.new(type: "rb", detector_class: RubyDetector, calculator_class: RubyCalculator))
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: attractor-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Julian Rubisch
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-02-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: attractor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: aruba
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: cucumber
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: standard
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: structured_changelog
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: " Attractor plugin for the Ruby programming language and its ecosystem\n"
|
140
|
+
email:
|
141
|
+
- julian@julianrubisch.at
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- ".gitignore"
|
147
|
+
- Gemfile
|
148
|
+
- README.md
|
149
|
+
- Rakefile
|
150
|
+
- attractor-ruby.gemspec
|
151
|
+
- bin/console
|
152
|
+
- bin/setup
|
153
|
+
- lib/attractor/calculators/ruby_calculator.rb
|
154
|
+
- lib/attractor/detectors/ruby_detector.rb
|
155
|
+
- lib/attractor/ruby.rb
|
156
|
+
- lib/attractor/ruby/version.rb
|
157
|
+
homepage: https://github.com/julianrubisch/attractor-ruby
|
158
|
+
licenses:
|
159
|
+
- MIT
|
160
|
+
metadata:
|
161
|
+
homepage_uri: https://github.com/julianrubisch/attractor-ruby
|
162
|
+
source_code_uri: https://github.com/julianrubisch/attractor-ruby
|
163
|
+
bug_tracker_uri: https://github.com/julianrubisch/attractor-ruby/issues
|
164
|
+
changelog_uri: https://github.com/julianrubisch/attractor-ruby/CHANGELOG.md
|
165
|
+
post_install_message:
|
166
|
+
rdoc_options: []
|
167
|
+
require_paths:
|
168
|
+
- lib
|
169
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - ">="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
requirements: []
|
180
|
+
rubygems_version: 3.0.3
|
181
|
+
signing_key:
|
182
|
+
specification_version: 4
|
183
|
+
summary: Attractor plugin for the Ruby programming language and its ecosystem
|
184
|
+
test_files: []
|