ivy4r 0.11.0 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === 0.11.1 / 2010-06-09
2
+ * Fixed a bug reported by Rhett Sutphin that prevented the use of MRI.
3
+ * Added mapping from java to ruby via RJB and source example from
4
+ Stanford Parser Ruby Wrapper by William Patrick McNeill.
5
+
1
6
  === 0.11.0 / 2010-05-31
2
7
  * Fixed a few bugs and issues reported by Rhett Sutphin. See issues on github 3-6.
3
8
  * Ivy4r should work with MRI and JRuby, previously only JRuby was supported.
data/Manifest.txt CHANGED
@@ -1,39 +1,40 @@
1
- History.txt
2
- Manifest.txt
3
- README.txt
4
- Rakefile
5
- bin/ivy4r
6
- lib/buildr/ivy_extension.rb
7
- lib/ivy/artifactproperty.rb
8
- lib/ivy/artifactreport.rb
9
- lib/ivy/buildlist.rb
10
- lib/ivy/buildnumber.rb
11
- lib/ivy/cachepath.rb
12
- lib/ivy/cleancache.rb
13
- lib/ivy/configure.rb
14
- lib/ivy/findrevision.rb
15
- lib/ivy/info.rb
16
- lib/ivy/java/all_version_matcher.rb
17
- lib/ivy/listmodules.rb
18
- lib/ivy/makepom.rb
19
- lib/ivy/publish.rb
20
- lib/ivy/report.rb
21
- lib/ivy/resolve.rb
22
- lib/ivy/retrieve.rb
23
- lib/ivy/settings.rb
24
- lib/ivy/target.rb
25
- lib/ivy/targets.rb
26
- lib/ivy4r.rb
27
- lib/ivy4r_java_extensions.rb
28
- lib/rake/ivy_extension.rb
29
- test/buildlist/p1/buildfile
30
- test/buildlist/p1/ivy.xml
31
- test/buildlist/sub/p2/buildfile
32
- test/buildlist/sub/p2/ivy.xml
33
- test/buildlist/sub/p3/buildfile
34
- test/buildlist/sub/p3/ivy.xml
35
- test/ivy/ivysettings.xml
36
- test/ivy/ivytest.xml
37
- test/ivy/test_target.rb
38
- test/ivy/test_targets.rb
39
- test/test_ivy4r.rb
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ bin/ivy4r
6
+ lib/buildr/ivy_extension.rb
7
+ lib/ivy/artifactproperty.rb
8
+ lib/ivy/artifactreport.rb
9
+ lib/ivy/buildlist.rb
10
+ lib/ivy/buildnumber.rb
11
+ lib/ivy/cachepath.rb
12
+ lib/ivy/cleancache.rb
13
+ lib/ivy/configure.rb
14
+ lib/ivy/findrevision.rb
15
+ lib/ivy/info.rb
16
+ lib/ivy/java/all_version_matcher.rb
17
+ lib/ivy/java/java_object_wrapper.rb
18
+ lib/ivy/listmodules.rb
19
+ lib/ivy/makepom.rb
20
+ lib/ivy/publish.rb
21
+ lib/ivy/report.rb
22
+ lib/ivy/resolve.rb
23
+ lib/ivy/retrieve.rb
24
+ lib/ivy/settings.rb
25
+ lib/ivy/target.rb
26
+ lib/ivy/targets.rb
27
+ lib/ivy4r.rb
28
+ lib/ivy4r_java_extensions.rb
29
+ lib/rake/ivy_extension.rb
30
+ test/buildlist/p1/buildfile
31
+ test/buildlist/p1/ivy.xml
32
+ test/buildlist/sub/p2/buildfile
33
+ test/buildlist/sub/p2/ivy.xml
34
+ test/buildlist/sub/p3/buildfile
35
+ test/buildlist/sub/p3/ivy.xml
36
+ test/ivy/ivysettings.xml
37
+ test/ivy/ivytest.xml
38
+ test/ivy/test_target.rb
39
+ test/ivy/test_targets.rb
40
+ test/test_ivy4r.rb
@@ -158,7 +158,7 @@ module Buildr
158
158
  @base_ivy.__resolve__
159
159
  else
160
160
  unless @resolved
161
- @resolved = ivy4r.resolve :file => file
161
+ @resolved = ivy4r.resolve :file => file
162
162
  @project.send(:info, "Calling '#{post_resolve_tasks.size}' post_resolve tasks for '#{@project.name}'")
