pelusa 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -1
- data/Gemfile +1 -0
- data/Readme.md +18 -2
- data/bin/pelusa +6 -0
- data/lib/pelusa/lint/indentation_level.rb +0 -37
- data/lib/pelusa/runner.rb +2 -4
- data/lib/pelusa/version.rb +1 -1
- data/lib/pelusa.rb +1 -0
- metadata +4 -4
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Readme.md
CHANGED
@@ -15,11 +15,21 @@ Here's a sample of pelusa linting on its own code base:
|
|
15
15
|
|
16
16
|
![](http://f.cl.ly/items/3Z341M0q2u1K242m0144/%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202012-02-14%20%D0%B2%203.29.38%20PM.png)
|
17
17
|
|
18
|
+
## Why Pelusa?
|
19
|
+
|
20
|
+
Pelusa happens to be Spanish for the word "Lint". Yeah, I couldn't believe it
|
21
|
+
either.
|
22
|
+
|
18
23
|
## Install and usage
|
19
24
|
|
20
25
|
rvm use rbx-head
|
21
26
|
gem install pelusa
|
22
27
|
|
28
|
+
To run pelusa, you must run Rubinius in 1.9 mode. To do this, export this
|
29
|
+
environment variable:
|
30
|
+
|
31
|
+
export RBXOPT=-X19
|
32
|
+
|
23
33
|
Then go to a directory where you have some Ruby code, and type this:
|
24
34
|
|
25
35
|
pelusa path/to/some_file.rb
|
@@ -32,9 +42,9 @@ Or just run all the Ruby files (`**/*.rb`) without arguments:
|
|
32
42
|
|
33
43
|
This project was born as an inspiration from [one of our Monday
|
34
44
|
Talks](http://talks.codegram.com/object-oriented-nirvana) about Object Oriented
|
35
|
-
Nirvana by @oriolgual. After reading [this blog
|
45
|
+
Nirvana by [@oriolgual](http://twitter.com/oriolgual). After reading [this blog
|
36
46
|
post](http://binstock.blogspot.com/2008/04/perfecting-oos-small-classes-and-short.html)
|
37
|
-
he prepared his talk and I (
|
47
|
+
he prepared his talk and I ([@txustice](http://twitter.com/txustice)) found it interesting, so I explored the
|
38
48
|
possibility of programmatically linting these practices on a Ruby project. This
|
39
49
|
*doesn't mean* that any of us thinks these are the true and only practices of
|
40
50
|
Object Orientation, it's just a set of constraints that are fun to follow to
|
@@ -52,6 +62,12 @@ At some point it will be user-extendable by default, but for now you are better
|
|
52
62
|
off forking the project and adding your own lints as you need them in your team
|
53
63
|
(or removing some default ones you don't like).
|
54
64
|
|
65
|
+
## Special mentions
|
66
|
+
|
67
|
+
The beautiful UTF-8 flowers before each lint ran are taken from [Testosterone](http://github.com/masylum/testosterone),
|
68
|
+
a project by [@masylum](http://twitter.com/masylum). They're really beautiful,
|
69
|
+
thanks!!!
|
70
|
+
|
55
71
|
## Contributing
|
56
72
|
|
57
73
|
You can easily contribute to Pelusa. Its codebase is simple and
|
data/bin/pelusa
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
3
3
|
|
4
|
+
warning = %q{Pelusa needs Rubinius to run in 1.9 mode.
|
5
|
+
Please either `export RBXOPT=-X19` before running it or compile Rubinius with
|
6
|
+
1.9 support enabled by default.}
|
7
|
+
|
8
|
+
abort warning unless Rubinius.ruby19?
|
9
|
+
|
4
10
|
require 'pelusa'
|
5
11
|
|
6
12
|
cli = Pelusa::Cli.new(ARGV)
|
@@ -55,40 +55,3 @@ module Pelusa
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
58
|
-
def check_indentation_levels!
|
59
|
-
violations = Set.new
|
60
|
-
|
61
|
-
get_body_from_node = lambda do |node|
|
62
|
-
if node.respond_to?(:body) && !node.body.is_a?(Rubinius::AST::NilLiteral)
|
63
|
-
node.body
|
64
|
-
elsif node.respond_to?(:else)
|
65
|
-
node.else
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
iterate = self.class.iterator do |node|
|
70
|
-
if node.is_a?(Rubinius::AST::Define)
|
71
|
-
_iterate = self.class.iterator do |node|
|
72
|
-
__iterate = self.class.iterator do |node|
|
73
|
-
if body = get_body_from_node[node]
|
74
|
-
if node.line != [body].flatten.first.line
|
75
|
-
violations << body.line
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
Array(get_body_from_node[node]).each(&__iterate)
|
81
|
-
end
|
82
|
-
node.body.array.each(&_iterate)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
report "Doesn't use more than one indentation level" do
|
87
|
-
Array(ast).each(&iterate)
|
88
|
-
if violations.empty?
|
89
|
-
Report.new
|
90
|
-
else
|
91
|
-
Report.new(violations) { |violations| "There's too much of indentation at lines #{violations.to_a.join(', ')}." }
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
data/lib/pelusa/runner.rb
CHANGED
@@ -41,13 +41,11 @@ module Pelusa
|
|
41
41
|
private
|
42
42
|
#######
|
43
43
|
|
44
|
-
# Internal: Returns the
|
45
|
-
# current Rubinius mode.
|
44
|
+
# Internal: Returns the Melbourne 1.9 parser.
|
46
45
|
#
|
47
46
|
# Returns a Rubinius::Melbourne parser.
|
48
47
|
def parser
|
49
|
-
|
50
|
-
Rubinius::Melbourne
|
48
|
+
Rubinius::Melbourne19
|
51
49
|
end
|
52
50
|
end
|
53
51
|
end
|
data/lib/pelusa/version.rb
CHANGED
data/lib/pelusa.rb
CHANGED
metadata
CHANGED
@@ -2,24 +2,24 @@
|
|
2
2
|
name: pelusa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Josep M. Bach
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
version_requirements: &
|
15
|
+
version_requirements: &6324 !ruby/object:Gem::Requirement
|
16
16
|
none: false
|
17
17
|
requirements:
|
18
18
|
- - ! '>='
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0'
|
21
21
|
prerelease: false
|
22
|
-
requirement: *
|
22
|
+
requirement: *6324
|
23
23
|
name: mocha
|
24
24
|
type: :development
|
25
25
|
description: Static analysis Lint-type tool to improve your OO Ruby code
|