moran 0.5 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/motion/moran/moran.rb +10 -3
- data/motion/moran/ruby_to_java.rb +12 -8
- data/motion/moran/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 764ea7daa392c9c631d505683fd31abbc736b7cc
|
4
|
+
data.tar.gz: 87759f4175c0c2a11e6b1ed810b0e6e70db2c350
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 211ad06528572d877283ab1858b03098b0d699567d67839905b861d4afa2ffc0bd9163b6c6f94641bc98c82ef438ef14794ecb4675925923ee08f9e2a1a05539
|
7
|
+
data.tar.gz: f6a027bba5e29eeba076240419bffc86ad0e3cd63860570ea874294e840cbabda8213b686aefebda594e75387c1070b1e4c41345d1499d89382689fd5d5b5f40
|
data/motion/moran/moran.rb
CHANGED
@@ -6,12 +6,19 @@ class Moran
|
|
6
6
|
mapper = Com::Fasterxml::Jackson::Databind::ObjectMapper.new
|
7
7
|
mapper.configure(Com::Fasterxml::Jackson::Core::JsonParser::Feature::ALLOW_UNQUOTED_FIELD_NAMES,
|
8
8
|
true)
|
9
|
-
|
9
|
+
is_array = json.lstrip[0] == "["
|
10
|
+
mapper.readValue(json, is_array ? Array : Hash)
|
10
11
|
end
|
11
12
|
|
12
|
-
def generate(
|
13
|
+
def generate(obj)
|
13
14
|
mapper = Com::Fasterxml::Jackson::Databind::ObjectMapper.new
|
14
|
-
|
15
|
+
converted =
|
16
|
+
if obj.is_a?(Array)
|
17
|
+
RubyToJava.convert_array(obj)
|
18
|
+
else
|
19
|
+
RubyToJava.convert_hash(obj)
|
20
|
+
end
|
21
|
+
mapper.writeValueAsString(converted)
|
15
22
|
end
|
16
23
|
|
17
24
|
end
|
@@ -3,7 +3,11 @@
|
|
3
3
|
class RubyToJava
|
4
4
|
|
5
5
|
def self.convert_hash(hash)
|
6
|
-
RubyToJava.new.to_hashmap(hash)
|
6
|
+
RubyToJava.new.to_hashmap(hash)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.convert_array(array)
|
10
|
+
RubyToJava.new.to_array(array)
|
7
11
|
end
|
8
12
|
|
9
13
|
def to_hashmap(old_hash)
|
@@ -14,17 +18,17 @@ class RubyToJava
|
|
14
18
|
end
|
15
19
|
end
|
16
20
|
|
21
|
+
def to_array(array)
|
22
|
+
array.map { |v| v.is_a?(String) ? v.toString : v }
|
23
|
+
end
|
24
|
+
|
17
25
|
private
|
18
26
|
|
19
27
|
def convert_value(value)
|
20
|
-
new_value ||= to_hashmap(value)
|
21
|
-
new_value ||=
|
22
|
-
new_value ||= value.toString
|
28
|
+
new_value ||= to_hashmap(value) if value.is_a?(Hash)
|
29
|
+
new_value ||= to_array(value) if value.is_a?(Array)
|
30
|
+
new_value ||= value.toString if value.is_a?(String)
|
23
31
|
new_value ||= value
|
24
32
|
end
|
25
33
|
|
26
|
-
def convert_array(array)
|
27
|
-
array.map { |v| v.is_a?(String) ? v.toString : v }
|
28
|
-
end
|
29
|
-
|
30
34
|
end
|
data/motion/moran/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moran
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.6'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darin Wilson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: motion-gradle
|