pronto-fasterer 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dd221421de004195b8ade84dd1ae4e9ca6d24847
4
+ data.tar.gz: c10d829747f9f6bf988160127b9600c56e35c4b9
5
+ SHA512:
6
+ metadata.gz: 5aa3e16bc4e5f8e7858ebd3226787915bb0fec94e5731cf1799d8f320baeadce0548f8fd1551d10a5ce794cfc6d7dc9024077b06caa28b01d148148d326309fb
7
+ data.tar.gz: 49c9b43c2bc45cd3d1f5280d2f0af4506fb66ff98a0398ca8b04975fd9e031e6676d82327999ed4a46f0246eb164afea509d3427d753eb5f6b702174c07d69c7
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2015 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,12 @@
1
+ # Pronto runner for Fasterer
2
+
3
+ [![Code Climate](https://codeclimate.com/github/mmozuras/pronto-fasterer.png)](https://codeclimate.com/github/mmozuras/pronto-fasterer)
4
+ [![Build Status](https://travis-ci.org/mmozuras/pronto-fasterer.png)](https://travis-ci.org/mmozuras/pronto-fasterer)
5
+ [![Gem Version](https://badge.fury.io/rb/pronto-fasterer.png)](http://badge.fury.io/rb/pronto-fasterer)
6
+ [![Dependency Status](https://gemnasium.com/mmozuras/pronto-fasterer.png)](https://gemnasium.com/mmozuras/pronto-fasterer)
7
+
8
+ Pronto runner for [Fasterer](https://github.com/DamirSvrtan/fasterer), speed improvements suggester. [What is Pronto?](https://github.com/mmozuras/pronto)
9
+
10
+ ## Configuration
11
+
12
+ Configuring Fasterer via .fasterer.yml will work just fine with pronto-fasterer.
@@ -0,0 +1,5 @@
1
+ module Pronto
2
+ module FastererVersion
3
+ VERSION = '0.4.0'
4
+ end
5
+ end
@@ -0,0 +1,70 @@
1
+ require 'pronto'
2
+ require 'fasterer'
3
+ require 'yaml'
4
+
5
+ module Pronto
6
+ class Fasterer < Runner
7
+ CONFIG_FILE_NAME = '.fasterer.yml'
8
+ SPEEDUPS_KEY = 'speedups'
9
+ EXCLUDE_PATHS_KEY = 'exclude_paths'
10
+
11
+ def initialize
12
+ end
13
+
14
+ def run(patches, _)
15
+ return [] unless patches
16
+
17
+ valid_patches = patches.select do |patch|
18
+ patch.additions > 0 &&
19
+ ruby_file?(patch.new_file_full_path) &&
20
+ !ignored_files.include?(patch.delta.new_file[:path])
21
+ end
22
+
23
+ valid_patches.map { |patch| inspect(patch) }.flatten.compact
24
+ end
25
+
26
+ def inspect(patch)
27
+ analyzer = ::Fasterer::Analyzer.new(patch.new_file_full_path)
28
+ analyzer.scan
29
+
30
+ errors = []
31
+ analyzer.errors.each { |error| errors << error }
32
+
33
+ errors
34
+ .select { |error| !ignored_speedups.include?(error.name) }
35
+ .flat_map do |error|
36
+ patch.added_lines
37
+ .select { |line| line.new_lineno == error.line }
38
+ .map { |line| new_message(error, line) }
39
+ end
40
+ end
41
+
42
+ def new_message(error, line)
43
+ path = line.patch.delta.new_file[:path]
44
+ Message.new(path, line, :warning, error.explanation)
45
+ end
46
+
47
+ def ignored_speedups
48
+ @ignored_speedups ||= config[SPEEDUPS_KEY].select do |_, value|
49
+ value == false
50
+ end.keys.map(&:to_sym)
51
+ end
52
+
53
+ def ignored_files
54
+ @ignored_files ||= config[EXCLUDE_PATHS_KEY].flat_map { |path| Dir[path] }
55
+ end
56
+
57
+ def config
58
+ @config ||=
59
+ if File.exist?(CONFIG_FILE_NAME)
60
+ YAML.load_file(CONFIG_FILE_NAME)
61
+ else
62
+ nil_config_file
63
+ end
64
+ end
65
+
66
+ def nil_config_file
67
+ { SPEEDUPS_KEY => {}, EXCLUDE_PATHS_KEY => [] }
68
+ end
69
+ end
70
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pronto-fasterer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
+ platform: ruby
6
+ authors:
7
+ - Mindaugas Mozūras
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fasterer
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.11
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.11
27
+ - !ruby/object:Gem::Dependency
28
+ name: pronto
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.4.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.4.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.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-its
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ description:
84
+ email: mindaugas.mozuras@gmail.com
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - LICENSE
90
+ - README.md
91
+ - lib/pronto/fasterer.rb
92
+ - lib/pronto/fasterer/version.rb
93
+ homepage: http://github.org/mmozuras/pronto-fasterer
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 1.3.6
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.4.5
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: Pronto runner for Fasterer, speed improvements suggester
117
+ test_files: []
118
+ has_rdoc: