valise 0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/README +69 -0
- data/doc/Specification +72 -0
- data/doc/Specifications +81 -0
- data/doc/coverage/assets/0.5.3/app.js +88 -0
- data/doc/coverage/assets/0.5.3/fancybox/blank.gif +0 -0
- data/doc/coverage/assets/0.5.3/fancybox/fancy_close.png +0 -0
- data/doc/coverage/assets/0.5.3/fancybox/fancy_loading.png +0 -0
- data/doc/coverage/assets/0.5.3/fancybox/fancy_nav_left.png +0 -0
- data/doc/coverage/assets/0.5.3/fancybox/fancy_nav_right.png +0 -0
- data/doc/coverage/assets/0.5.3/fancybox/fancy_shadow_e.png +0 -0
- data/doc/coverage/assets/0.5.3/fancybox/fancy_shadow_n.png +0 -0
- data/doc/coverage/assets/0.5.3/fancybox/fancy_shadow_ne.png +0 -0
- data/doc/coverage/assets/0.5.3/fancybox/fancy_shadow_nw.png +0 -0
- data/doc/coverage/assets/0.5.3/fancybox/fancy_shadow_s.png +0 -0
- data/doc/coverage/assets/0.5.3/fancybox/fancy_shadow_se.png +0 -0
- data/doc/coverage/assets/0.5.3/fancybox/fancy_shadow_sw.png +0 -0
- data/doc/coverage/assets/0.5.3/fancybox/fancy_shadow_w.png +0 -0
- data/doc/coverage/assets/0.5.3/fancybox/fancy_title_left.png +0 -0
- data/doc/coverage/assets/0.5.3/fancybox/fancy_title_main.png +0 -0
- data/doc/coverage/assets/0.5.3/fancybox/fancy_title_over.png +0 -0
- data/doc/coverage/assets/0.5.3/fancybox/fancy_title_right.png +0 -0
- data/doc/coverage/assets/0.5.3/fancybox/fancybox-x.png +0 -0
- data/doc/coverage/assets/0.5.3/fancybox/fancybox-y.png +0 -0
- data/doc/coverage/assets/0.5.3/fancybox/fancybox.png +0 -0
- data/doc/coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.css +363 -0
- data/doc/coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.pack.js +44 -0
- data/doc/coverage/assets/0.5.3/favicon_green.png +0 -0
- data/doc/coverage/assets/0.5.3/favicon_red.png +0 -0
- data/doc/coverage/assets/0.5.3/favicon_yellow.png +0 -0
- data/doc/coverage/assets/0.5.3/highlight.css +129 -0
- data/doc/coverage/assets/0.5.3/highlight.pack.js +1 -0
- data/doc/coverage/assets/0.5.3/jquery-1.6.2.min.js +18 -0
- data/doc/coverage/assets/0.5.3/jquery.dataTables.min.js +152 -0
- data/doc/coverage/assets/0.5.3/jquery.timeago.js +141 -0
- data/doc/coverage/assets/0.5.3/jquery.url.js +174 -0
- data/doc/coverage/assets/0.5.3/loading.gif +0 -0
- data/doc/coverage/assets/0.5.3/magnify.png +0 -0
- data/doc/coverage/assets/0.5.3/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/doc/coverage/assets/0.5.3/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/doc/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/doc/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/doc/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/doc/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/doc/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/doc/coverage/assets/0.5.3/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/doc/coverage/assets/0.5.3/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/doc/coverage/assets/0.5.3/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/doc/coverage/assets/0.5.3/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/doc/coverage/assets/0.5.3/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/doc/coverage/assets/0.5.3/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/doc/coverage/assets/0.5.3/smoothness/jquery-ui-1.8.4.custom.css +295 -0
- data/doc/coverage/assets/0.5.3/stylesheet.css +383 -0
- data/doc/coverage/index.html +5843 -0
- data/doc/coverage/jquery-1.3.2.min.js +19 -0
- data/doc/coverage/jquery.tablesorter.min.js +15 -0
- data/doc/coverage/lib-fileset-errors_rb.html +231 -0
- data/doc/coverage/lib-fileset-item_rb.html +303 -0
- data/doc/coverage/lib-fileset-populator_rb.html +249 -0
- data/doc/coverage/lib-fileset-search-root_rb.html +1053 -0
- data/doc/coverage/lib-fileset-utils_rb.html +453 -0
- data/doc/coverage/lib-fileset_rb.html +789 -0
- data/doc/coverage/print.css +12 -0
- data/doc/coverage/rcov.js +42 -0
- data/doc/coverage/screen.css +270 -0
- data/lib/valise/errors.rb +30 -0
- data/lib/valise/item.rb +105 -0
- data/lib/valise/path-matcher.rb +113 -0
- data/lib/valise/search-root.rb +166 -0
- data/lib/valise/stack.rb +169 -0
- data/lib/valise/stem-decorator.rb +56 -0
- data/lib/valise/utils.rb +65 -0
- data/lib/valise.rb +219 -0
- data/spec/addable.rb +41 -0
- data/spec/dump_load.rb +32 -0
- data/spec/error_handling.rb +9 -0
- data/spec/fileset.rb +170 -0
- data/spec/glob_handling.rb +28 -0
- data/spec/item.rb +35 -0
- data/spec/merge_diff.rb +93 -0
- data/spec/population.rb +51 -0
- data/spec/search_root.rb +24 -0
- data/spec/stemming.rb +33 -0
- data/spec_help/file-sandbox.rb +164 -0
- data/spec_help/gem_test_suite.rb +17 -0
- data/spec_help/spec_helper.rb +3 -0
- data/spec_help/ungemmer.rb +37 -0
- metadata +220 -0
data/doc/README
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
== Fileset
|
2
|
+
=== Simple file management
|
3
|
+
|
4
|
+
Applications tend to need preferences and configuration files, which can be a bit of a pain to maintain. Fileset allows you to describe a directory structure with raw files or YAML documents, and then populate the local directories of the install target.
|
5
|
+
|
6
|
+
=== Features
|
7
|
+
|
8
|
+
With FileSet you get the following things:
|
9
|
+
* Default file contents
|
10
|
+
* Search paths
|
11
|
+
* Even simpler file access
|
12
|
+
|
13
|
+
=== Usage
|
14
|
+
|
15
|
+
Essentially, FileSet lets you do this:
|
16
|
+
|
17
|
+
==== Search paths
|
18
|
+
|
19
|
+
set = FileSet.new([""] + %w{etc myapp}, %w{~ .myapp}, %{.myapp})
|
20
|
+
|
21
|
+
When you create a fileset, the directories you give it define where in the
|
22
|
+
filesystem it will work.
|
23
|
+
|
24
|
+
Throughout, FileSet uses arrays of strings to reference files, which is a little cheaper when manipulating file paths, and slightly more platform agnostic than strings delimited by '/'. Development so far has been entirely in Linux, so I'd imagine this will work pretty well on OS X, and mostly all right on Windows - although I wouldn't expect Windows-style %ESCAPES% to work.
|
25
|
+
|
26
|
+
==== Definition
|
27
|
+
set.define do
|
28
|
+
dir 'www' do
|
29
|
+
file 'index.html', align(<<-EOF)
|
30
|
+
<<<
|
31
|
+
<html><body>
|
32
|
+
<h1 class="ironic">Sparse Docco</h1>
|
33
|
+
</body></html>
|
34
|
+
EOF
|
35
|
+
end
|
36
|
+
|
37
|
+
dir 'conf' do
|
38
|
+
yaml_file 'uses.yaml', {'count' => 1001}
|
39
|
+
end
|
40
|
+
|
41
|
+
dir 'empty'
|
42
|
+
end
|
43
|
+
|
44
|
+
A few features:
|
45
|
+
* a simple DSL for definition of files
|
46
|
+
* Basic text or yaml file definition
|
47
|
+
* Left flush alignment of file text (aligned an optional '<<<')
|
48
|
+
* Definition blocks can be repeated, as can dir blocks, so the FileSet can be handed around to different program modules to collect their file requirements
|
49
|
+
|
50
|
+
==== Filesystem population
|
51
|
+
set.populate
|
52
|
+
|
53
|
+
This step creates directories and writes files. The first directory listed in the search path used to initialize the FileSet that can be written to is the destination for the files. The intention is that an administrator will be able to deploy system-wide configuration, while users will still be able to install default configs in their home directories.
|
54
|
+
|
55
|
+
FileSet::populate won't overwrite existing files, so re-populating won't wipe out the configuration changes your users have made.
|
56
|
+
|
57
|
+
FileSet::populate is intentionally left as a separate step, so that it can be initiated as appropriate to the application. Some apps may want to populate automatically every time they're run, others might want to wait for a commandline switch.
|
58
|
+
|
59
|
+
If populate is never run, the default values in the define block will be returned if the files are read.
|
60
|
+
|
61
|
+
==== File access
|
62
|
+
set.load(%w{www index.html}) #=> "<html><body>...."
|
63
|
+
conf = set.get_file(%w{conf uses.yaml})
|
64
|
+
conf.contents['count'] += 1
|
65
|
+
conf.store
|
66
|
+
|
67
|
+
FileSet#load returns the contents of the file: either a string or the data stored in the YAML document.
|
68
|
+
|
69
|
+
FileSet#get_file returns a wrapper that allows the contents of the file to be accessed, changed, and then rewritten with FileSet#store.
|
data/doc/Specification
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
|
2
|
+
FileSet error cases
|
3
|
+
|
4
|
+
FileSet
|
5
|
+
should be a FileSet::Set
|
6
|
+
retrieving files
|
7
|
+
should get default text files
|
8
|
+
should get text files from library files
|
9
|
+
should get default nested files
|
10
|
+
should get text files from filesystem
|
11
|
+
|
12
|
+
FileSet - the unpath method:
|
13
|
+
state => ["state"]
|
14
|
+
a File => #path
|
15
|
+
|
16
|
+
FileSet
|
17
|
+
FileSet::Populator
|
18
|
+
should populate successfully
|
19
|
+
FileSet::ReversePopulator
|
20
|
+
should populate successfully
|
21
|
+
|
22
|
+
FileSet
|
23
|
+
should be addable
|
24
|
+
should add in order
|
25
|
+
|
26
|
+
FileSet::Item
|
27
|
+
full_path
|
28
|
+
should be an instance of FileSet::DefinedDefaults (FAILED - 1)
|
29
|
+
raw_file
|
30
|
+
(FAILED - 2)
|
31
|
+
contents
|
32
|
+
(FAILED - 3)
|
33
|
+
#contents=
|
34
|
+
should save contents (FAILED - 4)
|
35
|
+
should make contents available (FAILED - 5)
|
36
|
+
contents
|
37
|
+
should == "testing"
|
38
|
+
|
39
|
+
Failures:
|
40
|
+
|
41
|
+
1) FileSet::Item full_path
|
42
|
+
Failure/Error: its (:full_path) { should == "./root/item" }
|
43
|
+
TypeError:
|
44
|
+
can't convert String into Array
|
45
|
+
# ./spec/item.rb:11
|
46
|
+
|
47
|
+
2) FileSet::Item raw_file
|
48
|
+
Failure/Error: its (:raw_file) { should == File::open("./root/item") }
|
49
|
+
TypeError:
|
50
|
+
can't convert String into Array
|
51
|
+
# ./spec/item.rb:12
|
52
|
+
|
53
|
+
3) FileSet::Item contents
|
54
|
+
Failure/Error: its (:contents) { should == nil }
|
55
|
+
TypeError:
|
56
|
+
can't convert String into Array
|
57
|
+
# ./spec/item.rb:13
|
58
|
+
|
59
|
+
4) FileSet::Item#contents= should save contents
|
60
|
+
Failure/Error: subject.save
|
61
|
+
TypeError:
|
62
|
+
can't convert String into Array
|
63
|
+
# ./spec/item.rb:23
|
64
|
+
|
65
|
+
5) FileSet::Item#contents= should make contents available
|
66
|
+
Failure/Error: subject.save
|
67
|
+
TypeError:
|
68
|
+
can't convert String into Array
|
69
|
+
# ./spec/item.rb:28
|
70
|
+
|
71
|
+
Finished in 0.33091 seconds
|
72
|
+
17 examples, 5 failures
|
data/doc/Specifications
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
|
2
|
+
Valise error conditions
|
3
|
+
HandlerCollision is raised
|
4
|
+
[33m when a file handler collides from the same path (PENDING: Not Yet Implemented)[0m
|
5
|
+
[33m when a file handler collides with a glob path (PENDING: Not Yet Implemented)[0m
|
6
|
+
[33m when two Valises are added with a handler for the same path (PENDING: Not Yet Implemented)[0m
|
7
|
+
|
8
|
+
Valise
|
9
|
+
merge
|
10
|
+
[32m should merge values from the bottom[0m
|
11
|
+
[32m should obscure values from lower down[0m
|
12
|
+
[32m should prefer topmost value[0m
|
13
|
+
[32m should prefer top nil to bottom value[0m
|
14
|
+
[32m should do a deep merge[0m
|
15
|
+
diff
|
16
|
+
[32m should reduce actual contents of an item to minimal[0m
|
17
|
+
[32m should mask missing keys[0m
|
18
|
+
|
19
|
+
Valise with stemming
|
20
|
+
[32m should find a file in a stemed dir[0m
|
21
|
+
[32m should find a file in a stemed dir defined in a block[0m
|
22
|
+
[32m should find a file in a normal dir behind stemming[0m
|
23
|
+
|
24
|
+
Valise::SearchRoot
|
25
|
+
[32m should find a file in the root[0m
|
26
|
+
[32m should raise PathNotInRoot if path isn't in root[0m
|
27
|
+
|
28
|
+
Valise
|
29
|
+
[32m should be a Valise::Set[0m
|
30
|
+
retrieving files
|
31
|
+
[32m should get default text files[0m
|
32
|
+
[32m should get text files from library files[0m
|
33
|
+
[32m should get default nested files[0m
|
34
|
+
[32m should get text files from filesystem[0m
|
35
|
+
|
36
|
+
Valise - the unpath method:
|
37
|
+
[32m state => ["state"][0m
|
38
|
+
[32m a File => #path[0m
|
39
|
+
|
40
|
+
Valise
|
41
|
+
population
|
42
|
+
[32m should populate successfully[0m
|
43
|
+
reverse population
|
44
|
+
[32m should populate successfully[0m
|
45
|
+
|
46
|
+
Valise glob handling
|
47
|
+
[32m should recognize based on a full path[0m
|
48
|
+
[32m should recognize base on a file glob[0m
|
49
|
+
[32m should recognize based on a path glob[0m
|
50
|
+
|
51
|
+
Valise
|
52
|
+
[32m should store data as YAML[0m
|
53
|
+
[32m should load data from YAML[0m
|
54
|
+
|
55
|
+
Valise
|
56
|
+
[32m should be addable[0m
|
57
|
+
[32m should add in order[0m
|
58
|
+
[32m should combine file handlers[0m
|
59
|
+
|
60
|
+
Invidual items in the set
|
61
|
+
full_path
|
62
|
+
[32m should == "root/item"[0m
|
63
|
+
#contents=
|
64
|
+
[32m raw_file[0m
|
65
|
+
[32m should make contents available[0m
|
66
|
+
contents
|
67
|
+
[32m should == "testing"[0m
|
68
|
+
|
69
|
+
Pending:
|
70
|
+
[33m Valise error conditions HandlerCollision is raised when a file handler collides from the same path[0m
|
71
|
+
[36m # Not Yet Implemented[0m
|
72
|
+
[36m # [0m
|
73
|
+
[33m Valise error conditions HandlerCollision is raised when a file handler collides with a glob path[0m
|
74
|
+
[36m # Not Yet Implemented[0m
|
75
|
+
[36m # [0m
|
76
|
+
[33m Valise error conditions HandlerCollision is raised when two Valises are added with a handler for the same path[0m
|
77
|
+
[36m # Not Yet Implemented[0m
|
78
|
+
[36m # [0m
|
79
|
+
|
80
|
+
Finished in 0.38578 seconds
|
81
|
+
[33m36 examples, 0 failures, 3 pending[0m
|
@@ -0,0 +1,88 @@
|
|
1
|
+
$(document).ready(function() {
|
2
|
+
// Configuration for fancy sortable tables for source file groups
|
3
|
+
$('.file_list').dataTable({
|
4
|
+
"aaSorting": [[ 1, "asc" ]],
|
5
|
+
"bPaginate": false,
|
6
|
+
"bJQueryUI": true,
|
7
|
+
"aoColumns": [
|
8
|
+
null,
|
9
|
+
{ "sType": "percent" },
|
10
|
+
null,
|
11
|
+
null,
|
12
|
+
null,
|
13
|
+
null,
|
14
|
+
null
|
15
|
+
]
|
16
|
+
});
|
17
|
+
|
18
|
+
// Syntax highlight all files up front - deactivated
|
19
|
+
// $('.source_table pre code').each(function(i, e) {hljs.highlightBlock(e, ' ')});
|
20
|
+
|
21
|
+
// Syntax highlight source files on first toggle of the file view popup
|
22
|
+
$("a.src_link").click(function() {
|
23
|
+
// Get the source file element that corresponds to the clicked element
|
24
|
+
var source_table = $($(this).attr('href'));
|
25
|
+
|
26
|
+
// If not highlighted yet, do it!
|
27
|
+
if (!source_table.hasClass('highlighted')) {
|
28
|
+
source_table.find('pre code').each(function(i, e) {hljs.highlightBlock(e, ' ')});
|
29
|
+
source_table.addClass('highlighted');
|
30
|
+
};
|
31
|
+
});
|
32
|
+
|
33
|
+
// Set-up of popup for source file views
|
34
|
+
$("a.src_link").fancybox({
|
35
|
+
'hideOnContentClick': true,
|
36
|
+
'centerOnScroll': true,
|
37
|
+
'width': '90%',
|
38
|
+
'padding': 0,
|
39
|
+
'transitionIn': 'elastic'
|
40
|
+
});
|
41
|
+
|
42
|
+
// Hide src files and file list container after load
|
43
|
+
$('.source_files').hide();
|
44
|
+
$('.file_list_container').hide();
|
45
|
+
|
46
|
+
// Add tabs based upon existing file_list_containers
|
47
|
+
$('.file_list_container h2').each(function(){
|
48
|
+
var container_id = $(this).parent().attr('id');
|
49
|
+
var group_name = $(this).find('.group_name').first().html();
|
50
|
+
var covered_percent = $(this).find('.covered_percent').first().html();
|
51
|
+
|
52
|
+
$('.group_tabs').append('<li><a href="#' + container_id + '">' + group_name + ' ('+ covered_percent +')</a></li>');
|
53
|
+
});
|
54
|
+
|
55
|
+
$('.group_tabs a').each( function() {
|
56
|
+
$(this).addClass($(this).attr('href').replace('#', ''));
|
57
|
+
});
|
58
|
+
|
59
|
+
// Make sure tabs don't get ugly focus borders when active
|
60
|
+
$('.group_tabs a').live('focus', function() { $(this).blur(); });
|
61
|
+
|
62
|
+
var favicon_path = $('link[rel="shortcut icon"]').attr('href');
|
63
|
+
$('.group_tabs a').live('click', function(){
|
64
|
+
if (!$(this).parent().hasClass('active')) {
|
65
|
+
$('.group_tabs a').parent().removeClass('active');
|
66
|
+
$(this).parent().addClass('active');
|
67
|
+
$('.file_list_container').hide();
|
68
|
+
$(".file_list_container" + $(this).attr('href')).show();
|
69
|
+
window.location.href = window.location.href.split('#')[0] + $(this).attr('href').replace('#', '#_');
|
70
|
+
|
71
|
+
// Force favicon reload - otherwise the location change containing anchor would drop the favicon...
|
72
|
+
// Works only on firefox, but still... - Anyone know a better solution to force favicon on local file?
|
73
|
+
$('link[rel="shortcut icon"]').remove();
|
74
|
+
$('head').append('<link rel="shortcut icon" type="image/png" href="'+ favicon_path +'" />');
|
75
|
+
};
|
76
|
+
return false;
|
77
|
+
});
|
78
|
+
|
79
|
+
if (jQuery.url.attr('anchor')) {
|
80
|
+
$('.group_tabs a.'+jQuery.url.attr('anchor').replace('_', '')).click();
|
81
|
+
} else {
|
82
|
+
$('.group_tabs a:first').click();
|
83
|
+
};
|
84
|
+
|
85
|
+
$("abbr.timeago").timeago();
|
86
|
+
$('#loading').fadeOut();
|
87
|
+
$('#wrapper').show();
|
88
|
+
});
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|