gom-core 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ module Gom; module Core; end; end
2
+
1
3
  require 'gom/logger'
2
4
  require 'gom/core/primitive'
3
5
  require 'gom/core/version'
@@ -1,24 +1,19 @@
1
- module Gom
2
- module Core
3
- end
4
- end
5
-
6
1
  class Gom::Core::Primitive
7
2
 
8
3
  Types = {
9
- "Symbol" => :symbol,
10
- "Fixnum" => :integer,
11
- "Bignum" => :integer,
12
- "BigDecimal" => :decimal,
13
- "Float" => :float,
14
- "Date" => :date,
15
- "DateTime" => :datetime,
16
- "Time" => :datetime,
17
- "TrueClass" => :boolean,
18
- "FalseClass" => :boolean,
19
- "URI::HTTP" => :uri,
20
- "URI::HTTPS" => :uri,
21
- "URI::Generic" => :uri,
4
+ Symbol => :symbol,
5
+ Fixnum => :integer,
6
+ Bignum => :integer,
7
+ #BigDecimal => :decimal,
8
+ Float => :float,
9
+ Date => :date,
10
+ DateTime => :datetime,
11
+ Time => :datetime,
12
+ TrueClass => :boolean,
13
+ FalseClass => :boolean,
14
+ URI::HTTP => :uri,
15
+ URI::HTTPS => :uri,
16
+ URI::Generic => :uri,
22
17
  }
23
18
 
24
19
  Parsers = {
@@ -27,6 +22,7 @@ class Gom::Core::Primitive
27
22
  :float => Proc.new { |txt| txt.to_f },
28
23
  :integer => Proc.new { |txt| txt.to_i },
29
24
  :uri => Proc.new { |s| URI.parse(s) },
25
+ :boolean => Proc.new { |s| (s == 'true' ? true : false) },
30
26
  }
31
27
 
32
28
  Formatters = Hash.new(Proc.new{|o|o.to_s}).update(
@@ -43,12 +39,12 @@ class Gom::Core::Primitive
43
39
  # text, type -> value
44
40
  def self.decode txt, type = :string
45
41
  parser = type && Parsers[type.to_sym]
46
- parser && parser.call(txt) || txt
42
+ parser ? parser.call(txt) : txt
47
43
  end
48
44
 
49
45
  # value -> text, type
50
46
  def self.encode value
51
- type = Types[value.class.name] || :string
47
+ type = Types[value.class] || :string
52
48
  formatter = Formatters[type]
53
49
  [ formatter.call(value), type]
54
50
  end
@@ -1,5 +1,5 @@
1
1
  module Gom
2
2
  module Core
3
- VERSION = '0.2.5'
3
+ VERSION = '0.2.6'
4
4
  end
5
5
  end
@@ -7,6 +7,21 @@ describe Gom::Core::Primitive do
7
7
  # TODO: test & implementation
8
8
  end
9
9
 
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([
13
+ :boolean, :date, :datetime, :float, :integer, :symbol, :uri
14
+ ])
15
+ end
16
+
17
+ it "encodes booleans" do
18
+ expect(Primitive.encode(true)).to eq(['true', :boolean])
19
+ expect(Primitive.decode(*Primitive.encode(true))).to be(true)
20
+
21
+ expect(Primitive.encode(false)).to eq(['false', :boolean])
22
+ expect(Primitive.decode(*Primitive.encode(false))).to be(false)
23
+ end
24
+
10
25
  it "should encode URIs" do
11
26
  uri = URI.parse "http://www.artcom.de/"
12
27
  Primitive.encode(uri).should == [uri.to_s, :uri]
File without changes
metadata CHANGED
@@ -1,97 +1,86 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gom-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
5
- prerelease:
4
+ version: 0.2.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - art+com/dirk luesebrink
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-20 00:00:00.000000000 Z
11
+ date: 2013-08-28 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec-mocks
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: guard
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: guard-rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: debugger
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
- description: ! "\n this gem includes stuff which is of use for the server as well
83
+ description: "\n this gem includes stuff which is of use for the server as well
95
84
  as for gom\n scripting clients\n "
96
85
  email:
97
86
  - dirk.luesebrink@artcom.de
@@ -99,73 +88,54 @@ executables: []
99
88
  extensions: []
100
89
  extra_rdoc_files: []
101
90
  files:
102
- - !binary |-
103
- LmRvY3VtZW50
104
- - !binary |-
105
- LmdpdGlnbm9yZQ==
106
- - !binary |-
107
- LnRyYXZpcy55bWw=
108
- - !binary |-
109
- R2VtZmlsZQ==
110
- - !binary |-
111
- R3VhcmRmaWxl
112
- - !binary |-
113
- TElDRU5TRQ==
114
- - !binary |-
115
- UkVBRE1FLm1k
116
- - !binary |-
117
- UmFrZWZpbGU=
118
- - !binary |-
119
- Z29tLWNvcmUuZ2Vtc3BlYw==
120
- - !binary |-
121
- bGliL2dvbS1jb3JlLnJi
122
- - !binary |-
123
- bGliL2dvbS9jb3JlLnJi
124
- - !binary |-
125
- bGliL2dvbS9jb3JlL3ByaW1pdGl2ZS5yYg==
126
- - !binary |-
127
- bGliL2dvbS9jb3JlL3ZlcnNpb24ucmI=
128
- - !binary |-
129
- bGliL2dvbS9sb2dnZXIucmI=
130
- - !binary |-
131
- c3BlYy9nb20vY29yZS9wcmltaXRpdmVfc3BlYy5yYg==
132
- - !binary |-
133
- c3BlYy9nb20vbG9nZ2VyX3NwZWMucmI=
134
- - !binary |-
135
- c3BlYy9zcGVjLm9wdHM=
136
- - !binary |-
137
- c3BlYy9zcGVjX2hlbHBlci5yYg==
91
+ - .document
92
+ - .gitignore
93
+ - .travis.yml
94
+ - Gemfile
95
+ - Guardfile
96
+ - LICENSE
97
+ - README.md
98
+ - Rakefile
99
+ - config/license_finder.yml
100
+ - doc/dependencies.csv
101
+ - doc/dependencies.db
102
+ - doc/dependencies.html
103
+ - gom-core.gemspec
104
+ - lib/gom-core.rb
105
+ - lib/gom/core.rb
106
+ - lib/gom/core/primitive.rb
107
+ - lib/gom/core/version.rb
108
+ - lib/gom/logger.rb
109
+ - spec/spec.opts
110
+ - spec/spec_helper.rb
111
+ - spec/unit/gom/core/primitive_spec.rb
112
+ - spec/unit/gom/logger_spec.rb
138
113
  homepage: http://github.com/artcom/gom-core
139
- licenses: []
114
+ licenses:
115
+ - MIT
116
+ metadata: {}
140
117
  post_install_message:
141
118
  rdoc_options: []
142
119
  require_paths:
143
120
  - lib
144
121
  required_ruby_version: !ruby/object:Gem::Requirement
145
- none: false
146
122
  requirements:
147
- - - ! '>='
123
+ - - '>='
148
124
  - !ruby/object:Gem::Version
149
125
  version: '0'
150
126
  required_rubygems_version: !ruby/object:Gem::Requirement
151
- none: false
152
127
  requirements:
153
- - - ! '>='
128
+ - - '>='
154
129
  - !ruby/object:Gem::Version
155
130
  version: '0'
156
131
  requirements: []
157
132
  rubyforge_project:
158
- rubygems_version: 1.8.25
133
+ rubygems_version: 2.0.6
159
134
  signing_key:
160
- specification_version: 3
135
+ specification_version: 4
161
136
  summary: basic GOM functionallity
162
137
  test_files:
163
- - !binary |-
164
- c3BlYy9nb20vY29yZS9wcmltaXRpdmVfc3BlYy5yYg==
165
- - !binary |-
166
- c3BlYy9nb20vbG9nZ2VyX3NwZWMucmI=
167
- - !binary |-
168
- c3BlYy9zcGVjLm9wdHM=
169
- - !binary |-
170
- c3BlYy9zcGVjX2hlbHBlci5yYg==
171
- has_rdoc:
138
+ - spec/spec.opts
139
+ - spec/spec_helper.rb
140
+ - spec/unit/gom/core/primitive_spec.rb
141
+ - spec/unit/gom/logger_spec.rb