cft_smartcloud 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/.gitignore +1 -0
  2. data/CHANGELOG +11 -0
  3. data/README.md +106 -0
  4. data/VERSION +1 -1
  5. data/bin/cft_smartcloud +33 -7
  6. data/bin/smartcloud +33 -7
  7. data/cft_smartcloud.gemspec +84 -20
  8. data/lib/config/config.yml +2 -0
  9. data/lib/curl_client.rb +42 -0
  10. data/lib/rest-client-1.6.6-master/.gitignore +6 -0
  11. data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/README.rdoc +10 -1
  12. data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/Rakefile +0 -0
  13. data/lib/rest-client-1.6.6-master/VERSION +1 -0
  14. data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/bin/restclient +5 -4
  15. data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/history.md +22 -0
  16. data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/rest-client.rb +0 -0
  17. data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/rest_client.rb +0 -0
  18. data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/abstract_response.rb +0 -0
  19. data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/exceptions.rb +0 -0
  20. data/lib/rest-client-1.6.6-master/lib/restclient/net_http_ext.rb +55 -0
  21. data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/payload.rb +17 -2
  22. data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/raw_response.rb +0 -0
  23. data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/request.rb +21 -19
  24. data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/resource.rb +0 -0
  25. data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/response.rb +0 -0
  26. data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient.rb +0 -0
  27. data/lib/rest-client-1.6.6-master/rest-client.gemspec +76 -0
  28. data/lib/rest-client-1.6.6-master/spec/abstract_response_spec.rb +85 -0
  29. data/lib/rest-client-1.6.6-master/spec/base.rb +16 -0
  30. data/lib/rest-client-1.6.6-master/spec/exceptions_spec.rb +98 -0
  31. data/lib/rest-client-1.6.6-master/spec/integration/certs/equifax.crt +19 -0
  32. data/lib/rest-client-1.6.6-master/spec/integration/certs/verisign.crt +14 -0
  33. data/lib/rest-client-1.6.6-master/spec/integration/request_spec.rb +25 -0
  34. data/lib/rest-client-1.6.6-master/spec/integration_spec.rb +38 -0
  35. data/lib/rest-client-1.6.6-master/spec/master_shake.jpg +0 -0
  36. data/lib/rest-client-1.6.6-master/spec/payload_spec.rb +234 -0
  37. data/lib/rest-client-1.6.6-master/spec/raw_response_spec.rb +17 -0
  38. data/lib/rest-client-1.6.6-master/spec/request2_spec.rb +40 -0
  39. data/lib/rest-client-1.6.6-master/spec/request_spec.rb +536 -0
  40. data/lib/rest-client-1.6.6-master/spec/resource_spec.rb +134 -0
  41. data/lib/rest-client-1.6.6-master/spec/response_spec.rb +169 -0
  42. data/lib/rest-client-1.6.6-master/spec/restclient_spec.rb +73 -0
  43. data/lib/slop-2.3.1/.gemtest +0 -0
  44. data/lib/slop-2.3.1/.gitignore +6 -0
  45. data/lib/slop-2.3.1/.yardopts +6 -0
  46. data/lib/slop-2.3.1/CHANGES.md +137 -0
  47. data/lib/slop-2.3.1/LICENSE +20 -0
  48. data/lib/slop-2.3.1/README.md +293 -0
  49. data/lib/slop-2.3.1/Rakefile +6 -0
  50. data/lib/slop-2.3.1/lib/slop.rb +1022 -0
  51. data/lib/slop-2.3.1/slop.gemspec +11 -0
  52. data/lib/slop-2.3.1/test/commands_test.rb +151 -0
  53. data/lib/slop-2.3.1/test/helper.rb +13 -0
  54. data/lib/slop-2.3.1/test/option_test.rb +198 -0
  55. data/lib/slop-2.3.1/test/slop_test.rb +574 -0
  56. data/lib/smartcloud.rb +186 -116
  57. data/lib/terminal-table-1.4.4/History.rdoc +53 -0
  58. data/lib/terminal-table-1.4.4/Manifest +24 -0
  59. data/lib/terminal-table-1.4.4/README.rdoc +240 -0
  60. data/lib/terminal-table-1.4.4/Rakefile +15 -0
  61. data/lib/terminal-table-1.4.4/Todo.rdoc +14 -0
  62. data/lib/terminal-table-1.4.4/examples/examples.rb +80 -0
  63. data/lib/terminal-table-1.4.4/lib/terminal-table/cell.rb +88 -0
  64. data/lib/terminal-table-1.4.4/lib/terminal-table/core_ext.rb +8 -0
  65. data/lib/terminal-table-1.4.4/lib/terminal-table/import.rb +4 -0
  66. data/lib/terminal-table-1.4.4/lib/terminal-table/row.rb +48 -0
  67. data/lib/terminal-table-1.4.4/lib/terminal-table/separator.rb +14 -0
  68. data/lib/terminal-table-1.4.4/lib/terminal-table/style.rb +61 -0
  69. data/lib/terminal-table-1.4.4/lib/terminal-table/table.rb +217 -0
  70. data/lib/terminal-table-1.4.4/lib/terminal-table/table_helper.rb +9 -0
  71. data/lib/terminal-table-1.4.4/lib/terminal-table/version.rb +6 -0
  72. data/lib/terminal-table-1.4.4/lib/terminal-table.rb +27 -0
  73. data/lib/terminal-table-1.4.4/spec/cell_spec.rb +54 -0
  74. data/lib/terminal-table-1.4.4/spec/core_ext_spec.rb +18 -0
  75. data/lib/terminal-table-1.4.4/spec/import_spec.rb +11 -0
  76. data/lib/terminal-table-1.4.4/spec/spec.opts +1 -0
  77. data/lib/terminal-table-1.4.4/spec/spec_helper.rb +8 -0
  78. data/lib/terminal-table-1.4.4/spec/table_spec.rb +525 -0
  79. data/lib/terminal-table-1.4.4/tasks/docs.rake +13 -0
  80. data/lib/terminal-table-1.4.4/tasks/gemspec.rake +3 -0
  81. data/lib/terminal-table-1.4.4/tasks/spec.rake +25 -0
  82. data/lib/terminal-table-1.4.4/terminal-table.gemspec +30 -0
  83. data/responses/addresses +26 -0
  84. data/responses/addresses.blank +2 -0
  85. data/responses/instances +74 -0
  86. data/responses/keys +33 -0
  87. data/responses/locations +142 -0
  88. data/responses/offerings_image +3780 -0
  89. data/responses/storage +379 -0
  90. metadata +86 -22
  91. data/README.rdoc +0 -75
  92. data/lib/rest-client-1.6.3/VERSION +0 -1
  93. data/lib/rest-client-1.6.3/lib/restclient/net_http_ext.rb +0 -21
@@ -0,0 +1,217 @@
1
+
2
+ module Terminal
3
+ class Table
4
+
5
+ attr_reader :title
6
+ attr_reader :headings
7
+
8
+ ##
9
+ # Generates a ASCII table with the given _options_.
10
+
11
+ def initialize options = {}, &block
12
+ @column_widths = []
13
+ self.style = options.fetch :style, {}
14
+ self.title = options.fetch :title, nil
15
+ self.headings = options.fetch :headings, []
16
+ self.rows = options.fetch :rows, []
17
+ yield_or_eval(&block) if block
18
+ end
19
+
20
+ ##
21
+ # Align column _n_ to the given _alignment_ of :center, :left, or :right.
22
+
23
+ def align_column n, alignment
24
+ r = rows
25
+ column(n).each_with_index do |col, i|
26
+ cell = r[i][n]
27
+ cell.alignment = alignment unless cell.alignment?
28
+ end
29
+ end
30
+
31
+ ##
32
+ # Add a row.
33
+
34
+ def add_row array
35
+ row = array == :separator ? Separator.new(self) : Row.new(self, array)
36
+ @rows << row
37
+ recalc_column_widths row
38
+ end
39
+ alias :<< :add_row
40
+
41
+ ##
42
+ # Add a separator.
43
+
44
+ def add_separator
45
+ self << :separator
46
+ end
47
+
48
+ def cell_spacing
49
+ cell_padding + style.border_y.length
50
+ end
51
+
52
+ def cell_padding
53
+ style.padding_left + style.padding_right
54
+ end
55
+
56
+ ##
57
+ # Return column _n_.
58
+
59
+ def column n, method = :value, array = rows
60
+ array.map { |row|
61
+ cell = row[n]
62
+ cell && method ? cell.__send__(method) : cell
63
+ }.compact
64
+ end
65
+
66
+ ##
67
+ # Return _n_ column including headings.
68
+
69
+ def column_with_headings n, method = :value
70
+ column n, method, headings_with_rows
71
+ end
72
+
73
+ ##
74
+ # Return columns.
75
+
76
+ def columns
77
+ (0...number_of_columns).map { |n| column n }
78
+ end
79
+
80
+ ##
81
+ # Return length of column _n_.
82
+
83
+ def column_width n
84
+ width = @column_widths[n] || 0
85
+ width + additional_column_widths[n].to_i
86
+ end
87
+ alias length_of_column column_width # for legacy support
88
+
89
+ ##
90
+ # Return total number of columns available.
91
+
92
+ def number_of_columns
93
+ headings_with_rows.map { |r| r.cells.size }.max
94
+ end
95
+
96
+ ##
97
+ # Set the headings
98
+
99
+ def headings= array
100
+ @headings = Row.new(self, array)
101
+ recalc_column_widths @headings
102
+ end
103
+
104
+ ##
105
+ # Render the table.
106
+
107
+ def render
108
+ separator = Separator.new(self)
109
+ buffer = [separator]
110
+ unless @title.nil?
111
+ opts = {:value => @title, :alignment => :center, :colspan => number_of_columns}
112
+ buffer << Row.new(self, [opts])
113
+ buffer << separator
114
+ end
115
+ unless @headings.cells.empty?
116
+ buffer << @headings
117
+ buffer << separator
118
+ end
119
+ buffer += @rows
120
+ buffer << separator
121
+ buffer.map { |r| r.render }.join("\n")
122
+ end
123
+ alias :to_s :render
124
+
125
+ ##
126
+ # Return rows without separator rows.
127
+
128
+ def rows
129
+ @rows.reject { |row| row.is_a? Separator }
130
+ end
131
+
132
+ def rows= array
133
+ @rows = []
134
+ array.each { |arr| self << arr }
135
+ end
136
+
137
+ def style=(options)
138
+ style.apply options
139
+ end
140
+
141
+ def style
142
+ @style ||= Style.new
143
+ end
144
+
145
+ def title=(title)
146
+ @title = title
147
+ recalc_column_widths Row.new(self, [title])
148
+ end
149
+
150
+ ##
151
+ # Check if _other_ is equal to self. _other_ is considered equal
152
+ # if it contains the same headings and rows.
153
+
154
+ def == other
155
+ if other.respond_to? :render and other.respond_to? :rows
156
+ self.headings == other.headings and self.rows == other.rows
157
+ end
158
+ end
159
+
160
+ private
161
+
162
+ def columns_width
163
+ @column_widths.inject(0) { |s, i| s + i + cell_spacing } + style.border_y.length
164
+ end
165
+
166
+ def additional_column_widths
167
+ return [] if style.width.nil?
168
+ spacing = style.width - columns_width
169
+ if spacing < 0
170
+ raise "Table width exceeds wanted width of #{wanted} characters."
171
+ else
172
+ per_col = spacing / number_of_columns
173
+ arr = (1...number_of_columns).to_a.map { |i| per_col }
174
+ other_cols = arr.inject(0) { |s, i| s + i }
175
+ arr << spacing - other_cols
176
+ arr
177
+ end
178
+ end
179
+
180
+ def recalc_column_widths row
181
+ return if row.is_a? Separator
182
+ i = 0
183
+ row.cells.each do |cell|
184
+ colspan = cell.colspan
185
+ cell_value = cell.value_for_column_width_recalc
186
+ colspan.downto(1) do |j|
187
+ cell_length = cell_value.to_s.length
188
+ if colspan > 1
189
+ spacing_length = cell_spacing * (colspan - 1)
190
+ length_in_columns = (cell_length - spacing_length)
191
+ cell_length = (length_in_columns.to_f / colspan).ceil
192
+ end
193
+ if @column_widths[i].to_i < cell_length
194
+ @column_widths[i] = cell_length
195
+ end
196
+ i = i + 1
197
+ end
198
+ end
199
+ end
200
+
201
+ ##
202
+ # Return headings combined with rows.
203
+
204
+ def headings_with_rows
205
+ [@headings] + rows
206
+ end
207
+
208
+ def yield_or_eval &block
209
+ return unless block
210
+ if block.arity > 0
211
+ yield self
212
+ else
213
+ self.instance_eval(&block)
214
+ end
215
+ end
216
+ end
217
+ end
@@ -0,0 +1,9 @@
1
+ module Terminal
2
+ class Table
3
+ module TableHelper
4
+ def table headings = [], *rows, &block
5
+ Terminal::Table.new :headings => headings.to_a, :rows => rows, &block
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+
2
+ module Terminal
3
+ class Table
4
+ VERSION = '1.4.4'
5
+ end
6
+ end
@@ -0,0 +1,27 @@
1
+ #--
2
+ # Copyright (c) 2008-2009 TJ Holowaychuk <tj@vision-media.ca>
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ $:.unshift File.dirname(__FILE__)
25
+ %w(version core_ext table cell row separator style table_helper).each do |file|
26
+ require "terminal-table/#{file}"
27
+ end
@@ -0,0 +1,54 @@
1
+ require 'rubygems'
2
+ require 'term/ansicolor'
3
+
4
+ class String; include Term::ANSIColor; end
5
+
6
+ require File.dirname(__FILE__) + '/spec_helper'
7
+
8
+ describe Terminal::Table do
9
+ Cell = Terminal::Table::Cell
10
+
11
+ it "should default alignment to the left" do
12
+ cell = Cell.new :value => 'foo', :table => Terminal::Table.new, :index => 0
13
+ cell.value.should == 'foo'
14
+ cell.alignment.should == :left
15
+ end
16
+
17
+ it "should allow overriding of alignment" do
18
+ cell = Cell.new :value => 'foo', :alignment => :center, :table => Terminal::Table.new, :index => 0
19
+ cell.value.should == 'foo'
20
+ cell.alignment.should == :center
21
+ end
22
+
23
+ it "should allow :left, :right and :center for alignment" do
24
+ @cell = Cell.new :value => 'foo', :table => Terminal::Table.new, :index => 0
25
+ @cell.alignment = :left
26
+ @cell.alignment = :right
27
+ @cell.alignment = :center
28
+ lambda { @cell.alignment = "foo" }.should raise_error
29
+ end
30
+
31
+ it "should allow multiline content" do
32
+ cell = Cell.new :value => "foo\nbarrissimo", :table => Terminal::Table.new, :index => 0
33
+ cell.value.should == "foo\nbarrissimo"
34
+ cell.lines.should == ['foo', 'barrissimo']
35
+ cell.value_for_column_width_recalc.should == 'barrissimo'
36
+ cell.render(1).should == " barrissimo "
37
+ end
38
+
39
+ it "should allow colorized content" do
40
+ cell = Cell.new :value => "foo".red, :table => Terminal::Table.new, :index => 0
41
+ cell.value.should == "\e[31mfoo\e[0m"
42
+ cell.value_for_column_width_recalc.should == 'foo'
43
+ cell.render.should == " \e[31mfoo\e[0m "
44
+ end
45
+
46
+ it "should render padding properly" do
47
+ @table = Terminal::Table.new(:rows => [['foo', '2'], ['3', '4']], :style => {:padding_right => 3})
48
+ cell = @table.rows.first.cells.first
49
+ cell.value.should == 'foo'
50
+ cell.alignment.should == :left
51
+ cell.render.should == " foo "
52
+ end
53
+
54
+ end
@@ -0,0 +1,18 @@
1
+
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ describe String do
5
+ describe "#align" do
6
+ it "should center" do
7
+ 'foo'.align(:center, 10).should == ' foo '
8
+ end
9
+
10
+ it "should align left" do
11
+ 'foo'.align(:left, 10).should == 'foo '
12
+ end
13
+
14
+ it "should align right" do
15
+ 'foo'.align(:right, 10).should == ' foo'
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+ require "terminal-table/import"
4
+
5
+ describe Object do
6
+ describe "#table" do
7
+ it "should allow creation of a terminal table" do
8
+ table(['foo', 'bar'], ['a', 'b'], [1, 2]).should be_instance_of(Terminal::Table)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,8 @@
1
+
2
+ require File.dirname(__FILE__) + '/../lib/terminal-table'
3
+
4
+ class String
5
+ def deindent
6
+ strip.gsub(/^ */, '')
7
+ end
8
+ end