vitreous_share 0.0.27 → 0.0.31
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/lib/vitreous/share/element.rb +9 -0
- data/lib/vitreous/share/indexer.rb +5 -2
- data/lib/vitreous/share/indexer_utils.rb +6 -0
- data/lib/vitreous/share/version.rb +1 -1
- data/test/element_test.rb +3 -1
- data/test/fixtures/folder_structure/_home.txt +1 -1
- data/test/fixtures/index.json +16 -6
- data/test/fixtures/render_collection.txt +2 -0
- data/test/fixtures/render_home.txt +15 -0
- data/test/fixtures/render_item.txt +2 -0
- data/test/fixtures/render_not_found.txt +7 -5
- data/test/fixtures/structure.json +1 -1
- data/test/fixtures/template/collection.html +2 -0
- data/test/fixtures/template/home.html +7 -0
- data/test/fixtures/template/item.html +2 -0
- data/test/fixtures/template/layout.html +6 -0
- data/test/fixtures/template/not_found.html +7 -0
- data/test/indexer_utils_test.rb +17 -0
- data/test/render_test.rb +3 -3
- metadata +9 -5
- data/test/fixtures/render_root.txt +0 -13
|
@@ -18,7 +18,8 @@ module Vitreous
|
|
|
18
18
|
{
|
|
19
19
|
'title' => Vitreous::Share::IndexerUtils.to_title( structure['name'] ),
|
|
20
20
|
'link' => '/',
|
|
21
|
-
'
|
|
21
|
+
'slug' => '',
|
|
22
|
+
'type' => 'home',
|
|
22
23
|
'elements' => tree( structure['elements'].select { |e| !(e['name'] =~ /^_/) }.sort { |x, y| x['name'] <=> y['name'] } )
|
|
23
24
|
}.merge(
|
|
24
25
|
Vitreous::Share::IndexerUtils.meta_properties(
|
|
@@ -30,7 +31,8 @@ module Vitreous
|
|
|
30
31
|
def generate_not_found( structure )
|
|
31
32
|
{
|
|
32
33
|
'title' => 'Not found',
|
|
33
|
-
'type' => '
|
|
34
|
+
'type' => 'not_found',
|
|
35
|
+
'slug' => 'not_found',
|
|
34
36
|
'elements' => [],
|
|
35
37
|
}.merge(
|
|
36
38
|
Vitreous::Share::IndexerUtils.meta_properties(
|
|
@@ -44,6 +46,7 @@ module Vitreous
|
|
|
44
46
|
{
|
|
45
47
|
'title' => Vitreous::Share::IndexerUtils.to_title( e[0]['name'] ),
|
|
46
48
|
'link' => Vitreous::Share::IndexerUtils.to_link( e[0]['path'] ),
|
|
49
|
+
'slug' => Vitreous::Share::IndexerUtils.to_slug( e[0]['path'] ),
|
|
47
50
|
'type' => e.any? { |e2| e2['type'] == 'directory' } ? 'collection' : 'item',
|
|
48
51
|
'elements' => tree( e[0]['elements'].sort { |x, y| x['name'] <=> y['name'] } )
|
|
49
52
|
}.merge( Vitreous::Share::IndexerUtils.meta_properties( e ) )
|
data/test/element_test.rb
CHANGED
|
@@ -7,8 +7,10 @@ class ElementTest < Test::Unit::TestCase
|
|
|
7
7
|
|
|
8
8
|
assert_equal( 'fixtures', home.title )
|
|
9
9
|
assert_equal( '/', home.link )
|
|
10
|
-
assert_equal( true, home.
|
|
10
|
+
assert_equal( true, home.home? )
|
|
11
11
|
assert_equal( false, home.item? )
|
|
12
|
+
assert_equal( false, home.collection? )
|
|
13
|
+
assert_equal( false, home.not_found? )
|
|
12
14
|
assert_equal( 3, home.elements.size )
|
|
13
15
|
assert_equal( 1, home.items.size )
|
|
14
16
|
assert_equal( 2, home.collections.size )
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
home content
|
data/test/fixtures/index.json
CHANGED
|
@@ -2,16 +2,19 @@
|
|
|
2
2
|
"home": {
|
|
3
3
|
"title": "fixtures",
|
|
4
4
|
"link": "/",
|
|
5
|
-
"
|
|
5
|
+
"slug": "",
|
|
6
|
+
"type": "home",
|
|
6
7
|
"elements": [
|
|
7
8
|
{
|
|
8
9
|
"title": "subfolder 1",
|
|
9
10
|
"link": "/subfolder-1",
|
|
11
|
+
"slug": "subfolder-1",
|
|
10
12
|
"type": "collection",
|
|
11
13
|
"elements": [
|
|
12
14
|
{
|
|
13
15
|
"title": "bbb",
|
|
14
16
|
"link": "/subfolder-1/bbb",
|
|
17
|
+
"slug": "bbb",
|
|
15
18
|
"type": "item",
|
|
16
19
|
"elements": [
|
|
17
20
|
|
|
@@ -36,6 +39,7 @@
|
|
|
36
39
|
{
|
|
37
40
|
"title": "aaa",
|
|
38
41
|
"link": "/subfolder-1/aaa",
|
|
42
|
+
"slug": "aaa",
|
|
39
43
|
"type": "item",
|
|
40
44
|
"elements": [
|
|
41
45
|
|
|
@@ -60,11 +64,13 @@
|
|
|
60
64
|
{
|
|
61
65
|
"title": "subsubfolder 1",
|
|
62
66
|
"link": "/subfolder-1/subsubfolder-1",
|
|
67
|
+
"slug": "subsubfolder-1",
|
|
63
68
|
"type": "collection",
|
|
64
69
|
"elements": [
|
|
65
70
|
{
|
|
66
71
|
"title": "file 1",
|
|
67
72
|
"link": "/subfolder-1/subsubfolder-1/file-1",
|
|
73
|
+
"slug": "file-1",
|
|
68
74
|
"type": "item",
|
|
69
75
|
"elements": [
|
|
70
76
|
|
|
@@ -101,11 +107,13 @@
|
|
|
101
107
|
{
|
|
102
108
|
"title": "subfolder 2",
|
|
103
109
|
"link": "/subfolder-2",
|
|
110
|
+
"slug": "subfolder-2",
|
|
104
111
|
"type": "collection",
|
|
105
112
|
"elements": [
|
|
106
113
|
{
|
|
107
114
|
"title": "file 1",
|
|
108
115
|
"link": "/subfolder-2/file-1",
|
|
116
|
+
"slug": "file-1",
|
|
109
117
|
"type": "item",
|
|
110
118
|
"elements": [
|
|
111
119
|
|
|
@@ -124,6 +132,7 @@
|
|
|
124
132
|
{
|
|
125
133
|
"title": "file 1",
|
|
126
134
|
"link": "/file-1",
|
|
135
|
+
"slug": "file-1",
|
|
127
136
|
"type": "item",
|
|
128
137
|
"elements": [
|
|
129
138
|
|
|
@@ -160,21 +169,22 @@
|
|
|
160
169
|
"wadus uri"
|
|
161
170
|
],
|
|
162
171
|
"jpg": "wadus uri",
|
|
163
|
-
"description": "
|
|
172
|
+
"description": "home content",
|
|
164
173
|
"descriptions": [
|
|
165
|
-
"
|
|
174
|
+
"home content"
|
|
166
175
|
],
|
|
167
|
-
"txt": "
|
|
176
|
+
"txt": "home content",
|
|
168
177
|
"jpgs": [
|
|
169
178
|
"wadus uri"
|
|
170
179
|
],
|
|
171
180
|
"txts": [
|
|
172
|
-
"
|
|
181
|
+
"home content"
|
|
173
182
|
]
|
|
174
183
|
},
|
|
175
184
|
"not_found": {
|
|
176
185
|
"title": "Not found",
|
|
177
|
-
"type": "
|
|
186
|
+
"type": "not_found",
|
|
187
|
+
"slug": "not_found",
|
|
178
188
|
"elements": [
|
|
179
189
|
|
|
180
190
|
],
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
assets: /assets_path
|
|
2
|
+
|
|
3
|
+
collection: subfolder 1
|
|
4
|
+
item: bbb
|
|
5
|
+
item: aaa
|
|
6
|
+
collection: subfolder 2
|
|
7
|
+
item: file 1
|
|
8
|
+
|
|
9
|
+
home title: fixtures
|
|
10
|
+
home jpg: wadus uri
|
|
11
|
+
home txt: home content
|
|
12
|
+
home description: home content
|
|
13
|
+
home file: wadus uri
|
|
14
|
+
home link: /
|
|
15
|
+
home slug:
|
|
@@ -6,8 +6,10 @@ assets: /assets_path
|
|
|
6
6
|
collection: subfolder 2
|
|
7
7
|
item: file 1
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
not_found title: Not found
|
|
10
|
+
not_found jpg: wadus uri
|
|
11
|
+
not_found txt: This is the not found item
|
|
12
|
+
not_found description: This is the not found item
|
|
13
|
+
not_found file: wadus uri
|
|
14
|
+
not_found link:
|
|
15
|
+
not_found slug: not_found
|
|
@@ -10,10 +10,16 @@ assets: {{assets}}
|
|
|
10
10
|
{{/home}}
|
|
11
11
|
|
|
12
12
|
{{#element}}
|
|
13
|
+
{{#home?}}
|
|
14
|
+
{{>home}}
|
|
15
|
+
{{/home?}}
|
|
13
16
|
{{#collection?}}
|
|
14
17
|
{{>collection}}
|
|
15
18
|
{{/collection?}}
|
|
16
19
|
{{#item?}}
|
|
17
20
|
{{>item}}
|
|
18
21
|
{{/item?}}
|
|
22
|
+
{{#not_found?}}
|
|
23
|
+
{{>not_found}}
|
|
24
|
+
{{/not_found?}}
|
|
19
25
|
{{/element}}
|
data/test/indexer_utils_test.rb
CHANGED
|
@@ -11,6 +11,23 @@ class IndexerUtilsTest < Test::Unit::TestCase
|
|
|
11
11
|
)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
def test_full_path_to_slug
|
|
15
|
+
assert_equal(
|
|
16
|
+
'pepe-y-jun',
|
|
17
|
+
Vitreous::Share::IndexerUtils.to_slug( '/folder 1/folder 2/001 pepe y juán.txt' )
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
assert_equal(
|
|
21
|
+
'',
|
|
22
|
+
Vitreous::Share::IndexerUtils.to_slug( '/' )
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
assert_equal(
|
|
26
|
+
'',
|
|
27
|
+
Vitreous::Share::IndexerUtils.to_slug( '' )
|
|
28
|
+
)
|
|
29
|
+
end
|
|
30
|
+
|
|
14
31
|
def test_to_slug
|
|
15
32
|
assert_equal(
|
|
16
33
|
'pepe-y-jun',
|
data/test/render_test.rb
CHANGED
|
@@ -41,7 +41,7 @@ class IndexerTest < Test::Unit::TestCase
|
|
|
41
41
|
assert_equal( File.read( "#{FIXTURES_PATH}/render_item.txt" ), result.body )
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
def
|
|
44
|
+
def test_render_home
|
|
45
45
|
index = JSON.load( File.read( "#{FIXTURES_PATH}/index.json" ) )
|
|
46
46
|
result =
|
|
47
47
|
Vitreous::Share::Render.render(
|
|
@@ -53,12 +53,12 @@ class IndexerTest < Test::Unit::TestCase
|
|
|
53
53
|
|
|
54
54
|
# # write fixture
|
|
55
55
|
# puts "This should be commented out!"
|
|
56
|
-
# File.open( "#{FIXTURES_PATH}/
|
|
56
|
+
# File.open( "#{FIXTURES_PATH}/render_home.txt", 'w' ) do |f|
|
|
57
57
|
# f.write result.body
|
|
58
58
|
# end
|
|
59
59
|
|
|
60
60
|
assert_equal( 200, result.status )
|
|
61
|
-
assert_equal( File.read( "#{FIXTURES_PATH}/
|
|
61
|
+
assert_equal( File.read( "#{FIXTURES_PATH}/render_home.txt" ), result.body )
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
def test_render_not_found
|
metadata
CHANGED
|
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
|
5
5
|
segments:
|
|
6
6
|
- 0
|
|
7
7
|
- 0
|
|
8
|
-
-
|
|
9
|
-
version: 0.0.
|
|
8
|
+
- 31
|
|
9
|
+
version: 0.0.31
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Fernando Guillen
|
|
@@ -14,7 +14,7 @@ autorequire:
|
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
16
|
|
|
17
|
-
date: 2011-08-
|
|
17
|
+
date: 2011-08-23 00:00:00 +02:00
|
|
18
18
|
default_executable:
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
@@ -173,13 +173,15 @@ files:
|
|
|
173
173
|
- test/fixtures/folder_structure/file 1.txt
|
|
174
174
|
- test/fixtures/index.json
|
|
175
175
|
- test/fixtures/render_collection.txt
|
|
176
|
+
- test/fixtures/render_home.txt
|
|
176
177
|
- test/fixtures/render_item.txt
|
|
177
178
|
- test/fixtures/render_not_found.txt
|
|
178
|
-
- test/fixtures/render_root.txt
|
|
179
179
|
- test/fixtures/structure.json
|
|
180
180
|
- test/fixtures/template/collection.html
|
|
181
|
+
- test/fixtures/template/home.html
|
|
181
182
|
- test/fixtures/template/item.html
|
|
182
183
|
- test/fixtures/template/layout.html
|
|
184
|
+
- test/fixtures/template/not_found.html
|
|
183
185
|
- test/index_searcher_test.rb
|
|
184
186
|
- test/indexer_test.rb
|
|
185
187
|
- test/indexer_utils_test.rb
|
|
@@ -241,13 +243,15 @@ test_files:
|
|
|
241
243
|
- test/fixtures/folder_structure/file 1.txt
|
|
242
244
|
- test/fixtures/index.json
|
|
243
245
|
- test/fixtures/render_collection.txt
|
|
246
|
+
- test/fixtures/render_home.txt
|
|
244
247
|
- test/fixtures/render_item.txt
|
|
245
248
|
- test/fixtures/render_not_found.txt
|
|
246
|
-
- test/fixtures/render_root.txt
|
|
247
249
|
- test/fixtures/structure.json
|
|
248
250
|
- test/fixtures/template/collection.html
|
|
251
|
+
- test/fixtures/template/home.html
|
|
249
252
|
- test/fixtures/template/item.html
|
|
250
253
|
- test/fixtures/template/layout.html
|
|
254
|
+
- test/fixtures/template/not_found.html
|
|
251
255
|
- test/index_searcher_test.rb
|
|
252
256
|
- test/indexer_test.rb
|
|
253
257
|
- test/indexer_utils_test.rb
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
assets: /assets_path
|
|
2
|
-
|
|
3
|
-
collection: subfolder 1
|
|
4
|
-
item: bbb
|
|
5
|
-
item: aaa
|
|
6
|
-
collection: subfolder 2
|
|
7
|
-
item: file 1
|
|
8
|
-
|
|
9
|
-
collection title: fixtures
|
|
10
|
-
collection jpg: wadus uri
|
|
11
|
-
collection txt: root content
|
|
12
|
-
collection description: root content
|
|
13
|
-
collection file: wadus uri
|