cook 2.0.6 → 2.0.7
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/Rakefile +1 -1
- data/lib/cook.rb +1 -1
- data/lib/rake/config.rb +40 -4
- data/lib/rake/cookUtils.rb +8 -0
- data/lib/rake/extensions.rb +83 -7
- metadata +9 -8
data/Rakefile
CHANGED
@@ -34,7 +34,7 @@ end
|
|
34
34
|
|
35
35
|
Hoe.spec 'cook' do
|
36
36
|
developer('Stephen Gaito', 'stephen@perceptisys.co.uk')
|
37
|
-
dependency('rake', '~>
|
37
|
+
dependency('rake', '~> 10.3.1');
|
38
38
|
dependency('construct', '~> 0.1.7');
|
39
39
|
dependency('erubis', '~> 2.7');
|
40
40
|
dependency('greenletters', '~> 0.2');
|
data/lib/cook.rb
CHANGED
data/lib/rake/config.rb
CHANGED
@@ -114,6 +114,10 @@ end
|
|
114
114
|
|
115
115
|
class Construct
|
116
116
|
|
117
|
+
def cloneData()
|
118
|
+
@data = @data.clone;
|
119
|
+
end
|
120
|
+
|
117
121
|
def empty?()
|
118
122
|
@data.empty?();
|
119
123
|
end
|
@@ -196,6 +200,21 @@ class Construct
|
|
196
200
|
end
|
197
201
|
return result;
|
198
202
|
end
|
203
|
+
|
204
|
+
def prettyPrint(result, prefix)
|
205
|
+
if empty? then
|
206
|
+
result.puts(prefix+'=emptyConstruct');
|
207
|
+
else
|
208
|
+
data.keys.sort{ |x,y| x.to_s <=> y.to_s }.each do | aKey |
|
209
|
+
aValue = data[aKey];
|
210
|
+
if aValue.respond_to?(:prettyPrint) then
|
211
|
+
aValue.prettyPrint(result, prefix+'.'+aKey.to_s);
|
212
|
+
else
|
213
|
+
result.puts(prefix+'.'+aKey.to_s+"="+aValue.to_s);
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
199
218
|
|
200
219
|
end
|
201
220
|
|
@@ -339,6 +358,13 @@ class Conf
|
|
339
358
|
end
|
340
359
|
|
341
360
|
def self.add_recipes_path(aRecipesPath)
|
361
|
+
#
|
362
|
+
# Make sure the recipeDir is in the load path
|
363
|
+
#
|
364
|
+
$LOAD_PATH.unshift(aRecipesPath);
|
365
|
+
#
|
366
|
+
# Add this path to the collection of recipe paths to search
|
367
|
+
#
|
342
368
|
@@recipePaths.push(aRecipesPath);
|
343
369
|
end
|
344
370
|
|
@@ -458,6 +484,12 @@ class Conf
|
|
458
484
|
end
|
459
485
|
end
|
460
486
|
|
487
|
+
def self.prettyPrint
|
488
|
+
result = StringIO.new;
|
489
|
+
@@data.prettyPrint(result, "Conf");
|
490
|
+
result.string;
|
491
|
+
end
|
492
|
+
|
461
493
|
end
|
462
494
|
|
463
495
|
module Rake
|
@@ -494,9 +526,9 @@ module Rake
|
|
494
526
|
return options;
|
495
527
|
end
|
496
528
|
|
497
|
-
alias_method :
|
498
|
-
def
|
499
|
-
|
529
|
+
alias_method :rake_config_original_collect_command_line_tasks, :collect_command_line_tasks
|
530
|
+
def collect_command_line_tasks
|
531
|
+
rake_config_original_collect_command_line_tasks;
|
500
532
|
@top_level_tasks.unshift("cookPostConfig");
|
501
533
|
@top_level_tasks.unshift("cookConfig");
|
502
534
|
@top_level_tasks.unshift("cookPreConfig");
|
@@ -809,7 +841,11 @@ config :cookPostConfig do
|
|
809
841
|
Rake::Application.mesg "--------------------\nTasks defined\n\n";
|
810
842
|
Rake::Application.mesg_pp Rake.application.tasks;
|
811
843
|
Rake::Application.mesg "--------------------\nConfiguration data\n\n";
|
812
|
-
Rake::Application.
|
844
|
+
Rake::Application.mesg_conf # Conf.data;
|
845
|
+
Rake::Application.mesg "--------------------\nRecipe paths\n\n";
|
846
|
+
Rake::Application.mesg_pp Conf.get_recipe_paths
|
847
|
+
Rake::Application.mesg "--------------------\nRuby load paths\n\n";
|
848
|
+
Rake::Application.mesg_pp $LOAD_PATH
|
813
849
|
Rake::Application.mesg "--------------------\n\n";
|
814
850
|
end
|
815
851
|
end
|
data/lib/rake/cookUtils.rb
CHANGED
@@ -251,6 +251,14 @@ end
|
|
251
251
|
#############################################################################
|
252
252
|
# Apply templates and/or copy resources
|
253
253
|
|
254
|
+
def apply_partial(aPartialResourcePath)
|
255
|
+
require 'erubis'
|
256
|
+
templateFileName = find_resource(aPartialResourcePath);
|
257
|
+
mesg "Applying erubis partial template: [#{templateFileName}]";
|
258
|
+
eruby = Erubis::Eruby.new(IO.read(templateFileName));
|
259
|
+
eruby.result(binding()).chomp();
|
260
|
+
end
|
261
|
+
|
254
262
|
def applyTemplate(templateFileName, resultFileName, mode = nil, owner = nil, group = nil)
|
255
263
|
require 'erubis'
|
256
264
|
mesg "Applying erubis template: [#{templateFileName}]\nto produce: [#{resultFileName}]";
|
data/lib/rake/extensions.rb
CHANGED
@@ -1,8 +1,54 @@
|
|
1
1
|
require 'logger';
|
2
|
-
require 'pp'
|
3
|
-
require '
|
2
|
+
require 'pp';
|
3
|
+
require 'yaml';
|
4
|
+
require 'stringio';
|
4
5
|
require 'greenletters';
|
5
6
|
|
7
|
+
class Hash
|
8
|
+
|
9
|
+
def cloneData()
|
10
|
+
end
|
11
|
+
|
12
|
+
def prettyPrint(result, prefix)
|
13
|
+
if empty? then
|
14
|
+
result.puts(prefix+'=emptyHash');
|
15
|
+
else
|
16
|
+
keys.sort{ |x,y| x.to_s <=> y.to_s }.each do | aKey |
|
17
|
+
aValue = self[aKey];
|
18
|
+
if aValue.respond_to?(:prettyPrint) then
|
19
|
+
aValue.prettyPrint(result, prefix+'.'+aKey.to_s);
|
20
|
+
else
|
21
|
+
result.puts(prefix+'.'+aKey.to_s+"="+aValue.to_s);
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Array
|
29
|
+
def prettyPrint(result, prefix)
|
30
|
+
if empty? then
|
31
|
+
result.puts(prefix+'=emptyArray');
|
32
|
+
else
|
33
|
+
index = 0;
|
34
|
+
each do | aValue |
|
35
|
+
if aValue.respond_to?(:prettyPrint) then
|
36
|
+
aValue.prettyPrint(result, prefix+'['+index.to_s+']');
|
37
|
+
else
|
38
|
+
result.puts(prefix+'['+index.to_s+']='+aValue.to_s);
|
39
|
+
end
|
40
|
+
index += 1;
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class String
|
47
|
+
def prettyPrint(result, prefix)
|
48
|
+
result.puts(prefix+'="'+to_s+'"');
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
6
52
|
module Greenletters
|
7
53
|
#
|
8
54
|
# We need to add the Greenletters::Process#result method to return the
|
@@ -86,36 +132,46 @@ module Rake
|
|
86
132
|
def self.logger()
|
87
133
|
return @logger;
|
88
134
|
end
|
135
|
+
|
89
136
|
def self.logFile()
|
90
137
|
return @logFile;
|
91
138
|
end
|
139
|
+
|
92
140
|
def self.logData(someData)
|
93
141
|
@logFile.write(someData) if @logFile;
|
94
142
|
end
|
143
|
+
|
95
144
|
def self.set_logger(aLogger, aLogFile=nil)
|
96
145
|
@logFile = aLogFile;
|
97
146
|
oldLogger = @logger;
|
98
147
|
@logger = aLogger;
|
99
148
|
return oldLogger;
|
100
149
|
end
|
150
|
+
|
101
151
|
def self.log(*args)
|
102
152
|
@logger.log(*args) if @logger;
|
103
153
|
end
|
154
|
+
|
104
155
|
def self.fatal(*args)
|
105
156
|
@logger.fatal(*args) if @logger;
|
106
157
|
end
|
158
|
+
|
107
159
|
def self.error(*args)
|
108
160
|
@logger.error(*args) if @logger;
|
109
161
|
end
|
162
|
+
|
110
163
|
def self.warn(*args)
|
111
164
|
@logger.warn(*args) if @logger;
|
112
165
|
end
|
166
|
+
|
113
167
|
def self.info(*args)
|
114
168
|
@logger.info(*args) if @logger;
|
115
169
|
end
|
170
|
+
|
116
171
|
def self.debug(*args)
|
117
172
|
@logger.debug(*args) if @logger;
|
118
173
|
end
|
174
|
+
|
119
175
|
def self.mesg(*args)
|
120
176
|
@logger.info(*args) if @logger;
|
121
177
|
$stderr.puts(*args) if @logToStderr;
|
@@ -135,6 +191,20 @@ module Rake
|
|
135
191
|
$stderr.puts(s.string) if @logToStderr;
|
136
192
|
end
|
137
193
|
|
194
|
+
def self.mesg_yaml(*args)
|
195
|
+
args.each do | anArg |
|
196
|
+
str = YAML.dump(anArg);
|
197
|
+
@logger.info(str);
|
198
|
+
$stderr.puts(str) if @logToStderr;
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
def self.mesg_conf
|
203
|
+
str = Conf.prettyPrint;
|
204
|
+
@logger.info(str);
|
205
|
+
$stderr.puts(str) if @logToStderr;
|
206
|
+
end
|
207
|
+
|
138
208
|
end
|
139
209
|
|
140
210
|
module DSL
|
@@ -147,6 +217,13 @@ module Rake
|
|
147
217
|
Rake::Application.mesg_pp(*args);
|
148
218
|
end
|
149
219
|
|
220
|
+
def mesg_yaml(*args)
|
221
|
+
Rake::Application.mesg_yaml(*args);
|
222
|
+
end
|
223
|
+
|
224
|
+
def mesg_conf
|
225
|
+
Rake::Application.mesg_conf;
|
226
|
+
end
|
150
227
|
end
|
151
228
|
|
152
229
|
class Task
|
@@ -156,7 +233,7 @@ module Rake
|
|
156
233
|
def invoke_with_call_chain(task_args, invocation_chain) # :nodoc:
|
157
234
|
new_chain = InvocationChain.append(self, invocation_chain)
|
158
235
|
@lock.synchronize do
|
159
|
-
if application.options.trace
|
236
|
+
if application.options.trace then
|
160
237
|
Rake::Application.mesg "** Invoke #{name} #{format_trace_flags}"
|
161
238
|
end
|
162
239
|
return if @already_invoked
|
@@ -172,11 +249,11 @@ module Rake
|
|
172
249
|
# Execute the actions associated with this task.
|
173
250
|
def execute(args=nil)
|
174
251
|
args ||= EMPTY_TASK_ARGS
|
175
|
-
if application.options.dryrun
|
252
|
+
if application.options.dryrun then
|
176
253
|
Rake::Application.mesg "** Execute (dry run) #{name}"
|
177
254
|
return
|
178
255
|
end
|
179
|
-
if application.options.trace
|
256
|
+
if application.options.trace then
|
180
257
|
Rake::Application.mesg "** Execute #{name}"
|
181
258
|
end
|
182
259
|
application.enhance_with_matching_rule(name) if @actions.empty?
|
@@ -189,11 +266,10 @@ module Rake
|
|
189
266
|
end
|
190
267
|
end
|
191
268
|
end
|
192
|
-
|
193
269
|
end
|
194
270
|
|
195
271
|
end
|
196
272
|
|
197
|
-
self.extend Rake::DSL
|
273
|
+
#self.extend Rake::DSL
|
198
274
|
|
199
275
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.7
|
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-
|
12
|
+
date: 2014-04-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 10.3.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 10.3.1
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: construct
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,7 +130,7 @@ dependencies:
|
|
130
130
|
requirements:
|
131
131
|
- - ~>
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version: '3.
|
133
|
+
version: '3.11'
|
134
134
|
type: :development
|
135
135
|
prerelease: false
|
136
136
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -138,7 +138,7 @@ dependencies:
|
|
138
138
|
requirements:
|
139
139
|
- - ~>
|
140
140
|
- !ruby/object:Gem::Version
|
141
|
-
version: '3.
|
141
|
+
version: '3.11'
|
142
142
|
description: ! "cook is a rake extension with:\n\n1. configuration file,\n1. the ability
|
143
143
|
to retrieve passwords from encrypted configuration files,\n1. the ability to create
|
144
144
|
files using Erubis templates,\n1. the ablity to interact with both local and remote
|
@@ -174,7 +174,8 @@ files:
|
|
174
174
|
- test/test_cook.rb
|
175
175
|
- .gemtest
|
176
176
|
homepage: https://github.com/stephengaito/rGems-cook
|
177
|
-
licenses:
|
177
|
+
licenses:
|
178
|
+
- MIT
|
178
179
|
post_install_message:
|
179
180
|
rdoc_options:
|
180
181
|
- --main
|
@@ -194,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
195
|
- !ruby/object:Gem::Version
|
195
196
|
version: '0'
|
196
197
|
requirements: []
|
197
|
-
rubyforge_project:
|
198
|
+
rubyforge_project:
|
198
199
|
rubygems_version: 1.8.23
|
199
200
|
signing_key:
|
200
201
|
specification_version: 3
|