gom-core 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gom/core/primitive.rb +4 -2
- data/lib/gom/core/version.rb +1 -1
- data/spec/unit/gom/core/primitive_spec.rb +7 -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: 82f536e89cfc574ce6419bb01413b638b81d3f0a
|
4
|
+
data.tar.gz: 2a9f08896890e5eaef9a765156b1da8edd82bd14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92150020cf4abb1049e9a2c71bb107e9578cbc841dca0eb39ee5857dfd0a30826a2be90d46b8bd4749b35ac3d3e59630514ba9b3e1c3082da0ca6a468ab50303
|
7
|
+
data.tar.gz: d7d147ac227a11dc627f2ec66a89d52eecfd914d78b538578cae08487e7605c08d4db1b55742c9d764ab0dd4132a4e49d28edc829a254603eb4c876fd6b582f6
|
data/lib/gom/core/primitive.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Gom::Core::Primitive
|
2
2
|
|
3
|
-
|
3
|
+
TypeMap = {
|
4
4
|
Symbol => :symbol,
|
5
5
|
Fixnum => :integer,
|
6
6
|
Bignum => :integer,
|
@@ -16,6 +16,8 @@ class Gom::Core::Primitive
|
|
16
16
|
URI::Generic => :uri,
|
17
17
|
}
|
18
18
|
|
19
|
+
TypeCodes = TypeMap.values.uniq.sort
|
20
|
+
|
19
21
|
Parsers = {
|
20
22
|
:date => Proc.new { |date| ::Date.parse(date) },
|
21
23
|
:datetime => Proc.new { |time| ::DateTime.parse(time) },
|
@@ -44,7 +46,7 @@ class Gom::Core::Primitive
|
|
44
46
|
|
45
47
|
# value -> text, type
|
46
48
|
def self.encode value
|
47
|
-
type =
|
49
|
+
type = TypeMap[value.class] || :string
|
48
50
|
formatter = Formatters[type]
|
49
51
|
[ formatter.call(value), type]
|
50
52
|
end
|
data/lib/gom/core/version.rb
CHANGED
@@ -8,10 +8,15 @@ describe Gom::Core::Primitive do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'implements these known types' do
|
11
|
-
expect(
|
12
|
-
|
11
|
+
expect(Primitive::TypeMap).to be_kind_of(Hash)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'lists all unique types in the TypeCode constant' do
|
15
|
+
expect(Primitive::TypeCodes).to eq([
|
13
16
|
:boolean, :date, :datetime, :float, :integer, :symbol, :uri
|
14
17
|
])
|
18
|
+
|
19
|
+
expect(Primitive::TypeCodes).to eq(Primitive::TypeMap.values.uniq.sort)
|
15
20
|
end
|
16
21
|
|
17
22
|
it "encodes booleans" do
|
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.7
|
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-
|
11
|
+
date: 2013-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|