emf_jruby 0.1.4-java → 0.1.5-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/emf/xmi.rb +28 -0
  2. data/lib/emf_jruby.rb +2 -1
  3. metadata +3 -2
data/lib/emf/xmi.rb ADDED
@@ -0,0 +1,28 @@
1
+ # java_import org.eclipse.emf.ecore.resource.URIConverter
2
+ java_import org.eclipse.emf.ecore.resource.ResourceSet
3
+ java_import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
4
+ java_import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl
5
+ # java_import import org.eclipse.emf.common.util.URI
6
+ java_import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl
7
+ java_import org.eclipse.emf.ecore.EObject
8
+ java_import org.eclipse.emf.ecore.resource.Resource
9
+
10
+ module EMF
11
+
12
+ def self.to_xmi_str(data)
13
+ if data.is_a? EObject
14
+ resource_set = ResourceSetImpl.new
15
+ resource = XMIResourceImpl.new
16
+ resource_set.resources.add resource
17
+ resource.contents.add e_object
18
+ to_xmi_str(resource)
19
+ elsif data.is_a? Resource
20
+ writer = java.io.StringWriter.new
21
+ data.save(writer,nil)
22
+ writer.to_s
23
+ else
24
+ raise "I do not know how to save a #{data.class}"
25
+ end
26
+ end
27
+
28
+ end
data/lib/emf_jruby.rb CHANGED
@@ -8,4 +8,5 @@ end
8
8
  require 'emf/ast_serialization'
9
9
  require 'emf/emf_to_json'
10
10
  require 'emf/eobject_util'
11
- require 'emf/model'
11
+ require 'emf/model'
12
+ require 'emf/xmi'
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: emf_jruby
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.4
5
+ version: 0.1.5
6
6
  platform: java
7
7
  authors:
8
8
  - Federico Tomassetti
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-30 00:00:00.000000000 Z
12
+ date: 2013-08-01 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: EMF support for JRuby. Support for loading and saving models in JSon.
15
15
  email: f.tomassetti@gmail.com
@@ -23,6 +23,7 @@ files:
23
23
  - lib/emf/ast_serialization.rb
24
24
  - lib/emf/eobject_util.rb
25
25
  - lib/emf/model.rb
26
+ - lib/emf/xmi.rb
26
27
  - lib/jars/org.antlr.runtime_3.0.0.v200803061811.jar
27
28
  - lib/jars/org.eclipse.emf.common_2.8.0.v20130125-0546.jar
28
29
  - lib/jars/org.eclipse.emf.ecore.xmi_2.8.1.v20130125-0546.jar