gom-core 0.2.7 → 0.2.8

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: 82f536e89cfc574ce6419bb01413b638b81d3f0a
4
- data.tar.gz: 2a9f08896890e5eaef9a765156b1da8edd82bd14
3
+ metadata.gz: 1c365f9e55da5e92d6b88f5766752d984a76cd08
4
+ data.tar.gz: f37ee584094966fc5e07cbad771f0131e1ce8df1
5
5
  SHA512:
6
- metadata.gz: 92150020cf4abb1049e9a2c71bb107e9578cbc841dca0eb39ee5857dfd0a30826a2be90d46b8bd4749b35ac3d3e59630514ba9b3e1c3082da0ca6a468ab50303
7
- data.tar.gz: d7d147ac227a11dc627f2ec66a89d52eecfd914d78b538578cae08487e7605c08d4db1b55742c9d764ab0dd4132a4e49d28edc829a254603eb4c876fd6b582f6
6
+ metadata.gz: 874188265d87c647d412bc03e3189138278b3dca8b5e5f17e59c8ecb60fbb28f438913ed693e8249c6260b4787c8a822cb2b639637f3fccf100cc5ddad81ed31
7
+ data.tar.gz: e87f8c33af870b89288bb03d3d67c952e48cc567bcf037aef56297bf2787bcc92d12349fd85a1f3c3a153de7ddb06cf45b39d51bbab8aa80a456bebd5876b7e9
@@ -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
- :string => Proc.new { |s| s.to_s },
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 = :string
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] || :string
50
+ type = TypeMap[value.class] || :txt
50
51
  formatter = Formatters[type]
51
52
  [ formatter.call(value), type]
52
53
  end
@@ -1,5 +1,5 @@
1
1
  module Gom
2
2
  module Core
3
- VERSION = '0.2.7'
3
+ VERSION = '0.2.8'
4
4
  end
5
5
  end
@@ -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, :string].should == Primitive.encode(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.7
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 00:00:00.000000000 Z
11
+ date: 2013-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec