thorium 0.3.2 → 0.3.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d3aa3492009a3196b4b9e1fb4536b3d67c528d9
4
- data.tar.gz: 7f2cfad46f9e1c95036d39a72e35dbfde90fe677
3
+ metadata.gz: d0be3adba8cd2cbb26b1afeea7fd9c2ee1d0232c
4
+ data.tar.gz: c5f5b2c231ff20c98cb109722bee1eb39e483162
5
5
  SHA512:
6
- metadata.gz: f7f0e101967546c9c28b32cbfa49d8142222575e63b3e2756861b9dda8484e1fcfe106414aef885a909be9ab543c05c975f8a51154400236defcd13a380c9343
7
- data.tar.gz: ae5600f280de12b28aee26c9caba27850ac2ef9656d453e92e5aba9602001c19acf810db177af3a5a32c1474a905970d8732161d1f864b695237a8809c157fbe
6
+ metadata.gz: b266ff24f8d12859f3090733b31df86627778c53fddd78931cbac3208ad29487dedaf1070b71abb40f0bd11da7b5623d6b108afc826d5982291d4eee4bdf9a5a
7
+ data.tar.gz: 136274242cfbe0e4778c47e16721b1f2a98abb90656b1481c1b231e013b5eb8030313282447908eb9904bb18f3b1f2098f91808d016423e27e4dfe2b46292308
data/lib/thorium/base.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'thor'
2
2
  require 'thor/group'
3
3
 
4
+ require_relative 'core/bootstrap.rb'
4
5
  require_relative 'version'
5
6
  require_relative 'tasks/common'
6
7
  require_relative 'tasks/apache'
@@ -16,20 +17,21 @@ module ThoriumCLI
16
17
 
17
18
  class_option :verbose, :type => :boolean, :default => false
18
19
  @@os = ENV['_system_type']
20
+ @@skip = ""
19
21
 
20
22
  desc "pubkeys", "Simple public keys manipulation tool"
21
23
  def pubkeys
22
24
  public_keys = Dir.glob(File.expand_path("~/.ssh") + "/*.pub")
23
25
  if public_keys.any?
24
- say "\nPublic keys found:"
25
- say "------------------"
26
+ puts "\nPublic keys found:"
27
+ puts "------------------"
26
28
  public_keys.each_with_index do |f, i|
27
29
  say "[#{i+1}] #{f}", :blue
28
30
  run "cat #{f}", verbose: false
29
31
  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 - 1]}" unless index == "n"
32
+ ask_options = {:limited_to => ("1".."#{public_keys.size}").to_a, skip: @@skip}
33
+ index = ask("Which key do you want in your clipboard?", :green, ask_options)
34
+ run "pbcopy < #{public_keys[index.to_i-1]}" unless index == ask_options[:skip]
33
35
  else
34
36
  say "No public keys have been found.", :red
35
37
  generate_new = yes?("Do you want to generate a new one?", :green)
@@ -0,0 +1,25 @@
1
+ require "thor"
2
+
3
+ class Thor
4
+ module Shell
5
+ class Basic
6
+
7
+ def ask_filtered(statement, color, options)
8
+ answer_set = options[:limited_to]
9
+ correct_answer = nil
10
+ if options.has_key? :skip
11
+ statement += options[:skip].strip.empty? ? " (Enter to skip)" : " (#{options[:skip]} to skip)"
12
+ end
13
+ until correct_answer
14
+ answers = answer_set.join(", ")
15
+ answer = ask_simply("#{statement} [#{answers}]", color, options)
16
+ skipped = (options.has_key?(:skip) && (answer == options[:skip].chomp))
17
+ correct_answer = answer_set.include?(answer) || skipped ? answer : nil
18
+ say("Your response must be one of: [#{answers}]. Please try again.") unless correct_answer
19
+ end
20
+ correct_answer
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -4,8 +4,8 @@ module ApacheCLI
4
4
 
5
5
  include Thor::Actions
6
6
 
7
- class_option :verbose, :type => :boolean, :default => 1
8
- class_option :sudo, :type => :boolean, :default => 1
7
+ class_option :verbose, :type => :boolean, :default => true
8
+ class_option :sudo, :type => :boolean, :default => true
9
9
  class_option :ctl_method, :enum => ['apachectl', 'apache2ctl', 'service'], :default => 'apachectl'
10
10
 
11
11
  desc "ctl [ARGS]", "Apache controller wrapper"
@@ -19,7 +19,7 @@ module ApacheCLI
19
19
  LONGDESC
20
20
  def ctl(*args)
21
21
  command = "#{options[:ctl_method]} #{args * ' '}"
22
- command = 'sudo ' + command if options[:root] == 1
22
+ command = 'sudo ' + command if options[:sudo]
23
23
  run(command, {:verbose => options[:verbose], :capture => false})
24
24
  end
25
25
 
@@ -10,8 +10,8 @@ module GitCLI
10
10
  desc "list", "Lists Github repositories"
11
11
  def list
12
12
  require 'json'
13
- require 'pp'
14
13
  gh_uname = ask("Enter Github username: ", :green)
14
+ abort if gh_uname.empty?
15
15
  puts "\nFetching Github repositories (#{gh_uname})..."
16
16
  puts "------------------------------------------"
17
17
  @repos = get_gh_repos(gh_uname).each_with_index.map do |e, i|
@@ -23,10 +23,13 @@ module GitCLI
23
23
  desc "clone", "Clones a repository from the list"
24
24
  def clone
25
25
  list
26
- index = ask("Which repository would you like to clone?", :green, :limited_to => ("1".."#{@repos.size}").to_a).to_i
26
+ # Do not do anything if list is empty
27
+ ask_options = {limited_to: ("1".."#{@repos.size}").to_a, skip: ""}
28
+ answer = ask("Which repository would you like to clone?", :green, ask_options)
29
+ abort if answer == ask_options[:skip]
27
30
  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}")
31
+ url = protocol == "s" ? @repos[answer.to_i-1][2] : @repos[answer-1][3]
32
+ run "git clone #{url}"
30
33
  end
31
34
 
32
35
  no_commands {
@@ -1,3 +1,3 @@
1
1
  module Thorium
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thorium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Stankevich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-20 00:00:00.000000000 Z
11
+ date: 2014-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -34,6 +34,7 @@ files:
34
34
  - bin/thorium
35
35
  - lib/thorium.rb
36
36
  - lib/thorium/base.rb
37
+ - lib/thorium/core/bootstrap.rb
37
38
  - lib/thorium/tasks/apache.rb
38
39
  - lib/thorium/tasks/common.rb
39
40
  - lib/thorium/tasks/git.rb