byebug-cleaner 0.1.2
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +31 -0
- data/Rakefile +34 -0
- data/lib/byebug-cleaner.rb +4 -0
- data/lib/byebug/byebug.rb +6 -0
- data/lib/byebug/cleaner/cleaner.rb +51 -0
- data/lib/byebug/cleaner/output.rb +8 -0
- data/lib/byebug/cleaner/parser.rb +81 -0
- data/lib/byebug/cleaner/railtie.rb +5 -0
- data/lib/byebug/cleaner/version.rb +3 -0
- data/lib/tasks/clean_tasks.rake +8 -0
- metadata +69 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f32bd5a9f7563a4ec1fec0d284fe73151a30bc59
|
4
|
+
data.tar.gz: 06d3edacd09788b94ac1641cf1b5efcfcd4fd3f4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b44de141b58d4019a4160aa567509923a004f78f5d9d981b498c5008d81a612d34dd79247c4fbc8c3c4a56c55b9f4e57a79d595ad093daa862162f757f27c290
|
7
|
+
data.tar.gz: 7824a8b2c221b331c644d1003e97b281869e539f16df9f85b4947efe337893f2e4f4d87a46d1053796709b943b85b17339c60eb57368b3f1beee80a83b525d1f
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017 Ilyas Valiullov
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# ByebugCleaner
|
2
|
+
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
You can remove all byebug tag from source code using rake task:
|
6
|
+
```bash
|
7
|
+
rails byebug:clean
|
8
|
+
```
|
9
|
+
Default path for clean is [app/*]. Script recursively search byebug tag in files and delete whole line.
|
10
|
+
|
11
|
+
Task default create backup files.
|
12
|
+
Get help for more options:
|
13
|
+
```bash
|
14
|
+
rails byebug:clean -- -h
|
15
|
+
```
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
Add this line to your application's Gemfile:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
gem 'byebug-cleaner', github: "IlyasValiullov/byebug-cleaner"
|
22
|
+
```
|
23
|
+
|
24
|
+
And then execute:
|
25
|
+
```bash
|
26
|
+
$ bundle install
|
27
|
+
```
|
28
|
+
|
29
|
+
|
30
|
+
## License
|
31
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'ByebugCleaner'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
load 'tasks/clean_tasks.rake'
|
21
|
+
|
22
|
+
|
23
|
+
require 'bundler/gem_tasks'
|
24
|
+
|
25
|
+
require 'rake/testtask'
|
26
|
+
|
27
|
+
Rake::TestTask.new(:test) do |t|
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = false
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
task default: :test
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'byebug/cleaner/output'
|
2
|
+
|
3
|
+
module ByebugCleaner
|
4
|
+
class Cleaner
|
5
|
+
include ByebugCleaner
|
6
|
+
|
7
|
+
def self.clean argv
|
8
|
+
|
9
|
+
#Get options for clean
|
10
|
+
optparse = ArgumentParser.new
|
11
|
+
options = optparse.parse(argv[-1..argv.size])
|
12
|
+
|
13
|
+
|
14
|
+
root = Pathname.new("#{Dir.pwd}")
|
15
|
+
pwd = "#{Dir.pwd}/#{options.dir}"
|
16
|
+
puts "Folder for searching is #{options.dir}"
|
17
|
+
|
18
|
+
|
19
|
+
dirs = Dir[ File.join(pwd, '**', '*') ]
|
20
|
+
dirs.delete_if {|f| File.directory?(f) }
|
21
|
+
|
22
|
+
filelist = Rake::FileList.new
|
23
|
+
filelist.include(dirs)
|
24
|
+
|
25
|
+
results = []
|
26
|
+
filelist.each do |file_name|
|
27
|
+
str = IO.read(file_name)
|
28
|
+
next if !str.match(/.*byebug.*/)
|
29
|
+
FileUtils.cp(file_name, "#{file_name}.backup") if options.backup
|
30
|
+
file_path = Pathname.new(file_name)
|
31
|
+
file_clean_path = file_path.relative_path_from(root)
|
32
|
+
|
33
|
+
text = File.read(file_name)
|
34
|
+
new_content = text.gsub(/.*byebug.*/, "")
|
35
|
+
|
36
|
+
File.open(file_name, "w") {|file| file.puts new_content }
|
37
|
+
|
38
|
+
results << file_clean_path
|
39
|
+
end
|
40
|
+
|
41
|
+
if results.size > 0
|
42
|
+
puts "Files was changed:"
|
43
|
+
results.each do |file_name|
|
44
|
+
puts ByebugCleaner::green_str(" - #{file_name}")
|
45
|
+
end
|
46
|
+
else
|
47
|
+
puts ByebugCleaner::cyan_str("Byebug wasn't found.")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module ByebugCleaner
|
2
|
+
class ArgumentParser
|
3
|
+
|
4
|
+
class Options
|
5
|
+
attr_accessor :dir, :backup, :test
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
self.dir = "app"
|
9
|
+
self.backup = true
|
10
|
+
self.test = 0
|
11
|
+
end
|
12
|
+
|
13
|
+
def define_options(parser)
|
14
|
+
parser.banner = "Usage: rake byebug:clean -- [options]"
|
15
|
+
parser.separator "Task recursively search files where 'byebug' uses and remove this line from file."
|
16
|
+
parser.separator ""
|
17
|
+
parser.separator "Default options:"
|
18
|
+
parser.separator " Dir - {RAILS_APP}/app"
|
19
|
+
parser.separator " Backup - true"
|
20
|
+
parser.separator ""
|
21
|
+
parser.separator "Specific options:"
|
22
|
+
|
23
|
+
# add additional options
|
24
|
+
dir_option(parser)
|
25
|
+
boolean_backup_option(parser)
|
26
|
+
|
27
|
+
parser.separator ""
|
28
|
+
parser.separator "Common options:"
|
29
|
+
# No argument, shows at tail. This will print an options summary.
|
30
|
+
# Try it and see!
|
31
|
+
parser.on("-h", "--help", "Prints this help") do
|
32
|
+
puts parser
|
33
|
+
exit
|
34
|
+
end
|
35
|
+
# Another typical switch to print the version.
|
36
|
+
parser.on("-v", "Show version") do
|
37
|
+
puts VERSION
|
38
|
+
exit
|
39
|
+
end
|
40
|
+
parser.separator ""
|
41
|
+
parser.separator "Examples:"
|
42
|
+
parser.separator " rake byebug:clean"
|
43
|
+
parser.separator " rake byebug:clean -- -dspec"
|
44
|
+
parser.separator " rake byebug:clean -- --dir=app/models --no-debug"
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
def dir_option(parser)
|
49
|
+
# Cast 'time' argument to a Time object.
|
50
|
+
parser.on("-dDIR", "--dir=DIR", String, "Set dir for searching") do |dir|
|
51
|
+
self.dir = dir
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def boolean_backup_option(parser)
|
57
|
+
# Boolean switch.
|
58
|
+
parser.on("-b", "--[no-]backup", "Backup files") do |b|
|
59
|
+
self.backup = b
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
#
|
65
|
+
# Return a structure describing the options.
|
66
|
+
#
|
67
|
+
def parse(args)
|
68
|
+
# The options specified on the command line will be collected in
|
69
|
+
# *options*.
|
70
|
+
@options = Options.new
|
71
|
+
opt_parser = OptionParser.new do |parser|
|
72
|
+
@options.define_options(parser)
|
73
|
+
end
|
74
|
+
opt_parser.parse!(args)
|
75
|
+
|
76
|
+
@options
|
77
|
+
end
|
78
|
+
|
79
|
+
# attr_reader :parser, :options
|
80
|
+
end # class OptparseExample
|
81
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: byebug-cleaner
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ilyas Valiullov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-07-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5'
|
27
|
+
description: Remove byebug tag before push your code in repos.
|
28
|
+
email:
|
29
|
+
- ilyas.valiullov@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- MIT-LICENSE
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- lib/byebug-cleaner.rb
|
38
|
+
- lib/byebug/byebug.rb
|
39
|
+
- lib/byebug/cleaner/cleaner.rb
|
40
|
+
- lib/byebug/cleaner/output.rb
|
41
|
+
- lib/byebug/cleaner/parser.rb
|
42
|
+
- lib/byebug/cleaner/railtie.rb
|
43
|
+
- lib/byebug/cleaner/version.rb
|
44
|
+
- lib/tasks/clean_tasks.rake
|
45
|
+
homepage: https://github.com/IlyasValiullov/byebug-cleaner
|
46
|
+
licenses:
|
47
|
+
- MIT
|
48
|
+
metadata: {}
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 2.5.1
|
66
|
+
signing_key:
|
67
|
+
specification_version: 4
|
68
|
+
summary: Gem for clean byebug tag from source code.
|
69
|
+
test_files: []
|