bellboy 0.3.4 → 0.4.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/lib/bellboy.rb +30 -0
- data/lib/bellboy/cli.rb +41 -0
- data/lib/bellboy/logger.rb +1 -1
- data/spec/logger_spec.rb +1 -1
- metadata +2 -2
data/lib/bellboy.rb
CHANGED
@@ -67,6 +67,36 @@ module Bellboy
|
|
67
67
|
|
68
68
|
Ridley.new(ridley_options)
|
69
69
|
end
|
70
|
+
|
71
|
+
def list(berksfile)
|
72
|
+
databags = {}
|
73
|
+
|
74
|
+
local_sources = Bellboy.berks_sources(berksfile)
|
75
|
+
|
76
|
+
local_sources.each do |source|
|
77
|
+
Bellboy.logger.debug "Source: #{source.cached_cookbook.path}"
|
78
|
+
|
79
|
+
path = File.join(source.cached_cookbook.path, 'data_bags')
|
80
|
+
Dir.foreach(path) do |dir|
|
81
|
+
subdir = File.join(path, dir)
|
82
|
+
|
83
|
+
next unless File.directory?(subdir)
|
84
|
+
next if dir == '.' || dir == '..'
|
85
|
+
|
86
|
+
databags[dir] = []
|
87
|
+
|
88
|
+
Dir.foreach(subdir) do |item|
|
89
|
+
next if item == '.' || item == '..'
|
90
|
+
next unless item.match('^.*\.json$')
|
91
|
+
|
92
|
+
databags[dir] << item.chomp('.json')
|
93
|
+
end
|
94
|
+
end if Dir.exists?(path)
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
databags
|
99
|
+
end
|
70
100
|
end
|
71
101
|
end
|
72
102
|
|
data/lib/bellboy/cli.rb
CHANGED
@@ -99,5 +99,46 @@ module Bellboy
|
|
99
99
|
berksfile = Bellboy.berks_from_file(options[:berksfile])
|
100
100
|
Bellboy::Uploader.upload(berksfile, options)
|
101
101
|
end
|
102
|
+
|
103
|
+
desc 'list', 'List all databags for all Cookbooks known by Berkshelf'
|
104
|
+
method_option :berksfile,
|
105
|
+
type: :string,
|
106
|
+
default: Berkshelf::DEFAULT_FILENAME,
|
107
|
+
desc: 'Path to a Berksfile to operate off of.',
|
108
|
+
aliases: '-b',
|
109
|
+
banner: 'PATH'
|
110
|
+
method_option :bellboyfile,
|
111
|
+
type: :string,
|
112
|
+
default: Bellboy::DEFAULT_FILENAME,
|
113
|
+
desc: 'Path to a Bellboy file to operate off of.',
|
114
|
+
aliases: '-d',
|
115
|
+
banner: 'PATH'
|
116
|
+
method_option :bags,
|
117
|
+
type: :boolean,
|
118
|
+
desc: 'List only the databags.',
|
119
|
+
aliases: '-B',
|
120
|
+
default: false
|
121
|
+
method_option :json,
|
122
|
+
type: :boolean,
|
123
|
+
desc: 'Output in JSON format.',
|
124
|
+
aliases: '-j',
|
125
|
+
default: false
|
126
|
+
def list
|
127
|
+
berksfile = Bellboy.berks_from_file(options[:berksfile])
|
128
|
+
databags = Bellboy.list(berksfile)
|
129
|
+
|
130
|
+
if options[:json]
|
131
|
+
Bellboy.logger.log databags.to_json
|
132
|
+
else
|
133
|
+
databags.each do |bag, items|
|
134
|
+
Bellboy.logger.log options[:bags] ? bag : "#{bag}:"
|
135
|
+
|
136
|
+
items.each do |item|
|
137
|
+
Bellboy.logger.log "\t#{item}"
|
138
|
+
end unless options[:bags]
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
102
143
|
end
|
103
144
|
end
|
data/lib/bellboy/logger.rb
CHANGED
data/spec/logger_spec.rb
CHANGED
@@ -24,7 +24,7 @@ describe 'logger' do
|
|
24
24
|
|
25
25
|
it 'should log debug messages when \'verbose\' is enabled' do
|
26
26
|
logger = Bellboy::Logger.new( {:verbose => true} )
|
27
|
-
content = capture(:
|
27
|
+
content = capture(:stderr) { logger.debug 'test message #4' }
|
28
28
|
expect(content).to eq("test message #4\n")
|
29
29
|
end
|
30
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bellboy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|