super_serialize 0.0.3 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9582fd7206a15c2a01a88c444079c4141f7b8f44
4
- data.tar.gz: e67b84f14b3dc54068e6c1ed9fa9ad07090ca65b
3
+ metadata.gz: 643b5a34abc544e4a27c77af7679a6243746dc4e
4
+ data.tar.gz: 20bb2ef4df1ffa1bb82c32cf7274aeb3e82d507c
5
5
  SHA512:
6
- metadata.gz: 5bc58f79564ab70d5a6c97833a26067ebf3f4bf292b175ba1fe9d5cd50eefd9ae525ce5095b538eadda53421e0fb89e4cc2ca035940b062fc22852ff657abbef
7
- data.tar.gz: e945146f60d42d1a3d00f87a260194a284dd772bc1cdd2a60e77cafdc1b0bf18d6edd1ea5f21aa810a177f1414cdd64d1a55bf66271cde29f6237e508c57fc17
6
+ metadata.gz: d6aff682824fd655df8108ef2d25c3ba2c5a6a3b06989721313f3cd2f2e227265c72f823a7a49219a98259feb2906598814944cc27ed53ae4a77058f6a6efd3b
7
+ data.tar.gz: 9334bcde876cf0b1b2b097312edd10a11a04cbe76d8d22f5720b8f37cfe8e6cb72c404025e870c8d0aa59c4b63c1384437452e8e3b7b140297c73562a5bf3708
@@ -1,3 +1,3 @@
1
1
  module SuperSerialize
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -75,7 +75,7 @@ module SuperSerialize
75
75
  def #{attr_name}
76
76
  value = super
77
77
  return value.with_indifferent_access if value.is_a?(Hash)
78
- return value unless is_valid_yaml?(value)
78
+ return value unless should_return_loaded_yaml?(value)
79
79
 
80
80
  object = YAML::load(value)
81
81
  object.is_a?(Hash) ? object.with_indifferent_access : object
@@ -90,6 +90,8 @@ module SuperSerialize
90
90
 
91
91
  if trying_to_serialize_a_hash?(value)
92
92
  value = attempt_to_sanitize_hash_syntax(value)
93
+ elsif is_number_string_starting_with_zero?(value)
94
+ value = value.to_yaml
93
95
  end
94
96
  end
95
97
 
@@ -160,6 +162,15 @@ module SuperSerialize
160
162
  end
161
163
  end
162
164
 
165
+ def should_return_loaded_yaml?(value)
166
+ return false if is_number_string_starting_with_zero?(value)
167
+ is_valid_yaml?(value)
168
+ end
169
+
170
+ def is_number_string_starting_with_zero?(value)
171
+ !!(value =~ /^0\d+\.*\d*$/)
172
+ end
173
+
163
174
  def trying_to_serialize_a_hash?(value)
164
175
  return false unless value.is_a?(String)
165
176
  !!(value =~ /^{.+}$/)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super_serialize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Quiñones