volcano 0.1.0

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/volcano +104 -0
  3. metadata +64 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3d40887b50383c78e538fb7006af891e2296fd7a2ab04e5e71e78170dd0e93fd
4
+ data.tar.gz: 1288e96e1bee06eb3cabf786ace2b850d3db038a8ac983261a9100e8338a7459
5
+ SHA512:
6
+ metadata.gz: 0d389e7720d19ebf3b32f77a0c6e7a1fd67f54434b9b3a8d550a0a04b2bd7244c3988a4976e0d62b6c249237f296648084cf21b24956513ff58401a143e37e1d
7
+ data.tar.gz: c6c3315dc6707d247ee9d2289c137749bdd867b7a258ad2d14c3bce82f20021f85e0b9515e525153a950782f0b3928b6486fbd5beb125f753d63a4fd6a0418ce
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'optparse'
4
+ require 'net/http'
5
+ require 'fileutils'
6
+ require 'zip'
7
+
8
+ helptext = %{
9
+ Volcano v 0.1.0
10
+ Usage: volcano command [args]...
11
+ Commands:
12
+ help: print this help text.
13
+ install: install a package.
14
+ uninstall: remove a package.
15
+ }
16
+
17
+ options = {}
18
+ OptionParser.new do |parser|
19
+ parser.banner = helptext
20
+ end.parse!
21
+
22
+ config = File.join (File.expand_path "~"), ".volcano"
23
+
24
+ unless File.directory? "#{config}"
25
+ puts "\x1b[0;33mNo config directory, creating one at #{config}...\x1b[0;0m"
26
+ Dir.mkdir config
27
+ end
28
+
29
+ File.write "#{config}/env", "export SDX_PATH=#{config}"
30
+
31
+ if ARGV.empty?
32
+ puts helptext
33
+ exit 1
34
+ end
35
+
36
+ op = ARGV.shift
37
+
38
+ case op
39
+ when "help"
40
+ puts helptext
41
+ exit 0
42
+ when "install"
43
+ if ARGV.empty?
44
+ puts helptext
45
+ exit 1
46
+ end
47
+ repo = ARGV.shift
48
+ unless /^[A-Za-z0-9-]+\/[A-Za-z0-9-]+$/ =~ repo
49
+ puts "\x1b[0;31mError: invalid repo #{repo}"
50
+ exit 1
51
+ end
52
+ last = (repo.split "/")[-1]
53
+ puts "Downloading github.com/#{repo}..."
54
+ Net::HTTP.start "api.github.com", :use_ssl => true do |http|
55
+ resp = http.get "/repos/#{repo}/zipball/master"
56
+ case resp
57
+ when Net::HTTPRedirection
58
+ uri = resp['location']
59
+ uri = URI.parse uri
60
+ Net::HTTP.start uri.host, uri.port, :use_ssl => true do |http|
61
+ resp = Net::HTTP.get uri
62
+ FileUtils.rm_rf "#{config}/#{last}"
63
+ Dir.mkdir "#{config}/#{last}"
64
+ Zip::InputStream.open (StringIO.new resp) do |io|
65
+ entries = []
66
+ while entry = io.get_next_entry
67
+ entries << entry.name
68
+ unless entry.name.end_with? "/"
69
+ dirname = File.dirname entry.name
70
+ dirname = (dirname.split "/")[1..-1].join "/"
71
+ name = File.join dirname, (File.basename entry.name)
72
+ if name[0] == "/"
73
+ name = name[1..-1]
74
+ end
75
+ FileUtils.mkdir_p (File.join "#{config}/#{last}", dirname)
76
+ File.write "#{config}/#{last}/#{name}", io.read
77
+ end
78
+ end
79
+ env = File.read "#{config}/env"
80
+ File.write "#{config}/env", "#{env}:#{config}/#{last}:#{config}/#{last}/lib"
81
+ FileUtils.rm_rf "#{config}/#{entries[0]}"
82
+ end
83
+ end
84
+ else
85
+ puts "\x1b[0;31mError: invalid repo #{repo}"
86
+ exit 1
87
+ end
88
+ end
89
+ when "uninstall"
90
+ if ARGV.empty?
91
+ puts helptext
92
+ exit 1
93
+ end
94
+ repo = ARGV.shift
95
+ unless /^[A-Za-z0-9-]+$/ =~ repo
96
+ puts "\x1b[0;31mError: invalid repo #{repo}"
97
+ exit 1
98
+ end
99
+ if File.directory? "#{config}/#{repo}"
100
+ FileUtils.rm_rf "#{config}/#{repo}"
101
+ else
102
+ puts "\x1b[0;31mError: library #{repo} is not installed\x1b[0;0m"
103
+ end
104
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: volcano
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - sugarfi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-08-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubyzip
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.3.0
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.3.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 2.3.0
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.3.0
33
+ description:
34
+ email: sugarfi@sugarfi.dev
35
+ executables:
36
+ - volcano
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - bin/volcano
41
+ homepage: https://github.com/SardonyxLang/Volcano
42
+ licenses:
43
+ - MIT
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubygems_version: 3.1.2
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: Package manager for Sardonyx
64
+ test_files: []