rfind 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/rfind.rb +54 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b98ecb28e0ce9fd3eb910fe5370f9e1c27a8b649
|
4
|
+
data.tar.gz: 5bd7bacfbd1cbe9f4e048ec65b3737e3b59cb9f4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 09f9edc1a80bd3d210b41255049bd10062d61e0af6355918b1ade2b47e1fd8bc046d59d06ca9283c2f638e597ff32fed2475b876ec2d1593df599ceeda378fd8
|
7
|
+
data.tar.gz: 4150d1b3774c27da6dc4154f10b1a84f7d6a0205f2828b6137f1aed8a68aed056ab7011696a67f6eddd80c78b02da2e860a26a9b15e6f4e5cae763f31ab2fe1a
|
data/lib/rfind.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'optparse'
|
5
|
+
require 'find'
|
6
|
+
require 'paint'
|
7
|
+
|
8
|
+
class RFind
|
9
|
+
|
10
|
+
params = {}
|
11
|
+
options = OptionParser.new do |x|
|
12
|
+
x.banner = 'rfind <options> <file> <startPath>'
|
13
|
+
x.separator ''
|
14
|
+
|
15
|
+
x.on("-v", "--verbose", "Gives verbose output from program") { params[:verbose] = :true }
|
16
|
+
|
17
|
+
x.on("-h", "--help", "Lists all options") { puts options; exit }
|
18
|
+
end
|
19
|
+
|
20
|
+
options.parse!(ARGV)
|
21
|
+
|
22
|
+
puts params
|
23
|
+
|
24
|
+
|
25
|
+
fileName = ARGV[0].to_s()
|
26
|
+
if ARGV[1] == nil
|
27
|
+
startPath = '/'
|
28
|
+
else
|
29
|
+
startPath = ARGV[1].to_s()
|
30
|
+
end
|
31
|
+
|
32
|
+
puts fileName
|
33
|
+
puts startPath
|
34
|
+
|
35
|
+
|
36
|
+
filePaths = []
|
37
|
+
Find.find(startPath) do |path|
|
38
|
+
#
|
39
|
+
if path.start_with?('/dev')
|
40
|
+
Find.prune # Don't look any further into this directory.
|
41
|
+
end
|
42
|
+
if path =~ /#{fileName}/
|
43
|
+
filePaths << path
|
44
|
+
puts Paint[path, :green, :bright]
|
45
|
+
elsif params[:verbose] == :true
|
46
|
+
puts Paint[path, :red, :bright]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
#Ruby adds ["array stuff"] around arrays with to_s() which is annoying to look at
|
51
|
+
#join("\n") puts a newline inbetween each element of the array and converts to a string
|
52
|
+
puts Paint[filePaths.join("\n"), :green, :bright] if params[:verbose] == :true
|
53
|
+
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rfind
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Dowd
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-05 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: This is a basic implementation of the find command. It outputs in colour
|
14
|
+
to the command line to make it easier to view.
|
15
|
+
email: danny25106@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/rfind.rb
|
21
|
+
homepage: http://rubygems.org/gems/rfind
|
22
|
+
licenses:
|
23
|
+
- MIT
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.0.14
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Basic find implementation with colour output
|
45
|
+
test_files: []
|