malagant-raw 0.4.13 → 0.8.1
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/History.txt +2 -5
- data/Manifest.txt +1 -1
- data/{README.txt → README} +1 -0
- data/Rakefile +1 -6
- data/bin/raw +2 -2
- data/lib/ant_libraries.rb +9 -4
- data/lib/ant_project.rb +86 -50
- data/lib/ant_task.rb +50 -34
- data/lib/raw.rb +2 -2
- data/lib/raw_runner.rb +102 -29
- data/lib/raw_utilities.rb +1 -0
- data/lib/rjb_adapter.rb +1 -1
- metadata +7 -6
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/{README.txt → README}
RENAMED
data/Rakefile
CHANGED
|
@@ -20,7 +20,7 @@ def apply_default_hoe_properties(hoe)
|
|
|
20
20
|
hoe.remote_rdoc_dir = ''
|
|
21
21
|
hoe.rubyforge_name = 'raw'
|
|
22
22
|
hoe.author = 'Michael Johann'
|
|
23
|
-
hoe.email = 'malagant1969@
|
|
23
|
+
hoe.email = 'malagant1969@googlemail.com'
|
|
24
24
|
hoe.url = 'http://kenai.com/projects/raw/'
|
|
25
25
|
hoe.summary = 'A Ruby module that wraps the Apache Ant build tool.
|
|
26
26
|
RAW can be used to invoke Ant Tasks from a Ruby or a JRuby script.'
|
|
@@ -42,8 +42,3 @@ Hoe.new('raw', RAW::VERSION) do |hoe|
|
|
|
42
42
|
apply_default_hoe_properties hoe
|
|
43
43
|
hoe.spec_extras = { :platform => 'java' }
|
|
44
44
|
end
|
|
45
|
-
|
|
46
|
-
Rake::TestTask.new('test') do |t|
|
|
47
|
-
t.ruby_opts = ['-r test/load_devcreek.rb']
|
|
48
|
-
t.test_files = ['test/*test.rb']
|
|
49
|
-
end
|
data/bin/raw
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
require 'lib/raw_runner'
|
|
1
|
+
#!/usr/bin/env jruby
|
|
2
|
+
require '../lib/raw_runner'
|
|
3
3
|
|
data/lib/ant_libraries.rb
CHANGED
|
@@ -9,23 +9,28 @@
|
|
|
9
9
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
10
|
# See the License for the specific language governing permissions and limitations
|
|
11
11
|
# under the License.
|
|
12
|
+
|
|
12
13
|
require 'rjb_adapter'
|
|
13
14
|
|
|
14
15
|
module RAW
|
|
16
|
+
# Defining some Java classes for building the ant tasks etc
|
|
15
17
|
module ApacheAnt
|
|
18
|
+
# The default logger
|
|
16
19
|
DefaultLogger = RjbAdapter.import_class("org.apache.tools.ant.DefaultLogger")
|
|
20
|
+
# The main class from Apache ANT
|
|
17
21
|
Main = RjbAdapter.import_class("org.apache.tools.ant.Main")
|
|
22
|
+
# The ANT project class
|
|
18
23
|
Project = RjbAdapter.import_class("org.apache.tools.ant.Project")
|
|
24
|
+
# The ANT RuntimeConfigurable
|
|
19
25
|
RuntimeConfigurable = RjbAdapter.import_class("org.apache.tools.ant.RuntimeConfigurable")
|
|
26
|
+
# The ANT target class
|
|
20
27
|
Target = RjbAdapter.import_class("org.apache.tools.ant.Target")
|
|
28
|
+
# ANT's class for dynamically wrapping taks
|
|
21
29
|
UnknownElement = RjbAdapter.import_class("org.apache.tools.ant.UnknownElement")
|
|
22
30
|
end
|
|
23
31
|
|
|
24
32
|
module JavaLang
|
|
33
|
+
# Java's System class for access to System.out and System.err
|
|
25
34
|
System = RjbAdapter.import_class("java.lang.System")
|
|
26
35
|
end
|
|
27
|
-
|
|
28
|
-
module XmlSax
|
|
29
|
-
AttributeListImpl = RjbAdapter.import_class("org.xml.sax.helpers.AttributeListImpl")
|
|
30
|
-
end
|
|
31
36
|
end
|
data/lib/ant_project.rb
CHANGED
|
@@ -14,86 +14,122 @@ module RAW
|
|
|
14
14
|
class AntProject
|
|
15
15
|
require 'logger'
|
|
16
16
|
require 'ant_task'
|
|
17
|
-
require 'ant_libraries'
|
|
18
17
|
|
|
19
|
-
private
|
|
20
18
|
@@classes_loaded = false
|
|
21
19
|
|
|
20
|
+
# Here we go: Let's define some attributes
|
|
21
|
+
public
|
|
22
|
+
# getter and setter for the project instance,
|
|
23
|
+
# the logger, the declarative and the attribute ant_version
|
|
24
|
+
attr_accessor :project, :logger, :ant_version, :declarative
|
|
25
|
+
|
|
26
|
+
# Create an AntProject. Parameters are specified via a hash:
|
|
27
|
+
# :ant_home => <em>Ant basedir</em>
|
|
28
|
+
# -A String indicating the location of the ANT_HOME directory. If provided, RAW will
|
|
29
|
+
# load the classes from the ANT_HOME/lib dir. If ant_home is not provided, the ANT jar files
|
|
30
|
+
# must be available on the CLASSPATH.
|
|
31
|
+
# :name => <em>project_name</em>
|
|
32
|
+
# -A String indicating the name of this project.
|
|
33
|
+
# :basedir => <em>project_basedir</em>
|
|
34
|
+
# -A String indicating the basedir of this project. Corresponds to the 'basedir' attribute
|
|
35
|
+
# on an Ant project.
|
|
36
|
+
# :declarative => <em>declarative_mode</em>
|
|
37
|
+
# -A boolean value indicating wether ANT tasks created by this project instance should
|
|
38
|
+
# have their execute() method invoked during their creation. For example, with
|
|
39
|
+
# the option :declarative => <em>true</em> the following task would execute;
|
|
40
|
+
# @antProject.echo(:message => "An Echo Task")
|
|
41
|
+
# However, with the option :declarative => false, the programmer is required to execute the
|
|
42
|
+
# task explicitly;
|
|
43
|
+
# echoTask = @antProject.echo(:message => "An Echo Task")
|
|
44
|
+
# echoTask.execute()
|
|
45
|
+
# Default value is <em>true</em>.
|
|
46
|
+
# :logger => <em>Logger</em>
|
|
47
|
+
# -A Logger instance. Defaults to Logger.new(STDOUT)
|
|
48
|
+
# :loglevel => <em>The level to set the logger to</em>
|
|
49
|
+
# -Defaults to Logger::ERROR
|
|
22
50
|
# This is for further initializations inside the constructor
|
|
51
|
+
# and must be called once from the users ANT script
|
|
52
|
+
# Example usage:
|
|
53
|
+
# init_project :basedir => '/Users/mjohann/projects/jruby_raw',
|
|
54
|
+
# :name => 'JRuby',
|
|
55
|
+
# :default => 'jar',
|
|
56
|
+
# :anthome => ANT_HOME
|
|
23
57
|
def init_project(options)
|
|
24
|
-
|
|
58
|
+
# The ANT version used
|
|
59
|
+
logger.info RAW::ApacheAnt::Main.ant_version
|
|
60
|
+
@ant_version = RAW::ApacheAnt::Main.ant_version[/\d\.\d\.\d/].to_f
|
|
61
|
+
# instance of ANT project
|
|
25
62
|
@project = RAW::ApacheAnt::Project.new
|
|
63
|
+
# The default project name taken from the options hash or left blank
|
|
26
64
|
@project.name = options[:name] || ''
|
|
65
|
+
# The default ANT target taken from the options hash or left blank
|
|
27
66
|
@project.default = ''
|
|
67
|
+
# The project's base directory taken from the options hash or the current working directory
|
|
28
68
|
@project.basedir = options[:basedir] || FileUtils::pwd
|
|
69
|
+
# intializing the ANT project
|
|
29
70
|
@project.init
|
|
30
71
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
72
|
+
# Sets the task definitions to be declared only or they get executed directly
|
|
73
|
+
# Default is true
|
|
74
|
+
unless options[:declarative]
|
|
75
|
+
logger.debug("declarative is nil")
|
|
76
|
+
self.declarative = true
|
|
34
77
|
else
|
|
35
|
-
|
|
36
|
-
self.declarative= options[:declarative]
|
|
78
|
+
logger.debug("declarative is #{options[:declarative]}")
|
|
79
|
+
self.declarative = options[:declarative]
|
|
37
80
|
end
|
|
38
81
|
|
|
82
|
+
# Here we setup the default logger instance
|
|
39
83
|
default_logger = ApacheAnt::DefaultLogger.new
|
|
40
|
-
default_logger.message_output_level =
|
|
84
|
+
default_logger.message_output_level = Logger::INFO
|
|
85
|
+
# Output is either Standard out or the stream in options hash
|
|
41
86
|
default_logger.output_print_stream = options[:outputstr] || JavaLang::System.out
|
|
42
87
|
default_logger.error_print_stream = options[:errorstr] || JavaLang::System.err
|
|
88
|
+
# Output will be like in log4j.properties configured
|
|
43
89
|
default_logger.emacs_mode = false
|
|
44
|
-
|
|
90
|
+
# Set the default logger as the build listener
|
|
45
91
|
@project.add_build_listener(default_logger)
|
|
46
92
|
end
|
|
47
93
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
94
|
+
# Constructor will be called internally and consumes
|
|
95
|
+
# the options hash which can contain infos about a logger
|
|
96
|
+
def initialize(options)
|
|
97
|
+
@logger = options[:logger] || Logger.new(STDOUT)
|
|
98
|
+
logger.level = options[:loglevel] || Logger::INFO
|
|
52
99
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
# -A String indicating the location of the ANT_HOME directory. If provided, RAW will
|
|
56
|
-
# load the classes from the ANT_HOME/lib dir. If ant_home is not provided, the Ant jar files
|
|
57
|
-
# must be available in the CLASSPATH.
|
|
58
|
-
# :name=><em>project_name</em>
|
|
59
|
-
# -A String indicating the name of this project.
|
|
60
|
-
# :basedir=><em>project_basedir</em>
|
|
61
|
-
# -A String indicating the basedir of this project. Corresponds to the 'basedir' attribute
|
|
62
|
-
# on an Ant project.
|
|
63
|
-
# :declarative=><em>declarative_mode</em>
|
|
64
|
-
# -A boolean value indicating wether Ant tasks created by this project instance should
|
|
65
|
-
# have their execute() method invoked during their creation. For example, with
|
|
66
|
-
# the option :declarative=>true the following task would execute;
|
|
67
|
-
# @antProject.echo(:message => "An Echo Task")
|
|
68
|
-
# However, with the option :declarative=>false, the programmer is required to execute the
|
|
69
|
-
# task explicitly;
|
|
70
|
-
# echoTask = @antProject.echo(:message => "An Echo Task")
|
|
71
|
-
# echoTask.execute()
|
|
72
|
-
# Default value is <em>true</em>.
|
|
73
|
-
# :logger=><em>Logger</em>
|
|
74
|
-
# -A Logger instance. Defaults to Logger.new(STDOUT)
|
|
75
|
-
# :loglevel=><em>The level to set the logger to</em>
|
|
76
|
-
# -Defaults to Logger::ERROR
|
|
77
|
-
def initialize(options = Hash.new)
|
|
100
|
+
@task_stack = Array.new
|
|
101
|
+
end
|
|
78
102
|
|
|
79
|
-
|
|
80
|
-
|
|
103
|
+
def property_value(name)
|
|
104
|
+
project.get_property(name)
|
|
105
|
+
end
|
|
81
106
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
107
|
+
def build_instance_variable(prop)
|
|
108
|
+
begin
|
|
109
|
+
instance_variable = "@#{instvar(prop[0])} = '#{prop[1]}'"
|
|
110
|
+
self.instance_eval instance_variable
|
|
111
|
+
logger.debug instance_variable
|
|
112
|
+
rescue SyntaxError => e
|
|
113
|
+
logger.error "Problem with #{instance_variable}. Cannot create valid instance variable."
|
|
114
|
+
raise e
|
|
87
115
|
end
|
|
116
|
+
end
|
|
88
117
|
|
|
89
|
-
|
|
118
|
+
def build_properties
|
|
119
|
+
project.properties.each do |prop|
|
|
120
|
+
build_instance_variable(prop)
|
|
121
|
+
end
|
|
122
|
+
logger.debug instance_variables
|
|
123
|
+
# TODO: Hack
|
|
90
124
|
@ant_version = RAW::ApacheAnt::Main.ant_version[/\d\.\d\.\d/].to_f
|
|
125
|
+
end
|
|
91
126
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
127
|
+
def instvar(name)
|
|
128
|
+
name = name.gsub('.', '_')
|
|
129
|
+
name.gsub('-', '_')
|
|
95
130
|
end
|
|
96
131
|
|
|
132
|
+
|
|
97
133
|
def method_missing(sym, *args)
|
|
98
134
|
begin
|
|
99
135
|
task = AntTask.new(sym.to_s, self, args[0])
|
data/lib/ant_task.rb
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
module RAW
|
|
14
14
|
class AntTask
|
|
15
15
|
attr_accessor :unknown_element, :project, :taskname, :logger, :executed
|
|
16
|
-
|
|
17
|
-
public
|
|
16
|
+
|
|
17
|
+
public
|
|
18
18
|
# Creates an AntTask
|
|
19
19
|
# taskname
|
|
20
20
|
# -A String representing the name of an Ant Task. This name should correspond to
|
|
@@ -28,8 +28,8 @@ module RAW
|
|
|
28
28
|
# antProject = AntProject.new()
|
|
29
29
|
# antTask = AntTask.new('javac', antProject, {:debug => 'on', :verbose => 'no', :fork => 'no'})
|
|
30
30
|
def initialize(taskname, antProject, attributes)
|
|
31
|
-
|
|
32
|
-
taskname = taskname[1, taskname.length-1] if taskname[0,1] == "_"
|
|
31
|
+
|
|
32
|
+
taskname = taskname[1, taskname.length-1] if taskname[0, 1] == "_"
|
|
33
33
|
@logger = antProject.logger
|
|
34
34
|
@taskname = taskname
|
|
35
35
|
@project_wrapper = antProject
|
|
@@ -37,66 +37,66 @@ module RAW
|
|
|
37
37
|
@logger.debug(antProject.to_s)
|
|
38
38
|
@unknown_element = create_unknown_element(@project, taskname)
|
|
39
39
|
@logger.debug(to_s)
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
add_attributes(attributes)
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
end
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
# Displays the Class name followed by the Task name
|
|
46
46
|
# -e.g. AntTask[javac]
|
|
47
47
|
def to_s
|
|
48
48
|
return self.class.name + "[#{@taskname}]"
|
|
49
|
-
end
|
|
50
|
-
|
|
49
|
+
end
|
|
50
|
+
|
|
51
51
|
def create_unknown_element(project, taskname)
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
element = ApacheAnt::UnknownElement.new(taskname)
|
|
54
54
|
element.project = project
|
|
55
55
|
element.owning_target = ApacheAnt::Target.new
|
|
56
56
|
element.task_name = taskname
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
#DNR. This initializes the Task's Wrapper object and prevents NullPointerExeption upon execution of the task
|
|
59
59
|
element.runtime_configurable_wrapper
|
|
60
|
-
|
|
61
|
-
if(@project_wrapper.ant_version >= 1.6)
|
|
60
|
+
|
|
61
|
+
if (@project_wrapper.ant_version >= 1.6)
|
|
62
62
|
element.task_type = taskname
|
|
63
63
|
element.namespace = ''
|
|
64
64
|
element.qname = taskname
|
|
65
65
|
end
|
|
66
|
-
|
|
66
|
+
|
|
67
67
|
return element
|
|
68
|
-
|
|
68
|
+
|
|
69
69
|
end
|
|
70
|
-
|
|
70
|
+
|
|
71
71
|
# Sets each attribute on the AntTask instance.
|
|
72
72
|
# :attributes - is a Hash.
|
|
73
73
|
def add_attributes(attributes)
|
|
74
|
-
|
|
74
|
+
|
|
75
75
|
return if attributes == nil
|
|
76
|
-
|
|
76
|
+
|
|
77
77
|
wrapper = ApacheAnt::RuntimeConfigurable.new(@unknown_element, @unknown_element.task_name)
|
|
78
|
-
|
|
79
|
-
if(@project_wrapper.ant_version >= 1.6)
|
|
80
|
-
attributes.each do |key, val|
|
|
81
|
-
apply_to_wrapper(wrapper, key.to_s, val){ |k,v| wrapper.set_attribute(k, v)}
|
|
78
|
+
|
|
79
|
+
if (@project_wrapper.ant_version >= 1.6)
|
|
80
|
+
attributes.each do |key, val|
|
|
81
|
+
apply_to_wrapper(wrapper, key.to_s, val){ |k, v| wrapper.set_attribute(k, v)}
|
|
82
82
|
end
|
|
83
|
-
else
|
|
83
|
+
else
|
|
84
84
|
@unknown_element.runtime_configurable_wrapper = wrapper
|
|
85
85
|
attribute_list = XmlSax::AttributeListImpl.new()
|
|
86
|
-
attributes.each do |key, val|
|
|
87
|
-
apply_to_wrapper(wrapper, key.to_s, val){ |k,v| attribute_list.add_attribute(k, 'CDATA', v)}
|
|
86
|
+
attributes.each do |key, val|
|
|
87
|
+
apply_to_wrapper(wrapper, key.to_s, val){ |k, v| attribute_list.add_attribute(k, 'CDATA', v)}
|
|
88
88
|
end
|
|
89
89
|
wrapper.set_attributes(attribute_list)
|
|
90
90
|
end
|
|
91
|
-
|
|
91
|
+
|
|
92
92
|
end
|
|
93
|
-
|
|
93
|
+
|
|
94
94
|
def apply_to_wrapper(wrapper, key, value)
|
|
95
|
-
|
|
95
|
+
|
|
96
96
|
raise ArgumentError, "ArgumentError: You cannot use an Array as an argument. Use the :join method instead; i.e ['file1', 'file2'].join(File::PATH_SEPARATOR)." if value.is_a?(Array)
|
|
97
|
-
|
|
97
|
+
|
|
98
98
|
begin
|
|
99
|
-
if(key == 'pcdata')
|
|
99
|
+
if (key == 'pcdata')
|
|
100
100
|
wrapper.add_text(value.to_s)
|
|
101
101
|
else
|
|
102
102
|
yield key, value.to_s
|
|
@@ -104,22 +104,38 @@ module RAW
|
|
|
104
104
|
rescue StandardError
|
|
105
105
|
raise ArgumentError, "ArgumentError: Unable to set :#{key} attribute with value => '#{value}'"
|
|
106
106
|
end
|
|
107
|
-
|
|
107
|
+
|
|
108
108
|
end
|
|
109
|
-
|
|
109
|
+
|
|
110
110
|
# Add <em>child</em> as a child of this task.
|
|
111
111
|
def add(child)
|
|
112
112
|
@unknown_element.add_child(child.unknown_element())
|
|
113
113
|
@unknown_element.runtime_configurable_wrapper.add_child(child.unknown_element().runtime_configurable_wrapper)
|
|
114
114
|
end
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
# Invokes the AntTask.
|
|
117
117
|
def execute
|
|
118
118
|
@unknown_element.maybe_configure
|
|
119
119
|
@unknown_element.execute
|
|
120
|
+
build_instance_variable(@unknown_element.wrapper)
|
|
120
121
|
@executed = true
|
|
121
122
|
return nil
|
|
122
123
|
end
|
|
123
|
-
|
|
124
|
+
|
|
125
|
+
private
|
|
126
|
+
|
|
127
|
+
def build_instance_variable(wrapper)
|
|
128
|
+
variable = wrapper.attributeMap.get('property')
|
|
129
|
+
|
|
130
|
+
if variable
|
|
131
|
+
logger.debug "creating variable = @#{variable} with value #{@project_wrapper.property_value(variable.to_s)}"
|
|
132
|
+
unless @project_wrapper.instance_variable_defined? "@#{variable.to_s}".to_sym
|
|
133
|
+
instance_eval <<-END
|
|
134
|
+
@project_wrapper.instance_variable_set(:@#{@project_wrapper.instvar(variable)}, @project_wrapper.property_value(variable.to_s))
|
|
135
|
+
END
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
124
140
|
end
|
|
125
141
|
end
|
data/lib/raw.rb
CHANGED
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
10
|
# See the License for the specific language governing permissions and limitations
|
|
11
11
|
# under the License.
|
|
12
|
+
|
|
13
|
+
require 'rubygems'
|
|
12
14
|
require 'raw_utilities'
|
|
13
15
|
require 'ant_project'
|
|
14
|
-
require 'ant_task'
|
|
15
|
-
require 'raw_runner'
|
|
16
16
|
require 'fileutils'
|
|
17
17
|
|
|
18
18
|
module RAW
|
data/lib/raw_runner.rb
CHANGED
|
@@ -1,19 +1,29 @@
|
|
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
2
|
+
# you may not use this file except in compliance with the License.
|
|
3
|
+
# You may obtain a copy of the License at
|
|
4
|
+
#
|
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
#
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and limitations
|
|
11
|
+
# under the License.
|
|
12
|
+
|
|
1
13
|
$LOAD_PATH.push(File.dirname(__FILE__) + '/../lib')
|
|
2
14
|
|
|
3
15
|
require 'open-uri'
|
|
4
16
|
require 'fileutils'
|
|
17
|
+
require 'optparse'
|
|
5
18
|
require 'raw'
|
|
6
19
|
|
|
7
20
|
module RAW
|
|
8
21
|
class RawRunner < RAW::AntProject
|
|
9
|
-
attr_reader :root
|
|
10
|
-
attr_writer :logger
|
|
22
|
+
attr_reader :root, :targets
|
|
11
23
|
|
|
12
24
|
def initialize(template, root = '', options = {})
|
|
13
25
|
super(options)
|
|
14
26
|
@targets = Hash.new
|
|
15
|
-
logger = options[:logger] || Logger.new(STDOUT)
|
|
16
|
-
@logger.level = options[:loglevel] || Logger::INFO
|
|
17
27
|
@root = File.expand_path(File.directory?(root) ? root : File.join(Dir.pwd, root))
|
|
18
28
|
|
|
19
29
|
if template
|
|
@@ -45,31 +55,20 @@ module RAW
|
|
|
45
55
|
end
|
|
46
56
|
end
|
|
47
57
|
|
|
48
|
-
def
|
|
49
|
-
|
|
50
|
-
|
|
58
|
+
def condition(options)
|
|
59
|
+
property = options[:property]
|
|
60
|
+
environment = options[:value]
|
|
51
61
|
|
|
52
|
-
def build_instance_variable(prop)
|
|
53
|
-
instance_variable = "@#{instvar(prop[0])} = '#{prop[1]}'"
|
|
54
|
-
self.instance_eval instance_variable
|
|
55
|
-
logger.debug instance_variable
|
|
56
|
-
end
|
|
57
62
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
if name
|
|
64
|
+
build_instance_variable([name, options[:location] || options[:value]])
|
|
65
|
+
elsif file || environment
|
|
66
|
+
build_properties
|
|
67
|
+
else
|
|
68
|
+
logger.debug options.inspect
|
|
69
|
+
raise "No name or file attribute given for property!"
|
|
61
70
|
end
|
|
62
|
-
|
|
63
|
-
# TODO: Hack
|
|
64
|
-
@ant_version = RAW::ApacheAnt::Main.ant_version[/\d\.\d\.\d/].to_f
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def instvar(name)
|
|
68
|
-
name.gsub('.', '_')
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def self.parse!(args=ARGV)
|
|
72
|
-
RawRunner.new(args[0], args[1], args[2])
|
|
71
|
+
method_missing(:property, options)
|
|
73
72
|
end
|
|
74
73
|
|
|
75
74
|
|
|
@@ -84,14 +83,88 @@ module RAW
|
|
|
84
83
|
end
|
|
85
84
|
|
|
86
85
|
def target(name, depends = [], &block)
|
|
87
|
-
|
|
86
|
+
targets[name] = block
|
|
88
87
|
end
|
|
89
88
|
|
|
90
89
|
def build(task)
|
|
91
|
-
block =
|
|
90
|
+
block = targets[task]
|
|
92
91
|
block.call
|
|
93
92
|
end
|
|
94
93
|
end
|
|
94
|
+
|
|
95
|
+
# Handles the startup of RAW with parsing options etc.
|
|
96
|
+
class RawTool
|
|
97
|
+
def parse!(args)
|
|
98
|
+
if args.length == 0
|
|
99
|
+
puts options
|
|
100
|
+
elsif args.length == 1 && args[0] == ('-h' || '--help')
|
|
101
|
+
options.parse!(args)
|
|
102
|
+
else
|
|
103
|
+
general, sub = split_args(args)
|
|
104
|
+
options.parse!(args)
|
|
105
|
+
|
|
106
|
+
if general.empty?
|
|
107
|
+
puts options
|
|
108
|
+
else
|
|
109
|
+
@root_dir = '.' if @root_dir.nil?
|
|
110
|
+
RawRunner.new(general[0], @root_dir, {:loglevel => @loglevel})
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def split_args(args)
|
|
116
|
+
left = []
|
|
117
|
+
while args[0] and args[0] =~ /^-/ do
|
|
118
|
+
left << args.shift
|
|
119
|
+
end
|
|
120
|
+
left << args.shift if args[0]
|
|
121
|
+
return [left, args]
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def self.parse!(args = ARGV)
|
|
125
|
+
RawTool.new.parse!(args)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def loglevel(level)
|
|
129
|
+
case level
|
|
130
|
+
when 'debug'
|
|
131
|
+
Logger::DEBUG
|
|
132
|
+
when 'info'
|
|
133
|
+
Logger::INFO
|
|
134
|
+
when 'warn'
|
|
135
|
+
Logger::WARN
|
|
136
|
+
when 'error'
|
|
137
|
+
Logger::ERROR
|
|
138
|
+
when 'fatal'
|
|
139
|
+
Logger::FATAL
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Options and how they are used
|
|
144
|
+
def options
|
|
145
|
+
OptionParser.new do |o|
|
|
146
|
+
o.set_summary_indent(' ')
|
|
147
|
+
o.banner = "Usage: raw raw-script-url [OPTIONS]"
|
|
148
|
+
o.define_head "Ruby ANT Wrapper (RAW)."
|
|
149
|
+
|
|
150
|
+
o.separator ""
|
|
151
|
+
o.separator "GENERAL OPTIONS"
|
|
152
|
+
|
|
153
|
+
o.on("-v", "--verbose", "Turn on verbose ant output.") { |verbose| $verbose = verbose }
|
|
154
|
+
o.on("-h", "--help", "Show this help message.") { puts o; exit }
|
|
155
|
+
o.on("-r", "--root directory", "Set the root path of the script. Defaults to '.'") { |root| $root_dir = root}
|
|
156
|
+
o.on("-l", "--loglevel level", "Set the log level. Default is info. Possible values are: error, warn, info, debug") { |level| @loglevel = loglevel(level)}
|
|
157
|
+
o.separator ""
|
|
158
|
+
o.separator "EXAMPLES"
|
|
159
|
+
o.separator " run example script:"
|
|
160
|
+
o.separator " raw scripts/ant.rb -r ../.. -v \n"
|
|
161
|
+
o.separator " Run a raw-script from a pastie URL:"
|
|
162
|
+
o.separator " raw http://www.pastie.org/508302 -r ../.. -v -l debug \n"
|
|
163
|
+
o.separator " Run a script without parameters:"
|
|
164
|
+
o.separator " raw ant.rb\n"
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|
|
95
168
|
end
|
|
96
169
|
|
|
97
|
-
RAW::
|
|
170
|
+
RAW::RawTool.parse!
|
data/lib/raw_utilities.rb
CHANGED
data/lib/rjb_adapter.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: malagant-raw
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael Johann
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-
|
|
12
|
+
date: 2009-08-10 00:00:00 -07:00
|
|
13
13
|
default_executable: raw
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
@@ -31,12 +31,12 @@ extensions: []
|
|
|
31
31
|
extra_rdoc_files:
|
|
32
32
|
- History.txt
|
|
33
33
|
- Manifest.txt
|
|
34
|
-
- README
|
|
34
|
+
- README
|
|
35
35
|
- LICENSE
|
|
36
36
|
files:
|
|
37
37
|
- History.txt
|
|
38
38
|
- Manifest.txt
|
|
39
|
-
- README
|
|
39
|
+
- README
|
|
40
40
|
- LICENSE
|
|
41
41
|
- Rakefile
|
|
42
42
|
- bin/raw
|
|
@@ -52,10 +52,11 @@ files:
|
|
|
52
52
|
- spec/spec_helper.rb
|
|
53
53
|
has_rdoc: true
|
|
54
54
|
homepage: http://kenai.com/projects/raw
|
|
55
|
+
licenses:
|
|
55
56
|
post_install_message:
|
|
56
57
|
rdoc_options:
|
|
57
58
|
- --main
|
|
58
|
-
- README
|
|
59
|
+
- README
|
|
59
60
|
require_paths:
|
|
60
61
|
- lib
|
|
61
62
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
@@ -73,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
73
74
|
requirements: []
|
|
74
75
|
|
|
75
76
|
rubyforge_project:
|
|
76
|
-
rubygems_version: 1.
|
|
77
|
+
rubygems_version: 1.3.5
|
|
77
78
|
signing_key:
|
|
78
79
|
specification_version: 2
|
|
79
80
|
summary: RAW is a Ruby ANT Wrapper for describing Apache ANT tasks in ruby instead of XML.
|