pagoda 0.7.3 → 0.7.4
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 +4 -4
- data/lib/pagoda/cli/core_ext.rb +1 -190
- data/lib/pagoda/cli/helpers/app.rb +1 -1
- data/lib/pagoda/cli/helpers/base.rb +5 -40
- data/lib/pagoda/cli/helpers.rb +13 -33
- data/lib/pagoda/cli/version.rb +1 -1
- data/pagoda.gemspec +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f68dbfdee4fc21612c902e14ea8b90c792e37e6e
|
4
|
+
data.tar.gz: 4eb03823c3d5729c177afda1356eb684e475bb3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bce58317eae1fddcd86e2959d13c803230df8b374d03e4df5d0d4f739fee01d030e20bcd775d058bfd44271b5d147586242a07645294a7ced9b0a400f5c13b0
|
7
|
+
data.tar.gz: b9d42f6fdb5de37b0e3d8ee2f48fe6babd41dd842f4e909086e3a1129d61bfc98df68c6d73a2ecc037da2ccf09f1710d563c9a00ae8e79cecf878bb7e8f66249
|
data/lib/pagoda/cli/core_ext.rb
CHANGED
@@ -17,193 +17,4 @@ unless String.method_defined?(:shellescape)
|
|
17
17
|
empty? ? "''" : gsub(/([^A-Za-z0-9_\-.,:\/@\n])/n, '\\\\\\1').gsub(/\n/, "'\n'")
|
18
18
|
end
|
19
19
|
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class String
|
23
|
-
|
24
|
-
#
|
25
|
-
# Colors Hash
|
26
|
-
#
|
27
|
-
COLORS = {
|
28
|
-
:black => 0,
|
29
|
-
:red => 1,
|
30
|
-
:green => 2,
|
31
|
-
:yellow => 3,
|
32
|
-
:blue => 4,
|
33
|
-
:magenta => 5,
|
34
|
-
:cyan => 6,
|
35
|
-
:white => 7,
|
36
|
-
:default => 9,
|
37
|
-
|
38
|
-
:light_black => 10,
|
39
|
-
:light_red => 11,
|
40
|
-
:light_green => 12,
|
41
|
-
:light_yellow => 13,
|
42
|
-
:light_blue => 14,
|
43
|
-
:light_magenta => 15,
|
44
|
-
:light_cyan => 16,
|
45
|
-
:light_white => 17
|
46
|
-
}
|
47
|
-
|
48
|
-
#
|
49
|
-
# Modes Hash
|
50
|
-
#
|
51
|
-
MODES = {
|
52
|
-
:default => 0, # Turn off all attributes
|
53
|
-
#:bright => 1, # Set bright mode
|
54
|
-
:underline => 4, # Set underline mode
|
55
|
-
:blink => 5, # Set blink mode
|
56
|
-
:swap => 7, # Exchange foreground and background colors
|
57
|
-
:hide => 8 # Hide text (foreground color would be the same as background)
|
58
|
-
}
|
59
|
-
|
60
|
-
protected
|
61
|
-
|
62
|
-
#
|
63
|
-
# Set color values in new string intance
|
64
|
-
#
|
65
|
-
def set_color_parameters( params )
|
66
|
-
if (params.instance_of?(Hash))
|
67
|
-
@color = params[:color]
|
68
|
-
@background = params[:background]
|
69
|
-
@mode = params[:mode]
|
70
|
-
@uncolorized = params[:uncolorized]
|
71
|
-
self
|
72
|
-
else
|
73
|
-
nil
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
public
|
78
|
-
|
79
|
-
#
|
80
|
-
# Change color of string
|
81
|
-
#
|
82
|
-
# Examples:
|
83
|
-
#
|
84
|
-
# puts "This is blue".colorize( :blue )
|
85
|
-
# puts "This is light blue".colorize( :light_blue )
|
86
|
-
# puts "This is also blue".colorize( :color => :blue )
|
87
|
-
# puts "This is light blue with red background".colorize( :color => :light_blue, :background => :red )
|
88
|
-
# puts "This is light blue with red background".colorize( :light_blue ).colorize( :background => :red )
|
89
|
-
# puts "This is blue text on red".blue.on_red
|
90
|
-
# puts "This is red on blue".colorize( :red ).on_blue
|
91
|
-
# puts "This is red on blue and underline".colorize( :red ).on_blue.underline
|
92
|
-
# puts "This is blue text on red".blue.on_red.blink
|
93
|
-
# puts "This is uncolorized".blue.on_red.uncolorize
|
94
|
-
#
|
95
|
-
def colorize( params )
|
96
|
-
return self unless STDOUT.isatty
|
97
|
-
|
98
|
-
begin
|
99
|
-
require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /win32/
|
100
|
-
rescue LoadError
|
101
|
-
raise 'You must gem install win32console to use colorize on Windows'
|
102
|
-
end
|
103
|
-
|
104
|
-
color_parameters = {}
|
105
|
-
|
106
|
-
if (params.instance_of?(Hash))
|
107
|
-
color_parameters[:color] = COLORS[params[:color]]
|
108
|
-
color_parameters[:background] = COLORS[params[:background]]
|
109
|
-
color_parameters[:mode] = MODES[params[:mode]]
|
110
|
-
elsif (params.instance_of?(Symbol))
|
111
|
-
color_parameters[:color] = COLORS[params]
|
112
|
-
end
|
113
|
-
|
114
|
-
color_parameters[:color] ||= @color ||= COLORS[:default]
|
115
|
-
color_parameters[:background] ||= @background ||= COLORS[:default]
|
116
|
-
color_parameters[:mode] ||= @mode ||= MODES[:default]
|
117
|
-
|
118
|
-
color_parameters[:uncolorized] ||= @uncolorized ||= self.dup
|
119
|
-
|
120
|
-
# calculate bright mode
|
121
|
-
color_parameters[:color] += 50 if color_parameters[:color] > 10
|
122
|
-
|
123
|
-
color_parameters[:background] += 50 if color_parameters[:background] > 10
|
124
|
-
|
125
|
-
"\033[#{color_parameters[:mode]};#{color_parameters[:color]+30};#{color_parameters[:background]+40}m#{color_parameters[:uncolorized]}\033[0m".set_color_parameters( color_parameters )
|
126
|
-
end
|
127
|
-
|
128
|
-
#
|
129
|
-
# Return uncolorized string
|
130
|
-
#
|
131
|
-
def uncolorize
|
132
|
-
@uncolorized || self
|
133
|
-
end
|
134
|
-
|
135
|
-
#
|
136
|
-
# Return true if sting is colorized
|
137
|
-
#
|
138
|
-
def colorized?
|
139
|
-
!defined?(@uncolorized).nil?
|
140
|
-
end
|
141
|
-
|
142
|
-
#
|
143
|
-
# Make some color and on_color methods
|
144
|
-
#
|
145
|
-
COLORS.each_key do | key |
|
146
|
-
next if key == :default
|
147
|
-
|
148
|
-
define_method key do
|
149
|
-
self.colorize( :color => key )
|
150
|
-
end
|
151
|
-
|
152
|
-
define_method "on_#{key}" do
|
153
|
-
self.colorize( :background => key )
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
#
|
158
|
-
# Methods for modes
|
159
|
-
#
|
160
|
-
MODES.each_key do | key |
|
161
|
-
next if key == :default
|
162
|
-
|
163
|
-
define_method key do
|
164
|
-
self.colorize( :mode => key )
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
class << self
|
169
|
-
|
170
|
-
#
|
171
|
-
# Return array of available modes used by colorize method
|
172
|
-
#
|
173
|
-
def modes
|
174
|
-
keys = []
|
175
|
-
MODES.each_key do | key |
|
176
|
-
keys << key
|
177
|
-
end
|
178
|
-
keys
|
179
|
-
end
|
180
|
-
|
181
|
-
#
|
182
|
-
# Return array of available colors used by colorize method
|
183
|
-
#
|
184
|
-
def colors
|
185
|
-
keys = []
|
186
|
-
COLORS.each_key do | key |
|
187
|
-
keys << key
|
188
|
-
end
|
189
|
-
keys
|
190
|
-
end
|
191
|
-
|
192
|
-
#
|
193
|
-
# Display color matrix with color names.
|
194
|
-
#
|
195
|
-
def color_matrix( txt = "[X]" )
|
196
|
-
size = String.colors.length
|
197
|
-
String.colors.each do | color |
|
198
|
-
String.colors.each do | back |
|
199
|
-
print txt.colorize( :color => color, :background => back )
|
200
|
-
end
|
201
|
-
puts " < #{color}"
|
202
|
-
end
|
203
|
-
String.colors.reverse.each_with_index do | back, index |
|
204
|
-
puts "#{"|".rjust(txt.length)*(size-index)} < #{back}"
|
205
|
-
end
|
206
|
-
""
|
207
|
-
end
|
208
|
-
end
|
209
|
-
end
|
20
|
+
end
|
@@ -127,7 +127,7 @@ module Pagoda
|
|
127
127
|
display "+> #{dname} has been successfully destroyed. RIP #{dname}."
|
128
128
|
remove_app(my_app)
|
129
129
|
else
|
130
|
-
if confirm ["Are you totally completely sure you want to delete #{dname} forever and ever?", "THIS CANNOT BE UNDONE!
|
130
|
+
if confirm ["Are you totally completely sure you want to delete #{dname} forever and ever?", "THIS CANNOT BE UNDONE! "]
|
131
131
|
display
|
132
132
|
display "+> Destroying #{dname}"
|
133
133
|
client.app_destroy(my_app)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'pagoda-client'
|
2
|
+
require 'highline/import'
|
2
3
|
|
3
4
|
module Pagoda
|
4
5
|
module Command
|
@@ -9,48 +10,12 @@ module Pagoda
|
|
9
10
|
class << self
|
10
11
|
include Pagoda::Helpers
|
11
12
|
def ask_for_credentials
|
12
|
-
username = ask
|
13
|
-
|
14
|
-
password = running_on_windows? ? ask_for_password_on_windows : ask_for_password
|
13
|
+
username = ask("<%= color('Username: ', :blue) %>")
|
14
|
+
password = ask("<%= color('Password: ', :blue) %>") { |q| q.echo = '*' }
|
15
15
|
# api_key = Pagoda::Client.new(user, password).api_key
|
16
|
-
[username, password] # return
|
16
|
+
[username.to_s, password.to_s] # return
|
17
17
|
end
|
18
18
|
|
19
|
-
def ask_for_password
|
20
|
-
echo_off
|
21
|
-
password = ask
|
22
|
-
puts
|
23
|
-
echo_on
|
24
|
-
return password
|
25
|
-
end
|
26
|
-
|
27
|
-
def ask_for_password_on_windows
|
28
|
-
require "Win32API"
|
29
|
-
char = nil
|
30
|
-
password = ''
|
31
|
-
|
32
|
-
while char = Win32API.new("crtdll", "_getch", [ ], "L").Call do
|
33
|
-
break if char == 10 || char == 13 # received carriage return or newline
|
34
|
-
if char == 127 || char == 8 # backspace and delete
|
35
|
-
password.slice!(-1, 1)
|
36
|
-
else
|
37
|
-
# windows might throw a -1 at us so make sure to handle RangeError
|
38
|
-
(password << char.chr) rescue RangeError
|
39
|
-
end
|
40
|
-
end
|
41
|
-
return password
|
42
|
-
end
|
43
|
-
|
44
|
-
def echo_off
|
45
|
-
silently(system("stty -echo"))
|
46
|
-
rescue
|
47
|
-
end
|
48
|
-
|
49
|
-
def echo_on
|
50
|
-
silently(system("stty echo"))
|
51
|
-
rescue
|
52
|
-
end
|
53
|
-
|
54
19
|
end
|
55
20
|
|
56
21
|
attr_reader :client
|
@@ -96,7 +61,7 @@ module Pagoda
|
|
96
61
|
else
|
97
62
|
if soft_fail
|
98
63
|
display "I was unable to find your application name."
|
99
|
-
ask "what is the name of your application? "
|
64
|
+
ask "<%= color('what is the name of your application? ', :blue) %>"
|
100
65
|
else
|
101
66
|
error "Unable to find the app. please specify using -a or --app="
|
102
67
|
end
|
data/lib/pagoda/cli/helpers.rb
CHANGED
@@ -15,13 +15,7 @@ module Pagoda
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def display(msg="", newline=true, level=1)
|
18
|
-
|
19
|
-
if newline
|
20
|
-
(running_on_windows?) ? puts("#{indent}#{msg}") : puts("#{indent}#{msg}".green)
|
21
|
-
else
|
22
|
-
(running_on_windows?) ? print("#{indent}#{msg}") : print("#{indent}#{msg}".green)
|
23
|
-
STDOUT.flush
|
24
|
-
end
|
18
|
+
say("<%= color('#{msg}', :green)%>")
|
25
19
|
end
|
26
20
|
|
27
21
|
def format_date(date)
|
@@ -29,43 +23,29 @@ module Pagoda
|
|
29
23
|
date.strftime("%Y-%m-%d %H:%M %Z")
|
30
24
|
end
|
31
25
|
|
32
|
-
def ask(message=nil, level=1)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
26
|
+
# def ask(message=nil, level=1)
|
27
|
+
# (running_on_windows?) ? print("#{build_indent(level)}#{message}") : print("#{build_indent(level)}#{message}".blue)
|
28
|
+
# STDOUT.flush
|
29
|
+
# STDIN.gets.strip
|
30
|
+
# end
|
37
31
|
|
38
|
-
def confirm(message="Are you sure you wish to continue?
|
32
|
+
def confirm(message="Are you sure you wish to continue? ", level=1)
|
39
33
|
return true if ARGV.include? "-f"
|
40
34
|
case message
|
41
35
|
when Array
|
42
|
-
|
43
|
-
iteration = 0
|
44
|
-
message.each do |m|
|
45
|
-
if iteration == count - 1
|
46
|
-
(running_on_windows?) ? display("#{m} ", false, level) : display("#{m} ".blue, false, level)
|
47
|
-
else
|
48
|
-
(running_on_windows?) ? display("#{m} ", false, level) : display("#{m} ".blue, true, level)
|
49
|
-
end
|
50
|
-
iteration += 1
|
51
|
-
end
|
36
|
+
agree("<%= color('#{message.join("\n")}', :blue)%>")
|
52
37
|
when String
|
53
|
-
(
|
38
|
+
agree("<%= color('#{message}', :blue)%>")
|
54
39
|
end
|
55
|
-
ask.downcase == 'y'
|
56
40
|
end
|
57
41
|
|
58
42
|
def error(msg, exit=true, level=1)
|
59
|
-
indent = build_indent(level)
|
60
43
|
STDERR.puts
|
61
44
|
case msg
|
62
45
|
when Array
|
63
|
-
(
|
64
|
-
msg.each do |m|
|
65
|
-
(running_on_windows?) ? STDERR.puts("#{indent}** #{m}") : STDERR.puts("#{indent}** #{m}".red)
|
66
|
-
end
|
46
|
+
say("<%= color('#{msg.join("\n")}', :red)%>")
|
67
47
|
when String
|
68
|
-
(
|
48
|
+
say("<%= color(msg, :red)%>")
|
69
49
|
end
|
70
50
|
STDERR.puts
|
71
51
|
exit 1 if exit
|
@@ -90,10 +70,10 @@ module Pagoda
|
|
90
70
|
error "you do not have git installed on your computer" unless has_git?
|
91
71
|
if git('remote').split("\n").include?(remote)
|
92
72
|
display "Given remote (#{remote}) is already in use on this repo"
|
93
|
-
remote = ask
|
73
|
+
remote = ask("<%= color('what would you like to call the new remote? ', :blue) %>")
|
94
74
|
end
|
95
75
|
unless File.directory?(".git")
|
96
|
-
if confirm "git has not been initialized yet, would you like us to do this for you?
|
76
|
+
if confirm "git has not been initialized yet, would you like us to do this for you? "
|
97
77
|
display "git repo is being created in '#{Dir.pwd}'"
|
98
78
|
git "init"
|
99
79
|
else
|
data/lib/pagoda/cli/version.rb
CHANGED
data/pagoda.gemspec
CHANGED
@@ -23,6 +23,6 @@ Gem::Specification.new do |gem|
|
|
23
23
|
gem.add_dependency "rest-client"
|
24
24
|
gem.add_dependency "gli", '~> 2.0.0'
|
25
25
|
gem.add_dependency "websocket-client-simple"
|
26
|
-
|
26
|
+
gem.add_dependency 'highline'
|
27
27
|
# gem.add_dependency 'eventmachine'
|
28
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pagoda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lyon Hill
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: highline
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description: Pagoda Box User facing interface to improve workflow with Pagoda Box
|
112
126
|
email:
|
113
127
|
- lyon@pagodabox.com
|