rdh 1.0.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.
- checksums.yaml +7 -0
- data/bin/rdh +81 -0
- data/lib/rdh/rdh_api.rb +25 -0
- data/lib/rdh.rb +25 -0
- metadata +48 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f8b7280b1d41a2c6d040e2b025d66bae545106d6
|
4
|
+
data.tar.gz: eca74487410a7076f648811dee340cd4f2f26c99
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e552ce426bfc52de46a83a800dc7cb329653f6286b8e12d1306c5a3c37a7c4c16a13fadca079b4e22fa50b5c04bc064b95d1e9654c59d89921f2e52065f63d73
|
7
|
+
data.tar.gz: 5aebda18ea28e7c1fe64396656d819e5e08ddaf22b34e9cace0dc3d8919847f27a512fe316b8cde97b66a26615d7baa5e4bff796a93749164527b9b6a7fab849
|
data/bin/rdh
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rdh'
|
4
|
+
|
5
|
+
action = ARGV[0] # either inspect or contribute
|
6
|
+
|
7
|
+
def inspect_gem
|
8
|
+
gem_name = ARGV[1]
|
9
|
+
version = ARGV[2]
|
10
|
+
|
11
|
+
resp = Rdh.inspect_gem(gem_name, version)
|
12
|
+
puts resp
|
13
|
+
if resp[:success] == false
|
14
|
+
puts "Apologies, We coudn't find any helping information for this gem."
|
15
|
+
puts "Maybe you can help by contributing?"
|
16
|
+
exit 1
|
17
|
+
end
|
18
|
+
puts 'Found dependencies:'
|
19
|
+
resp[:results].each do |dep|
|
20
|
+
puts ' - ' + dep['name']
|
21
|
+
end
|
22
|
+
|
23
|
+
puts 'We can try to install these packages for you, proceed ? (y/N)'
|
24
|
+
input = STDIN.gets.chomp
|
25
|
+
case input
|
26
|
+
when 'Y', 'y'
|
27
|
+
os = resp[:os]
|
28
|
+
deps = ''
|
29
|
+
resp[:results].each do |dep|
|
30
|
+
deps += dep['name'] + ' '
|
31
|
+
end
|
32
|
+
if os == 'linux'
|
33
|
+
system('sudo apt-get -y install '+ deps)
|
34
|
+
elsif os == 'macos'
|
35
|
+
system('brew install ' + deps)
|
36
|
+
else
|
37
|
+
puts 'Failed to detect os'
|
38
|
+
exit 0
|
39
|
+
end
|
40
|
+
else
|
41
|
+
exit 1
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def contribute
|
46
|
+
os = Rdh.get_os
|
47
|
+
# list of installed gems
|
48
|
+
gems = Bundler.load.specs
|
49
|
+
puts 'Found ' + gems.length.to_s + ' gems,'
|
50
|
+
puts 'we will loop over the gems so you can add deps, you can add one or more dependencies separated by commas,'
|
51
|
+
puts 'enter "n" to skip to the next gem, or exit to cancel and quit'
|
52
|
+
gems.each do |gem|
|
53
|
+
puts " => enter dependencies for " + gem.name + "(" + gem.version.to_s + "): "
|
54
|
+
input = STDIN.gets.chomp
|
55
|
+
if input == 'n'
|
56
|
+
next
|
57
|
+
elsif input == 'exit'
|
58
|
+
exit 1
|
59
|
+
else
|
60
|
+
dependencies = []
|
61
|
+
deps = input.split(/[\s,]+/)
|
62
|
+
deps.each do |d|
|
63
|
+
dependencies.push({name: d, os: os})
|
64
|
+
end
|
65
|
+
if dependencies.length > 0
|
66
|
+
Rdh.contribute_gem(gem.name, gem.version.to_s, dependencies)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
puts 'Thanks for your contributions !'
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
if action == 'inspect'
|
76
|
+
inspect_gem
|
77
|
+
elsif action == 'contribute'
|
78
|
+
contribute
|
79
|
+
else
|
80
|
+
puts "error: unkown operation, either 'inspect' or 'contribute'"
|
81
|
+
end
|
data/lib/rdh/rdh_api.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
BASE_URI = 'http://localhost:3000'
|
5
|
+
|
6
|
+
class RdhApi
|
7
|
+
|
8
|
+
def self.get(gem_name, version, os)
|
9
|
+
uri = BASE_URI + '/api/gems/' + gem_name
|
10
|
+
options = {os: os, version: version}
|
11
|
+
|
12
|
+
resp = HTTParty.get(uri, options)
|
13
|
+
if resp.code != 200
|
14
|
+
return {success: false, code: resp.code}
|
15
|
+
end
|
16
|
+
return {success: true, results: JSON.parse(resp.body), os: os}
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.create(gem_name, version, dependencies)
|
20
|
+
body = {dependencies: dependencies, version: version}
|
21
|
+
uri = BASE_URI + '/api/gems/' + gem_name
|
22
|
+
|
23
|
+
HTTParty.post(uri, :body => body.to_json, :headers => { 'Content-Type' => 'application/json' })
|
24
|
+
end
|
25
|
+
end
|
data/lib/rdh.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rdh/rdh_api'
|
2
|
+
|
3
|
+
class Rdh
|
4
|
+
def self.get_os
|
5
|
+
os = RbConfig::CONFIG['host_os']
|
6
|
+
if os =~ /darwin|mac os/
|
7
|
+
return 'macos'
|
8
|
+
elsif os =~ /linux/
|
9
|
+
return 'linux'
|
10
|
+
else
|
11
|
+
return 'unknown'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.inspect_gem(gem_name, version)
|
16
|
+
os = self.get_os
|
17
|
+
dep = RdhApi.get(gem_name, version, os)
|
18
|
+
return dep
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def self.contribute_gem(gem_name, version, dependencies)
|
23
|
+
resp = RdhApi.create(gem_name, version, dependencies)
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rdh
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eslam Mostafa
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-03-11 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A gem that interacts with rdh-api to help you list system dependences
|
14
|
+
for a certain gem
|
15
|
+
email: cseslam@gmail.com
|
16
|
+
executables:
|
17
|
+
- rdh
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- bin/rdh
|
22
|
+
- lib/rdh.rb
|
23
|
+
- lib/rdh/rdh_api.rb
|
24
|
+
homepage:
|
25
|
+
licenses:
|
26
|
+
- MIT
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 2.6.10
|
45
|
+
signing_key:
|
46
|
+
specification_version: 4
|
47
|
+
summary: Ruby Dependency Helper Gem
|
48
|
+
test_files: []
|