karo 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of karo might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a6208e6d5c789482d34ba5d8deb7d87e739953a
4
- data.tar.gz: a4855f848b1ad56b3808695d6bc7be01aeff71c8
3
+ metadata.gz: 2cef5122b1fb4265a148cd2f1c700684a044f3e1
4
+ data.tar.gz: 06353a8e2e1a1d299d94d2a7ef2bc602a8b8a159
5
5
  SHA512:
6
- metadata.gz: 29d57337e8ae7c563fb93241d7d8e44820096eb0039f5dcc6d84e4add649d3599cb84367d16cdada7456d40d603e70b9465c4f90d9c26b74b6dd934b77a7afe1
7
- data.tar.gz: 5e9e9424bfe7507321c410265661c5fd80ba2b28a6f4406d58f4dee354c76e652b1900d8bb69167bb921a87f2e9e91ac3a0b4cd9a59411503812d2a3a7d090ad
6
+ metadata.gz: 33f114b6f81e5e816e49b0b1ee89a058dff3472fa96e1a1a6bdfd28486595dfebd4bd14117094eef6e6ff3f38d5701738f2efaea0c24204110e090bd60ea599b
7
+ data.tar.gz: 6c5c1a3a18256511e54143b5655ec7acd731c933d5539efee70c98eb7b9a4722623dfd829ae81657bf00b2b58279c2652456105250c941bda2456984ac1ea290
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## v2.1.1
4
+
5
+ ### Features
6
+
7
+ - Refactoring CLI "server" and "client" commands
8
+
3
9
  ## v2.1.0
4
10
 
5
11
  ### Features
@@ -77,18 +77,10 @@ module Karo
77
77
 
78
78
  > Beginning deploy...
79
79
  LONGDESC
80
- def client(cmd, *extra)
80
+ def client(cmd, *extras)
81
81
  configuration = Config.load_configuration(options)
82
-
83
- if configuration["commands"] && configuration["commands"]["client"] && configuration["commands"]["client"][cmd]
84
- cmd = configuration["commands"]["client"][cmd]
85
- end
86
-
87
- to_run = "#{cmd} #{extra.flatten.uniq.join(" ")}"
88
-
89
- say to_run, :green if options[:verbose]
90
-
91
- system to_run
82
+ command = make_command configuration, "client", cmd, extras
83
+ run_it command, options[:verbose]
92
84
  end
93
85
  map clt: :client
94
86
  map local: :client
@@ -145,29 +137,21 @@ module Karo
145
137
 
146
138
  > 25224800 active memory
147
139
  LONGDESC
148
- def server(cmd, *extra)
140
+ def server(cmd, *extras)
149
141
  configuration = Config.load_configuration(options)
150
142
 
151
143
  ssh = "ssh #{configuration["user"]}@#{configuration["host"]}"
152
-
153
- # Forces pseudo-tty allocation
154
144
  ssh << " -t" if options[:tty]
155
145
 
156
- if configuration["commands"] && configuration["commands"]["server"] && configuration["commands"]["server"][cmd]
157
- cmd = configuration["commands"]["server"][cmd]
158
- end
159
-
160
- to_run = "#{ssh} '#{cmd} #{extra.flatten.uniq.join(" ")}'"
161
-
162
- say to_run, :green if options[:verbose]
163
- system to_run
146
+ command = make_command configuration, "server", cmd, extras
147
+ run_it "#{ssh} #{command}", options[:verbose]
164
148
  end
165
149
  map srv: :server
166
150
  map remote: :server
167
151
 
168
152
  desc "top", "run top command on a given server environment"
169
- def top(*extra)
170
- invoke :server, ["top", extra]
153
+ def top(*extras)
154
+ invoke :server, ["top", extras]
171
155
  end
172
156
 
173
157
  desc "ssh", "open ssh console for a given server environment"
@@ -192,18 +176,18 @@ module Karo
192
176
  end
193
177
 
194
178
  desc "rake", "run rake commands for a rails app on a given server environment"
195
- def rake(command, *extra)
179
+ def rake(command, *extras)
196
180
  configuration = Config.load_configuration(options)
197
181
 
198
182
  path = File.join(configuration["path"], "current")
199
183
  cmd = "cd #{path} && export RAILS_ENV=#{options[:environment]} && bundle exec rake #{command}"
200
184
 
201
- invoke :server, [cmd, extra]
185
+ invoke :server, [cmd, extras]
202
186
  end
203
187
 
204
188
  desc "log", "displays server log for a given environment"
205
189
  class_option :continous, type: :boolean, lazy_default: true, aliases: "-f", desc: "The -f option causes tail to not stop when end of file is reached, but rather to wait for additional data to be appended to the input."
206
- def log(*extra)
190
+ def log(*extras)
207
191
  configuration = Config.load_configuration(options)
208
192
 
209
193
  path = File.join(configuration["path"], "shared/log/#{options["environment"]}.log")
@@ -212,7 +196,7 @@ module Karo
212
196
  cmd << " -f" if options[:continous]
213
197
  cmd << " #{path}"
214
198
 
215
- invoke :server, [cmd, extra]
199
+ invoke :server, [cmd, extras]
216
200
  end
217
201
 
218
202
  desc "version", "displays karo's current version"
@@ -220,6 +204,25 @@ module Karo
220
204
  say Karo::VERSION
221
205
  end
222
206
 
207
+ private
208
+
209
+ def make_command(configuration, namespace, command, extras)
210
+ commands = configuration["commands"]
211
+
212
+ if commands && commands[namespace] && commands[namespace][command]
213
+ command = commands[namespace][command]
214
+ end
215
+
216
+ extras = extras.flatten.uniq.join(" ")
217
+
218
+ "#{command} #{extras}"
219
+ end
220
+
221
+ def run_it(cmd, verbose=false)
222
+ say cmd, :green if verbose
223
+ system cmd
224
+ end
225
+
223
226
  end
224
227
 
225
228
  end
@@ -1,3 +1,3 @@
1
1
  module Karo
2
- VERSION = "2.1.0"
2
+ VERSION = "2.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: karo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rahul Trikha