couch-quilt 0.4.1 → 0.5.0
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.
- data/couch-quilt.gemspec +7 -2
- data/lib/couchquilt.rb +3 -0
- data/lib/couchquilt/core_ext/array.rb +37 -0
- data/lib/couchquilt/core_ext/hash.rb +43 -0
- data/lib/couchquilt/database.rb +68 -0
- data/lib/couchquilt/fs.rb +51 -83
- data/lib/couchquilt/mapper.rb +6 -42
- data/lib/couchquilt/version.rb +1 -1
- data/spec/couchquilt/core_ext_spec.rb +111 -0
- data/spec/couchquilt/fs_spec.rb +418 -207
- data/spec/couchquilt/mapper_spec.rb +0 -76
- data/spec/spec_helper.rb +2 -2
- metadata +9 -4
@@ -3,82 +3,6 @@ require File.join(File.dirname(__FILE__), '../spec_helper.rb')
|
|
3
3
|
describe Couchquilt::Mapper do
|
4
4
|
include Couchquilt::Mapper
|
5
5
|
|
6
|
-
describe "map_json" do
|
7
|
-
describe "value mapping" do
|
8
|
-
it "should map string value" do
|
9
|
-
result = map_json({ "key" => "value" })
|
10
|
-
result.should == ["key.js"]
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should map integer value" do
|
14
|
-
result = map_json({ "key" => 1 })
|
15
|
-
result.should == ["key.i.js"]
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should map float value" do
|
19
|
-
result = map_json({ "key" => 1.1 })
|
20
|
-
result.should == ["key.f.js"]
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should map false value" do
|
24
|
-
result = map_json({ "key" => false })
|
25
|
-
result.should == ["key.b.js"]
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should map true value" do
|
29
|
-
result = map_json({ "key" => true })
|
30
|
-
result.should == ["key.b.js"]
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should map an array value" do
|
34
|
-
result = map_json(["value"])
|
35
|
-
result.should == ["0i.js"]
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should map hash value" do
|
39
|
-
result = map_json({ "key" => {}})
|
40
|
-
result.should == ["key"]
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should map array value" do
|
44
|
-
result = map_json({ "key" => []})
|
45
|
-
result.should == ["key.array"]
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "nested mapping" do
|
50
|
-
it "should map only keys" do
|
51
|
-
result = map_json("key" => { "key" => "value" })
|
52
|
-
result.should == ["key"]
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe "array mapping" do
|
57
|
-
it "should map uniq array values" do
|
58
|
-
result = map_json(["value1", "value2"])
|
59
|
-
result.should == ["0i.js", "1i.js"]
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should map equal array values" do
|
63
|
-
result = map_json(["value", "value"])
|
64
|
-
result.should == ["0i.js", "1i.js"]
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe "map_fs" do
|
70
|
-
before do
|
71
|
-
@json = { :a => 1, :b => 2}
|
72
|
-
end
|
73
|
-
|
74
|
-
it "should remove all contents for empty keys" do
|
75
|
-
result = map_fs(@json)
|
76
|
-
result.should == {}
|
77
|
-
end
|
78
|
-
|
79
|
-
# TODO: really spec this
|
80
|
-
end
|
81
|
-
|
82
6
|
describe "key_for" do
|
83
7
|
it "should return parsed integer value for 1i" do
|
84
8
|
result = key_for("1i")
|
data/spec/spec_helper.rb
CHANGED
@@ -4,5 +4,5 @@ require 'spec'
|
|
4
4
|
require File.join(File.dirname(__FILE__), '../lib/couchquilt')
|
5
5
|
require File.join(File.dirname(__FILE__), '../lib/couchquilt/debugged_fs')
|
6
6
|
|
7
|
-
SERVER_NAME = "http://127.0.0.1:5984"
|
8
|
-
TESTDB
|
7
|
+
SERVER_NAME = "http://127.0.0.1:5984" unless defined? SERVER_NAME
|
8
|
+
TESTDB = "quilt-test-db" unless defined? TESTDB
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 5
|
8
|
+
- 0
|
9
|
+
version: 0.5.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- "Johannes J\xC3\xB6rg Schmidt"
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-04-02 00:00:00 +02:00
|
18
18
|
default_executable: couchquilt
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -76,11 +76,15 @@ files:
|
|
76
76
|
- bin/couchquilt
|
77
77
|
- couch-quilt.gemspec
|
78
78
|
- lib/couchquilt.rb
|
79
|
+
- lib/couchquilt/core_ext/array.rb
|
80
|
+
- lib/couchquilt/core_ext/hash.rb
|
79
81
|
- lib/couchquilt/couch_client.rb
|
82
|
+
- lib/couchquilt/database.rb
|
80
83
|
- lib/couchquilt/debugged_fs.rb
|
81
84
|
- lib/couchquilt/fs.rb
|
82
85
|
- lib/couchquilt/mapper.rb
|
83
86
|
- lib/couchquilt/version.rb
|
87
|
+
- spec/couchquilt/core_ext_spec.rb
|
84
88
|
- spec/couchquilt/fs_spec.rb
|
85
89
|
- spec/couchquilt/mapper_spec.rb
|
86
90
|
- spec/spec_helper.rb
|
@@ -117,4 +121,5 @@ summary: Access CouchDB from filesystem.
|
|
117
121
|
test_files:
|
118
122
|
- spec/spec_helper.rb
|
119
123
|
- spec/couchquilt/fs_spec.rb
|
124
|
+
- spec/couchquilt/core_ext_spec.rb
|
120
125
|
- spec/couchquilt/mapper_spec.rb
|