vitreous_share 0.0.13 → 0.0.15

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.
@@ -12,7 +12,7 @@ module Vitreous
12
12
  'link' => Vitreous::Share::IndexerUtils.to_link( e[0]['path'] ),
13
13
  'type' => e.any? { |e2| e2['type'] == 'directory' } ? 'collection' : 'item',
14
14
  'elements' => generate( e[0]['elements'].sort { |x, y| x['name'] <=> y['name'] } )
15
- }.merge( Vitreous::Share::IndexerUtils.meta( e ) )
15
+ }.merge( Vitreous::Share::IndexerUtils.meta_properties( e ) )
16
16
  end
17
17
  end
18
18
 
@@ -35,17 +35,21 @@ module Vitreous
35
35
  end
36
36
  end
37
37
 
38
- def self.meta( elements )
38
+ def self.meta_properties( elements )
39
39
  result = {}
40
40
 
41
41
  elements.select { |e| e['type'] == 'file' }.each do |e|
42
- ext_name = File.basename( e['path'] ).split( '.' )[-1]
43
- meta_ext_name = File.basename( e['path'] ).split( '.' )[1..-1].reverse.join( '_' )
42
+ ext_name = File.basename( e['path'] ).split( '.' )[-1]
43
+ multi_ext_name = File.basename( e['path'] ).split( '.' )[1..-1].reverse.join( '_' )
44
44
 
45
- if( ext_name =~ Vitreous::TXT_EXTENSIONS )
46
- result[meta_ext_name] = e['content']
45
+ if( ext_name == 'meta' )
46
+ result[multi_ext_name] = YAML.load( e['content'] )
47
+ elsif( ext_name =~ Vitreous::TXT_EXTENSIONS )
48
+ result['description'] ||= e['content']
49
+ result[multi_ext_name] = e['content']
47
50
  else
48
- result[meta_ext_name] = e['uri']
51
+ result['file'] ||= e['uri']
52
+ result[multi_ext_name] = e['uri']
49
53
  end
50
54
  end
51
55
 
@@ -1,5 +1,5 @@
1
1
  module Vitreous
2
2
  module Share
3
- VERSION = "0.0.13"
3
+ VERSION = "0.0.15"
4
4
  end
5
5
  end
@@ -1,3 +1,3 @@
1
1
  module Vitreous
2
- TXT_EXTENSIONS = /^(txt|md|html|meta)$/
2
+ TXT_EXTENSIONS = /^(txt|text|md|html|meta)$/
3
3
  end
@@ -0,0 +1,6 @@
1
+ title: This is my new title
2
+ collection: collection1
3
+ price: 10
4
+ summary: |
5
+ This is a summary
6
+ two lines long
@@ -15,11 +15,19 @@
15
15
  "elements": [
16
16
 
17
17
  ],
18
+ "file": "wadus uri",
18
19
  "jpg": "wadus uri",
20
+ "description": "file content",
19
21
  "txt": "file content",
22
+ "files": [
23
+ "wadus uri"
24
+ ],
20
25
  "jpgs": [
21
26
  "wadus uri"
22
27
  ],
28
+ "descriptions": [
29
+ "file content"
30
+ ],
23
31
  "txts": [
24
32
  "file content"
25
33
  ]
@@ -31,11 +39,19 @@
31
39
  "elements": [
32
40
 
33
41
  ],
42
+ "file": "wadus uri",
34
43
  "jpg": "wadus uri",
44
+ "description": "file content",
35
45
  "txt": "file content",
46
+ "files": [
47
+ "wadus uri"
48
+ ],
36
49
  "jpgs": [
37
50
  "wadus uri"
38
51
  ],
52
+ "descriptions": [
53
+ "file content"
54
+ ],
39
55
  "txts": [
40
56
  "file content"
41
57
  ]
@@ -52,7 +68,11 @@
52
68
  "elements": [
53
69
 
54
70
  ],
71
+ "description": "file content",
55
72
  "txt": "file content",
73
+ "descriptions": [
74
+ "file content"
75
+ ],
56
76
  "txts": [
57
77
  "file content"
58
78
  ]
@@ -60,11 +80,19 @@
60
80
  ]
61
81
  }
62
82
  ],
83
+ "file": "wadus uri",
63
84
  "jpg": "wadus uri",
85
+ "description": "file content",
64
86
  "txt": "file content",
