depralyzer 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/depralyzer +46 -0
- data/lib/depralyzer/generator.rb +58 -0
- data/lib/depralyzer/version.rb +8 -0
- data/lib/depralyzer.rb +20 -0
- metadata +49 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 763decd8e05adabf78824638e7e89c8eaf6e8b42368466455b7bd0bf6287ee3c
|
4
|
+
data.tar.gz: dc35091e134db2c9c3ea486c672cb89d20d7432a9722ad7ea72e48585ea135ca
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7df0641541812bbbe0c164c67bfaccb42a341f9195fbe72742562cced4e4b8795ab180716e7bd08c175b5665e0ba5c457fb67f579f757636dd9f7e5b984fce75
|
7
|
+
data.tar.gz: c55707f00bdc700e8e6eec759c8bef9f7207a5cec2d8b9cce7280306aee03be2f3a4345deb0a8c5fc047ade7680a1d344843f16c50e764cc4d0b1b357a3de189
|
data/bin/depralyzer
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# depralyzer [dir/*.rb]
|
4
|
+
#
|
5
|
+
|
6
|
+
require 'optparse'
|
7
|
+
require 'depralyzer/version'
|
8
|
+
require 'depralyzer/generator'
|
9
|
+
|
10
|
+
print_version = false
|
11
|
+
spec_dir = './spec'
|
12
|
+
exc_spec_dir = nil
|
13
|
+
|
14
|
+
opt = OptionParser.new
|
15
|
+
|
16
|
+
opt.on('-o VAL', 'Output directory (default: ./spec)') { |dir| spec_dir = dir }
|
17
|
+
opt.on('--output-dir VAL', '') { |dir| spec_dir = dir }
|
18
|
+
|
19
|
+
opt.on('-v', 'Print version') { |_| print_version = true }
|
20
|
+
opt.on('--version', '') { |_| print_version = true }
|
21
|
+
|
22
|
+
args = opt.parse(ARGV)
|
23
|
+
|
24
|
+
if print_version
|
25
|
+
puts "depralyzer #{Depralyzer::VERSION}"
|
26
|
+
exit 0
|
27
|
+
end
|
28
|
+
|
29
|
+
dir_or_file = args.first
|
30
|
+
if dir_or_file.nil?
|
31
|
+
puts "Usage: depralyzer [dir/*.rb] -options"
|
32
|
+
exit 1
|
33
|
+
end
|
34
|
+
unless dir_or_file.match(/.rb$/)
|
35
|
+
dir_or_file = dir_or_file.gsub(/\/$/, '') + "/**/*.rb"
|
36
|
+
end
|
37
|
+
|
38
|
+
generator = Depralyzer::Generator.new(spec_dir)
|
39
|
+
|
40
|
+
files = Dir.glob(dir_or_file)
|
41
|
+
files -= Dir.glob(exc_spec_dir) if exc_spec_dir
|
42
|
+
|
43
|
+
files.each do |file_path|
|
44
|
+
generator.write_spec(file_path, force_write, dry_run, rails_mode)
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'depralyzer'
|
4
|
+
#
|
5
|
+
# RSpec Code Generator
|
6
|
+
#
|
7
|
+
module Depralyzer
|
8
|
+
class Generator
|
9
|
+
|
10
|
+
DEPRECATION_FORMAT = /DEPRECATION WARNING: .+?. \(called from .+?\)$/
|
11
|
+
|
12
|
+
attr_accessor :input
|
13
|
+
|
14
|
+
def initialize(input)
|
15
|
+
@input = File.read(input)
|
16
|
+
end
|
17
|
+
|
18
|
+
def process
|
19
|
+
warnings = input.scan(DEPRECATION_FORMAT)
|
20
|
+
summary = summarize warnings
|
21
|
+
pretty_output summary
|
22
|
+
end
|
23
|
+
|
24
|
+
def pretty_output(summary)
|
25
|
+
puts "Total of #{summary.size} deprecation types with #{occurrence(summary)} occurrences"
|
26
|
+
summary.each do |top, details|
|
27
|
+
puts
|
28
|
+
puts "### #{top}"
|
29
|
+
details.each do |note, cnt|
|
30
|
+
puts sprintf("- %10d %s", cnt, note)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def occurrence(summary)
|
36
|
+
i = 0
|
37
|
+
summary.each do |_, detail|
|
38
|
+
detail.each do |_, cnt |
|
39
|
+
i += cnt
|
40
|
+
end
|
41
|
+
end
|
42
|
+
i
|
43
|
+
end
|
44
|
+
|
45
|
+
def summarize(warnings)
|
46
|
+
summary = {}
|
47
|
+
warnings.each do |warning|
|
48
|
+
content = warning.sub('DEPRECATION WARNING: ','')
|
49
|
+
type, details = content.split('. ', 2)
|
50
|
+
summary[type] = {} unless summary.key?(type)
|
51
|
+
summary[type][details] = 0 unless summary[type].key?(details)
|
52
|
+
summary[type][details] += 1
|
53
|
+
end
|
54
|
+
summary
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
data/lib/depralyzer.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'depralyzer/version'
|
4
|
+
|
5
|
+
#
|
6
|
+
# Depralyzer Facade
|
7
|
+
#
|
8
|
+
module Depralyzer
|
9
|
+
class << self
|
10
|
+
|
11
|
+
def version
|
12
|
+
VERSION
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.analyze(file_path)
|
17
|
+
generator = Depralyzer::Generator.new(spec_dir)
|
18
|
+
generator.write_spec(file_path, force_write, dry_run)
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: depralyzer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Timothy Chambers
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-11-17 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: depralyzer analyzes and summarizes your deprecations.
|
14
|
+
email:
|
15
|
+
- tim@possibilogy.com
|
16
|
+
executables:
|
17
|
+
- depralyzer
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- bin/depralyzer
|
22
|
+
- lib/depralyzer.rb
|
23
|
+
- lib/depralyzer/generator.rb
|
24
|
+
- lib/depralyzer/version.rb
|
25
|
+
homepage: https://github.com/tjchambers/depralyzer
|
26
|
+
licenses:
|
27
|
+
- MIT
|
28
|
+
metadata: {}
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
requirements: []
|
44
|
+
rubyforge_project:
|
45
|
+
rubygems_version: 2.7.6
|
46
|
+
signing_key:
|
47
|
+
specification_version: 4
|
48
|
+
summary: depralyzer analyzes and summarizes your deprecations.
|
49
|
+
test_files: []
|