163
163
  post_resolve_tasks.each { |p| p.call(self) }
164
164
  end
@@ -217,7 +217,7 @@ module Buildr
217
217
 
218
218
  # The basic file name to use in project dir as ivy.xml file. Normally this should be __ivy.xml__
219
219
  # If the file resides in a sub directory the relative path from project can be set with this method
220
- def ivy_xml_filename
220
+ def ivy_xml_filename
221
221
  @ivy_file ||= Ivy.setting('ivy.file') || 'ivy.xml'
222
222
  end
223
223
 
@@ -0,0 +1,160 @@
1
+ # Extenions to the {Ruby-Java Bridge}[http://rjb.rubyforge.org/] module that
2
+ # add a generic Java object wrapper class for transparent access of java objects
3
+ # from ruby using RJB.
4
+ #
5
+ # This file was part of the Stanford Parser Ruby Wrapper by William Patrick McNeill.
6
+ # Only a few modifications have been done to make it compatible with ivy4r and the
7
+ # Java Ant objects that are accessed.
8
+ module Rjb
9
+ class JavaObjectWrapper
10
+ include Enumerable
11
+
12
+ # The underlying Java object.
13
+ attr_reader :java_object
14
+
15
+ # Initialize with a Java object <em>obj</em>. If <em>obj</em> is a
16
+ # String, treat it as a Java class name and instantiate it. Otherwise,
17
+ # treat <em>obj</em> as an instance of a Java object.
18
+ def initialize(obj, *args)
19
+ @java_object = obj.class == String ? Rjb::import(obj).send(:new, *args) : obj
20
+ end
21
+
22
+ # Enumerate all the items in the object using its iterator. If the object
23
+ # has no iterator, this function yields nothing.
24
+ def each
25
+ if @java_object.getClass.getMethods.any? {|m| m.getName == "iterator"}
26
+ i = @java_object.iterator
27
+ while i.hasNext
28
+ yield wrap_java_object(i.next)
29
+ end
30
+ end
31
+ end # each
32
+
33
+ # Reflect unhandled method calls to the underlying Java object and wrap
34
+ # the return value in the appropriate Ruby object.
35
+ def method_missing(m, *args)
36
+ begin
37
+ JavaObjectWrapper.wrap_java_object(@java_object.send(m, *args))
38
+ rescue RuntimeError => e
39
+ # The instance method failed. See if this is a static method.
40
+ if not e.message.match(/^Fail: unknown method name/).nil?
41
+ getClass.send(m, *args)
42
+ end
43
+ end
44
+ end
45
+
46
+ # Checks if underlying java object responds to method prior using standard respond_to? method.
47
+ def respond_to?(sym)
48
+ java = @java_object.getClass.getMethods.any? {|m| m.getName == sym.to_s} || super.respond_to?(sym)
49
+ end
50
+
51
+ # Show the classname of the underlying Java object.
52
+ def inspect
53
+ "<#{@java_object._classname}>"
54
+ end
55
+
56
+ # Use the underlying Java object's stringification.
57
+ def to_s
58
+ toString
59
+ end
60
+
61
+ # All wrapping is done at class level and not at instance level this deviates from the base
62
+ # implementation
63
+ class << self
64
+ # Convert a value returned by a call to the underlying Java object to the
65
+ # appropriate Ruby object.
66
+ #
67
+ # If the value is a JavaObjectWrapper, convert it using a protected
68
+ # function with the name wrap_ followed by the underlying object's
69
+ # classname with the Java path delimiters converted to underscores. For
70
+ # example, a <tt>java.util.ArrayList</tt> would be converted by a function
71
+ # called wrap_java_util_ArrayList.
72
+ #
73
+ # If the value lacks the appropriate converter function, wrap it in a
74
+ # generic JavaObjectWrapper.
75
+ #
76
+ # If the value is not a JavaObjectWrapper, return it unchanged.
77
+ #
78
+ # This function is called recursively for every element in an Array.
79
+ def wrap_java_object(object)
80
+ if object.kind_of?(Array)
81
+ object.collect {|item| wrap_java_object(item)}
82
+ elsif object.respond_to?(:_classname)
83
+ # Ruby-Java Bridge Java objects all have a _classname member
84
+ find_converter(object) || JavaObjectWrapper.new(object)
85
+ else
86
+ object
87
+ end
88
+ end
89
+
90
+ protected
91
+ # Checks if any class in objects class hierachy or interface of class has a converter method defined
92
+ # if converter exists returns converted object.
93
+ def find_converter(object)
94
+ classnames_to_check(object).each do |name|
95
+ wrapper = wrapper_name(name)
96
+ if respond_to? wrapper
97
+ return send(wrapper, object)
98
+ end
99
+ end
100
+
101
+ nil
102
+ end
103
+
104
+ # Returns all java classnames that should be checked for an adequate mapper for given object.
105
+ def classnames_to_check(object)
106
+ names = []
107
+ clazz = object.getClass
108
+ while clazz
109
+ names << clazz.getName
110
+ clazz.getInterfaces.each {|i| names << i.getName}
111
+ clazz = clazz.getSuperclass
112
+ end
113
+
114
+ names.uniq
115
+ end
116
+
117
+ # Returns the wrapper name for given java classname.
118
+ def wrapper_name(java_classname)
119
+ ("convert_" + java_classname.gsub(/\./, "_")).downcase.to_sym
120
+ end
121
+
122
+ # Convert <tt>java.util.List</tt> objects to Ruby Array objects.
123
+ def convert_java_util_list(object)
124
+ array_list = []
125
+ object.size.times do
126
+ |i| array_list << wrap_java_object(object.get(i))
127
+ end
128
+ array_list
129
+ end
130
+
131
+ # Convert <tt>java.util.Set</tt> objects to Ruby array object with no duplicates.
132
+ def convert_java_util_set(object)
133
+ set = []
134
+ i = object.iterator
135
+ while i.hasNext
136
+ set << wrap_java_object(i.next)
137
+ end
138
+ set.uniq
139
+ end
140
+
141
+ # Convert <tt>java.util.Map</tt> objects to Ruby Hash object.
142
+ def convert_java_util_map(object)
143
+ hash = {}
144
+ i = object.entrySet.iterator
145
+ while i.hasNext
146
+ entry = i.next
147
+ hash[wrap_java_object(entry.getKey)] = wrap_java_object(entry.getValue)
148
+ end
149
+ hash
150
+ end
151
+
152
+ # Convert <tt>java.lang.String</tt> objects to Ruby String.
153
+ def convert_java_lang_string(object)
154
+ object.toString
155
+ end
156
+
157
+ end
158
+ end
159
+
160
+ end
data/lib/ivy/target.rb CHANGED
@@ -5,6 +5,8 @@ require 'facets/hash/update_values'
5
5
 