87
+ "files": [
88
+ "wadus uri"
89
+ ],
65
90
  "jpgs": [
66
91
  "wadus uri"
67
92
  ],
93
+ "descriptions": [
94
+ "file content"
95
+ ],
68
96
  "txts": [
69
97
  "file content"
70
98
  ]
@@ -81,7 +109,11 @@
81
109
  "elements": [
82
110
 
83
111
  ],
112
+ "description": "file content",
84
113
  "txt": "file content",
114
+ "descriptions": [
115
+ "file content"
116
+ ],
85
117
  "txts": [
86
118
  "file content"
87
119
  ]
@@ -95,12 +127,34 @@
95
127
  "elements": [
96
128
 
97
129
  ],
130
+ "file": "wadus uri",
98
131
  "jpg": "wadus uri",
132
+ "meta": {
133
+ "title": "This is my new title",
134
+ "collection": "collection1",
135
+ "price": 10,
136
+ "summary": "This is a summary\ntwo lines long\n"
137
+ },
138
+ "description": "file content",
99
139
  "txt_thumb": "file content",
100
140
  "txt": "file content",
141
+ "files": [
142
+ "wadus uri"
143
+ ],
101
144
  "jpgs": [
102
145
  "wadus uri"
103
146
  ],
147
+ "metas": [
148
+ {
149
+ "title": "This is my new title",
150
+ "collection": "collection1",
151
+ "price": 10,
152
+ "summary": "This is a summary\ntwo lines long\n"
153
+ }
154
+ ],
155
+ "descriptions": [
156
+ "file content"
157
+ ],
104
158
  "txts": [
105
159
  "file content",
106
160
  "file content"
@@ -1,146 +1,156 @@
1
1
  {
2
2
  "name": "fixtures",
3
+ "path": "/",
3
4
  "uri": "wadus uri",
5
+ "type": "directory",
4
6
  "elements": [
5
7
  {
6
8
  "name": "01 subfolder 1",
9
+ "path": "/01 subfolder 1",
7
10
  "uri": "wadus uri",
11
+ "type": "directory",
8
12
  "elements": [
9
13
  {
10
14
  "name": "001 bbb.jpg",
15
+ "path": "/01 subfolder 1/001 bbb.jpg",
11
16
  "uri": "wadus uri",
17
+ "type": "file",
12
18
  "elements": [
13
19
 
14
20
  ],
15
- "type": "file",
16
- "content": null,
17
- "path": "/01 subfolder 1/001 bbb.jpg"
21
+ "content": null
18
22
  },
19
23
  {
20
24
  "name": "001 bbb.txt",
25
+ "path": "/01 subfolder 1/001 bbb.txt",
21
26
  "uri": "wadus uri",
27
+ "type": "file",
22
28
  "elements": [
23
29
 
24
30
  ],
25
- "type": "file",
26
- "content": "file content",
27
- "path": "/01 subfolder 1/001 bbb.txt"
31
+ "content": "file content"
28
32
  },
29
33
  {
30
34
  "name": "002 aaa.jpg",
35
+ "path": "/01 subfolder 1/002 aaa.jpg",
31
36
  "uri": "wadus uri",
37
+ "type": "file",
32
38
  "elements": [
33
39
 
34
40
  ],
35
- "type": "file",
36
- "content": null,
37
- "path": "/01 subfolder 1/002 aaa.jpg"
41
+ "content": null
38
42
  },
39
43
  {
40
44
  "name": "002 aaa.txt",
45
+ "path": "/01 subfolder 1/002 aaa.txt",
41
46
  "uri": "wadus uri",
47
+ "type": "file",
42
48
  "elements": [
43
49
 
44
50
  ],
45
- "type": "file",
46
- "content": "file content",
47
- "path": "/01 subfolder 1/002 aaa.txt"
51
+ "content": "file content"
48
52
  },
49
53
  {
50
54
  "name": "subsubfolder 1",
55
+ "path": "/01 subfolder 1/subsubfolder 1",
51
56
  "uri": "wadus uri",
57
+ "type": "directory",
52
58
  "elements": [
53
59
  {
54
60
  "name": "file 1.txt",
61
+ "path": "/01 subfolder 1/subsubfolder 1/file 1.txt",
55
62
  "uri": "wadus uri",
63
+ "type": "file",
56
64
  "elements": [
57
65
 
58
66
  ],
59
- "type": "file",
60
- "content": "file content",
61
- "path": "/01 subfolder 1/subsubfolder 1/file 1.txt"
67
+ "content": "file content"
62
68
  }
63
69
  ],
64
- "type": "directory",
65
- "content": null,
66
- "path": "/01 subfolder 1/subsubfolder 1"
70
+ "content": null
67
71
  }
68
72
  ],
69
- "type": "directory",
70
- "content": null,
71
- "path": "/01 subfolder 1"
73
+ "content": null
72
74
  },
73
75
  {
74
76
  "name": "01 subfolder 1.jpg",
77
+ "path": "/01 subfolder 1.jpg",
75
78
  "uri": "wadus uri",
79
+ "type": "file",
76
80
  "elements": [
77
81
 
78
82
  ],
79
- "type": "file",
80
- "content": null,
81
- "path": "/01 subfolder 1.jpg"
83
+ "content": null
82
84
  },
83
85
  {
84
86
  "name": "01 subfolder 1.txt",
87
+ "path": "/01 subfolder 1.txt",
85
88
  "uri": "wadus uri",
89
+ "type": "file",
86
90
  "elements": [
87
91
 
88
92
  ],
89
- "type": "file",
90
- "content": "file content",
91
- "path": "/01 subfolder 1.txt"
93
+ "content": "file content"
92
94
  },
93
95
  {
94
96
  "name": "02 subfolder 2",
97
+ "path": "/02 subfolder 2",
95
98
  "uri": "wadus uri",
99
+ "type": "directory",
96
100
  "elements": [
97
101
  {
98
102
  "name": "file 1.txt",
103
+ "path": "/02 subfolder 2/file 1.txt",
99
104
  "uri": "wadus uri",
105
+ "type": "file",
100
106
  "elements": [
101
107
 
102
108
  ],
103
- "type": "file",
104
- "content": "file content",
105
- "path": "/02 subfolder 2/file 1.txt"
109
+ "content": "file content"
106
110
  }
107
111
  ],
108
- "type": "directory",
109
- "content": null,
110
- "path": "/02 subfolder 2"
112
+ "content": null
111
113
  },
112
114
  {
113
115
  "name": "file 1.jpg",
116
+ "path": "/file 1.jpg",
114
117
  "uri": "wadus uri",
118
+ "type": "file",
115
119
  "elements": [
116
120
 
117
121
  ],
122
+ "content": null
123
+ },
124
+ {
125
+ "name": "file 1.meta",
126
+ "path": "/file 1.meta",
127
+ "uri": "wadus uri",
118
128
  "type": "file",
119
- "content": null,
120
- "path": "/file 1.jpg"
129
+ "elements": [
130
+
131
+ ],
132
+ "content": "title: This is my new title\ncollection: collection1\nprice: 10\nsummary: |\n This is a summary\n two lines long\n"
121
133
  },
122
134
  {
123
135
  "name": "file 1.thumb.txt",
136
+ "path": "/file 1.thumb.txt",
124
137
  "uri": "wadus uri",
138
+ "type": "file",
125
139
  "elements": [
126
140
 
127
141
  ],
128
- "type": "file",
129
- "content": "file content",
130
- "path": "/file 1.thumb.txt"
142
+ "content": "file content"
131
143
  },
132
144
  {
133
145
  "name": "file 1.txt",
146
+ "path": "/file 1.txt",
134
147
  "uri": "wadus uri",
148
+ "type": "file",
135
149
  "elements": [
136
150
 
137
151
  ],
138
- "type": "file",
139
- "content": "file content",
140
- "path": "/file 1.txt"
152
+ "content": "file content"
141
153
  }
142
154
  ],
143
- "type": "directory",
144
- "content": null,
145
- "path": "/"
155
+ "content": null
146
156
  }
@@ -54,7 +54,16 @@ class IndexerUtilsTest < Test::Unit::TestCase
54
54
  assert_equal( 3, groups.size )
55
55
  end
56
56
 
57
- def test_meta
57
+ def test_meta_properties
58
+ meta = <<-EOS
59
+ title: This is my new title
60
+ collection: collection1
61
+ price: 10
62
+ summary: |
63
+ This is a summary
64
+ two lines long
65
+ EOS
66
+
58
67
  structure = [
59
68
  {
60
69
  "type" => "file",
@@ -70,6 +79,13 @@ class IndexerUtilsTest < Test::Unit::TestCase
70
79
  "uri" => "http://dropbox.com/user/folder 1.txt",
71
80
  "name" => "folder 1.txt"
72
81
  },
82
+ {
83
+ "type" => "file",
84
+ "content" => meta,
85
+ "path" => "/folder 1.meta",
86
+ "uri" => "http://dropbox.com/user/folder 1.meta",
87
+ "name" => "folder 1.meta"
88
+ },
73
89
  {
74
90
  "type" => "directory",
75
91
  "content" => nil,
@@ -79,24 +95,34 @@ class IndexerUtilsTest < Test::Unit::TestCase
79
95
  }
80
96
  ]
81
97
 
82
- meta = Vitreous::Share::IndexerUtils.meta( structure )
98
+ meta_properties = Vitreous::Share::IndexerUtils.meta_properties( structure )
99
+
100
+ assert_equal( "http://dropbox.com/user/folder 1.jpg", meta_properties['jpg'] )
101
+ assert_equal( "file content", meta_properties['txt'] )
102
+ assert_equal( ["file content"], meta_properties['txts'] )
103
+ assert_equal( ["http://dropbox.com/user/folder 1.jpg"], meta_properties['jpgs'] )
104
+
105
+ # file/description
106
+ assert_equal( "http://dropbox.com/user/folder 1.jpg", meta_properties['file'] )
107
+ assert_equal( "file content", meta_properties['description'] )
83
108
 
84
- assert_equal( "http://dropbox.com/user/folder 1.jpg", meta['jpg'] )
85
- assert_equal( "file content", meta['txt'] )
86
- assert_equal( ["file content"], meta['txts'] )
87
- assert_equal( ["http://dropbox.com/user/folder 1.jpg"], meta['jpgs'] )
109
+ # meta
110
+ assert_equal( "This is my new title", meta_properties['meta']['title'] )
111
+ assert_equal( "collection1", meta_properties['meta']['collection'] )
112
+ assert_equal( 10, meta_properties['meta']['price'] )
113
+ assert_equal( "This is a summary\ntwo lines long\n", meta_properties['meta']['summary'] )
88
114
  end
89
115
 
90
116
  def test_meta_arrays
91
- meta = {
92
- 'jpg' => 'jpg',
93
- 'jpg_0' => 'jpg 0',
94
- 'jpg_1' => 'jpg 1',
95
- 'txt' => 'txt',
96
- 'txt_0' => 'txt 0'
117
+ meta_properties = {
118
+ 'jpg' => 'jpg',
119
+ 'jpg_0' => 'jpg 0',
120
+ 'jpg_1' => 'jpg 1',
121
+ 'txt' => 'txt',
122
+ 'txt_0' => 'txt 0'
97
123
  }
98
124
 
99
- meta_arrays = Vitreous::Share::IndexerUtils.meta_arrays( meta )
125
+ meta_arrays = Vitreous::Share::IndexerUtils.meta_arrays( meta_properties )
100
126
 
101
127
  assert_equal( ["txt", "txt 0"], meta_arrays['txts'] )
102
128
  assert_equal( ["jpg", "jpg 0", "jpg 1"], meta_arrays['jpgs'] )
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 13
9
- version: 0.0.13
8
+ - 15
9
+ version: 0.0.15
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-07-30 00:00:00 +02:00
17
+ date: 2011-08-07 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -162,6 +162,7 @@ files:
162
162
  - test/fixtures/folder_structure/01 subfolder 1/subsubfolder 1/file 1.txt
163
163
  - test/fixtures/folder_structure/02 subfolder 2/file 1.txt
164
164
  - test/fixtures/folder_structure/file 1.jpg
165
+ - test/fixtures/folder_structure/file 1.meta
165
166
  - test/fixtures/folder_structure/file 1.thumb.txt
166
167
  - test/fixtures/folder_structure/file 1.txt
167
168
  - test/fixtures/index.json
@@ -217,6 +218,7 @@ test_files:
217
218
  - test/fixtures/folder_structure/01 subfolder 1/subsubfolder 1/file 1.txt
218
219
  - test/fixtures/folder_structure/02 subfolder 2/file 1.txt
219
220
  - test/fixtures/folder_structure/file 1.jpg
221
+ - test/fixtures/folder_structure/file 1.meta
220
222
  - test/fixtures/folder_structure/file 1.thumb.txt
221
223
  - test/fixtures/folder_structure/file 1.txt
222
224
  - test/fixtures/index.json