roodi 3.1.1 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -4
- data/History.txt +8 -0
- data/README.md +20 -3
- data/Rakefile +2 -11
- data/bin/roodi +5 -5
- data/lib/roodi/core/runner.rb +24 -0
- data/lib/roodi/version.rb +1 -1
- data/lib/roodi_task.rb +10 -5
- data/spec/roodi/core/runner_spec.rb +19 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc65ef0c9ffac9f896579cda0a56572065ea813f
|
4
|
+
data.tar.gz: 8c0c7e0b9ca16a6f2e2597fc38677c6ac12ea663
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5ff37f5f09ebfab6113e5fcf9e0705998ff1067174df0be337f4ee3b42fcfadc1273639e7447e56b26bb89089879f16e2fbd5d8a68598473211f345b2e38eb9
|
7
|
+
data.tar.gz: 6f07ed9c3bb7f711daf43f5ce2108b98654f06a315aed57c83e3d0d236d790a517d8811868d98e3ac18db5fa588504718e2541839107b3a7fe85e9e39a95edd4
|
data/.travis.yml
CHANGED
data/History.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
= 3.2.0
|
2
|
+
* Checks all files under current directory by default
|
3
|
+
* Made it easier to run for the whole project as a rake task
|
4
|
+
* Added instructions for how to add Roodi to your Rakefile
|
5
|
+
* Removed support for Ruby Enterprise Edition
|
6
|
+
* Removed support for Ruby 1.8
|
7
|
+
* Improved installation instructions and corrected spelling error
|
8
|
+
|
1
9
|
= 3.1.1
|
2
10
|
* Merge pull request #23 from metricfu/remove_rubygems_require
|
3
11
|
* Fix ruby warnings
|
data/README.md
CHANGED
@@ -1,16 +1,21 @@
|
|
1
1
|
# roodi
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/roodi/roodi.png?branch=master)](https://travis-ci.org/roodi/roodi)
|
4
|
-
[![Code Climate](https://codeclimate.com/repos/5204c3fc7e00a47bf7015e4e/badges/44ede0c56a53ff100012/gpa.png)](https://codeclimate.com/repos/5204c3fc7e00a47bf7015e4e/feed)
|
5
4
|
[![Coverage Status](https://coveralls.io/repos/roodi/roodi/badge.png?branch=master)](https://coveralls.io/r/roodi/roodi?branch=master)
|
6
5
|
|
7
6
|
## Description
|
8
7
|
|
9
|
-
Roodi stands for Ruby Object Oriented Design Inferometer. It parses your Ruby code and warns you about design issues you have based on the checks that
|
8
|
+
Roodi stands for Ruby Object Oriented Design Inferometer. It parses your Ruby code and warns you about design issues you have based on the checks that it has configured.
|
10
9
|
|
11
10
|
## Install
|
12
11
|
|
13
|
-
|
12
|
+
Open your terminal and type this:
|
13
|
+
|
14
|
+
`$ gem install roodi`
|
15
|
+
|
16
|
+
Alternatively, you can put it in your Gemfile:
|
17
|
+
|
18
|
+
`gem "roodi"`
|
14
19
|
|
15
20
|
## Synopsis
|
16
21
|
|
@@ -20,6 +25,10 @@ To check one or more files using the default configuration that comes with Roodi
|
|
20
25
|
|
21
26
|
## Example Usage
|
22
27
|
|
28
|
+
Check all ruby files recursively under the current directory:
|
29
|
+
|
30
|
+
`$ roodi` or `$ roodi .`
|
31
|
+
|
23
32
|
Check all ruby files in a rails app:
|
24
33
|
|
25
34
|
`$ roodi "rails_app/**/*.rb"`
|
@@ -40,6 +49,14 @@ If you're writing a check, it is useful to see the structure of a file the way t
|
|
40
49
|
|
41
50
|
`$ roodi-describe [filename]`
|
42
51
|
|
52
|
+
## Running it as part of your build
|
53
|
+
|
54
|
+
Add the following to your Rakefile:
|
55
|
+
|
56
|
+
require 'roodi_task'
|
57
|
+
RoodiTask.new
|
58
|
+
task :default => [:roodi]
|
59
|
+
|
43
60
|
## Custom Configuration
|
44
61
|
|
45
62
|
To change the set of checks included, or to change the default values of the checks, you can provide your own config file. The config file is a YAML file that lists the checks to be included. Each check can optionally include a hash of options that are passed to the check to configure it. For example, the default config file looks like this:
|
data/Rakefile
CHANGED
@@ -3,21 +3,12 @@ require 'rspec/core/rake_task'
|
|
3
3
|
require 'bundler'
|
4
4
|
require 'roodi'
|
5
5
|
require 'bundler/gem_tasks'
|
6
|
-
|
7
|
-
def roodi(ruby_files)
|
8
|
-
roodi = Roodi::Core::Runner.new
|
9
|
-
ruby_files.each { |file| roodi.check_file(file) }
|
10
|
-
roodi.errors.each {|error| puts error}
|
11
|
-
puts "\nFound #{roodi.errors.size} errors."
|
12
|
-
end
|
6
|
+
require 'roodi_task'
|
13
7
|
|
14
8
|
desc "Run all specs"
|
15
9
|
RSpec::Core::RakeTask.new(:spec)
|
16
10
|
|
17
11
|
desc "Run Roodi against all source files"
|
18
|
-
|
19
|
-
pattern = File.join(File.dirname(__FILE__), "**", "*.rb")
|
20
|
-
roodi(Dir.glob(pattern))
|
21
|
-
end
|
12
|
+
RoodiTask.new
|
22
13
|
|
23
14
|
task :default => [:spec, :roodi]
|
data/bin/roodi
CHANGED
@@ -10,12 +10,12 @@ config_param = ARGV.detect {|arg| arg =~ /-config=.*/}
|
|
10
10
|
runner.config = config_param.split("=")[1] if config_param
|
11
11
|
ARGV.delete config_param
|
12
12
|
|
13
|
-
|
14
|
-
Dir.glob(arg).each { |file| runner.check_file(file) }
|
15
|
-
end
|
13
|
+
puts "\nRunning Roodi checks"
|
16
14
|
|
15
|
+
runner.start(ARGV)
|
17
16
|
runner.errors.each {|error| puts error}
|
18
17
|
|
19
|
-
puts "\
|
18
|
+
puts "\nChecked #{runner.files_checked} files"
|
19
|
+
puts "Found #{runner.errors.size} errors"
|
20
20
|
|
21
|
-
exit runner.errors.size
|
21
|
+
exit runner.errors.size
|
data/lib/roodi/core/runner.rb
CHANGED
@@ -11,12 +11,36 @@ module Roodi
|
|
11
11
|
DEFAULT_CONFIG = File.join(File.dirname(__FILE__), "..", "..", "..", "roodi.yml")
|
12
12
|
|
13
13
|
attr_writer :config
|
14
|
+
attr_reader :files_checked
|
14
15
|
|
15
16
|
def initialize(*checks)
|
16
17
|
@config = DEFAULT_CONFIG
|
17
18
|
@checks = checks unless checks.empty?
|
18
19
|
end
|
19
20
|
|
21
|
+
def start(paths)
|
22
|
+
paths = ['.'] if paths == []
|
23
|
+
all_files = collect_files(paths)
|
24
|
+
@files_checked = all_files.count
|
25
|
+
all_files.each do |path|
|
26
|
+
check_file(path)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def collect_files(paths)
|
31
|
+
files = []
|
32
|
+
paths.each do |path|
|
33
|
+
if File.file?(path)
|
34
|
+
files << path
|
35
|
+
elsif File.directory?(path)
|
36
|
+
files += Dir.glob(File.join(path, '**/*.{rb,erb}'))
|
37
|
+
else
|
38
|
+
files += Dir.glob(path)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
files
|
42
|
+
end
|
43
|
+
|
20
44
|
def check(filename, content)
|
21
45
|
@checks ||= load_checks
|
22
46
|
@checker ||= CheckingVisitor.new(@checks)
|
data/lib/roodi/version.rb
CHANGED
data/lib/roodi_task.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'rake/tasklib'
|
2
|
+
require 'roodi'
|
3
|
+
|
1
4
|
class RoodiTask < Rake::TaskLib
|
2
5
|
attr_accessor :name
|
3
6
|
attr_accessor :patterns
|
@@ -6,7 +9,7 @@ class RoodiTask < Rake::TaskLib
|
|
6
9
|
|
7
10
|
def initialize name = :roodi, patterns = nil, config = nil
|
8
11
|
@name = name
|
9
|
-
@patterns = patterns ||
|
12
|
+
@patterns = patterns || []
|
10
13
|
@config = config
|
11
14
|
@verbose = Rake.application.options.trace
|
12
15
|
|
@@ -16,18 +19,20 @@ class RoodiTask < Rake::TaskLib
|
|
16
19
|
end
|
17
20
|
|
18
21
|
def define
|
19
|
-
desc "
|
22
|
+
desc "Run Roodi against all source files"
|
20
23
|
task name do
|
24
|
+
puts "\nRunning Roodi checks"
|
25
|
+
|
21
26
|
runner = Roodi::Core::Runner.new
|
22
27
|
|
23
28
|
runner.config = config if config
|
24
29
|
|
25
|
-
patterns
|
26
|
-
Dir.glob(pattern).each { |file| runner.check_file(file) }
|
27
|
-
end
|
30
|
+
runner.start(@patterns)
|
28
31
|
|
29
32
|
runner.errors.each {|error| puts error}
|
30
33
|
|
34
|
+
puts "\nChecked #{runner.files_checked} files"
|
35
|
+
|
31
36
|
raise "Found #{runner.errors.size} errors." unless runner.errors.empty?
|
32
37
|
end
|
33
38
|
self
|
@@ -32,6 +32,25 @@ describe Roodi::Core::Runner do
|
|
32
32
|
expect(subject.errors).to_not be_empty
|
33
33
|
expect(subject.errors[0]).to eq "dummy-file.rb looks like it's not a valid Ruby file."
|
34
34
|
end
|
35
|
+
|
36
|
+
it "checks that one file" do
|
37
|
+
subject.start(['lib/roodi.rb'])
|
38
|
+
expect(subject.files_checked).to eq 1
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "running against a directory" do
|
43
|
+
it "checks all files in that directory recursively" do
|
44
|
+
subject.start(['.'])
|
45
|
+
expect(subject.files_checked).to be > 1
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "running without specifying files or directory" do
|
50
|
+
it "checks all files in that directory recursively" do
|
51
|
+
subject.start([])
|
52
|
+
expect(subject.files_checked).to be > 1
|
53
|
+
end
|
35
54
|
end
|
36
55
|
|
37
56
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roodi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marty Andrews
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-11-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ruby_parser
|