hastebin 0.2.1 → 0.2.5
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 +4 -4
- data/bin/hastebin +58 -6
- data/lib/hastebin.rb +50 -15
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a989d32d1a453296754c92cf4d14472ef1ed89b10ec20191f1881f291c307ab2
|
|
4
|
+
data.tar.gz: 8f2e3004357c8f5689600b0142d3910ec1ab18f8708246c60e5f565a097af167
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e64c8370ecf52097217bdd08213452725c88eea219f4148c3c88b946a9957fd169ac025aba9b0079aded8d1258c7d4b512ec45b78430e3a70f8e44acf64b24db
|
|
7
|
+
data.tar.gz: ed44d944eeba7d16dfe5f2b95030d0b2bff3f02405e79f867a73ac780211a1aa1e32613bc283320e4609453954dc3889d196311245cc454b2556354f60bbac23
|
data/bin/hastebin
CHANGED
|
@@ -3,29 +3,36 @@ require 'optparse'
|
|
|
3
3
|
require "uri"
|
|
4
4
|
require "net/http"
|
|
5
5
|
require "hastebin"
|
|
6
|
+
require "colorize"
|
|
6
7
|
|
|
7
8
|
opts = OptionParser.new do |opts|
|
|
8
9
|
opts.banner = "\n«««««««««««««««««»»»»»»»»»»»»»»»»»»»"
|
|
9
10
|
opts.separator "««««««««««« Hastebin CLI »»»»»»»»»»»"
|
|
10
11
|
opts.separator "«««««««««««««««««»»»»»»»»»»»»»»»»»»»"
|
|
11
12
|
opts.separator ""
|
|
12
|
-
opts.separator 'Usage: hastebin
|
|
13
|
-
opts.separator 'Usage: hastebin
|
|
13
|
+
opts.separator 'Usage: hastebin --write "script" -> write'
|
|
14
|
+
opts.separator 'Usage: hastebin --up "/path/to/file" -> upload file'
|
|
15
|
+
opts.separator 'Usage: hastebin --download "key or key.rb" -> download via hasteb.in'
|
|
16
|
+
opts.separator 'Usage: hastebin --run "key or key.rb" -> run ruby via hasteb.in'
|
|
17
|
+
opts.separator 'Usage: hastebin --read "key or key.rb" -> Read files via hasteb.in'
|
|
14
18
|
opts.separator ""
|
|
15
19
|
opts.separator "Examples:"
|
|
16
|
-
opts.separator ' hastebin
|
|
17
|
-
opts.separator ' hastebin
|
|
20
|
+
opts.separator ' hastebin --write "puts("hello")"'
|
|
21
|
+
opts.separator ' hastebin --up "./text.txt"'
|
|
22
|
+
opts.separator ' hastebin --download "oquluqic"'
|
|
23
|
+
opts.separator ' hastebin --run "oquluqic"'
|
|
24
|
+
opts.separator ' hastebin --download "oquluqic"'
|
|
18
25
|
opts.separator ""
|
|
19
26
|
opts.separator "Options:"
|
|
20
27
|
|
|
21
|
-
opts.on("
|
|
28
|
+
opts.on("--write script") do |a|
|
|
22
29
|
|
|
23
30
|
puts "View in: https://hasteb.in/#{Hastebin.code(a)}"
|
|
24
31
|
|
|
25
32
|
exit
|
|
26
33
|
end
|
|
27
34
|
|
|
28
|
-
opts.on("
|
|
35
|
+
opts.on("--up file") do |a|
|
|
29
36
|
file = File.open(a)
|
|
30
37
|
data = []
|
|
31
38
|
file.each do |line|
|
|
@@ -36,5 +43,50 @@ opts = OptionParser.new do |opts|
|
|
|
36
43
|
|
|
37
44
|
exit
|
|
38
45
|
end
|
|
46
|
+
|
|
47
|
+
opts.on("--download key") do |key|
|
|
48
|
+
https = Net::HTTP.new('hasteb.in', 443)
|
|
49
|
+
|
|
50
|
+
https.use_ssl = true
|
|
51
|
+
|
|
52
|
+
res = https.get("/raw/#{key}")
|
|
53
|
+
|
|
54
|
+
File.open("#{key}", 'w') do |line|
|
|
55
|
+
line.puts(res.body)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
exit
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
opts.on("--run key") do |key|
|
|
62
|
+
|
|
63
|
+
https = Net::HTTP.new('hasteb.in', 443)
|
|
64
|
+
https.use_ssl = true
|
|
65
|
+
|
|
66
|
+
res = https.get("/raw/#{key}")
|
|
67
|
+
|
|
68
|
+
File.open("#{key}.rb", 'w') do |line|
|
|
69
|
+
line.puts(res.body)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
require("./#{key}")
|
|
73
|
+
|
|
74
|
+
require("./#{key}")
|
|
75
|
+
File.delete("./#{key}.rb")
|
|
76
|
+
|
|
77
|
+
exit
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
opts.on("--read key") do |key|
|
|
81
|
+
https = Net::HTTP.new('hasteb.in', 443)
|
|
82
|
+
|
|
83
|
+
https.use_ssl = true
|
|
84
|
+
|
|
85
|
+
res = https.get("/raw/#{key}")
|
|
86
|
+
|
|
87
|
+
puts res.body
|
|
88
|
+
|
|
89
|
+
exit
|
|
90
|
+
end
|
|
39
91
|
end
|
|
40
92
|
opts.parse!
|
data/lib/hastebin.rb
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
require "uri"
|
|
2
2
|
require "net/http"
|
|
3
3
|
require "json"
|
|
4
|
+
require "colorize"
|
|
4
5
|
|
|
5
6
|
module Hastebin
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
$base_url = "https://hasteb.in/"
|
|
9
|
+
$domain = $base_url.gsub("https://","").gsub('/','')
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def self.write(code)
|
|
13
|
+
url = URI($base_url + "documents")
|
|
9
14
|
|
|
10
15
|
https = Net::HTTP.new(url.host, url.port);
|
|
11
16
|
https.use_ssl = true
|
|
12
17
|
|
|
13
18
|
request = Net::HTTP::Post.new(url)
|
|
14
19
|
request.body = code
|
|
15
|
-
|
|
20
|
+
puts "[INFO] ".red + "Sent with success".green
|
|
16
21
|
$res = https.request(request)
|
|
17
22
|
|
|
18
23
|
return JSON.parse($res.read_body)['key']
|
|
19
24
|
end
|
|
20
25
|
|
|
26
|
+
|
|
21
27
|
def self.sendFile(path)
|
|
22
28
|
|
|
23
29
|
file = File.open(path)
|
|
@@ -26,24 +32,29 @@ def self.sendFile(path)
|
|
|
26
32
|
data.push(line)
|
|
27
33
|
$text = data.join("")
|
|
28
34
|
end
|
|
29
|
-
return
|
|
35
|
+
return write($text)
|
|
30
36
|
end
|
|
31
37
|
|
|
32
38
|
def self.readRaw(key)
|
|
33
39
|
|
|
34
|
-
https = Net::HTTP.new(
|
|
40
|
+
https = Net::HTTP.new($domain, 443)
|
|
35
41
|
|
|
36
42
|
https.use_ssl = true
|
|
37
43
|
|
|
38
44
|
res = https.get("/raw/#{key}")
|
|
39
45
|
|
|
46
|
+
if res.code.to_i == 404
|
|
47
|
+
puts "[INFO] ".red+"#{JSON.parse(res.body)['message']}".red
|
|
48
|
+
else
|
|
49
|
+
puts "[INFO] ".red+"Received with success".green
|
|
50
|
+
return res.body
|
|
51
|
+
end
|
|
40
52
|
|
|
41
|
-
return res.body
|
|
42
53
|
end
|
|
43
54
|
|
|
44
55
|
def self.run(key)
|
|
45
56
|
|
|
46
|
-
https = Net::HTTP.new(
|
|
57
|
+
https = Net::HTTP.new($domain, 443)
|
|
47
58
|
|
|
48
59
|
https.use_ssl = true
|
|
49
60
|
|
|
@@ -59,17 +70,41 @@ def self.run(key)
|
|
|
59
70
|
File.delete("./#{key}.rb")
|
|
60
71
|
end
|
|
61
72
|
|
|
62
|
-
|
|
73
|
+
def self.download(key)
|
|
63
74
|
|
|
64
|
-
|
|
75
|
+
https = Net::HTTP.new($domain, 443)
|
|
65
76
|
|
|
66
|
-
|
|
77
|
+
https.use_ssl = true
|
|
67
78
|
|
|
68
|
-
|
|
79
|
+
res = https.get("/raw/#{key}")
|
|
69
80
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
81
|
+
File.open("#{key}", 'w') do |line|
|
|
82
|
+
line.puts(res.body)
|
|
83
|
+
end
|
|
73
84
|
|
|
74
|
-
|
|
85
|
+
end
|
|
86
|
+
def self.base_url
|
|
87
|
+
return $base_url
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def self.domain
|
|
91
|
+
return $domain
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def self.ping
|
|
95
|
+
t = Time.now()
|
|
96
|
+
uri = URI($base_url)
|
|
97
|
+
res = Net::HTTP.get(uri)
|
|
98
|
+
t = (Time.now().to_f - t.to_f) * 1000
|
|
99
|
+
puts res
|
|
100
|
+
return t.to_i
|
|
101
|
+
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Warns
|
|
105
|
+
|
|
106
|
+
def self.code(code)
|
|
107
|
+
return "[INFO] ".red+"Please use " + "write".green + " instead of " + "code".red
|
|
108
|
+
end
|
|
109
|
+
|
|
75
110
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hastebin
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Astin
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-08-
|
|
11
|
+
date: 2020-08-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: json
|
|
@@ -24,6 +24,20 @@ dependencies:
|
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: colorize
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
27
41
|
description: ''
|
|
28
42
|
email:
|
|
29
43
|
- ''
|