moran 0.5 → 0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3454fe7b252f3096bc9815fbabaaf2be572a068f
4
- data.tar.gz: 45d56ceaf867411772302298515c26966f8fb0cb
3
+ metadata.gz: 764ea7daa392c9c631d505683fd31abbc736b7cc
4
+ data.tar.gz: 87759f4175c0c2a11e6b1ed810b0e6e70db2c350
5
5
  SHA512:
6
- metadata.gz: a6e5e82b1cbeec09290228a01fbd36c387584922d2f7d189354d810115e19c609286dc1243aae4def5448cc0dc7701e11fd7f76c53793a8bed70ffe52a8e1105
7
- data.tar.gz: 6f08376262d0d96f5425a8b30a2790d505f97c57515cb98a6009aaf52f250662b54a05d9da0914bf208c62322b4ccb317c7e0efcbadfdc21226225fcbeb26909
6
+ metadata.gz: 211ad06528572d877283ab1858b03098b0d699567d67839905b861d4afa2ffc0bd9163b6c6f94641bc98c82ef438ef14794ecb4675925923ee08f9e2a1a05539
7
+ data.tar.gz: f6a027bba5e29eeba076240419bffc86ad0e3cd63860570ea874294e840cbabda8213b686aefebda594e75387c1070b1e4c41345d1499d89382689fd5d5b5f40
@@ -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
- mapper.readValue(json, Hash)
9
+ is_array = json.lstrip[0] == "["
10
+ mapper.readValue(json, is_array ? Array : Hash)
10
11
  end
11
12
 
12
- def generate(hash)
13
+ def generate(obj)
13
14
  mapper = Com::Fasterxml::Jackson::Databind::ObjectMapper.new
14
- mapper.writeValueAsString(RubyToJava.convert_hash(hash));
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) if value.is_a?(Hash)
21
- new_value ||= convert_array(value) if value.is_a?(Array)
22
- new_value ||= value.toString if value.is_a?(String)
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
@@ -1,4 +1,4 @@
1
1
  module Moran
2
- VERSION = "0.5"
2
+ VERSION = "0.6"
3
3
  end
4
4
 
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.5'
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-06-24 00:00:00.000000000 Z
11
+ date: 2015-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: motion-gradle