ding 0.8.0 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8a39c932af78aaa0bb31eb6241ea47df2540a0d
4
- data.tar.gz: f779635e7018639696730787ae88ca5d3eb23518
3
+ metadata.gz: a1be9dc233de1e9fa9ef54dc9598581bf831bc05
4
+ data.tar.gz: 6ca2841edd020de0c0a6da25e027370497ae7423
5
5
  SHA512:
6
- metadata.gz: 874a0c0ac45b7f02a6b9c08dfeb7e4dd64e9bbab3d5e70b87be43ba0e84f54ce94f3c9b24a5040bd70636efa3c1b7e04835aa9151e82d9459eaf2531c81b92d5
7
- data.tar.gz: d4d7f4a3c2276fc4f0f3960320acb11cd96c3c920883159d76acc9ffac11ac44fb054136e6f4c361a0f9ef73188d78e6b82bc0e307ad64060de3d8e42eea7a5e
6
+ metadata.gz: 214c096bdc4cff13250bc1f0af923f331a5f29aa89ec59213f90355798c58e167faabd1e5d317ade850f8177a31e3a1c446860970ece0e26d3f9c6758aed1cda
7
+ data.tar.gz: 3274c3a8d55abdaaba7f1392dd9afcafc0977c53ccca7ecc9f21bd197516e0487b700d2f2f9b7c29f0cc3f10c13428516b49576ad46398c838c2333e89128a59
data/lib/ding/cli.rb CHANGED
@@ -116,7 +116,7 @@ module Ding
116
116
  say "\nDing ding ding: let's copy a public key to the clipboard:\n\n", :green
117
117
 
118
118
  Ding::Ssh.new(options).tap do |s|
119
- key_name = ask_which_item(s.list_ssh_keys, "\nWhich key do you want to copy?")
119
+ key_name = ask_which_item(s.list_ssh_keys, "Which key do you want to copy?")
120
120
  say "\n> Copying the public key to the clipboard", :green
121
121
  copy_file_to_clipboard s.ssh_public_key_file(key_name)
122
122
  end
@@ -141,7 +141,9 @@ module Ding
141
141
  def ask_which_item(items, prompt, mode=:single)
142
142
  return Array(items.first) if items.size == 1
143
143
  str_format = "\n %#{items.count.to_s.size}s: %s"
144
- prompt = prompt << "\n > Enter a single selection, multiple selections separated by ',', 'A' for all, 'Q' or nothing to quit" if mode == :multiple
144
+ prompt << "\n > Enter a single selection, "
145
+ prompt << "multiple selections separated by ',', 'A' for all, " if mode == :multiple
146
+ prompt << "'Q' or nothing to quit"
145
147
  question = set_color prompt, :yellow
146
148
  answers = {}
147
149
 
@@ -159,6 +161,9 @@ module Ding
159
161
  exit 0
160
162
  elsif answers[reply]
161
163
  answers.values_at(reply)
164
+ elsif mode == :single
165
+ say "\n --> That's not a valid selection, I'm out of here!\n\n", :red
166
+ exit 1
162
167
  elsif mode == :multiple && reply.upcase == 'A'
163
168
  answers.values
164
169
  elsif mode == :multiple && !replies.empty?
@@ -172,12 +177,8 @@ module Ding
172
177
  end
173
178
 
174
179
  def copy_file_to_clipboard(file)
175
- cmd = "cat #{file} | "
176
- if options[:verbose]
177
- cmd << 'tee >(pbcopy)'
178
- else
179
- cmd << 'pbcopy'
180
- end
180
+ cmd = "cat #{file}"
181
+ cmd << (options[:verbose] ? '|tee >(pbcopy)' : '|pbcopy')
181
182
  bash cmd
182
183
  end
183
184
 
@@ -0,0 +1,10 @@
1
+ module Ding
2
+ module Helpers
3
+ # NOTE: only for commands where we are interested in the effect
4
+ # as unless verbose is turned on, stdout and stderr are suppressed
5
+ def run_cmd(cmd)
6
+ cmd << ' &>/dev/null ' unless options[:verbose]
7
+ system cmd
8
+ end
9
+ end
10
+ end
@@ -1,5 +1,8 @@
1
1
  module Ding
