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
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
@@ -0,0 +1,81 @@
1
+
2
+ Valise error conditions
3
+ HandlerCollision is raised
4
+  when a file handler collides from the same path (PENDING: Not Yet Implemented)
5
+  when a file handler collides with a glob path (PENDING: Not Yet Implemented)
6
+  when two Valises are added with a handler for the same path (PENDING: Not Yet Implemented)
7
+
8
+ Valise
9
+ merge
10
+  should merge values from the bottom
11
+  should obscure values from lower down
12
+  should prefer topmost value
13
+  should prefer top nil to bottom value
14
+  should do a deep merge
15
+ diff
16
+  should reduce actual contents of an item to minimal
17
+  should mask missing keys
18
+
19
+ Valise with stemming
20
+  should find a file in a stemed dir
21
+  should find a file in a stemed dir defined in a block
22
+  should find a file in a normal dir behind stemming
23
+
24
+ Valise::SearchRoot
25
+  should find a file in the root
26
+  should raise PathNotInRoot if path isn't in root
27
+
28
+ Valise
29
+  should be a Valise::Set
30
+ retrieving files
31
+  should get default text files
32
+  should get text files from library files
33
+  should get default nested files
34
+  should get text files from filesystem
35
+
36
+ Valise - the unpath method:
37
+  state => ["state"]
38
+  a File => #path
39
+
40
+ Valise
41
+ population
42
+  should populate successfully
43
+ reverse population
44
+  should populate successfully
45
+
46
+ Valise glob handling
47
+  should recognize based on a full path
48
+  should recognize base on a file glob
49
+  should recognize based on a path glob
50
+
51
+ Valise
52
+  should store data as YAML
53
+  should load data from YAML
54
+
55
+ Valise
56
+  should be addable
57
+  should add in order
58
+  should combine file handlers
59
+
60
+ Invidual items in the set
61
+ full_path
62
+  should == "root/item"
63
+ #contents=
64
+  raw_file
65
+  should make contents available
66
+ contents
67
+  should == "testing"
68
+
69
+ Pending:
70
+  Valise error conditions HandlerCollision is raised when a file handler collides from the same path
71
+  # Not Yet Implemented
72
+  # 
73
+  Valise error conditions HandlerCollision is raised when a file handler collides with a glob path
74
+  # Not Yet Implemented
75
+  # 
76
+  Valise error conditions HandlerCollision is raised when two Valises are added with a handler for the same path
77
+  # Not Yet Implemented
78
+  # 
79
+
80
+ Finished in 0.38578 seconds
81
+ 36 examples, 0 failures, 3 pending
@@ -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
+ });