6
6
  require 'digest/md5'
7
7
 
8
+ require 'ivy/java/java_object_wrapper'
9
+
8
10
  module Ivy
9
11
 
10
12
  # Base class with general logic to call a Ivy ant target
@@ -137,24 +139,11 @@ module Ivy
137
139
  end
138
140
 
139
141
  def ant_properties
140
- p = @ant.project.properties
141
- p.respond_to?(:map) ? p : java_map_to_ruby_hash(p)
142
+ Rjb::JavaObjectWrapper.wrap_java_object @ant.project.properties
142
143
  end
143
144
 
144
145
  def ant_references
145
- r = @ant.project.references
146
- r.respond_to?(:map) ? r : java_map_to_ruby_hash(r)
147
- end
148
-
149
- private
150
- def java_map_to_ruby_hash(java_map)
151
- iterator = java_map.entry_set.iterator
152
- result = {}
153
- while iterator.has_next
154
- entry = iterator.next
155
- result[entry.key.to_string] = entry.value.to_string
156
- end
157
- result
146
+ Rjb::JavaObjectWrapper.wrap_java_object @ant.project.references
158
147
  end
159
148
  end
160
149
 
data/lib/ivy4r.rb CHANGED
@@ -36,7 +36,7 @@ is
36
36
  =end
37
37
  class Ivy4r
38
38
 
39
- VERSION = '0.11.0'
39
+ VERSION = '0.11.1'
40
40
 
41
41
  # Set the ant home directory to load ant classes from if no custom __antwrap__ is provided
42
42
  # and the default provided ant version 1.7.1 should not be used.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ivy4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Klaas Prause
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-05-31 00:00:00 +02:00
12
+ date: 2010-06-09 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -96,6 +96,7 @@ files:
96
96
  - lib/ivy/findrevision.rb
97
97
  - lib/ivy/info.rb
98
98
  - lib/ivy/java/all_version_matcher.rb
99
+ - lib/ivy/java/java_object_wrapper.rb
99
100
  - lib/ivy/listmodules.rb
100
101
  - lib/ivy/makepom.rb
101
102
  - lib/ivy/publish.rb