2
2
  class Git
3
+ include Ding::Helpers
4
+
5
+ attr_reader :options
3
6
 
4
7
  def initialize(options={})
5
8
  raise "#{repo} is NOT a git repository" unless git_repo?
@@ -99,16 +102,5 @@ module Ding
99
102
  def remote_prefix
100
103
  "#{remote_name}/"
101
104
  end
102
-
103
- # NOTE: only for commands where we are interested in the effect
104
- # as unless verbose is turned on, stdout and stderr are suppressed
105
- def run_cmd(cmd)
106
- cmd << ' &>/dev/null ' unless options[:verbose]
107
- system cmd
108
- end
109
-
110
- def options
111
- @options || {}
112
- end
113
105
  end
114
106
  end
@@ -2,6 +2,9 @@ require 'fileutils'
2
2
 
3
3
  module Ding
4
4
  class Ssh
5
+ include Ding::Helpers
6
+
7
+ attr_reader :options
5
8
 
6
9
  def initialize(options={})
7
10
  @options = options
@@ -17,7 +20,8 @@ module Ding
17
20
  end
18
21
 
19
22
  def delete_ssh_key(name)
20
- File.delete ssh_public_key_file(name), ssh_private_key_file(name) if ssh_key_exists? name
23
+ raise "ssh key #{name} does not exist!" if ssh_key_exists? name
24
+ File.delete ssh_public_key_file(name), ssh_private_key_file(name)
21
25
  end
22
26
 
23
27
  def update_config(host, name)
@@ -61,16 +65,5 @@ module Ding
61
65
  def ssh_config_file
62
66
  @ssh_config_file || options[:ssh_config_file] || File.join(ssh_config_path, 'config')
63
67
  end
64
-
65
- # NOTE: only for commands where we are interested in the effect
66
- # as unless verbose is turned on, stdout and stderr are suppressed
67
- def run_cmd(cmd)
68
- cmd << ' &>/dev/null ' unless options[:verbose]
69
- system cmd
70
- end
71
-
72
- def options
73
- @options || {}
74
- end
75
68
  end
76
69
  end
data/lib/ding/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ding
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.2"
3
3
  end
data/lib/ding.rb CHANGED
@@ -1,12 +1,13 @@
1
1
  require 'ding/version'
2
2
  require 'ding/cli'
3
+ require 'ding/helpers'
3
4
  require 'ding/models/git'
4
5
  require 'ding/models/ssh'
5
6
 
6
7
  module Ding
7
- MASTER_BRANCH = ENV['DING_MASTER_BRANCH'] || 'master'
8
- DEVELOP_BRANCH = ENV['DING_DEVELOP_BRANCH'] || 'develop'
9
- TESTING_BRANCH = ENV['DING_TESTING_BRANCH'] || 'testing'
8
+ MASTER_BRANCH = ENV['DING_MASTER_BRANCH'] || 'master'
9
+ DEVELOP_BRANCH = ENV['DING_DEVELOP_BRANCH'] || 'develop'
10
+ TESTING_BRANCH = ENV['DING_TESTING_BRANCH'] || 'testing'
10
11
  SACROSANCT_BRANCHES = (ENV['DING_SACROSANCT_BRANCHES'] || "#{MASTER_BRANCH} #{DEVELOP_BRANCH}").split
11
12
 
12
13
  # because we lurve the command line... ding!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ding
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Warren Bain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-16 00:00:00.000000000 Z
11
+ date: 2015-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -85,6 +85,7 @@ files:
85
85
  - ding.png
86
86
  - lib/ding.rb
87
87
  - lib/ding/cli.rb
88
+ - lib/ding/helpers.rb
88
89
  - lib/ding/models/git.rb
89
90
  - lib/ding/models/ssh.rb
90
91
  - lib/ding/version.rb