rontgen 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +5 -0
- data/lib/rontgen.rb +37 -0
- data/lib/rontgen/flog.rb +26 -0
- data/lib/rontgen/rubocop.rb +17 -0
- data/lib/rontgen/version.rb +5 -0
- data/metrics/flog.yml +2 -0
- data/metrics/rubocop.yml +16 -0
- data/rontgen.gemspec +19 -0
- data/tasks/flog.rake +33 -0
- data/tasks/rontgen.rake +15 -0
- data/tasks/rubocop.rake +20 -0
- data/template/Gemfile +12 -0
- data/template/metrics/flog.yml +2 -0
- data/template/metrics/rubocop.yml +16 -0
- metadata +64 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Handi Wiguna
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Rontgen
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'rontgen'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install rontgen
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/rontgen.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rontgen/version'
|
4
|
+
require 'rake'
|
5
|
+
require 'pathname'
|
6
|
+
|
7
|
+
module Rontgen
|
8
|
+
|
9
|
+
def self.root
|
10
|
+
Pathname('../../').expand_path(__FILE__)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.project_root
|
14
|
+
Pathname.pwd
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.gemfile_template
|
18
|
+
root.join('template/Gemfile')
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.project_gemfile
|
22
|
+
project_root.join('Gemfile.dev')
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.project_metrics
|
26
|
+
project_root.join('metrics')
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.project_lib
|
30
|
+
project_root.join('lib')
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.load_tasks
|
34
|
+
FileList[root.join('tasks/**/*.rake').to_s].each { |task| load(task) }
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
data/lib/rontgen/flog.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'flog'
|
4
|
+
require 'flog_cli'
|
5
|
+
|
6
|
+
module Rontgen
|
7
|
+
class Flog
|
8
|
+
CONFIG = 'flog.yml'.freeze
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@config = YAML.load_file(Rontgen.project_metrics.join(CONFIG))
|
12
|
+
@instance = ::Flog.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def threshold
|
16
|
+
@config.fetch('threshold')
|
17
|
+
end
|
18
|
+
|
19
|
+
def run!
|
20
|
+
@instance.flog(*FlogCLI.expand_dirs_to_files(Rontgen.project_lib))
|
21
|
+
@instance.totals.select { |name, score| name[-5, 5] != '#none' }
|
22
|
+
.map { |name, score| [name, score.round(1)] }
|
23
|
+
.sort_by { |name, score| score }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubocop'
|
4
|
+
|
5
|
+
module Rontgen
|
6
|
+
class Rubocop
|
7
|
+
CONFIG = 'rubocop.yml'.freeze
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@instance = ::Rubocop::CLI.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def run!
|
14
|
+
@instance.run(%W[--config #{Rontgen.project_metrics.join(CONFIG).to_s}])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/metrics/flog.yml
ADDED
data/metrics/rubocop.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
AllCops:
|
2
|
+
Includes:
|
3
|
+
- 'Rakefile'
|
4
|
+
- 'Gemfile'
|
5
|
+
- 'Gemfile.dev'
|
6
|
+
- 'Gemfile.local'
|
7
|
+
- '../**/*.rake'
|
8
|
+
Excludes: []
|
9
|
+
|
10
|
+
# Document classes and non-namespace modules.
|
11
|
+
Documentation:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
# Limit lines to 80 characters.
|
15
|
+
LineLength:
|
16
|
+
Enabled: false
|
data/rontgen.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rontgen/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "rontgen"
|
8
|
+
gem.version = Rontgen::VERSION
|
9
|
+
gem.authors = ["Handi Wiguna"]
|
10
|
+
gem.email = ["handi@domikado.com"]
|
11
|
+
gem.description = ""
|
12
|
+
gem.summary = ""
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
end
|
data/tasks/flog.rake
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
namespace :rontgen do
|
4
|
+
begin
|
5
|
+
require 'rontgen/flog'
|
6
|
+
|
7
|
+
desc 'Code complexity analysis'
|
8
|
+
task :flog do
|
9
|
+
flog = Rontgen::Flog.new
|
10
|
+
threshold = flog.threshold
|
11
|
+
results = flog.run!
|
12
|
+
|
13
|
+
if results.any?
|
14
|
+
max = results.last[1]
|
15
|
+
abort "Adjust flog score down to #{max}" unless max >= threshold
|
16
|
+
end
|
17
|
+
|
18
|
+
bad_methods = results.select { |name, score| score > threshold }
|
19
|
+
if bad_methods.any?
|
20
|
+
bad_methods.reverse_each do |name, score|
|
21
|
+
printf "%8.1f: %s\n", score, name
|
22
|
+
end
|
23
|
+
|
24
|
+
abort "#{bad_methods.size} methods have a flog complexity > #{threshold}"
|
25
|
+
else
|
26
|
+
puts 'OK'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
rescue LoadError
|
31
|
+
puts '**In order to run flog, you must: gem install flog**'
|
32
|
+
end
|
33
|
+
end
|
data/tasks/rontgen.rake
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
namespace :rontgen do
|
6
|
+
desc 'Update Gemfile.dev'
|
7
|
+
task :gemfile do
|
8
|
+
cp Rontgen.gemfile_template, Rontgen.project_gemfile
|
9
|
+
end
|
10
|
+
|
11
|
+
desc 'Copy default config for analysis'
|
12
|
+
task :config do
|
13
|
+
cp_r Rontgen.root.join('template/metrics'), Rontgen.project_root
|
14
|
+
end
|
15
|
+
end
|
data/tasks/rubocop.rake
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
namespace :rontgen do
|
4
|
+
begin
|
5
|
+
require 'rontgen/rubocop'
|
6
|
+
|
7
|
+
desc 'Checking code style'
|
8
|
+
task :rubocop do
|
9
|
+
begin
|
10
|
+
rubocop = Rontgen::Rubocop.new
|
11
|
+
rubocop.run!
|
12
|
+
rescue Encoding::CompatibilityError => exception
|
13
|
+
puts exception.message
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
rescue LoadError
|
18
|
+
puts '**In order to run rubocop, you must: gem install rubocop**'
|
19
|
+
end
|
20
|
+
end
|
data/template/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
AllCops:
|
2
|
+
Includes:
|
3
|
+
- 'Rakefile'
|
4
|
+
- 'Gemfile'
|
5
|
+
- 'Gemfile.dev'
|
6
|
+
- 'Gemfile.local'
|
7
|
+
- '../**/*.rake'
|
8
|
+
Excludes: []
|
9
|
+
|
10
|
+
# Document classes and non-namespace modules.
|
11
|
+
Documentation:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
# Limit lines to 80 characters.
|
15
|
+
LineLength:
|
16
|
+
Enabled: false
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rontgen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Handi Wiguna
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-07-27 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: ''
|
15
|
+
email:
|
16
|
+
- handi@domikado.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- LICENSE.txt
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- lib/rontgen.rb
|
27
|
+
- lib/rontgen/flog.rb
|
28
|
+
- lib/rontgen/rubocop.rb
|
29
|
+
- lib/rontgen/version.rb
|
30
|
+
- metrics/flog.yml
|
31
|
+
- metrics/rubocop.yml
|
32
|
+
- rontgen.gemspec
|
33
|
+
- tasks/flog.rake
|
34
|
+
- tasks/rontgen.rake
|
35
|
+
- tasks/rubocop.rake
|
36
|
+
- template/Gemfile
|
37
|
+
- template/metrics/flog.yml
|
38
|
+
- template/metrics/rubocop.yml
|
39
|
+
homepage: ''
|
40
|
+
licenses: []
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
none: false
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
none: false
|
57
|
+
requirements: []
|
58
|
+
rubyforge_project:
|
59
|
+
rubygems_version: 1.8.23
|
60
|
+
signing_key:
|
61
|
+
specification_version: 3
|
62
|
+
summary: ''
|
63
|
+
test_files: []
|
64
|
+
has_rdoc:
|