thorium 0.1.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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/thorium +92 -0
  3. data/lib/thorium.rb +92 -0
  4. metadata +60 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ea7ce0f2b1656f58246d0e8ddd6b5773563d35e8
4
+ data.tar.gz: a9a20275e2dee472020c31e1b38f70682e30fcbd
5
+ SHA512:
6
+ metadata.gz: 08c5e81d2816599a0944cccb7ce754a0bfe3a19e0dd24168a18dc23e8ae652dbedff59561bd822f179630f1cc5eeb3eca26d983f821ea5ee5420e564842f9c6a
7
+ data.tar.gz: bbbfa3b6aac513acaf8e918c825c9c8afda69b0226556b82f090d9cca20db4a699fc192c38d6ed276f941a8e9dbc71ea58e37602bde84c2f2d69b0358e625934
data/bin/thorium ADDED
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env ruby
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
+ class_option :verbose, :type => :boolean, :default => 1
44
+
45
+ desc "list", "List Github repositories"
46
+ def list
47
+ require 'json'
48
+ username = ask("Github username: ")
49
+ github_url = "https://api.github.com/users/#{username}/repos"
50
+ github_repos_filepath = ENV['HOME'] + "/.thorium/github_repos_#{username}.json"
51
+ # Get repos from github api
52
+ get github_url, github_repos_filepath
53
+ # Save response in a file
54
+ response_json = File.read(github_repos_filepath)
55
+ response_hash = JSON.parse(response_json)
56
+ puts "#{username}'s repositories (name, ssh url, clone url)"
57
+ puts "====================================================="
58
+ print_table response_hash.map { |e| e.values_at("name", "ssh_url", "clone_url") }
59
+ end
60
+
61
+ end
62
+ end
63
+
64
+
65
+ module ThoriumCLI
66
+ # Main tasks class
67
+ class Thorium < Thor
68
+ package_name 'Thorium'
69
+
70
+ include ApacheCLI
71
+ include GitCLI
72
+
73
+ @@os = ENV['_system_type']
74
+
75
+ class_option :verbose, :type => :boolean, :default => false
76
+
77
+ desc "hello", "This command says hello to Thorium!"
78
+ def hello
79
+ name = ask("What is your name?")
80
+ puts "Hello #{name}! Hello from Thorium!"
81
+ end
82
+
83
+ desc "apache [SUBCOMMAND] [ARGS]", "Control Apache with ease!"
84
+ subcommand "apache", Apache
85
+
86
+ desc "git [SUBCOMMAND] [ARGS]", "Git wrapper"
87
+ subcommand "git", Git
88
+ end
89
+ end
90
+
91
+
92
+ ThoriumCLI::Thorium.start(ARGV)
data/lib/thorium.rb ADDED
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env ruby
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
+ class_option :verbose, :type => :boolean, :default => 1
44
+
45
+ desc "list", "List Github repositories"
46
+ def list
47
+ require 'json'
48
+ username = ask("Github username: ")
49
+ github_url = "https://api.github.com/users/#{username}/repos"
50
+ github_repos_filepath = ENV['HOME'] + "/.thorium/github_repos_#{username}.json"
51
+ # Get repos from github api
52
+ get github_url, github_repos_filepath
53
+ # Save response in a file
54
+ response_json = File.read(github_repos_filepath)
55
+ response_hash = JSON.parse(response_json)
56
+ puts "#{username}'s repositories (name, ssh url, clone url)"
57
+ puts "====================================================="
58
+ print_table response_hash.map { |e| e.values_at("name", "ssh_url", "clone_url") }
59
+ end
60
+
61
+ end
62
+ end
63
+
64
+
65
+ module ThoriumCLI
66
+ # Main tasks class
67
+ class Thorium < Thor
68
+ package_name 'Thorium'
69
+
70
+ include ApacheCLI
71
+ include GitCLI
72
+
73
+ @@os = ENV['_system_type']
74
+
75
+ class_option :verbose, :type => :boolean, :default => false
76
+
77
+ desc "hello", "This command says hello to Thorium!"
78
+ def hello
79
+ name = ask("What is your name?")
80
+ puts "Hello #{name}! Hello from Thorium!"
81
+ end
82
+
83
+ desc "apache [SUBCOMMAND] [ARGS]", "Control Apache with ease!"
84
+ subcommand "apache", Apache
85
+
86
+ desc "git [SUBCOMMAND] [ARGS]", "Git wrapper"
87
+ subcommand "git", Git
88
+ end
89
+ end
90
+
91
+
92
+ ThoriumCLI::Thorium.start(ARGV)
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: thorium
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Stankevich
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Workflow automation gem
28
+ email: standeo@gmail.com
29
+ executables:
30
+ - thorium
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - bin/thorium
35
+ - lib/thorium.rb
36
+ homepage: http://rubygems.org/gems/thorium
37
+ licenses:
38
+ - GPL3
39
+ metadata: {}
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubyforge_project:
56
+ rubygems_version: 2.2.2
57
+ signing_key:
58
+ specification_version: 4
59
+ summary: thorium!
60
+ test_files: []