vitreous_share 0.0.17 → 0.0.19

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/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ # Text version
2
+
3
+ This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
4
+
5
+ # HTML version
6
+
7
+ <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png" /></a><br /><span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Vitreous Component</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="http://vitreous.co" property="cc:attributionName" rel="cc:attributionURL">Fernando Guillen & Juan Jose Vidal</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="http://vitreous.co" rel="dct:source">vitreous.co</a>.
@@ -5,19 +5,34 @@ module Vitreous
5
5
  @structure = structure
6
6
  end
7
7
 
8
- def generate( structure = [@structure] )
8
+ def generate
9
+ structure = @structure
10
+
11
+ {
12
+ 'title' => Vitreous::Share::IndexerUtils.to_title( structure['name'] ),
13
+ 'link' => Vitreous::Share::IndexerUtils.to_link( structure['path'] ),
14
+ 'type' => 'collection',
15
+ 'elements' => tree( structure['elements'].select { |e| !(e['name'] =~ /^_root\./) }.sort { |x, y| x['name'] <=> y['name'] } )
16
+ }.merge(
17
+ Vitreous::Share::IndexerUtils.meta_properties(
18
+ structure['elements'].select { |e| e['name'] =~ /^_root\./ }
19
+ )
20
+ )
21
+ end
22
+
23
+ def tree( structure )
9
24
  Vitreous::Share::IndexerUtils.grouping( structure ).values.map do |e|
10
25
  {
11
26
  'title' => Vitreous::Share::IndexerUtils.to_title( e[0]['name'] ),
12
27
  'link' => Vitreous::Share::IndexerUtils.to_link( e[0]['path'] ),
13
28
  'type' => e.any? { |e2| e2['type'] == 'directory' } ? 'collection' : 'item',
14
- 'elements' => generate( e[0]['elements'].sort { |x, y| x['name'] <=> y['name'] } )
29
+ 'elements' => tree( e[0]['elements'].sort { |x, y| x['name'] <=> y['name'] } )
15
30
  }.merge( Vitreous::Share::IndexerUtils.meta_properties( e ) )
16
31
  end
17
32
  end
18
33
 
19
34
  def json
20
- JSON.pretty_generate( generate[0] )
35
+ JSON.pretty_generate( generate )
21
36
  end
22
37
  end
23
38
  end
@@ -1,5 +1,5 @@
1
1
  module Vitreous
2
2
  module Share
3
- VERSION = "0.0.17"
3
+ VERSION = "0.0.19"
4
4
  end
5
5
  end
File without changes
@@ -0,0 +1 @@
1
+ root content
@@ -160,5 +160,21 @@
160
160
  "file content"
161
161
  ]
162
162
  }
163
+ ],
164
+ "file": "wadus uri",
165
+ "jpg": "wadus uri",
166
+ "description": "root content",
167
+ "txt": "root content",
168
+ "files": [
169
+ "wadus uri"
170
+ ],
171
+ "jpgs": [
172
+ "wadus uri"
173
+ ],
174
+ "descriptions": [
175
+ "root content"
176
+ ],
177
+ "txts": [
178
+ "root content"
163
179
  ]
164
180
  }
@@ -111,6 +111,26 @@
111
111
  ],
112
112
  "content": null
113
113
  },
114
+ {
115
+ "name": "_root.jpg",
116
+ "path": "/_root.jpg",
117
+ "uri": "wadus uri",
118
+ "type": "file",
119
+ "elements": [
120
+
121
+ ],
122
+ "content": null
123
+ },
124
+ {
125
+ "name": "_root.txt",
126
+ "path": "/_root.txt",
127
+ "uri": "wadus uri",
128
+ "type": "file",
129
+ "elements": [
130
+
131
+ ],
132
+ "content": "root content"
133
+ },
114
134
  {
115
135
  "name": "file 1.jpg",
116
136
  "path": "/file 1.jpg",
data/test/indexer_test.rb CHANGED
@@ -7,7 +7,11 @@ class IndexerTest < Test::Unit::TestCase
7
7
  JSON.load( File.read( "#{FIXTURES_PATH}/structure.json" ) )
8
8
  )
9
9
 
10
- assert( indexer.generate.is_a? Array )
10
+ index = indexer.generate
11
+
12
+ assert( index.is_a? Hash )
13
+ assert_equal( 'fixtures', index['title'] )
14
+ assert_equal( '/', index['link'] )
11
15
  end
12
16
 
13
17
  def test_json
@@ -51,7 +51,7 @@ class IndexerUtilsTest < Test::Unit::TestCase
51
51
  structure = JSON.load( File.read( "#{FIXTURES_PATH}/structure.json" ) )
52
52
 
53
53
  groups = Vitreous::Share::IndexerUtils.grouping( structure['elements'] )
54
- assert_equal( 3, groups.size )
54
+ assert_equal( 4, groups.size )
55
55
  end
56
56
 
57
57
  def test_meta_properties
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 17
9
- version: 0.0.17
8
+ - 19
9
+ version: 0.0.19
10
10
  platform: ruby
11
11
  authors:
12
12
  - Fernando Guillen
@@ -138,6 +138,7 @@ files:
138
138
  - .gitignore
139
139
  - .rvmrc
140
140
  - Gemfile
141
+ - LICENSE.md
141
142
  - README.md
142
143
  - Rakefile
143
144
  - lib/vitreous/share/common_structure.rb
@@ -161,6 +162,8 @@ files:
161
162
  - test/fixtures/folder_structure/01 subfolder 1/002 aaa.txt
162
163
  - test/fixtures/folder_structure/01 subfolder 1/subsubfolder 1/file 1.txt
163
164
  - test/fixtures/folder_structure/02 subfolder 2/file 1.txt
165
+ - test/fixtures/folder_structure/_root.jpg
166
+ - test/fixtures/folder_structure/_root.txt
164
167
  - test/fixtures/folder_structure/file 1.jpg
165
168
  - test/fixtures/folder_structure/file 1.meta
166
169
  - test/fixtures/folder_structure/file 1.thumb.txt
@@ -217,6 +220,8 @@ test_files:
217
220
  - test/fixtures/folder_structure/01 subfolder 1/002 aaa.txt
218
221
  - test/fixtures/folder_structure/01 subfolder 1/subsubfolder 1/file 1.txt
219
222
  - test/fixtures/folder_structure/02 subfolder 2/file 1.txt
223
+ - test/fixtures/folder_structure/_root.jpg
224
+ - test/fixtures/folder_structure/_root.txt
220
225
  - test/fixtures/folder_structure/file 1.jpg
221
226
  - test/fixtures/folder_structure/file 1.meta
222
227
  - test/fixtures/folder_structure/file 1.thumb.txt