fog-core 1.27.3 → 1.27.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/changelog.md +7 -1
- data/lib/fog/core/collection.rb +2 -2
- data/lib/fog/core/logger.rb +2 -2
- data/lib/fog/core/model.rb +1 -10
- data/lib/fog/core/ssh.rb +3 -3
- data/lib/fog/core/version.rb +1 -1
- data/lib/fog/formatador.rb +55 -31
- data/lib/tasks/test_task.rb +4 -4
- data/spec/formatador_spec.rb +31 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e822a212a0601171bf7a7d5f61f5bc46211c66b7
|
4
|
+
data.tar.gz: 6abeed4e74994de0b27874fa1beefe93ff8c8fa3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c475dd52859470ac196901f374efab07bc3f7171b43fdc326ca0f637915c3e689dc7f85bf0720c6c6728d00dbcf76e88780494e70f5ca780c8963cb7ff37c85e
|
7
|
+
data.tar.gz: 47e064f9eabc07c9d8f8ef459456f4116745bba31dface8629b18ae64ff34618a96c911b798361904ecbbfaf5dd36b6dfc10e6e9153b45eb5e25dd7a4ffe6247
|
data/changelog.md
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
1.27.
|
1
|
+
1.27.4 01/26/2012
|
2
|
+
==========================================================
|
3
|
+
|
4
|
+
model fix for new formatador usage
|
5
|
+
fixes around formatador delegation
|
6
|
+
|
7
|
+
1.27.3 12/01/2012
|
2
8
|
==========================================================
|
3
9
|
|
4
10
|
rubocop fixes for fog collection
|
data/lib/fog/core/collection.rb
CHANGED
@@ -70,7 +70,7 @@ module Fog
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def inspect
|
73
|
-
Fog::Formatador.
|
73
|
+
Fog::Formatador.format(self)
|
74
74
|
end
|
75
75
|
|
76
76
|
def load(objects)
|
@@ -100,7 +100,7 @@ module Fog
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def table(attributes = nil)
|
103
|
-
Formatador.display_table(map(&:attributes), attributes)
|
103
|
+
Fog::Formatador.display_table(map(&:attributes), attributes)
|
104
104
|
end
|
105
105
|
|
106
106
|
def to_json(_options = {})
|
data/lib/fog/core/logger.rb
CHANGED
@@ -31,9 +31,9 @@ module Fog
|
|
31
31
|
channel = @channels[key]
|
32
32
|
if channel
|
33
33
|
message = if channel.tty?
|
34
|
-
value.gsub(::Formatador::PARSE_REGEX) { "\e[#{::Formatador::STYLES[$1.to_sym]}m" }.gsub(::Formatador::INDENT_REGEX, "")
|
34
|
+
value.gsub(Fog::Formatador::PARSE_REGEX) { "\e[#{Fog::Formatador::STYLES[$1.to_sym]}m" }.gsub(Fog::Formatador::INDENT_REGEX, "")
|
35
35
|
else
|
36
|
-
value.gsub(::Formatador::PARSE_REGEX, "").gsub(::Formatador::INDENT_REGEX, "")
|
36
|
+
value.gsub(Fog::Formatador::PARSE_REGEX, "").gsub(Fog::Formatador::INDENT_REGEX, "")
|
37
37
|
end
|
38
38
|
channel.write(message)
|
39
39
|
end
|
data/lib/fog/core/model.rb
CHANGED
@@ -21,16 +21,7 @@ module Fog
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def inspect
|
24
|
-
|
25
|
-
data = "#{Thread.current[:formatador].indentation}<#{self.class.name}"
|
26
|
-
Thread.current[:formatador].indent do
|
27
|
-
unless self.class.attributes.empty?
|
28
|
-
data << "\n#{Thread.current[:formatador].indentation}"
|
29
|
-
data << self.class.attributes.map { |attribute| "#{attribute}=#{send(attribute).inspect}" }.join(",\n#{Thread.current[:formatador].indentation}")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
data << "\n#{Thread.current[:formatador].indentation}>"
|
33
|
-
data
|
24
|
+
Fog::Formatador.format(self)
|
34
25
|
end
|
35
26
|
|
36
27
|
def reload
|
data/lib/fog/core/ssh.rb
CHANGED
@@ -109,14 +109,14 @@ module Fog
|
|
109
109
|
def display_stdout
|
110
110
|
data = stdout.split("\r\n")
|
111
111
|
if data.is_a?(String)
|
112
|
-
Formatador.display_line(data)
|
112
|
+
Fog::Formatador.display_line(data)
|
113
113
|
elsif data.is_a?(Array)
|
114
|
-
Formatador.display_lines(data)
|
114
|
+
Fog::Formatador.display_lines(data)
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
118
|
def display_stderr
|
119
|
-
Formatador.display_line(stderr.split("\r\n"))
|
119
|
+
Fog::Formatador.display_line(stderr.split("\r\n"))
|
120
120
|
end
|
121
121
|
|
122
122
|
def initialize(command)
|
data/lib/fog/core/version.rb
CHANGED
data/lib/fog/formatador.rb
CHANGED
@@ -1,65 +1,89 @@
|
|
1
1
|
module Fog
|
2
2
|
# Fog::Formatador
|
3
|
-
|
4
|
-
|
3
|
+
module Formatador
|
4
|
+
PARSE_REGEX = ::Formatador::PARSE_REGEX
|
5
|
+
STYLES = ::Formatador::STYLES
|
6
|
+
INDENT_REGEX = ::Formatador::INDENT_REGEX
|
5
7
|
|
6
|
-
def
|
7
|
-
|
8
|
-
@formatador ||= ::Formatador.new
|
8
|
+
def self.formatador
|
9
|
+
Thread.current[:formatador] ||= ::Formatador.new
|
9
10
|
end
|
10
11
|
|
11
|
-
def
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
def self.format(object, opts = { :include_nested => true })
|
13
|
+
string = init_string(object)
|
14
|
+
indent { string << object_string(object, opts) }
|
15
|
+
string << "#{indentation}>"
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
def self.display_line(data)
|
21
|
+
::Formatador.display_line(data)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.display_lines(data)
|
25
|
+
::Formatador.display_lines(data)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.display_compact_table(hashes, keys = nil, &block)
|
29
|
+
::Formatador.display_compact_table(hashes, keys, &block)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.display_table(hashes, keys = nil, &block)
|
33
|
+
::Formatador.display_table(hashes, keys, &block)
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.redisplay_progressbar(current, total, options = {})
|
37
|
+
::Formatador.redisplay_progressbar(current, total, options = {})
|
16
38
|
end
|
17
39
|
|
18
40
|
private
|
19
41
|
|
20
|
-
def indent(&block)
|
42
|
+
def self.indent(&block)
|
21
43
|
formatador.indent(&block)
|
22
44
|
end
|
23
45
|
|
24
|
-
def indentation
|
46
|
+
def self.indentation
|
25
47
|
formatador.indentation
|
26
48
|
end
|
27
49
|
|
28
|
-
def init_string
|
29
|
-
|
50
|
+
def self.init_string(object)
|
51
|
+
"#{indentation}<#{object.class.name}\n"
|
30
52
|
end
|
31
53
|
|
32
|
-
def object_string
|
33
|
-
"#{attribute_string}
|
54
|
+
def self.object_string(object, opts)
|
55
|
+
string = "#{attribute_string(object)}"
|
56
|
+
string << "#{nested_objects_string(object)}" if opts[:include_nested]
|
57
|
+
string
|
34
58
|
end
|
35
59
|
|
36
|
-
def attribute_string
|
37
|
-
|
38
|
-
|
39
|
-
else
|
60
|
+
def self.attribute_string(object)
|
61
|
+
return "" unless object.class.respond_to?(:attributes)
|
62
|
+
if object.class.attributes.empty?
|
40
63
|
""
|
64
|
+
else
|
65
|
+
"#{indentation}#{object_attributes(object)}\n"
|
41
66
|
end
|
42
67
|
end
|
43
68
|
|
44
|
-
def nested_objects_string
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
""
|
52
|
-
end
|
69
|
+
def self.nested_objects_string(object)
|
70
|
+
nested = ""
|
71
|
+
return nested if object.respond_to?(:empty) and object.empty?
|
72
|
+
return nested unless object.respond_to?(:map)
|
73
|
+
nested = "#{indentation}[\n"
|
74
|
+
indent { nested << indentation + inspect_object(object) }
|
75
|
+
nested << "#{indentation}\n#{indentation}]\n"
|
53
76
|
end
|
54
77
|
|
55
|
-
def object_attributes
|
78
|
+
def self.object_attributes(object)
|
56
79
|
attrs = object.class.attributes.map do |attr|
|
57
80
|
"#{attr}=#{object.send(attr).inspect}"
|
58
81
|
end
|
59
82
|
attrs.join(",\n#{indentation}")
|
60
83
|
end
|
61
84
|
|
62
|
-
def inspect_object
|
85
|
+
def self.inspect_object(object)
|
86
|
+
return "" unless object.respond_to?(:map)
|
63
87
|
object.map { |o| indentation + o.inspect }.join(", \n#{indentation}")
|
64
88
|
end
|
65
89
|
end
|
data/lib/tasks/test_task.rb
CHANGED
@@ -20,7 +20,7 @@ module Fog
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def tests(mocked)
|
23
|
-
Formatador.display_line
|
23
|
+
Fog::Formatador.display_line
|
24
24
|
start = Time.now.to_i
|
25
25
|
threads = []
|
26
26
|
Thread.main[:results] = []
|
@@ -33,9 +33,9 @@ module Fog
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
threads.each(&:join)
|
36
|
-
Formatador.display_table(Thread.main[:results].sort { |x, y| x[:provider] <=> y[:provider] })
|
37
|
-
Formatador.display_line("[bold]FOG_MOCK=#{mocked}[/] tests completed in [bold]#{Time.now.to_i - start}[/] seconds")
|
38
|
-
Formatador.display_line
|
36
|
+
Fog::Formatador.display_table(Thread.main[:results].sort { |x, y| x[:provider] <=> y[:provider] })
|
37
|
+
Fog::Formatador.display_line("[bold]FOG_MOCK=#{mocked}[/] tests completed in [bold]#{Time.now.to_i - start}[/] seconds")
|
38
|
+
Fog::Formatador.display_line
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
data/spec/formatador_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
class
|
3
|
+
class CollectionTestCase < Fog::Collection
|
4
4
|
def all
|
5
5
|
end
|
6
6
|
def map(*_args)
|
@@ -20,8 +20,11 @@ class TestCase < Fog::Collection
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
class NonCollectionTestCase
|
24
|
+
end
|
25
|
+
|
26
|
+
test_case_str1 = <<-EOL
|
27
|
+
<CollectionTestCase
|
25
28
|
this=["this", "that"],
|
26
29
|
that=["that", "this"]
|
27
30
|
[
|
@@ -30,28 +33,40 @@ test_case_str = <<-EOL
|
|
30
33
|
]
|
31
34
|
>
|
32
35
|
EOL
|
36
|
+
test_case_str1.chomp!
|
37
|
+
|
38
|
+
test_case_str2 = <<-EOL
|
39
|
+
<CollectionTestCase
|
40
|
+
this=["this", "that"],
|
41
|
+
that=["that", "this"]
|
42
|
+
>
|
43
|
+
EOL
|
44
|
+
test_case_str2.chomp!
|
33
45
|
|
34
|
-
|
46
|
+
test_case_str3 = <<-EOL
|
47
|
+
<NonCollectionTestCase
|
48
|
+
>
|
49
|
+
EOL
|
50
|
+
test_case_str3.chomp!
|
35
51
|
|
36
52
|
describe Fog::Formatador do
|
37
53
|
|
38
54
|
def setup
|
39
|
-
@
|
40
|
-
|
41
|
-
|
42
|
-
it "raises for missing required arguments" do
|
43
|
-
assert_raises(ArgumentError) { Fog::Formatador.new }
|
55
|
+
@collection_test = CollectionTestCase.new
|
56
|
+
@collection_test << 'this'
|
57
|
+
@non_collection_test = NonCollectionTestCase.new
|
44
58
|
end
|
45
59
|
|
46
|
-
it "should
|
47
|
-
@
|
60
|
+
it "should give a string representation of object with proper indentation" do
|
61
|
+
Fog::Formatador.format(@collection_test).must_equal test_case_str1
|
48
62
|
end
|
49
63
|
|
50
|
-
it
|
51
|
-
|
52
|
-
|
64
|
+
it 'should not include nested objects' do
|
65
|
+
opts = { :include_nested => false }
|
66
|
+
Fog::Formatador.format(@collection_test, opts).must_equal test_case_str2
|
67
|
+
end
|
53
68
|
|
54
|
-
it
|
55
|
-
|
69
|
+
it 'should not raise if object does not response to :empty? or :map' do
|
70
|
+
Fog::Formatador.format(@non_collection_test).must_equal test_case_str3
|
56
71
|
end
|
57
72
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.27.
|
4
|
+
version: 1.27.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Light
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-01-
|
12
|
+
date: 2015-01-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: builder
|