bakery 0.5.1 → 0.5.2
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/bin/bake +28 -3
- data/lib/bakery.rb +1 -0
- data/lib/bakery/bakery.rb +11 -1
- data/lib/bakery/detail/global_function.rb +2 -0
- data/lib/bakery/detail/load.rb +2 -0
- data/lib/bakery/detail/log.rb +46 -0
- data/lib/bakery/detail/search.rb +6 -1
- data/lib/bakery/icing.rb +43 -0
- data/lib/bakery/ingredients/detail/dir.ingredient +8 -0
- data/lib/bakery/ingredients/detail/file.ingredient +12 -0
- data/lib/bakery/ingredients/detail/marker.ingredient +2 -0
- data/lib/bakery/version.rb +1 -1
- metadata +2 -1
data/bin/bake
CHANGED
@@ -24,31 +24,56 @@ EOS
|
|
24
24
|
opt :recipe, "Set recipe file to bake from.", { :type => String, :default => File.join(Bakery::ROOT_DIR, '.recipe') }
|
25
25
|
opt :ingredients, "Set which ingredients to use when baking.", { :type => String, :default => File.join(Bakery::ROOT_DIR, '.ingredients') }
|
26
26
|
opt :destination, "Set the destination location.", { :type => String }
|
27
|
+
opt :verbose, "Verbose output.", { :default => false, :short => 'e' }
|
28
|
+
opt :debug, "Debug output.", { :default => false, :short => 'b' }
|
29
|
+
opt :quiet, "Ignore warnings.", { :default => false, :short => 'q' }
|
27
30
|
end
|
28
31
|
|
29
|
-
Trollop::die :recipe, ": '#{opts[:recipe]}' must exist" unless File.exist?(opts[:recipe])
|
32
|
+
Trollop::die :recipe, ": '#{opts[:recipe]}' must exist" unless File.exist?(opts[:recipe])
|
33
|
+
|
34
|
+
Bakery::Log::VERBOSE = opts[:verbose]
|
35
|
+
Bakery::Log::QUIET = opts[:quiet]
|
36
|
+
Bakery::Log::DEBUG = opts[:debug]
|
30
37
|
|
31
38
|
bake_init = Proc.new do
|
32
39
|
Bakery.addCake
|
33
40
|
|
34
41
|
# use default ingredients if an ingredients file is not provided
|
35
42
|
if File.exists? opts[:ingredients]
|
43
|
+
Bakery::Log.debug "loading ingredients: #{opts[:ingredients]}"
|
44
|
+
|
36
45
|
load opts[:ingredients]
|
37
46
|
else
|
38
|
-
|
47
|
+
Bakery::Log.warning "using default ingredients"
|
48
|
+
|
39
49
|
use_defaults
|
40
50
|
end
|
41
51
|
|
42
|
-
|
52
|
+
Bakery::Log.debug "loading recipe: #{opts[:recipe]}"
|
53
|
+
|
54
|
+
begin
|
55
|
+
load opts[:recipe]
|
56
|
+
|
57
|
+
Bakery::Log.puts "success"
|
58
|
+
rescue Exception => e
|
59
|
+
puts e
|
60
|
+
Bakery::Log.error "failure"
|
61
|
+
end
|
43
62
|
end
|
44
63
|
|
45
64
|
if opts[:destination]
|
46
65
|
if !Dir.exists? opts[:destination]
|
66
|
+
Bakery::Log.info "creating destination directory: #{opts[:destination]}"
|
67
|
+
|
47
68
|
FileUtils.mkdir_p opts[:destination]
|
69
|
+
else
|
70
|
+
Bakery::Log.debug "using destination directory: #{opts[:destination]}"
|
48
71
|
end
|
49
72
|
|
50
73
|
Dir.chdir opts[:destination], &bake_init
|
51
74
|
else
|
75
|
+
Bakery::Log.debug "destination set to current directory"
|
76
|
+
|
52
77
|
bake_init.call
|
53
78
|
end
|
54
79
|
|
data/lib/bakery.rb
CHANGED
data/lib/bakery/bakery.rb
CHANGED
@@ -19,10 +19,18 @@ module Bakery
|
|
19
19
|
def removeMarkerLayerFromStack path
|
20
20
|
# remove all markers that are in the current directory
|
21
21
|
@markers.select! { |marker|
|
22
|
-
!marker.getPath.start_with?
|
22
|
+
removed = !marker.getPath.start_with?(path)
|
23
|
+
|
24
|
+
if removed
|
25
|
+
Bakery::Log.debug "unset #{marker.class}: #{marker.getPath}"
|
26
|
+
end
|
27
|
+
|
28
|
+
removed
|
23
29
|
}
|
24
30
|
|
25
31
|
if @currentCake.root == path
|
32
|
+
Bakery::Log.debug "leaving project: #{@currentCake.root}"
|
33
|
+
|
26
34
|
@currentCake = @currentCake.parent
|
27
35
|
end
|
28
36
|
end
|
@@ -60,6 +68,8 @@ module Bakery
|
|
60
68
|
def addCake
|
61
69
|
cake = Cake.new @currentCake
|
62
70
|
|
71
|
+
Bakery::Log.debug "entering project: #{cake.root}"
|
72
|
+
|
63
73
|
@cakes.push cake
|
64
74
|
@currentCake = cake
|
65
75
|
end
|
data/lib/bakery/detail/load.rb
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2013
|
3
|
+
# Nathan Currier
|
4
|
+
#
|
5
|
+
# Use, modification, and distribution are all subject to the
|
6
|
+
# Boost Software License, Version 1.0. (See the accompanying
|
7
|
+
# file LICENSE.md or at http://rideliner.tk/LICENSE.html).
|
8
|
+
#
|
9
|
+
# <description>
|
10
|
+
#
|
11
|
+
|
12
|
+
module Bakery
|
13
|
+
module Log
|
14
|
+
class << self
|
15
|
+
private
|
16
|
+
def print tag, msg
|
17
|
+
puts "[#{tag}] #{msg}"
|
18
|
+
end
|
19
|
+
public
|
20
|
+
def puts msg
|
21
|
+
$stderr.puts msg
|
22
|
+
end
|
23
|
+
|
24
|
+
# output if not quiet
|
25
|
+
def warning msg
|
26
|
+
print 'WARNING', msg unless QUIET
|
27
|
+
end
|
28
|
+
|
29
|
+
# output all the time
|
30
|
+
def error msg
|
31
|
+
print 'ERROR', msg
|
32
|
+
end
|
33
|
+
|
34
|
+
# output if verbose
|
35
|
+
def info msg
|
36
|
+
print 'INFO', msg if VERBOSE
|
37
|
+
end
|
38
|
+
|
39
|
+
# output if debugging
|
40
|
+
def debug msg
|
41
|
+
print 'DEBUG', msg if DEBUG
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
data/lib/bakery/detail/search.rb
CHANGED
@@ -54,7 +54,8 @@ public
|
|
54
54
|
if file != nil
|
55
55
|
yield file
|
56
56
|
else
|
57
|
-
|
57
|
+
Bakery::Log.warning "no results found in search: #{filename}"
|
58
|
+
Bakery::Log.debug "search path: #{paths}"
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
@@ -67,7 +68,11 @@ public
|
|
67
68
|
|
68
69
|
def addSearchDirectory dir
|
69
70
|
if File.exist?(dir) && File.directory?(dir) && !@paths.include?(dir)
|
71
|
+
Bakery::Log.debug "directory added to search path: #{dir}"
|
72
|
+
|
70
73
|
@paths << dir
|
74
|
+
else
|
75
|
+
Bakery::Log.warning "directory not added to search path: #{dir}"
|
71
76
|
end
|
72
77
|
end
|
73
78
|
|
data/lib/bakery/icing.rb
CHANGED
@@ -10,12 +10,22 @@
|
|
10
10
|
#
|
11
11
|
|
12
12
|
def name n
|
13
|
+
if Bakery.getCake.icing[:name] == nil
|
14
|
+
Bakery::Log.debug "name set: #{n}"
|
15
|
+
else
|
16
|
+
Bakery::Log.debug "name overwritten: #{n}"
|
17
|
+
end
|
18
|
+
|
13
19
|
Bakery.getCake.icing[:name] = n
|
14
20
|
end
|
15
21
|
|
16
22
|
def authors *names
|
17
23
|
if Bakery.getCake.icing[:authors] == nil
|
24
|
+
Bakery::Log.debug "authors set: #{names}"
|
25
|
+
|
18
26
|
Bakery.getCake.icing[:authors] = Array.new
|
27
|
+
else
|
28
|
+
Bakery::Log.debug "authors concatenated: #{names}"
|
19
29
|
end
|
20
30
|
|
21
31
|
Bakery.getCake.icing[:authors].concat names
|
@@ -25,7 +35,11 @@ alias :author :authors
|
|
25
35
|
|
26
36
|
def description *desc
|
27
37
|
if Bakery.getCake.icing[:description] == nil
|
38
|
+
Bakery::Log.debug "description set: #{desc}"
|
39
|
+
|
28
40
|
Bakery.getCake.icing[:description] = Array.new
|
41
|
+
else
|
42
|
+
Bakery::Log.debug "description concatenated: #{desc}"
|
29
43
|
end
|
30
44
|
|
31
45
|
Bakery.getCake.icing[:description].concat desc
|
@@ -33,32 +47,61 @@ end
|
|
33
47
|
|
34
48
|
def summary *sum
|
35
49
|
if Bakery.getCake.icing[:summary] == nil
|
50
|
+
Bakery::Log.debug "summary set: #{sum}"
|
51
|
+
|
36
52
|
Bakery.getCake.icing[:summary] = Array.new
|
53
|
+
else
|
54
|
+
Bakery::Log.debug "summary concatenated: #{sum}"
|
37
55
|
end
|
38
56
|
|
39
57
|
Bakery.getCake.icing[:summary].concat sum
|
40
58
|
end
|
41
59
|
|
42
60
|
def copyright *lines
|
61
|
+
if Bakery.icing[:copyright] == nil
|
62
|
+
Bakery::Log.debug "copyright set: #{lines}"
|
63
|
+
else
|
64
|
+
Bakery::Log.debug "copyright overwritten: #{lines}"
|
65
|
+
end
|
66
|
+
|
43
67
|
Bakery.getCake.icing[:copyright] = lines
|
44
68
|
end
|
45
69
|
|
46
70
|
def defaultAuthors *names
|
71
|
+
if Bakery.icing[:authors] == nil
|
72
|
+
Bakery::Log.debug "default author set: #{names}"
|
73
|
+
else
|
74
|
+
Bakery::Log.debug "default author overwritten: #{names}"
|
75
|
+
end
|
76
|
+
|
47
77
|
Bakery.icing[:authors] = names
|
48
78
|
end
|
49
79
|
|
50
80
|
alias :defaultAuthor :defaultAuthors
|
51
81
|
|
52
82
|
def defaultCopyright *lines
|
83
|
+
if Bakery.icing[:copyright] == nil
|
84
|
+
Bakery::Log.debug "default copyright set: #{lines}"
|
85
|
+
else
|
86
|
+
Bakery::Log.debug "default copyright overwritten: #{lines}"
|
87
|
+
end
|
88
|
+
|
53
89
|
Bakery.icing[:copyright] = lines
|
54
90
|
end
|
55
91
|
|
56
92
|
def defaultDescription *desc
|
93
|
+
if Bakery.icing[:description] == nil
|
94
|
+
Bakery::Log.debug "default description set: #{desc}"
|
95
|
+
else
|
96
|
+
Bakery::Log.debug "default description overwritten: #{desc}"
|
97
|
+
end
|
98
|
+
|
57
99
|
Bakery.icing[:description] = desc
|
58
100
|
end
|
59
101
|
|
60
102
|
def loadIcing filename
|
61
103
|
Bakery::ICING_SEARCH.search(filename) { |file|
|
104
|
+
Bakery::Log.info "loading icing: #{file}"
|
62
105
|
load file
|
63
106
|
}
|
64
107
|
end
|
@@ -19,8 +19,12 @@ module Bakery
|
|
19
19
|
def initialize path, *args, &block
|
20
20
|
if !Dir.exists? path
|
21
21
|
if args.include? :create_recursive
|
22
|
+
Bakery::Log.info "creating directories: #{path}"
|
23
|
+
|
22
24
|
FileUtils.mkdir_p path
|
23
25
|
else
|
26
|
+
Bakery::Log.info "creating directory: #{path}"
|
27
|
+
|
24
28
|
FileUtils.mkdir path
|
25
29
|
end
|
26
30
|
end
|
@@ -28,9 +32,13 @@ module Bakery
|
|
28
32
|
super path
|
29
33
|
|
30
34
|
Dir.chdir path do
|
35
|
+
Bakery::Log.debug "entering directory: #{path}"
|
36
|
+
|
31
37
|
dispatch &block
|
32
38
|
|
33
39
|
Bakery.removeMarkerLayerFromStack Dir.pwd
|
40
|
+
|
41
|
+
Bakery::Log.debug "leaving directory: #{path}"
|
34
42
|
end
|
35
43
|
end
|
36
44
|
end
|
@@ -40,6 +40,12 @@ module Bakery
|
|
40
40
|
already_exists = File.exist? filename
|
41
41
|
|
42
42
|
if !already_exists || args.include?(:always_overwrite)
|
43
|
+
if !already_exists
|
44
|
+
Bakery::Log.info "#{self.class} creating: #{filename}"
|
45
|
+
else
|
46
|
+
Bakery::Log.info "#{self.class} overwriting: #{filename}"
|
47
|
+
end
|
48
|
+
|
43
49
|
super filename, 'w+'
|
44
50
|
|
45
51
|
dispatch &block
|
@@ -47,13 +53,19 @@ module Bakery
|
|
47
53
|
super filename, 'a+'
|
48
54
|
|
49
55
|
if args.include?(:always_append)
|
56
|
+
Bakery::Log.info "#{self.class} appending: #{filename}"
|
57
|
+
|
50
58
|
dispatch &block
|
59
|
+
else
|
60
|
+
Bakery::Log.info "#{self.class} opening: #{filename}"
|
51
61
|
end
|
52
62
|
end
|
53
63
|
end
|
54
64
|
|
55
65
|
def from filename
|
56
66
|
ICING_SEARCH.search(filename) { |file|
|
67
|
+
Bakery::Log.info "copying '#{file}' to '#{path}'"
|
68
|
+
|
57
69
|
FileUtils.cp file, path
|
58
70
|
}
|
59
71
|
end
|
data/lib/bakery/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bakery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- lib/bakery/detail/global_function.rb
|
50
50
|
- lib/bakery/detail/search.rb
|
51
51
|
- lib/bakery/detail/dispatcher.rb
|
52
|
+
- lib/bakery/detail/log.rb
|
52
53
|
- lib/bakery/ingredient.rb
|
53
54
|
- lib/bakery/icing.rb
|
54
55
|
- lib/bakery/bakery.rb
|