gom-core 0.2.7 → 0.2.8
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 +4 -4
- data/lib/gom/core/primitive.rb +4 -3
- data/lib/gom/core/version.rb +1 -1
- data/spec/unit/gom/core/primitive_spec.rb +2 -2
- 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: 1c365f9e55da5e92d6b88f5766752d984a76cd08
|
4
|
+
data.tar.gz: f37ee584094966fc5e07cbad771f0131e1ce8df1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 874188265d87c647d412bc03e3189138278b3dca8b5e5f17e59c8ecb60fbb28f438913ed693e8249c6260b4787c8a822cb2b639637f3fccf100cc5ddad81ed31
|
7
|
+
data.tar.gz: e87f8c33af870b89288bb03d3d67c952e48cc567bcf037aef56297bf2787bcc92d12349fd85a1f3c3a153de7ddb06cf45b39d51bbab8aa80a456bebd5876b7e9
|
data/lib/gom/core/primitive.rb
CHANGED
@@ -14,6 +14,7 @@ class Gom::Core::Primitive
|
|
14
14
|
URI::HTTP => :uri,
|
15
15
|
URI::HTTPS => :uri,
|
16
16
|
URI::Generic => :uri,
|
17
|
+
String => :txt,
|
17
18
|
}
|
18
19
|
|
19
20
|
TypeCodes = TypeMap.values.uniq.sort
|
@@ -28,7 +29,7 @@ class Gom::Core::Primitive
|
|
28
29
|
}
|
29
30
|
|
30
31
|
Formatters = Hash.new(Proc.new{|o|o.to_s}).update(
|
31
|
-
:
|
32
|
+
:txt => Proc.new { |s| s.to_s },
|
32
33
|
:date => Proc.new { |date| date.strftime('%Y-%m-%d') }, #.to_s(:db) },
|
33
34
|
:datetime => Proc.new { |time|
|
34
35
|
# back and forth, trying to 'normalize' the myriad of time formats
|
@@ -39,14 +40,14 @@ class Gom::Core::Primitive
|
|
39
40
|
)
|
40
41
|
|
41
42
|
# text, type -> value
|
42
|
-
def self.decode txt, type = :
|
43
|
+
def self.decode txt, type = :txt
|
43
44
|
parser = type && Parsers[type.to_sym]
|
44
45
|
parser ? parser.call(txt) : txt
|
45
46
|
end
|
46
47
|
|
47
48
|
# value -> text, type
|
48
49
|
def self.encode value
|
49
|
-
type = TypeMap[value.class] || :
|
50
|
+
type = TypeMap[value.class] || :txt
|
50
51
|
formatter = Formatters[type]
|
51
52
|
[ formatter.call(value), type]
|
52
53
|
end
|
data/lib/gom/core/version.rb
CHANGED
@@ -13,7 +13,7 @@ describe Gom::Core::Primitive do
|
|
13
13
|
|
14
14
|
it 'lists all unique types in the TypeCode constant' do
|
15
15
|
expect(Primitive::TypeCodes).to eq([
|
16
|
-
:boolean, :date, :datetime, :float, :integer, :symbol, :uri
|
16
|
+
:boolean, :date, :datetime, :float, :integer, :symbol, :txt, :uri
|
17
17
|
])
|
18
18
|
|
19
19
|
expect(Primitive::TypeCodes).to eq(Primitive::TypeMap.values.uniq.sort)
|
@@ -66,6 +66,6 @@ describe Gom::Core::Primitive do
|
|
66
66
|
it "should encode strings" do
|
67
67
|
s = "random text string: #{rand}."
|
68
68
|
s.should == Primitive.decode(*Primitive.encode(s))
|
69
|
-
[s, :
|
69
|
+
[s, :txt].should == Primitive.encode(s)
|
70
70
|
end
|
71
71
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gom-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- art+com/dirk luesebrink
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|