valise 0.5 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/README +17 -12
- data/lib/valise/stack.rb +1 -1
- data/spec/merge_diff.rb +6 -5
- metadata +4 -4
data/doc/README
CHANGED
@@ -1,27 +1,32 @@
|
|
1
|
-
==
|
1
|
+
== Valise
|
2
2
|
=== Simple file management
|
3
3
|
|
4
|
-
Applications tend to need preferences and configuration files, which can be a bit of a pain to maintain.
|
4
|
+
Applications tend to need preferences and configuration files, which can be a bit of a pain to maintain. Valise allows you to describe a directory structure with raw files or YAML documents, and then populate the local directories of the install target.
|
5
5
|
|
6
6
|
=== Features
|
7
7
|
|
8
|
-
With
|
8
|
+
With Valise::Set you get the following things:
|
9
9
|
* Default file contents
|
10
10
|
* Search paths
|
11
11
|
* Even simpler file access
|
12
12
|
|
13
13
|
=== Usage
|
14
14
|
|
15
|
-
Essentially,
|
15
|
+
Essentially, Valise::Set lets you do this:
|
16
16
|
|
17
17
|
==== Search paths
|
18
18
|
|
19
|
-
set =
|
19
|
+
set = Valise::Set.define do
|
20
|
+
rw %w{.myapp}
|
21
|
+
rw %w{~ .myapp}
|
22
|
+
rw [""] + %w{etc myapp}
|
23
|
+
ro from_here("myapp_defaults")
|
24
|
+
end
|
20
25
|
|
21
26
|
When you create a fileset, the directories you give it define where in the
|
22
27
|
filesystem it will work.
|
23
28
|
|
24
|
-
Throughout,
|
29
|
+
Throughout, Valise::Set 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
30
|
|
26
31
|
==== Definition
|
27
32
|
set.define do
|
@@ -45,16 +50,16 @@ A few features:
|
|
45
50
|
* a simple DSL for definition of files
|
46
51
|
* Basic text or yaml file definition
|
47
52
|
* Left flush alignment of file text (aligned an optional '<<<')
|
48
|
-
* Definition blocks can be repeated, as can dir blocks, so the
|
53
|
+
* Definition blocks can be repeated, as can dir blocks, so the Valise::Set can be handed around to different program modules to collect their file requirements
|
49
54
|
|
50
55
|
==== Filesystem population
|
51
56
|
set.populate
|
52
57
|
|
53
|
-
This step creates directories and writes files. The first directory listed in the search path used to initialize the
|
58
|
+
This step creates directories and writes files. The first directory listed in the search path used to initialize the Valise::Set 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
59
|
|
55
|
-
|
60
|
+
Valise::Set::populate won't overwrite existing files, so re-populating won't wipe out the configuration changes your users have made.
|
56
61
|
|
57
|
-
|
62
|
+
Valise::Set::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
63
|
|
59
64
|
If populate is never run, the default values in the define block will be returned if the files are read.
|
60
65
|
|
@@ -64,6 +69,6 @@ If populate is never run, the default values in the define block will be returne
|
|
64
69
|
conf.contents['count'] += 1
|
65
70
|
conf.store
|
66
71
|
|
67
|
-
|
72
|
+
Valise::Set#load returns the contents of the file: either a string or the data stored in the YAML document.
|
68
73
|
|
69
|
-
|
74
|
+
Valise::Set#get_file returns a wrapper that allows the contents of the file to be accessed, changed, and then rewritten with Valise::Set#store.
|
data/lib/valise/stack.rb
CHANGED
data/spec/merge_diff.rb
CHANGED
@@ -21,14 +21,15 @@ describe Valise do
|
|
21
21
|
sandbox.new :directory => "base/test"
|
22
22
|
sandbox.new :directory => "layer2/test"
|
23
23
|
sandbox.new :directory => "layer3/test"
|
24
|
-
sandbox
|
25
|
-
sandbox
|
26
|
-
sandbox
|
24
|
+
sandbox["base/test/file"].contents = YAML::dump(bottom_hash)
|
25
|
+
sandbox["layer2/test/file"].contents = YAML::dump(middle_hash)
|
26
|
+
sandbox["layer3/test/file"].contents = YAML::dump(top_hash)
|
27
27
|
|
28
28
|
Valise::Set.define do
|
29
29
|
handle "test/file", :yaml, :hash_merge
|
30
30
|
rw "layer3"
|
31
31
|
rw "layer2"
|
32
|
+
rw "missing"
|
32
33
|
rw "base"
|
33
34
|
end
|
34
35
|
end
|
@@ -55,7 +56,7 @@ describe Valise do
|
|
55
56
|
top_hash[:a] = 1
|
56
57
|
|
57
58
|
item.contents.should == {:a => 1}
|
58
|
-
item.stack.map{|stack| stack.contents[:a]}.should == [1,2,3]
|
59
|
+
item.stack.map{|stack| stack.contents[:a]}.should == [1,2,3,3]
|
59
60
|
end
|
60
61
|
|
61
62
|
it "should prefer top nil to bottom value" do
|
@@ -69,7 +70,7 @@ describe Valise do
|
|
69
70
|
middle_hash[:a] = {:a => {:a => 2}}
|
70
71
|
top_hash[:a] = {:a => {:a => 1}}
|
71
72
|
|
72
|
-
item.stack.map{|stack| stack.contents[:a][:a][:a]}.should == [1,2,3]
|
73
|
+
item.stack.map{|stack| stack.contents[:a][:a][:a]}.should == [1,2,3,3]
|
73
74
|
end
|
74
75
|
end
|
75
76
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: valise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: "0.
|
5
|
+
version: "0.6"
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Judson Lester
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-03-08 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: corundum
|
@@ -191,7 +191,7 @@ rdoc_options:
|
|
191
191
|
- --main
|
192
192
|
- doc/README
|
193
193
|
- --title
|
194
|
-
- valise-0.
|
194
|
+
- valise-0.6 RDoc
|
195
195
|
require_paths:
|
196
196
|
- lib/
|
197
197
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -199,7 +199,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
199
199
|
requirements:
|
200
200
|
- - ">="
|
201
201
|
- !ruby/object:Gem::Version
|
202
|
-
hash:
|
202
|
+
hash: 940501423
|
203
203
|
segments:
|
204
204
|
- 0
|
205
205
|
version: "0"
|