checkapi 0.0.1
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/bin/checkapi +3 -0
- data/lib/checkapi/version.rb +3 -0
- data/lib/checkapi.rb +94 -0
- metadata +78 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 37dd2076cf8b9f3613b9ce88171aba6bcc906875
|
|
4
|
+
data.tar.gz: 2134957c5945b00540674e51aa3da861e9a10524
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 5ef3e6e6e0f4944bbbb835d19d059c11ee7336efd3404c39566065681a3c12ee1a7a086678e021cb0acbb1cea185269f8a3e112db50b60dbea8124a19caf4d23
|
|
7
|
+
data.tar.gz: e4a01500561f8124d2f359aa2bff713857c28535a65ad49c0ab8349cd5b053fe056f1a10f9fbb25fa2819570ec5f1c58198ae711ded7f835f4ab7838780fb35f
|
data/bin/checkapi
ADDED
data/lib/checkapi.rb
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
require "checkapi/version"
|
|
2
|
+
require 'optparse'
|
|
3
|
+
require 'pathname'
|
|
4
|
+
|
|
5
|
+
module Checkapi
|
|
6
|
+
# Your code goes here...
|
|
7
|
+
def self.run
|
|
8
|
+
options = {}
|
|
9
|
+
option_parser = OptionParser.new do |opts|
|
|
10
|
+
opts.banner = 'here is help messages of the command line tool.'
|
|
11
|
+
|
|
12
|
+
opts.on('-f FILENAME', '--file FILENAME', 'file name') do |value|
|
|
13
|
+
options[:filename] = value
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
opts.on('-k A,B', '--keyword A,B', Array, 'List of search keywords') do |value|
|
|
17
|
+
options[:keywords] = value
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end.parse!
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
keywords = options[:keywords]
|
|
24
|
+
keywords ||= {}
|
|
25
|
+
|
|
26
|
+
if keywords.count > 0
|
|
27
|
+
if which("ag").nil?
|
|
28
|
+
system("brew update")
|
|
29
|
+
system("brew install ag")
|
|
30
|
+
end
|
|
31
|
+
regex = keywords[0]
|
|
32
|
+
if keywords.count > 1
|
|
33
|
+
|
|
34
|
+
keywords.each do |keyword|
|
|
35
|
+
|
|
36
|
+
index = keywords.index keyword
|
|
37
|
+
if index == 0
|
|
38
|
+
regex = "#{keyword}"
|
|
39
|
+
elsif
|
|
40
|
+
regex += "[\\s\\S]*#{keyword}"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
if File.exist? "CheckApiResult.txt"
|
|
48
|
+
system 'rm CheckApiResult.txt'
|
|
49
|
+
end
|
|
50
|
+
system "ag -C 200 \"#{regex}\" --heading --nonumbers > CheckApiResult.txt"
|
|
51
|
+
|
|
52
|
+
puts "open CheckApiResult.txt to view result!"
|
|
53
|
+
|
|
54
|
+
else
|
|
55
|
+
|
|
56
|
+
file_name = options[:filename]
|
|
57
|
+
if file_name
|
|
58
|
+
if File.exist? "CheckApiResult.txt"
|
|
59
|
+
system 'rm CheckApiResult.txt'
|
|
60
|
+
end
|
|
61
|
+
result_path = "#{Pathname.pwd}/CheckApiResult.txt"
|
|
62
|
+
result_file = File.new(result_path , "w+")
|
|
63
|
+
file_list_string = `find . -name *#{file_name}*`
|
|
64
|
+
file_list_string.each_line do |file_path|
|
|
65
|
+
file_path = File.expand_path(file_path)
|
|
66
|
+
file_path = file_path.strip
|
|
67
|
+
if File.exist? file_path
|
|
68
|
+
content = File.read(file_path)
|
|
69
|
+
result_file << content
|
|
70
|
+
result_file << "\n\n"
|
|
71
|
+
else
|
|
72
|
+
puts "#{file_path}not exist!"
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
result_file.close
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def self.which(cmd)
|
|
84
|
+
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
|
85
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
|
86
|
+
exts.each { |ext|
|
|
87
|
+
exe = File.join(path, "#{cmd}#{ext}")
|
|
88
|
+
return exe if File.executable?(exe) && !File.directory?(exe)
|
|
89
|
+
}
|
|
90
|
+
end
|
|
91
|
+
return nil
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
metadata
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: checkapi
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- kaich
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-12-09 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ~>
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.7'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ~>
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.7'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ~>
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ~>
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
description: search private api in frameworks. You need install VAPI in you device
|
|
42
|
+
to view the api result
|
|
43
|
+
email:
|
|
44
|
+
- chengkai1853@163.com
|
|
45
|
+
executables:
|
|
46
|
+
- checkapi
|
|
47
|
+
extensions: []
|
|
48
|
+
extra_rdoc_files: []
|
|
49
|
+
files:
|
|
50
|
+
- bin/checkapi
|
|
51
|
+
- lib/checkapi.rb
|
|
52
|
+
- lib/checkapi/version.rb
|
|
53
|
+
homepage: ''
|
|
54
|
+
licenses:
|
|
55
|
+
- MIT
|
|
56
|
+
metadata: {}
|
|
57
|
+
post_install_message:
|
|
58
|
+
rdoc_options: []
|
|
59
|
+
require_paths:
|
|
60
|
+
- lib
|
|
61
|
+
- bin
|
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
|
+
requirements:
|
|
64
|
+
- - '>='
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: '0'
|
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
|
+
requirements:
|
|
69
|
+
- - '>='
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
version: '0'
|
|
72
|
+
requirements: []
|
|
73
|
+
rubyforge_project:
|
|
74
|
+
rubygems_version: 2.4.8
|
|
75
|
+
signing_key:
|
|
76
|
+
specification_version: 4
|
|
77
|
+
summary: search private api in frameworks.
|
|
78
|
+
test_files: []
|