malagant-raw 0.8.1 → 0.8.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/lib/ant_project.rb +3 -1
- data/lib/raw_runner.rb +19 -9
- metadata +1 -1
data/lib/ant_project.rb
CHANGED
|
@@ -21,7 +21,7 @@ module RAW
|
|
|
21
21
|
public
|
|
22
22
|
# getter and setter for the project instance,
|
|
23
23
|
# the logger, the declarative and the attribute ant_version
|
|
24
|
-
attr_accessor :project, :logger, :ant_version, :declarative
|
|
24
|
+
attr_accessor :project, :logger, :ant_version, :declarative, :default_target
|
|
25
25
|
|
|
26
26
|
# Create an AntProject. Parameters are specified via a hash:
|
|
27
27
|
# :ant_home => <em>Ant basedir</em>
|
|
@@ -67,6 +67,8 @@ module RAW
|
|
|
67
67
|
# The project's base directory taken from the options hash or the current working directory
|
|
68
68
|
@project.basedir = options[:basedir] || FileUtils::pwd
|
|
69
69
|
# intializing the ANT project
|
|
70
|
+
@default_target = options[:default] if options[:default]
|
|
71
|
+
logger.debug "Default == #{options[:default]}"
|
|
70
72
|
@project.init
|
|
71
73
|
|
|
72
74
|
# Sets the task definitions to be declared only or they get executed directly
|
data/lib/raw_runner.rb
CHANGED
|
@@ -27,13 +27,21 @@ module RAW
|
|
|
27
27
|
@root = File.expand_path(File.directory?(root) ? root : File.join(Dir.pwd, root))
|
|
28
28
|
|
|
29
29
|
if template
|
|
30
|
-
logger.info("
|
|
30
|
+
logger.info("Applying script #{template}")
|
|
31
31
|
|
|
32
32
|
load_script(template)
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
# Execute the given target
|
|
35
|
+
if options[:target]
|
|
36
|
+
build options[:target]
|
|
37
|
+
# or find the default and call that
|
|
38
|
+
elsif @default_target
|
|
39
|
+
build @default_target.to_sym
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
logger.info"Applied script #{template}"
|
|
35
43
|
else
|
|
36
|
-
logger.info"
|
|
44
|
+
logger.info"No script #{template} applied."
|
|
37
45
|
end
|
|
38
46
|
end
|
|
39
47
|
|
|
@@ -88,6 +96,7 @@ module RAW
|
|
|
88
96
|
|
|
89
97
|
def build(task)
|
|
90
98
|
block = targets[task]
|
|
99
|
+
raise "No target named #{task} found." unless block
|
|
91
100
|
block.call
|
|
92
101
|
end
|
|
93
102
|
end
|
|
@@ -107,7 +116,7 @@ module RAW
|
|
|
107
116
|
puts options
|
|
108
117
|
else
|
|
109
118
|
@root_dir = '.' if @root_dir.nil?
|
|
110
|
-
RawRunner.new(general[0], @root_dir, {:loglevel => @loglevel})
|
|
119
|
+
RawRunner.new(general[0], @root_dir, {:loglevel => @loglevel, :target => @target})
|
|
111
120
|
end
|
|
112
121
|
end
|
|
113
122
|
end
|
|
@@ -128,15 +137,15 @@ module RAW
|
|
|
128
137
|
def loglevel(level)
|
|
129
138
|
case level
|
|
130
139
|
when 'debug'
|
|
131
|
-
|
|
140
|
+
Logger::DEBUG
|
|
132
141
|
when 'info'
|
|
133
|
-
|
|
142
|
+
Logger::INFO
|
|
134
143
|
when 'warn'
|
|
135
|
-
|
|
144
|
+
Logger::WARN
|
|
136
145
|
when 'error'
|
|
137
|
-
|
|
146
|
+
Logger::ERROR
|
|
138
147
|
when 'fatal'
|
|
139
|
-
|
|
148
|
+
Logger::FATAL
|
|
140
149
|
end
|
|
141
150
|
end
|
|
142
151
|
|
|
@@ -154,6 +163,7 @@ module RAW
|
|
|
154
163
|
o.on("-h", "--help", "Show this help message.") { puts o; exit }
|
|
155
164
|
o.on("-r", "--root directory", "Set the root path of the script. Defaults to '.'") { |root| $root_dir = root}
|
|
156
165
|
o.on("-l", "--loglevel level", "Set the log level. Default is info. Possible values are: error, warn, info, debug") { |level| @loglevel = loglevel(level)}
|
|
166
|
+
o.on("-t", "--target target", "Target to execute with ANT") { |target| @target = target.to_sym}
|
|
157
167
|
o.separator ""
|
|
158
168
|
o.separator "EXAMPLES"
|
|
159
169
|
o.separator " run example script:"
|