valise 0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. data/doc/README +69 -0
  2. data/doc/Specification +72 -0
  3. data/doc/Specifications +81 -0
  4. data/doc/coverage/assets/0.5.3/app.js +88 -0
  5. data/doc/coverage/assets/0.5.3/fancybox/blank.gif +0 -0
  6. data/doc/coverage/assets/0.5.3/fancybox/fancy_close.png +0 -0
  7. data/doc/coverage/assets/0.5.3/fancybox/fancy_loading.png +0 -0
  8. data/doc/coverage/assets/0.5.3/fancybox/fancy_nav_left.png +0 -0
  9. data/doc/coverage/assets/0.5.3/fancybox/fancy_nav_right.png +0 -0
  10. data/doc/coverage/assets/0.5.3/fancybox/fancy_shadow_e.png +0 -0
  11. data/doc/coverage/assets/0.5.3/fancybox/fancy_shadow_n.png +0 -0
  12. data/doc/coverage/assets/0.5.3/fancybox/fancy_shadow_ne.png +0 -0
  13. data/doc/coverage/assets/0.5.3/fancybox/fancy_shadow_nw.png +0 -0
  14. data/doc/coverage/assets/0.5.3/fancybox/fancy_shadow_s.png +0 -0
  15. data/doc/coverage/assets/0.5.3/fancybox/fancy_shadow_se.png +0 -0
  16. data/doc/coverage/assets/0.5.3/fancybox/fancy_shadow_sw.png +0 -0
  17. data/doc/coverage/assets/0.5.3/fancybox/fancy_shadow_w.png +0 -0
  18. data/doc/coverage/assets/0.5.3/fancybox/fancy_title_left.png +0 -0
  19. data/doc/coverage/assets/0.5.3/fancybox/fancy_title_main.png +0 -0
  20. data/doc/coverage/assets/0.5.3/fancybox/fancy_title_over.png +0 -0
  21. data/doc/coverage/assets/0.5.3/fancybox/fancy_title_right.png +0 -0
  22. data/doc/coverage/assets/0.5.3/fancybox/fancybox-x.png +0 -0
  23. data/doc/coverage/assets/0.5.3/fancybox/fancybox-y.png +0 -0
  24. data/doc/coverage/assets/0.5.3/fancybox/fancybox.png +0 -0
  25. data/doc/coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.css +363 -0
  26. data/doc/coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.pack.js +44 -0
  27. data/doc/coverage/assets/0.5.3/favicon_green.png +0 -0
  28. data/doc/coverage/assets/0.5.3/favicon_red.png +0 -0
  29. data/doc/coverage/assets/0.5.3/favicon_yellow.png +0 -0
  30. data/doc/coverage/assets/0.5.3/highlight.css +129 -0
  31. data/doc/coverage/assets/0.5.3/highlight.pack.js +1 -0
  32. data/doc/coverage/assets/0.5.3/jquery-1.6.2.min.js +18 -0
  33. data/doc/coverage/assets/0.5.3/jquery.dataTables.min.js +152 -0
  34. data/doc/coverage/assets/0.5.3/jquery.timeago.js +141 -0
  35. data/doc/coverage/assets/0.5.3/jquery.url.js +174 -0
  36. data/doc/coverage/assets/0.5.3/loading.gif +0 -0
  37. data/doc/coverage/assets/0.5.3/magnify.png +0 -0
  38. data/doc/coverage/assets/0.5.3/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  39. data/doc/coverage/assets/0.5.3/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  40. data/doc/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  41. data/doc/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  42. data/doc/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  43. data/doc/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  44. data/doc/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  45. data/doc/coverage/assets/0.5.3/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  46. data/doc/coverage/assets/0.5.3/smoothness/images/ui-icons_222222_256x240.png +0 -0
  47. data/doc/coverage/assets/0.5.3/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  48. data/doc/coverage/assets/0.5.3/smoothness/images/ui-icons_454545_256x240.png +0 -0
  49. data/doc/coverage/assets/0.5.3/smoothness/images/ui-icons_888888_256x240.png +0 -0
  50. data/doc/coverage/assets/0.5.3/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  51. data/doc/coverage/assets/0.5.3/smoothness/jquery-ui-1.8.4.custom.css +295 -0
  52. data/doc/coverage/assets/0.5.3/stylesheet.css +383 -0
  53. data/doc/coverage/index.html +5843 -0
  54. data/doc/coverage/jquery-1.3.2.min.js +19 -0
  55. data/doc/coverage/jquery.tablesorter.min.js +15 -0
  56. data/doc/coverage/lib-fileset-errors_rb.html +231 -0
  57. data/doc/coverage/lib-fileset-item_rb.html +303 -0
  58. data/doc/coverage/lib-fileset-populator_rb.html +249 -0
  59. data/doc/coverage/lib-fileset-search-root_rb.html +1053 -0
  60. data/doc/coverage/lib-fileset-utils_rb.html +453 -0
  61. data/doc/coverage/lib-fileset_rb.html +789 -0
  62. data/doc/coverage/print.css +12 -0
  63. data/doc/coverage/rcov.js +42 -0
  64. data/doc/coverage/screen.css +270 -0
  65. data/lib/valise/errors.rb +30 -0
  66. data/lib/valise/item.rb +105 -0
  67. data/lib/valise/path-matcher.rb +113 -0
  68. data/lib/valise/search-root.rb +166 -0
  69. data/lib/valise/stack.rb +169 -0
  70. data/lib/valise/stem-decorator.rb +56 -0
  71. data/lib/valise/utils.rb +65 -0
  72. data/lib/valise.rb +219 -0
  73. data/spec/addable.rb +41 -0
  74. data/spec/dump_load.rb +32 -0
  75. data/spec/error_handling.rb +9 -0
  76. data/spec/fileset.rb +170 -0
  77. data/spec/glob_handling.rb +28 -0
  78. data/spec/item.rb +35 -0
  79. data/spec/merge_diff.rb +93 -0
  80. data/spec/population.rb +51 -0
  81. data/spec/search_root.rb +24 -0
  82. data/spec/stemming.rb +33 -0
  83. data/spec_help/file-sandbox.rb +164 -0
  84. data/spec_help/gem_test_suite.rb +17 -0
  85. data/spec_help/spec_helper.rb +3 -0
  86. data/spec_help/ungemmer.rb +37 -0
  87. metadata +220 -0
