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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 072df97cdfc1a16de0a9659b0b551426966bd3a0
4
- data.tar.gz: 364006f1f9c31d59e0bc4d7c73e9c43096fe947e
3
+ metadata.gz: 82f536e89cfc574ce6419bb01413b638b81d3f0a
4
+ data.tar.gz: 2a9f08896890e5eaef9a765156b1da8edd82bd14
5
5
  SHA512:
6
- metadata.gz: e8fe342493ab6c4e566e40ad929622509cc81bdebb31c3a4352baba9f7be9d1848e82512e5d66e22ac1f7d1f595215b53ed2f447f9890cdf0571280b755f911e
7
- data.tar.gz: 566aa417398e18f59565a45d6a119cb492725b6735651f02efff8ffd8904b5dbf788b42a5e286fb9807d1817bd3a032a31120da7162e18266ca1fc28798151bd
6
+ metadata.gz: 92150020cf4abb1049e9a2c71bb107e9578cbc841dca0eb39ee5857dfd0a30826a2be90d46b8bd4749b35ac3d3e59630514ba9b3e1c3082da0ca6a468ab50303
7
+ data.tar.gz: d7d147ac227a11dc627f2ec66a89d52eecfd914d78b538578cae08487e7605c08d4db1b55742c9d764ab0dd4132a4e49d28edc829a254603eb4c876fd6b582f6
@@ -1,6 +1,6 @@
1
1
  class Gom::Core::Primitive
2
2
 
3
- Types = {
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 = Types[value.class] || :string
49
+ type = TypeMap[value.class] || :string
48
50
  formatter = Formatters[type]
49
51
  [ formatter.call(value), type]
50
52
  end
@@ -1,5 +1,5 @@
1
1
  module Gom
2
2
  module Core
3
- VERSION = '0.2.6'
3
+ VERSION = '0.2.7'
4
4
  end
5
5
  end
@@ -8,10 +8,15 @@ describe Gom::Core::Primitive do
8
8
  end
9
9
 
10
10
  it 'implements these known types' do
11
- expect(types = Primitive::Types).to be_kind_of(Hash)
12
- expect(types.values.uniq.sort).to eq([
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.6
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-08-28 00:00:00.000000000 Z
11
+ date: 2013-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec