pagoda 0.2.0 → 0.3.0
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.
- data/Gemfile.lock +5 -1
- data/lib/pagoda/command.rb +5 -2
- data/lib/pagoda/commands/app.rb +1 -1
- data/lib/pagoda/commands/base.rb +1 -1
- data/lib/pagoda/helpers.rb +199 -9
- data/lib/pagoda/version.rb +1 -1
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/lib/pagoda/command.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
require 'pagoda/helpers'
|
2
2
|
require 'pagoda/tunnel_proxy'
|
3
3
|
require 'pagoda/commands/base'
|
4
|
-
|
5
|
-
|
4
|
+
require 'pagoda/commands/auth'
|
5
|
+
require 'pagoda/commands/app'
|
6
|
+
require 'pagoda/commands/db'
|
7
|
+
require 'pagoda/commands/help'
|
8
|
+
require 'pagoda/commands/tunnel'
|
6
9
|
|
7
10
|
module Pagoda
|
8
11
|
module Command
|
data/lib/pagoda/commands/app.rb
CHANGED
@@ -193,7 +193,7 @@ module Pagoda::Command
|
|
193
193
|
display
|
194
194
|
else
|
195
195
|
client.deploy(app, branch, commit)
|
196
|
-
display "+> deploying
|
196
|
+
display "+> deploying current branch and commit...", false
|
197
197
|
loop_transaction
|
198
198
|
display "+> deployed"
|
199
199
|
display
|
data/lib/pagoda/commands/base.rb
CHANGED
@@ -146,7 +146,7 @@ module Pagoda
|
|
146
146
|
def extract_git_clone_url(soft=false)
|
147
147
|
begin
|
148
148
|
url = IniParse.parse( File.read("#{locate_app_root}/.git/config") )['remote "origin"']["url"]
|
149
|
-
raise unless url.match(/^git@github.com
|
149
|
+
raise unless url.match(/^((git@github.com:)|(.*:)|((http|https):\/\/.*github.com\/)|(git:\/\/github.com\/))(.*)\/(.*).git$/i)
|
150
150
|
url
|
151
151
|
rescue Exception => e
|
152
152
|
return false
|
data/lib/pagoda/helpers.rb
CHANGED
@@ -19,9 +19,9 @@ module Pagoda
|
|
19
19
|
def display(msg="", newline=true, level=1)
|
20
20
|
indent = build_indent(level)
|
21
21
|
if newline
|
22
|
-
puts("#{indent}#{msg}")
|
22
|
+
puts("#{indent}#{msg}".green)
|
23
23
|
else
|
24
|
-
print("#{indent}#{msg}")
|
24
|
+
print("#{indent}#{msg}".green)
|
25
25
|
STDOUT.flush
|
26
26
|
end
|
27
27
|
end
|
@@ -59,7 +59,7 @@ module Pagoda
|
|
59
59
|
gets.strip
|
60
60
|
end
|
61
61
|
|
62
|
-
def confirm(message="Are you sure you wish to continue? (y/n)?", level=1)
|
62
|
+
def confirm(message="Are you sure you wish to continue? (y/n)?".blue, level=1)
|
63
63
|
return true if args.include? "-f"
|
64
64
|
case message
|
65
65
|
when Array
|
@@ -67,14 +67,14 @@ module Pagoda
|
|
67
67
|
iteration = 0
|
68
68
|
message.each do |m|
|
69
69
|
if iteration == count - 1
|
70
|
-
display("#{m} ", false, level)
|
70
|
+
display("#{m} ".blue, false, level)
|
71
71
|
else
|
72
|
-
display("#{m} ", true, level)
|
72
|
+
display("#{m} ".blue, true, level)
|
73
73
|
end
|
74
74
|
iteration += 1
|
75
75
|
end
|
76
76
|
when String
|
77
|
-
display("#{message} ", false, level)
|
77
|
+
display("#{message} ".blue, false, level)
|
78
78
|
end
|
79
79
|
ask.downcase == 'y'
|
80
80
|
end
|
@@ -84,12 +84,12 @@ module Pagoda
|
|
84
84
|
STDERR.puts
|
85
85
|
case msg
|
86
86
|
when Array
|
87
|
-
STDERR.puts("#{indent}** Error:")
|
87
|
+
STDERR.puts("#{indent}** Error:".red)
|
88
88
|
msg.each do |m|
|
89
|
-
STDERR.puts("#{indent}** #{m}")
|
89
|
+
STDERR.puts("#{indent}** #{m}".red)
|
90
90
|
end
|
91
91
|
when String
|
92
|
-
STDERR.puts("#{indent}** Error: #{msg}")
|
92
|
+
STDERR.puts("#{indent}** Error: #{msg}".red)
|
93
93
|
end
|
94
94
|
STDERR.puts
|
95
95
|
exit 1 if exit
|
@@ -124,4 +124,194 @@ unless String.method_defined?(:shellescape)
|
|
124
124
|
empty? ? "''" : gsub(/([^A-Za-z0-9_\-.,:\/@\n])/n, '\\\\\\1').gsub(/\n/, "'\n'")
|
125
125
|
end
|
126
126
|
end
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
class String
|
131
|
+
|
132
|
+
#
|
133
|
+
# Colors Hash
|
134
|
+
#
|
135
|
+
COLORS = {
|
136
|
+
:black => 0,
|
137
|
+
:red => 1,
|
138
|
+
:green => 2,
|
139
|
+
:yellow => 3,
|
140
|
+
:blue => 4,
|
141
|
+
:magenta => 5,
|
142
|
+
:cyan => 6,
|
143
|
+
:white => 7,
|
144
|
+
:default => 9,
|
145
|
+
|
146
|
+
:light_black => 10,
|
147
|
+
:light_red => 11,
|
148
|
+
:light_green => 12,
|
149
|
+
:light_yellow => 13,
|
150
|
+
:light_blue => 14,
|
151
|
+
:light_magenta => 15,
|
152
|
+
:light_cyan => 16,
|
153
|
+
:light_white => 17
|
154
|
+
}
|
155
|
+
|
156
|
+
#
|
157
|
+
# Modes Hash
|
158
|
+
#
|
159
|
+
MODES = {
|
160
|
+
:default => 0, # Turn off all attributes
|
161
|
+
#:bright => 1, # Set bright mode
|
162
|
+
:underline => 4, # Set underline mode
|
163
|
+
:blink => 5, # Set blink mode
|
164
|
+
:swap => 7, # Exchange foreground and background colors
|
165
|
+
:hide => 8 # Hide text (foreground color would be the same as background)
|
166
|
+
}
|
167
|
+
|
168
|
+
protected
|
169
|
+
|
170
|
+
#
|
171
|
+
# Set color values in new string intance
|
172
|
+
#
|
173
|
+
def set_color_parameters( params )
|
174
|
+
if (params.instance_of?(Hash))
|
175
|
+
@color = params[:color]
|
176
|
+
@background = params[:background]
|
177
|
+
@mode = params[:mode]
|
178
|
+
@uncolorized = params[:uncolorized]
|
179
|
+
self
|
180
|
+
else
|
181
|
+
nil
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
public
|
186
|
+
|
187
|
+
#
|
188
|
+
# Change color of string
|
189
|
+
#
|
190
|
+
# Examples:
|
191
|
+
#
|
192
|
+
# puts "This is blue".colorize( :blue )
|
193
|
+
# puts "This is light blue".colorize( :light_blue )
|
194
|
+
# puts "This is also blue".colorize( :color => :blue )
|
195
|
+
# puts "This is light blue with red background".colorize( :color => :light_blue, :background => :red )
|
196
|
+
# puts "This is light blue with red background".colorize( :light_blue ).colorize( :background => :red )
|
197
|
+
# puts "This is blue text on red".blue.on_red
|
198
|
+
# puts "This is red on blue".colorize( :red ).on_blue
|
199
|
+
# puts "This is red on blue and underline".colorize( :red ).on_blue.underline
|
200
|
+
# puts "This is blue text on red".blue.on_red.blink
|
201
|
+
# puts "This is uncolorized".blue.on_red.uncolorize
|
202
|
+
#
|
203
|
+
def colorize( params )
|
204
|
+
return self unless STDOUT.isatty
|
205
|
+
|
206
|
+
begin
|
207
|
+
require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /win32/
|
208
|
+
rescue LoadError
|
209
|
+
raise 'You must gem install win32console to use colorize on Windows'
|
210
|
+
end
|
211
|
+
|
212
|
+
color_parameters = {}
|
213
|
+
|
214
|
+
if (params.instance_of?(Hash))
|
215
|
+
color_parameters[:color] = COLORS[params[:color]]
|
216
|
+
color_parameters[:background] = COLORS[params[:background]]
|
217
|
+
color_parameters[:mode] = MODES[params[:mode]]
|
218
|
+
elsif (params.instance_of?(Symbol))
|
219
|
+
color_parameters[:color] = COLORS[params]
|
220
|
+
end
|
221
|
+
|
222
|
+
color_parameters[:color] ||= @color ||= COLORS[:default]
|
223
|
+
color_parameters[:background] ||= @background ||= COLORS[:default]
|
224
|
+
color_parameters[:mode] ||= @mode ||= MODES[:default]
|
225
|
+
|
226
|
+
color_parameters[:uncolorized] ||= @uncolorized ||= self.dup
|
227
|
+
|
228
|
+
# calculate bright mode
|
229
|
+
color_parameters[:color] += 50 if color_parameters[:color] > 10
|
230
|
+
|
231
|
+
color_parameters[:background] += 50 if color_parameters[:background] > 10
|
232
|
+
|
233
|
+
"\033[#{color_parameters[:mode]};#{color_parameters[:color]+30};#{color_parameters[:background]+40}m#{color_parameters[:uncolorized]}\033[0m".set_color_parameters( color_parameters )
|
234
|
+
end
|
235
|
+
|
236
|
+
#
|
237
|
+
# Return uncolorized string
|
238
|
+
#
|
239
|
+
def uncolorize
|
240
|
+
@uncolorized || self
|
241
|
+
end
|
242
|
+
|
243
|
+
#
|
244
|
+
# Return true if sting is colorized
|
245
|
+
#
|
246
|
+
def colorized?
|
247
|
+
!defined?(@uncolorized).nil?
|
248
|
+
end
|
249
|
+
|
250
|
+
#
|
251
|
+
# Make some color and on_color methods
|
252
|
+
#
|
253
|
+
COLORS.each_key do | key |
|
254
|
+
next if key == :default
|
255
|
+
|
256
|
+
define_method key do
|
257
|
+
self.colorize( :color => key )
|
258
|
+
end
|
259
|
+
|
260
|
+
define_method "on_#{key}" do
|
261
|
+
self.colorize( :background => key )
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
#
|
266
|
+
# Methods for modes
|
267
|
+
#
|
268
|
+
MODES.each_key do | key |
|
269
|
+
next if key == :default
|
270
|
+
|
271
|
+
define_method key do
|
272
|
+
self.colorize( :mode => key )
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
class << self
|
277
|
+
|
278
|
+
#
|
279
|
+
# Return array of available modes used by colorize method
|
280
|
+
#
|
281
|
+
def modes
|
282
|
+
keys = []
|
283
|
+
MODES.each_key do | key |
|
284
|
+
keys << key
|
285
|
+
end
|
286
|
+
keys
|
287
|
+
end
|
288
|
+
|
289
|
+
#
|
290
|
+
# Return array of available colors used by colorize method
|
291
|
+
#
|
292
|
+
def colors
|
293
|
+
keys = []
|
294
|
+
COLORS.each_key do | key |
|
295
|
+
keys << key
|
296
|
+
end
|
297
|
+
keys
|
298
|
+
end
|
299
|
+
|
300
|
+
#
|
301
|
+
# Display color matrix with color names.
|
302
|
+
#
|
303
|
+
def color_matrix( txt = "[X]" )
|
304
|
+
size = String.colors.length
|
305
|
+
String.colors.each do | color |
|
306
|
+
String.colors.each do | back |
|
307
|
+
print txt.colorize( :color => color, :background => back )
|
308
|
+
end
|
309
|
+
puts " < #{color}"
|
310
|
+
end
|
311
|
+
String.colors.reverse.each_with_index do | back, index |
|
312
|
+
puts "#{"|".rjust(txt.length)*(size-index)} < #{back}"
|
313
|
+
end
|
314
|
+
""
|
315
|
+
end
|
316
|
+
end
|
127
317
|
end
|
data/lib/pagoda/version.rb
CHANGED
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 3
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.3.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- lyon hill
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-06-22 00:00:00 -06:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|