thorium 0.2.2 → 0.3.1
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/thorium +1 -105
- data/lib/thorium.rb +1 -109
- data/lib/thorium/base.rb +48 -0
- data/lib/thorium/tasks/apache.rb +30 -0
- data/lib/thorium/tasks/common.rb +0 -0
- data/lib/thorium/tasks/git.rb +42 -0
- data/lib/thorium/version.rb +3 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 441295ee5f5be485ddd9eef6e3618b9577fd1b47
|
4
|
+
data.tar.gz: 1700856feeb85ccb7683c71d7b0e4eb62094a47b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 629b47430a0577e76bd5b5780432215baac40aa48d5c90c31c1a51e0796fe2f9aad5e799402eae69fc1ab4c0257f306ef947bcd929e1021d1045ccde443e9bd3
|
7
|
+
data.tar.gz: 22887c00828f0d550ba73742bddd474de0ba01fdd1a466f58511584408586d40ea5ab8d46ea3e800904c28b64bff2fab6a6a629366bd2c4095bacb1622c93142
|
data/bin/thorium
CHANGED
@@ -1,109 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'thor/group'
|
5
|
-
|
6
|
-
module ApacheCLI
|
7
|
-
class Apache < Thor
|
8
|
-
package_name 'Thorium | Apache'
|
9
|
-
|
10
|
-
include Thor::Actions
|
11
|
-
|
12
|
-
class_option :verbose, :type => :boolean, :default => 1
|
13
|
-
class_option :sudo, :type => :boolean, :default => 1
|
14
|
-
class_option :ctl_method, :enum => ['apachectl', 'apache2ctl', 'service'], :default => 'apachectl'
|
15
|
-
|
16
|
-
desc "ctl [ARGS]", "Apache controller wrapper"
|
17
|
-
long_desc <<-LONGDESC
|
18
|
-
`start` - Starts apache
|
19
|
-
`stop` - Stops apache
|
20
|
-
`restart` - Restarts apache
|
21
|
-
`graceful` - Restarts apache gracefully
|
22
|
-
`status` - Apache status
|
23
|
-
> $ ctl restart
|
24
|
-
LONGDESC
|
25
|
-
def ctl(*args)
|
26
|
-
command = "#{options[:ctl_method]} #{args * ' '}"
|
27
|
-
command = 'sudo ' + command if options[:root] == 1
|
28
|
-
run(command, {:verbose => options[:verbose], :capture => false})
|
29
|
-
end
|
30
|
-
|
31
|
-
no_commands {
|
32
|
-
|
33
|
-
}
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
module GitCLI
|
38
|
-
class Git < Thor
|
39
|
-
package_name 'Thorium | Git'
|
40
|
-
|
41
|
-
include Thor::Actions
|
42
|
-
|
43
|
-
@@gh_api_url = "https://api.github.com"
|
44
|
-
|
45
|
-
class_option :verbose, :type => :boolean, :default => 1
|
46
|
-
|
47
|
-
desc "list", "Lists Github repositories"
|
48
|
-
def list
|
49
|
-
require 'json'
|
50
|
-
require 'pp'
|
51
|
-
gh_uname = ask("Enter Github username: ")
|
52
|
-
puts "\nFetching Github repositories (#{gh_uname})..."
|
53
|
-
puts "------------------------------------------"
|
54
|
-
@repos = get_gh_repos(gh_uname).each_with_index.map do |e, i|
|
55
|
-
e.values_at("name", "ssh_url", "clone_url").unshift("[#{i+1}]")
|
56
|
-
end
|
57
|
-
print_table @repos
|
58
|
-
end
|
59
|
-
|
60
|
-
desc "clone", "Clones a repository from the list"
|
61
|
-
def clone
|
62
|
-
list
|
63
|
-
index = ask("Which repository would you like to clone?", :limited_to => ("1".."#{@repos.size}").to_a).to_i
|
64
|
-
protocol = ask("Select a protocol (ssh or https)?", :limited_to => ["s", "h"])
|
65
|
-
url = protocol == "s" ? @repos[index-1][2] : @repos[index-1][3]
|
66
|
-
run("git clone #{url}")
|
67
|
-
end
|
68
|
-
|
69
|
-
no_commands {
|
70
|
-
def get_gh_repos(uname)
|
71
|
-
url = "#{@@gh_api_url}/users/#{uname}/repos"
|
72
|
-
gh_repos_filepath = ENV['HOME'] + "/.thorium/gh_repos_#{uname}.json"
|
73
|
-
get url, gh_repos_filepath, :verbose => false
|
74
|
-
JSON.parse File.read(gh_repos_filepath)
|
75
|
-
end
|
76
|
-
}
|
77
|
-
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
|
82
|
-
module ThoriumCLI
|
83
|
-
# Main tasks class
|
84
|
-
class Thorium < Thor
|
85
|
-
package_name 'Thorium'
|
86
|
-
|
87
|
-
include ApacheCLI
|
88
|
-
include GitCLI
|
89
|
-
|
90
|
-
@@os = ENV['_system_type']
|
91
|
-
|
92
|
-
class_option :verbose, :type => :boolean, :default => false
|
93
|
-
|
94
|
-
desc "hello", "This command says hello to Thorium!"
|
95
|
-
def hello
|
96
|
-
name = ask("What is your name?")
|
97
|
-
puts "Hello #{name}! Hello from Thorium!"
|
98
|
-
end
|
99
|
-
|
100
|
-
desc "apache [SUBCOMMAND] [ARGS]", "Control Apache with ease!"
|
101
|
-
subcommand "apache", Apache
|
102
|
-
|
103
|
-
desc "git [SUBCOMMAND] [ARGS]", "Git wrapper"
|
104
|
-
subcommand "git", Git
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
3
|
+
require 'thorium'
|
108
4
|
|
109
5
|
ThoriumCLI::Thorium.start(ARGV)
|
data/lib/thorium.rb
CHANGED
@@ -1,109 +1 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'thor'
|
4
|
-
require 'thor/group'
|
5
|
-
|
6
|
-
module ApacheCLI
|
7
|
-
class Apache < Thor
|
8
|
-
package_name 'Thorium | Apache'
|
9
|
-
|
10
|
-
include Thor::Actions
|
11
|
-
|
12
|
-
class_option :verbose, :type => :boolean, :default => 1
|
13
|
-
class_option :sudo, :type => :boolean, :default => 1
|
14
|
-
class_option :ctl_method, :enum => ['apachectl', 'apache2ctl', 'service'], :default => 'apachectl'
|
15
|
-
|
16
|
-
desc "ctl [ARGS]", "Apache controller wrapper"
|
17
|
-
long_desc <<-LONGDESC
|
18
|
-
`start` - Starts apache
|
19
|
-
`stop` - Stops apache
|
20
|
-
`restart` - Restarts apache
|
21
|
-
`graceful` - Restarts apache gracefully
|
22
|
-
`status` - Apache status
|
23
|
-
> $ ctl restart
|
24
|
-
LONGDESC
|
25
|
-
def ctl(*args)
|
26
|
-
command = "#{options[:ctl_method]} #{args * ' '}"
|
27
|
-
command = 'sudo ' + command if options[:root] == 1
|
28
|
-
run(command, {:verbose => options[:verbose], :capture => false})
|
29
|
-
end
|
30
|
-
|
31
|
-
no_commands {
|
32
|
-
|
33
|
-
}
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
module GitCLI
|
38
|
-
class Git < Thor
|
39
|
-
package_name 'Thorium | Git'
|
40
|
-
|
41
|
-
include Thor::Actions
|
42
|
-
|
43
|
-
@@gh_api_url = "https://api.github.com"
|
44
|
-
|
45
|
-
class_option :verbose, :type => :boolean, :default => 1
|
46
|
-
|
47
|
-
desc "list", "Lists Github repositories"
|
48
|
-
def list
|
49
|
-
require 'json'
|
50
|
-
require 'pp'
|
51
|
-
gh_uname = ask("Enter Github username: ")
|
52
|
-
puts "\nFetching Github repositories (#{gh_uname})..."
|
53
|
-
puts "------------------------------------------"
|
54
|
-
@repos = get_gh_repos(gh_uname).each_with_index.map do |e, i|
|
55
|
-
e.values_at("name", "ssh_url", "clone_url").unshift("[#{i+1}]")
|
56
|
-
end
|
57
|
-
print_table @repos
|
58
|
-
end
|
59
|
-
|
60
|
-
desc "clone", "Clones a repository from the list"
|
61
|
-
def clone
|
62
|
-
list
|
63
|
-
index = ask("Which repository would you like to clone?", :limited_to => ("1".."#{@repos.size}").to_a).to_i
|
64
|
-
protocol = ask("Select a protocol (ssh or https)?", :limited_to => ["s", "h"])
|
65
|
-
url = protocol == "s" ? @repos[index-1][2] : @repos[index-1][3]
|
66
|
-
run("git clone #{url}")
|
67
|
-
end
|
68
|
-
|
69
|
-
no_commands {
|
70
|
-
def get_gh_repos(uname)
|
71
|
-
url = "#{@@gh_api_url}/users/#{uname}/repos"
|
72
|
-
gh_repos_filepath = ENV['HOME'] + "/.thorium/gh_repos_#{uname}.json"
|
73
|
-
get url, gh_repos_filepath, :verbose => false
|
74
|
-
JSON.parse File.read(gh_repos_filepath)
|
75
|
-
end
|
76
|
-
}
|
77
|
-
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
|
82
|
-
module ThoriumCLI
|
83
|
-
# Main tasks class
|
84
|
-
class Thorium < Thor
|
85
|
-
package_name 'Thorium'
|
86
|
-
|
87
|
-
include ApacheCLI
|
88
|
-
include GitCLI
|
89
|
-
|
90
|
-
@@os = ENV['_system_type']
|
91
|
-
|
92
|
-
class_option :verbose, :type => :boolean, :default => false
|
93
|
-
|
94
|
-
desc "hello", "This command says hello to Thorium!"
|
95
|
-
def hello
|
96
|
-
name = ask("What is your name?")
|
97
|
-
puts "Hello #{name}! Hello from Thorium!"
|
98
|
-
end
|
99
|
-
|
100
|
-
desc "apache [SUBCOMMAND] [ARGS]", "Control Apache with ease!"
|
101
|
-
subcommand "apache", Apache
|
102
|
-
|
103
|
-
desc "git [SUBCOMMAND] [ARGS]", "Git wrapper"
|
104
|
-
subcommand "git", Git
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
|
109
|
-
ThoriumCLI::Thorium.start(ARGV)
|
1
|
+
require_relative 'thorium/base'
|
data/lib/thorium/base.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'thor/group'
|
3
|
+
|
4
|
+
require_relative 'version'
|
5
|
+
require_relative 'tasks/common'
|
6
|
+
require_relative 'tasks/apache'
|
7
|
+
require_relative 'tasks/git'
|
8
|
+
|
9
|
+
module ThoriumCLI
|
10
|
+
class Thorium < Thor
|
11
|
+
package_name 'Thorium'
|
12
|
+
|
13
|
+
include Thor::Actions
|
14
|
+
include ApacheCLI
|
15
|
+
include GitCLI
|
16
|
+
|
17
|
+
class_option :verbose, :type => :boolean, :default => false
|
18
|
+
@@os = ENV['_system_type']
|
19
|
+
|
20
|
+
desc "pubkeys", "Simple public keys manipulation tool"
|
21
|
+
def pubkeys
|
22
|
+
public_keys = Dir.glob(File.expand_path("~/.ssh") + "/*.pub")
|
23
|
+
if public_keys.any?
|
24
|
+
say "\nPublic keys found:"
|
25
|
+
say "------------------"
|
26
|
+
public_keys.each_with_index do |f, i|
|
27
|
+
say "[#{i+1}] #{f}", :blue
|
28
|
+
run "cat #{f}", verbose: false
|
29
|
+
end
|
30
|
+
answers = ["n"] + ("1".."#{public_keys.size}").to_a
|
31
|
+
index = ask("Which key do you want in your clipboard (n for none)?", :green, :limited_to => answers)
|
32
|
+
run "pbcopy < #{public_keys[index.to_i]}" unless index == "n"
|
33
|
+
else
|
34
|
+
say "No public keys have been found.", :red
|
35
|
+
generate_new = yes?("Do you want to generate a new one?", :green)
|
36
|
+
run "ssh-keygen" if generate_new
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Apache subcommand
|
41
|
+
desc "apache [SUBCOMMAND] [ARGS]", "Control Apache with ease!"
|
42
|
+
subcommand "apache", Apache
|
43
|
+
|
44
|
+
# Git subcommand
|
45
|
+
desc "git [SUBCOMMAND] [ARGS]", "Git wrapper"
|
46
|
+
subcommand "git", Git
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module ApacheCLI
|
2
|
+
class Apache < Thor
|
3
|
+
package_name 'Thorium | Apache'
|
4
|
+
|
5
|
+
include Thor::Actions
|
6
|
+
|
7
|
+
class_option :verbose, :type => :boolean, :default => 1
|
8
|
+
class_option :sudo, :type => :boolean, :default => 1
|
9
|
+
class_option :ctl_method, :enum => ['apachectl', 'apache2ctl', 'service'], :default => 'apachectl'
|
10
|
+
|
11
|
+
desc "ctl [ARGS]", "Apache controller wrapper"
|
12
|
+
long_desc <<-LONGDESC
|
13
|
+
`start` - Starts apache
|
14
|
+
`stop` - Stops apache
|
15
|
+
`restart` - Restarts apache
|
16
|
+
`graceful` - Restarts apache gracefully
|
17
|
+
`status` - Apache status
|
18
|
+
> $ ctl restart
|
19
|
+
LONGDESC
|
20
|
+
def ctl(*args)
|
21
|
+
command = "#{options[:ctl_method]} #{args * ' '}"
|
22
|
+
command = 'sudo ' + command if options[:root] == 1
|
23
|
+
run(command, {:verbose => options[:verbose], :capture => false})
|
24
|
+
end
|
25
|
+
|
26
|
+
no_commands {
|
27
|
+
|
28
|
+
}
|
29
|
+
end
|
30
|
+
end
|
File without changes
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module GitCLI
|
2
|
+
class Git < Thor
|
3
|
+
package_name 'Thorium | Git'
|
4
|
+
|
5
|
+
include Thor::Actions
|
6
|
+
|
7
|
+
class_option :verbose, :type => :boolean, :default => 1
|
8
|
+
@@gh_api_url = "https://api.github.com"
|
9
|
+
|
10
|
+
desc "list", "Lists Github repositories"
|
11
|
+
def list
|
12
|
+
require 'json'
|
13
|
+
require 'pp'
|
14
|
+
gh_uname = ask("Enter Github username: ", :green)
|
15
|
+
puts "\nFetching Github repositories (#{gh_uname})..."
|
16
|
+
puts "------------------------------------------"
|
17
|
+
@repos = get_gh_repos(gh_uname).each_with_index.map do |e, i|
|
18
|
+
e.values_at("name", "ssh_url", "clone_url").unshift("[#{i+1}]")
|
19
|
+
end
|
20
|
+
print_table @repos
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "clone", "Clones a repository from the list"
|
24
|
+
def clone
|
25
|
+
list
|
26
|
+
index = ask("Which repository would you like to clone?", :green, :limited_to => ("1".."#{@repos.size}").to_a).to_i
|
27
|
+
protocol = ask("Select a protocol (ssh or https)?", :green, :limited_to => ["s", "h"])
|
28
|
+
url = protocol == "s" ? @repos[index-1][2] : @repos[index-1][3]
|
29
|
+
run("git clone #{url}")
|
30
|
+
end
|
31
|
+
|
32
|
+
no_commands {
|
33
|
+
# Fetches Github repositories for a given user
|
34
|
+
def get_gh_repos(uname)
|
35
|
+
url = "#{@@gh_api_url}/users/#{uname}/repos"
|
36
|
+
gh_repos_filepath = ENV['HOME'] + "/.thorium/gh_repos_#{uname}.json"
|
37
|
+
get url, gh_repos_filepath, :verbose => false
|
38
|
+
JSON.parse File.read(gh_repos_filepath)
|
39
|
+
end
|
40
|
+
}
|
41
|
+
end
|
42
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thorium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Stankevich
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
description:
|
27
|
+
description: Simple workflow automation toolkit.
|
28
28
|
email: standeo@gmail.com
|
29
29
|
executables:
|
30
30
|
- thorium
|
@@ -33,6 +33,11 @@ extra_rdoc_files: []
|
|
33
33
|
files:
|
34
34
|
- bin/thorium
|
35
35
|
- lib/thorium.rb
|
36
|
+
- lib/thorium/base.rb
|
37
|
+
- lib/thorium/tasks/apache.rb
|
38
|
+
- lib/thorium/tasks/common.rb
|
39
|
+
- lib/thorium/tasks/git.rb
|
40
|
+
- lib/thorium/version.rb
|
36
41
|
homepage: http://rubygems.org/gems/thorium
|
37
42
|
licenses:
|
38
43
|
- GPL3
|
@@ -56,5 +61,5 @@ rubyforge_project:
|
|
56
61
|
rubygems_version: 2.2.2
|
57
62
|
signing_key:
|
58
63
|
specification_version: 4
|
59
|
-
summary:
|
64
|
+
summary: Ruby gem for workflow automation
|
60
65
|
test_files: []
|