Class: Script
- Inherits:
-
Object
- Object
- Script
- Defined in:
- lib/opnsrcint/script.rb
Instance Attribute Summary collapse
-
#list ⇒ Object
Returns the value of attribute list.
-
#mini_logo ⇒ Object
Returns the value of attribute mini_logo.
-
#script_name ⇒ Object
Returns the value of attribute script_name.
-
#tmp_list ⇒ Object
Returns the value of attribute tmp_list.
-
#url ⇒ Object
Returns the value of attribute url.
-
#user ⇒ Object
Returns the value of attribute user.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
- #git_hub ⇒ Object
-
#initialize(url, script_name, user, mini_logo = true, verbose = false) ⇒ Script
constructor
A new instance of Script.
- #print_(s, w, c = ':') ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(url, script_name, user, mini_logo = true, verbose = false) ⇒ Script
Returns a new instance of Script.
7 8 9 10 11 12 13 14 15 |
# File 'lib/opnsrcint/script.rb', line 7 def initialize(url, script_name, user, mini_logo=true, verbose=false) @min_logo = mini_logo @url = url @verbose = verbose @script_name = script_name @list = ['github', 'pypi'] @user = user @tmp_list = [] end |
Instance Attribute Details
#list ⇒ Object
Returns the value of attribute list.
6 7 8 |
# File 'lib/opnsrcint/script.rb', line 6 def list @list end |
#mini_logo ⇒ Object
Returns the value of attribute mini_logo.
6 7 8 |
# File 'lib/opnsrcint/script.rb', line 6 def mini_logo @mini_logo end |
#script_name ⇒ Object
Returns the value of attribute script_name.
6 7 8 |
# File 'lib/opnsrcint/script.rb', line 6 def script_name @script_name end |
#tmp_list ⇒ Object
Returns the value of attribute tmp_list.
6 7 8 |
# File 'lib/opnsrcint/script.rb', line 6 def tmp_list @tmp_list end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/opnsrcint/script.rb', line 6 def url @url end |
#user ⇒ Object
Returns the value of attribute user.
6 7 8 |
# File 'lib/opnsrcint/script.rb', line 6 def user @user end |
#verbose ⇒ Object
Returns the value of attribute verbose.
6 7 8 |
# File 'lib/opnsrcint/script.rb', line 6 def verbose @verbose end |
Instance Method Details
#git_hub ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/opnsrcint/script.rb', line 24 def git_hub html = Net::HTTP::get_response(URI(@url+'?tab=repositories')) json_repos = JSON::parse(Net::HTTP::get_response(URI("https://api.github.com/users/#{@user}/repos")).body) result = '' html.body.split("\n").map do |line| if line.include? '<title>' line = line.strip line = line[7, line.length-38] result += ("(Github.com name ) ~> "+line+"\n") end end URI::extract(html.body) do |line| if !@tmp_list.include? line if line.include? "https://avatars.githubusercontent.com/" result += " | Profile: \e[35;1m#{line}\e[0m\n" @tmp_list.append(line) end end end json_repos.length.times do |r| result += (" | "+ json_repos[r]['svn_url']+"\n") end json_repos.length.times do |r| url = json_repos[r]['svn_url'] sleep 0.1 begin Thread::new do |e| html = Net::HTTP::get_response(URI(url)) URI::extract(html.body) do |line| if line.include? 'https://gist.github.com' and line != 'https://gist.github.com' print_("gist", line ) elsif line.include? 'https://facebook.com' and line != 'https://facebook.com' print_("facebook", line) elsif line.include? 'https://twiter.com' and line != 'https://twiter.com' print_("twiter", line) elsif line.include? 'https://yahoo.com' and line != 'https://yahoo.com' print_("yahoo", line) elsif line.include? 'https://t.me/' and line != 'https://t.me/' print_("telegram", line, "\e[m34;1m➣" ) elsif line.include? 'mail.com' print_("Mail", line, ':📨:') elsif line.include? 'https://www.instagram.com/' and line != 'https://www.instagram.com/' print_("instagram", line) elsif line.include? 'https://linkedin.com/' and line != 'https://linkedin.com/' print_("linkedin", line) elsif line.include? "#{@user}" and @verbose and !line.start_with? 'https://github.com/' print_(URI(line).hostname, "\e[2m#{line}\e[0m") end end end rescue => e puts "\e[2mError: #{e}\e[0m" end end puts result end |
#print_(s, w, c = ':') ⇒ Object
17 18 19 20 21 22 |
# File 'lib/opnsrcint/script.rb', line 17 def print_(s, w, c=':') if true and @mini_logo c = ':' end print "\e[32;1m•>\e[0m \e[31m#{s.to_s}\e[33;1m#{c}\e[0m #{w}\n" end |
#run ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/opnsrcint/script.rb', line 83 def run if @list.include? @script_name case @script_name when 'github' git_hub end end end |