libsessho 1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/src/libsessho.rb +129 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ac9fabfdc2f7439dc1e10395b4c5911f218dc3f4
|
4
|
+
data.tar.gz: d8a5fc176ec73b452541823ab55ff0a89c041cef
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a549983774a2965056afb03a33827db040f4d599a69ba25aa3b28751c7c3886ec960a79e26fb0d590385d8939e13647c82ee190b8c257d196bb079f3ef25f024
|
7
|
+
data.tar.gz: bbe47f9c3db6704d4b3cabc4120897059d1a5e8437cff793f02d127b5dd1ecec8f2af92bd54309563fb137fb74d1c0c493c446954e3eb047225090cfa1662163
|
data/src/libsessho.rb
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
# META_VERSION 1.5
|
2
|
+
|
3
|
+
# This program is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU General Public License,
|
5
|
+
# version 2, as published by the Free Software Foundation.
|
6
|
+
#
|
7
|
+
# This program is distributed in the hope that it will be
|
8
|
+
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
9
|
+
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
10
|
+
# PURPOSE. See the GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public
|
13
|
+
# License along with this program; if not, write to the Free
|
14
|
+
# Software Foundation, Inc., 59 Temple Place, Suite 330,
|
15
|
+
# Boston, MA 02111-1307 USA.
|
16
|
+
|
17
|
+
=begin
|
18
|
+
class Version
|
19
|
+
def initialize(_1,_2=0,_3=0,_4=0)
|
20
|
+
@verstr = [_1,_2,_3,_4].map(&:to_s)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
=end
|
24
|
+
|
25
|
+
def upd_check
|
26
|
+
require 'net/http'
|
27
|
+
require 'timeout'
|
28
|
+
onln_content = nil
|
29
|
+
begin
|
30
|
+
Timeout.timeout(2) { onln_content = Net::HTTP.get(URI("https://raw.githubusercontent.com/sesshomariu/libsessho/master/libsessho.rb")) }
|
31
|
+
rescue
|
32
|
+
return [false,""]
|
33
|
+
else
|
34
|
+
onln_version = onln_content.match(/META_VERSION \d+\.\d+/).to_s.split[-1].to_f
|
35
|
+
this_version = File.read(__FILE__).match(/META_VERSION \d+\.\d+/).to_s.split[-1].to_f
|
36
|
+
upd_av = (onln_version>this_version)
|
37
|
+
return [upd_av, (upd_av ? onln_content : "")]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
$0==__FILE__&&( # not imported
|
42
|
+
upd_av, onln_cont = upd_check
|
43
|
+
upd_av ? puts("Update available. Updating...") : puts("No update available(or could not check repository).")
|
44
|
+
upd_av&&File.write(__FILE__,onln_cont)
|
45
|
+
exit
|
46
|
+
)
|
47
|
+
|
48
|
+
_UPD_upd_av, _UPD_onln_cont = upd_check
|
49
|
+
at_exit{_UPD_upd_av&&File.write(__FILE__,_UPD_onl_cont)}
|
50
|
+
Signal.trap("INT"){exit} # ensure proper exit
|
51
|
+
|
52
|
+
|
53
|
+
module Libsessho # error module / api module / dunno
|
54
|
+
class StringNotDivideableError<StandardError;end
|
55
|
+
end
|
56
|
+
|
57
|
+
def warning_msg(msg)
|
58
|
+
puts "\e[31m#{msg}\e[39m"
|
59
|
+
end
|
60
|
+
|
61
|
+
class String
|
62
|
+
def splitAt(pos)
|
63
|
+
raise ArgumentError,"Index out of range" if pos>=self.length
|
64
|
+
p2 = self.split("")
|
65
|
+
p1 = p2.shift(pos)
|
66
|
+
[p1,p2].map(&:join)
|
67
|
+
end
|
68
|
+
def substr(pos)
|
69
|
+
raise ArgumentError,"Index out of range" if pos>=self.length
|
70
|
+
self[pos,self.length]
|
71
|
+
end
|
72
|
+
def supstr(pos)
|
73
|
+
raise ArgumentError,"Index out of range" if pos>=self.length
|
74
|
+
self[0,pos]
|
75
|
+
end
|
76
|
+
def divide(by,supprErr=false)
|
77
|
+
supprErr||(self.length%by==0||raise(Libsessho::StringNotDivideableError,"Length of string is not divideable by #{by}"))
|
78
|
+
retarr = Array.new
|
79
|
+
s = self.split("")
|
80
|
+
until s.empty?
|
81
|
+
retarr.push s.shift(by)
|
82
|
+
end
|
83
|
+
return retarr.map(&:join)
|
84
|
+
end
|
85
|
+
def dropFileEnding
|
86
|
+
self.split(".").reverse[1,self.length].reverse.join(".")
|
87
|
+
end
|
88
|
+
def matches(s)
|
89
|
+
matcharr = Array.new
|
90
|
+
self.split("").each_with_index{|c,i|c==s&&matcharr<<i}
|
91
|
+
return matcharr
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
class Array
|
96
|
+
def intersect(sa);self.select{|i|sa.include?(i)};end
|
97
|
+
def subarr(pos)
|
98
|
+
raise ArgumentError,"Index out of range" if pos>=self.length
|
99
|
+
self[pos,self.length]
|
100
|
+
end
|
101
|
+
def suparr(pos)
|
102
|
+
raise ArgumentError,"Index out of range" if pos>=self.length
|
103
|
+
self[0,pos]
|
104
|
+
end
|
105
|
+
def matches(s)
|
106
|
+
matcharr = Array.new
|
107
|
+
self.each_with_index{|c,i|c==s&&matcharr<<i}
|
108
|
+
return matcharr
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def publicIP
|
113
|
+
require 'net/http'
|
114
|
+
return Net::HTTP.get(URI('https://api.ipify.org'))
|
115
|
+
end
|
116
|
+
|
117
|
+
def publicIPv6
|
118
|
+
require 'net/http'
|
119
|
+
Net::HTTP.get(URI("http://whatismyip.org")).match(/\h{,4}:\h{,4}:\h{,4}:\h{,4}:\h{,4}:\h{,4}:\h{,4}:\h{,4}/).to_s
|
120
|
+
end
|
121
|
+
|
122
|
+
def backtrack_call
|
123
|
+
raise NotImplementedError
|
124
|
+
end
|
125
|
+
|
126
|
+
def localIP
|
127
|
+
require 'socket'
|
128
|
+
Socket.ip_address_list.map{|i|i.inspect.split(" ")[-1].split(">")[0]}.select{|i|i.match(/^\d{,3}\.\d{,3}\.\d{,3}.\d{,3}$/)}.select{|i|i!="127.0.0.1"}[0]
|
129
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: libsessho
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.5'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- sesshomariu
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-11 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- src/libsessho.rb
|
20
|
+
homepage:
|
21
|
+
licenses:
|
22
|
+
- GPL-3.0
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.6.8
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Core library for scripts written by sessho/sesshomariu
|
44
|
+
test_files: []
|