@@ -0,0 +1,12 @@
1
+ /* Hide controls */
2
+
3
+ body {
4
+ color: #000000;
5
+ background-color: #ffffff;
6
+ }
7
+
8
+ /* Hide controls */
9
+
10
+ div.filters {
11
+ display: none;
12
+ }
@@ -0,0 +1,42 @@
1
+ function toggleCode( id ) {
2
+ if ( document.getElementById ) {
3
+ elem = document.getElementById( id );
4
+ } else if ( document.all ) {
5
+ elem = eval( "document.all." + id );
6
+ } else {
7
+ return false;
8
+ }
9
+
10
+ elemStyle = elem.style;
11
+
12
+ if ( elemStyle.display != "block" ) {
13
+ elemStyle.display = "block";
14
+ } else {
15
+ elemStyle.display = "none";
16
+ }
17
+
18
+ return true;
19
+ }
20
+
21
+ function restripe() {
22
+ i = 0;
23
+ $('table#report_table tbody tr').each(function(){
24
+ if (this.style.display != "none") {
25
+ i += 1;
26
+ classes = this.className.split(" ");
27
+ if ($.inArray("even",classes) != -1) {
28
+ classes.splice($.inArray("even",classes),1);
29
+ } else if ($.inArray("odd",classes) != -1) {
30
+ classes.splice($.inArray("odd",classes),1);
31
+ }
32
+ if (i % 2 === 0) {
33
+ this.className = classes.join(" ") + " odd";
34
+ } else {
35
+ this.className = classes.join(" ") + " even";
36
+ }
37
+ }
38
+ });
39
+ }
40
+
41
+ // Fix IE's lack of support for indexOf (!)
42
+ if (!Array.indexOf) { Array.prototype.indexOf = function(obj){ for(var i=0; i<this.length; i++){ if(this[i]==obj){return i;} } return -1; }}
@@ -0,0 +1,270 @@
1
+ /* @group General */
2
+
3
+ body {
4
+ font-family: Verdana, Helvetica, Arial, Sans-Serif;
5
+ font-size: 12px;
6
+ color: #4C4C4C;
7
+ background-color: #F4F2ED;
8
+ padding: 1em;
9
+ }
10
+
11
+ a:link {
12
+ color: #191919;
13
+ }
14
+
15
+ a:visited {
16
+ color: #191919;
17
+ }
18
+
19
+ pre, code {
20
+ color: #000000;
21
+ font-family: "Bitstream Vera Sans Mono","Monaco","Courier New",monospace;
22
+ font-size: 95%;
23
+ line-height: 1.3em;
24
+ margin-top: 0;
25
+ margin-bottom: 0;
26
+ padding: 0;
27
+ word-wrap: break-word;
28
+ }
29
+
30
+ h1, h2, h3, h4, h5, h6 {
31
+ margin: 0em 0em 1em 0em;
32
+ color: #666666;
33
+ }
34
+
35
+ h1 {
36
+ display: block;
37
+ font-size: 2em;
38
+ letter-spacing: -1px;
39
+ }
40
+
41
+ h2 {
42
+ margin-top: -1em;
43
+ }
44
+
45
+ fieldset {
46
+ display: inline;
47
+ border: 0px;
48
+ padding: 0px;
49
+ margin-right: 1em;
50
+ }
51
+
52
+ div.filters {
53
+ margin-bottom: 1em;
54
+ }
55
+
56
+ .hidden {
57
+ display: none;
58
+ }
59
+
60
+ /* @end */
61
+
62
+ /* @group Cross-References */
63
+
64
+ span.cross-ref-title {
65
+ font-size: 140%;
66
+ }
67
+
68
+ span.cross-ref a {
69
+ text-decoration: none;
70
+ }
71
+
72
+ span.cross-ref {
73
+ background-color:#f3f7fa;
74
+ border: 1px dashed #333;
75
+ margin: 1em;
76
+ padding: 0.5em;
77
+ overflow: hidden;
78
+ }
79
+
80
+ a.crossref-toggle {
81
+ text-decoration: none;
82
+ }
83
+
84
+ /* @end */
85
+
86
+ /* @group Report Table */
87
+
88
+ div.report_table_wrapper {
89
+ min-width: 900px;
90
+ }
91
+
92
+ table.report {
93
+ border-collapse: collapse;
94
+ border: 1px solid #666666;
95
+ width: 100%;
96
+ margin-bottom: 1em;
97
+ }
98
+
99
+ table.report tr {
100
+ line-height: 1.75em;
101
+ }
102
+
103
+ table.report th {
104
+ background: #666666;
105
+ color: #ffffff;
106
+ text-align: right;
107
+ text-transform: uppercase;
108
+ font-size: .8em;
109
+ font-weight: bold;
110
+ padding: 0em .5em;
111
+ border: 1px solid #666666;
112
+ }
113
+
114
+ table.report tfoot tr {
115
+ background: #dddddd;
116
+ font-weight: bold;
117
+ padding: .5em;
118
+ border: 1px solid #666666;
119
+ }
120
+
121
+ th.left_align, td.left_align {
122
+ text-align: left !important;
123
+ }
124
+
125
+ th.right_align, td.right_align {
126
+ text-align: right;
127
+ padding-right: 2em !important;
128
+ }
129
+
130
+ table.report th.header:hover {
131
+ cursor: pointer;
132
+ text-decoration: underline;
133
+ }
134
+
135
+ table.report th.headerSortUp:after{
136
+ content: "\25BC";
137
+ margin-left: 1em;
138
+ }
139
+
140
+ table.report th.headerSortDown:after {
141
+ content: "\25B2";
142
+ margin-left: 1em;
143
+ }
144
+
145
+ table.report tr.summary_row {
146
+ background: #cccccc;
147
+ border: 1px solid #cccccc;
148
+ }
149
+
150
+ table.report tr.summary_row td {
151
+ padding-left: .2em !important;
152
+ color: #333333;
153
+ font-weight: bold;
154
+ }
155
+
156
+ table.report td {
157
+ padding: .2em .5em .2em .5em;
158
+ }
159
+
160
+ table.report td a {
161
+ text-decoration: none;
162
+ }
163
+
164
+ table.report tbody tr:hover {
165
+ background: #cccccc !important;
166
+ }
167
+
168
+ table.report tr.summary_row td {
169
+ border-bottom: 1px solid #aaaaaa;
170
+ }
171
+
172
+ table.report tr {
173
+ background-color: #eeeeee;
174
+ }
175
+
176
+ table.report tr.odd {
177
+ background-color: #dddddd;
178
+ }
179
+
180
+ /* @end */
181
+
182
+ /* @group Percentage Graphs */
183
+
184
+ div.percent_graph_legend {
185
+ width: 5.5em;
186
+ float: left;
187
+ margin: .5em 1em .5em 0em;
188
+ height: 1em;
189
+ line-height: 1em;
190
+ }
191
+
192
+ div.percent_graph {
193
+ height: 1em;
194
+ border: #333333 1px solid;
195
+ empty-cells: show;
196
+ padding: 0px;
197
+ border-collapse: collapse;
198
+ width: 100px !important;
199
+ float: left;
200
+ margin: .5em 1em .5em 0em;
201
+ }
202
+
203
+ div.percent_graph div {
204
+ float: left;
205
+ height: 1em;
206
+ padding: 0px !important;
207
+ }
208
+
209
+ div.percent_graph div.covered {
210
+ background: #649632;
211
+ }
212
+
213
+ div.percent_graph div.uncovered {
214
+ background: #a92730;
215
+ }
216
+
217
+ div.percent_graph div.NA {
218
+ background: #eaeaea;
219
+ }
220
+
221
+ /* @end */
222
+
223
+ /* @group Details page */
224
+
225
+ table.details {
226
+ margin-top: 1em;
227
+ border-collapse: collapse;
228
+ width: 100%;
229
+ border: 1px solid #666666;
230
+ }
231
+
232
+ table.details tr {
233
+ line-height: 1.75em;
234
+ }
235
+
236
+ table.details td {
237
+ padding: .25em;
238
+ }
239
+
240
+ span.inferred, span.inferred1, span.marked, span.marked1, span.uncovered, span.uncovered1 {
241
+ display: block;
242
+ padding: .25em;
243
+ }
244
+
245
+ tr.inferred td, span.inferred {
246
+ background-color: #e0dedb;
247
+ }
248
+
249
+ tr.inferred1 td, span.inferred1 {
250
+ background-color: #e0dedb;
251
+ }
252
+
253
+ tr.marked td, span.marked, span.marked1 {
254
+ background-color: #bed2be;
255
+ }
256
+
257
+ tr.uncovered td, span.uncovered {
258
+ background-color: #ce8b8c;
259
+ }
260
+
261
+ tr.uncovered1 td, span.uncovered1 {
262
+ background-color: #ce8b8c;
263
+ }
264
+
265
+ div.key {
266
+ border: 1px solid #666666;
267
+ margin: 1em 0em;
268
+ }
269
+
270
+ /* @end */
@@ -0,0 +1,30 @@
1
+ module Valise
2
+ class Error < ::Exception; end
3
+
4
+ class PathOutsideOfRoot < Error; end
5
+ class PathNotInRoot < Error; end
6
+ class PathNotFound < Error; end
7
+ class ReadOnly < Error; end
8
+ class VirtualSearchPath < Error; end
9
+ class MalformedTree < Error; end
10
+ class RootNotInSet < Error; end
11
+
12
+ class WouldClobber < Error
13
+ def initialize(item)
14
+ @item = item
15
+ super("Would clobber #{item.segments.inspect}")
16
+ end
17
+
18
+ attr_reader :item
19
+ end
20
+
21
+ class CantPopulate < Error
22
+ def initialize(item, cause)
23
+ @item = item
24
+ @original_exception = cause
25
+ super("Couldn't populate #{item.segments.inspect}: #{cause.class}: #{cause.message}")
26
+ end
27
+
28
+ attr_reader :item, :original_exception
29
+ end
30
+ end
@@ -0,0 +1,105 @@
1
+ require 'valise/utils'
2
+
3
+ module Valise
4
+ class Serialization
5
+ @@classes = {}
6
+
7
+ class << self
8
+ def [](index)
9
+ @@classes[index]
10
+ end
11
+
12
+ def register(index)
13
+ @@classes[index] = self
14
+ end
15
+ end
16
+
17
+ class Raw < Serialization
18
+ register :raw
19
+
20
+ def self.dump(value)
21
+ value
22
+ end
23
+
24
+ def self.load(raw)
25
+ raw
26
+ end
27
+ end
28
+
29
+ class YAML < Serialization
30
+ register :yaml
31
+
32
+ def self.dump(value)
33
+ ::YAML::dump(value)
34
+ end
35
+
36
+ def self.load(raw)
37
+ ::YAML::load(raw)
38
+ end
39
+ end
40
+ end
41
+
42
+ class Item
43
+ include Unpath
44
+
45
+ def initialize(stack, root, dump_load)
46
+ @stack = stack
47
+ @root = root
48
+ @dump_load = dump_load || Serialization::Raw
49
+ @contents = nil
50
+ end
51
+
52
+ attr_reader :stack, :root
53
+ attr_accessor :contents
54
+
55
+ def inspect
56
+ "#{@root.inspect}//#{@stack.inspect}"
57
+ end
58
+
59
+ def segments
60
+ @stack.segments
61
+ end
62
+
63
+ def full_path
64
+ @root.full_path(segments)
65
+ end
66
+
67
+ def writable?
68
+ @root.writable?(segments)
69
+ end
70
+
71
+ def present?
72
+ @root.present?(segments)
73
+ end
74
+
75
+ def raw_file
76
+ File::open(full_path)
77
+ end
78
+
79
+ def open(&block)
80
+ File::open(full_path, "r", &block)
81
+ end
82
+
83
+ def save
84
+ root.write(self)
85
+ end
86
+
87
+ def contents
88
+ return @stack.merged(self)
89
+ end
90
+
91
+ def contents=(value)
92
+ @contents = @stack.diffed(self, value)
93
+ save
94
+ @contents
95
+ end
96
+
97
+ def dump_contents
98
+ @dump_load.dump(load_contents) #@contents?
99
+ end
100
+
101
+ def load_contents
102
+ @contents ||= @dump_load.load(@root.get_from(self))
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,113 @@
1
+ require 'valise/utils'
2
+
3
+ module Valise
4
+ class PathMatcher
5
+ include Unpath
6
+
7
+ def initialize(segment = nil)
8
+ @children = []
9
+ @segment = segment
10
+ @value = nil
11
+ end
12
+
13
+ attr_reader :segment
14
+
15
+ def each_pair(prefix = [])
16
+ segments = prefix.dup
17
+ segments << @segment if @segment
18
+ @children.each do |child|
19
+ child.each_pair(segments) do |segments, value|
20
+ yield(segments, value)
21
+ end
22
+ end
23
+ yield(segments, @value) if @value
24
+ end
25
+
26
+ def merge!(other)
27
+ other.each_pair do |path, value|
28
+ self[path] = value
29
+ end
30
+ end
31
+
32
+ def [](path)
33
+ retreive(unpath(path))
34
+ end
35
+
36
+ def retreive(segments)
37
+ if segments.empty?
38
+ return @value
39
+ else
40
+ @children.each do |child|
41
+ val = child.access(segments)
42
+ return val unless val.nil?
43
+ end
44
+ end
45
+ return nil
46
+ end
47
+
48
+ def access(segments)
49
+ return retreive(segments.drop(1)) if match?(segments.first)
50
+ return nil
51
+ end
52
+
53
+ def match?(segment)
54
+ @segment == segment
55
+ end
56
+
57
+ def []=(pattern, result)
58
+ store(unpath(pattern), result)
59
+ end
60
+
61
+ def store(segments, result)
62
+ if segments.empty?
63
+ @value = result
64
+ else
65
+ index = segments.shift
66
+ target = @children.find {|child| child.segment == index } ||
67
+ case index
68
+ when "**"; DirGlob.new.tap{|m| @children << m}
69
+ when /^[*].*/; FileGlob.new(index).tap{|m| @children << m}
70
+ else; PathMatcher.new(index).tap{|m| @children << m}
71
+ end
72
+ target.store(segments, result)
73
+ end
74
+ end
75
+ end
76
+
77
+ class DirGlob < PathMatcher
78
+ def initialize
79
+ super('**')
80
+ end
81
+
82
+ def match?(segment)
83
+ true
84
+ end
85
+
86
+ def access(segments)
87
+ if segments.empty?
88
+ return nil
89
+ else
90
+ super || access(segments.drop(1))
91
+ end
92
+ end
93
+ end
94
+
95
+ class FileGlob < PathMatcher
96
+ def initialize(segment)
97
+ super
98
+ @regex = %r{.*#{segment.sub(/^[*]/,"")}$}
99
+ end
100
+
101
+ def match?(segment)
102
+ @regex =~ segment
103
+ end
104
+
105
+ def store(segments, result)
106
+ if segments.empty?
107
+ @value = result
108
+ else
109
+ raise "File globs can only be used as suffixes"
110
+ end
111
+ end
112
+ end
113
+ end