pronto-rails_best_practices 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3440811c91e6bfd30091b7855face978bcbb7c8e
4
+ data.tar.gz: 6aa44c7c02ccf13ec9c899cea7f3eb37874833ef
5
+ SHA512:
6
+ metadata.gz: d23f37dc97d1dbbe24c5f86427cfd0da2ad8be01f6d610d15d649f7a2721421193966e92602241de626252b88c28fb431714c66dd8bb69dafb54135aa5d2fb70
7
+ data.tar.gz: 81a7c7cab0057d15e3ff06ce00d8117c62ad1793dbb80afb79dcdc54d8c651b38eb48581508d6d50671f8a17b98e77cd38cd9b6adf93f86196cc686dc0a5e3f6
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2013 Mindaugas Mozūras
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # Pronto runner for Rails Best Practices
2
+
3
+ [![Code Climate](https://codeclimate.com/github/mmozuras/pronto-rails_best_practices.png)](https://codeclimate.com/github/mmozuras/pronto-rails_best_practices)
4
+ [![Build Status](https://travis-ci.org/mmozuras/pronto-rails_best_practices.png)](https://travis-ci.org/mmozuras/pronto-rails_best_practices)
5
+ [![Dependency Status](https://gemnasium.com/mmozuras/pronto-rails_best_practices.png)](https://gemnasium.com/mmozuras/pronto-rails_best_practices)
6
+
7
+ Pronto runner for [Rails Best Practices](https://github.com/railsbp/rails_best_practices), code metric tool for Rails projects. [What is Pronto?](https://github.com/mmozuras/pronto)
@@ -0,0 +1,50 @@
1
+ require 'pronto'
2
+ require 'rails_best_practices'
3
+
4
+ module Pronto
5
+ class RailsBestPractices < Runner
6
+ def run(patches)
7
+ return [] unless patches
8
+
9
+ patches_with_additions = patches.select { |patch| patch.additions > 0 }
10
+
11
+ files = patches_with_additions.map do |patch|
12
+ Regexp.new(patch.new_file_full_path.to_s)
13
+ end
14
+
15
+ if files.any?
16
+ analyzer = ::RailsBestPractices::Analyzer.new('.', { 'silent' => true,
17
+ 'only' => files })
18
+ analyzer.analyze
19
+ messages_for(patches_with_additions, analyzer.errors).compact
20
+ else
21
+ []
22
+ end
23
+ end
24
+
25
+ def messages_for(patches, errors)
26
+ errors.map do |error|
27
+ patch = patch_for_error(patches, error)
28
+
29
+ if patch
30
+ line = patch.added_lines.find do |added_line|
31
+ added_line.new_lineno == error.line_number.to_i
32
+ end
33
+
34
+ new_message(line, error) if line
35
+ end
36
+ end
37
+ end
38
+
39
+ def new_message(line, error)
40
+ Message.new(line.patch.delta.new_file[:path], line, :warning,
41
+ error.message.capitalize)
42
+ end
43
+
44
+ def patch_for_error(patches, error)
45
+ patches.find do |patch|
46
+ patch.new_file_full_path.to_s == error.filename
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,5 @@
1
+ module Pronto
2
+ module RailsBestPracticesVersion
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pronto-rails_best_practices
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mindaugas Mozūras
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pronto
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails_best_practices
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.14.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.14.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 10.1.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 10.1.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.14.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 2.14.0
69
+ description:
70
+ email: mindaugas.mozuras@gmail.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - lib/pronto/rails_best_practices/version.rb
76
+ - lib/pronto/rails_best_practices.rb
77
+ - LICENSE
78
+ - README.md
79
+ homepage: http://github.org/mmozuras/pronto-rails_best_practices
80
+ licenses:
81
+ - MIT
82
+ metadata: {}
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: 1.3.6
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.0.7
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: Pronto runner for Rails Best Practices, code metric tool for Rails projects
103
+ test_files: []
104
+ has_rdoc: