space_object 0.1.3 → 0.1.4

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTU2ZjBhNWE0NWVhZGZhMzM1OTQxMTUzNjYyNDlhMzU1ZTk2ZGQxNQ==
4
+ NGJiNGY0NzQ5YTRhNWVkNjNhOGRmODEwZmY1YmFmYjcyMjYwZTQ4ZQ==
5
5
  data.tar.gz: !binary |-
6
- MDQ3OWFiOWIyMTIyZjFiODI2NmVlOGEzMGY1MWIyOGM0OTNjNGIyZQ==
6
+ MWI1YzQ1OGJhMTRiZDZiZTZkNmNmNGE2MGU3MTA3OTU4ZmNiNWI4Yg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YzcxNWE1N2QxMzczNmEyMzk3M2Q4Yjg0M2EyZmM2OGE0MDI1NGRlZmE5MjZl
10
- NGIzYTIzMWMzMTExYTc2NWU1ZGFmNjFkYmIzNTYyNTg5ZWY4N2Q1OTA4Yzc1
11
- ODk5YjRjNGZkM2EyZDYzMjQzMzc1MGI3NzE2ZmQ2MGQ5ZDY5Mjg=
9
+ ODZjZTM1MDI5ODBmNWUyYmNkNjE5ZTAyMTE5MTgzNjdiODgwOTQ3NzhkMDNk
10
+ ZmJlMjEyN2ZkNDVkNTZjYzIwZDkzM2M3MjhlNjJhMWMxMGQ2MzhlNzE4YzVm
11
+ ZGMyMDE4M2U2OGY3ZWRiNmM1YWVmNmQwZGNhZWEwMTFhNzI1ZDI=
12
12
  data.tar.gz: !binary |-
13
- MmNjNDY2YTRjMjZkOTY2NzQ1YmU5MmE5OTdlZWJiMWIwNGYwMWNlMmY4ODJi
14
- ZGQ2Yzg0YTI3N2I2NmJjZDIwYjRlY2NhYTU5MzZkMGU1MjBiODc0NzY4M2Ey
15
- MjViYjg1MDFmYTk2MmUyNjZkYWI4NTJkMTY5MTQ2ZjZlNDBjZmY=
13
+ MDJmMjQ2OTQxODBmYzI0ZmRlODNkNTkyZjM0ZDI5Y2ZhZGE2ZTgzNTQ0MGJh
14
+ ZGE5MTk3MTEyYjk1NjM5NWYxODRhMjkxNTc2YTk2YWI4MTMxZmYzODU4MTFi
15
+ ZWY1MDJhNTJlNjk5YzFjNjg4NzQxNGQyZmJjYzg3NWJiMmM4NWY=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- space_object (0.1.3)
4
+ space_object (0.1.4)
5
5
  activesupport (~> 4.0)
6
6
 
7
7
  GEM
@@ -5,9 +5,9 @@ require 'space_object/string_encodable'
5
5
 
6
6
  class Array
7
7
  def to_space_object
8
- each_with_index.map do |item, index|
9
- {index => item}.to_space_object
10
- end
8
+ Hash[each_with_index.map do |item, index|
9
+ [index, item]
10
+ end].to_space_object
11
11
  end
12
12
 
13
13
  def to_space_value
@@ -1,4 +1,4 @@
1
1
  module SpaceObject
2
2
  # space_object version
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
@@ -0,0 +1,74 @@
1
+ require 'spec_helper'
2
+
3
+ shared_examples_for 'a convertable object' do |object, expected|
4
+ it 'can be converted into a SpaceObject::Base via #to_space_object' do
5
+ expect(object.to_space_object).to eq(expected)
6
+ end
7
+ end
8
+
9
+ shared_examples_for 'a convertable key' do |object, expected|
10
+ it 'can be converted into a SpaceObject::Base-compatible key via #to_space_key' do
11
+ expect(object.to_space_key).to eq(expected)
12
+ end
13
+ end
14
+
15
+ shared_examples_for 'a convertable value' do |object, expected|
16
+ it 'can be converted into a SpaceObject::Base-compatible value via #to_space_value' do
17
+ expect(object.to_space_value).to eq(expected)
18
+ end
19
+ end
20
+
21
+ shared_examples_for 'a convertable key or value' do |object, expected|
22
+ it_should_behave_like 'a convertable key', object, expected
23
+ it_should_behave_like 'a convertable value', object, expected
24
+ end
25
+
26
+ describe Array do
27
+ it_should_behave_like 'a convertable object', ["foo", "bar"], SpaceObject.encode("0" => "foo", "1" => "bar")
28
+ end
29
+
30
+ describe FalseClass do
31
+ it_should_behave_like 'a convertable key or value', false, 'false'
32
+ end
33
+
34
+ describe Float do
35
+ f = 1.254583462345e10
36
+ it_should_behave_like 'a convertable key or value', f, f.to_s
37
+ end
38
+
39
+ describe Integer do
40
+ i = 12345678
41
+ it_should_behave_like 'a convertable key or value', i, i.to_s
42
+ end
43
+
44
+ describe Hash do
45
+ let(:hash) { {'foo' => 'bar'} }
46
+ it 'encodes itself using SpaceObject::Encoder' do
47
+ encoder = SpaceObject::Encoder.new(hash)
48
+ SpaceObject::Encoder.stub(:new).and_return encoder
49
+
50
+ expect(hash.to_space_object).to be_a(SpaceObject::Base)
51
+ expect(SpaceObject::Encoder).to have_received(:new).with(hash)
52
+ end
53
+ end
54
+
55
+ describe NilClass do
56
+ it_should_behave_like 'a convertable key or value', nil, ''
57
+ end
58
+
59
+ describe Regexp do
60
+ regexp = /\w+,\s\d+/
61
+ it_should_behave_like 'a convertable key or value', regexp, regexp.to_s
62
+ end
63
+
64
+ describe String do
65
+ it_should_behave_like 'a convertable key or value', 'foobar', 'foobar'
66
+ end
67
+
68
+ describe Symbol do
69
+ it_should_behave_like 'a convertable key or value', :foobar, 'foobar'
70
+ end
71
+
72
+ describe TrueClass do
73
+ it_should_behave_like 'a convertable key or value', true, 'true'
74
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: space_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Fruchtman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-15 00:00:00.000000000 Z
11
+ date: 2013-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc
@@ -90,6 +90,7 @@ files:
90
90
  - lib/space_object/string_encodable.rb
91
91
  - lib/space_object/version.rb
92
92
  - space_object.gemspec
93
+ - spec/core_ext/object/space_object_spec.rb
93
94
  - spec/space_object/base_spec.rb
94
95
  - spec/space_object/encoder_spec.rb
95
96
  - spec/space_object/parser_spec.rb
@@ -120,6 +121,7 @@ signing_key:
120
121
  specification_version: 4
121
122
  summary: A lightweight language for objects
122
123
  test_files:
124
+ - spec/core_ext/object/space_object_spec.rb
123
125
  - spec/space_object/base_spec.rb
124
126
  - spec/space_object/encoder_spec.rb
125
127
  - spec/space_object/parser_spec.rb