valise 0.9.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/valise/adapters/tilt.rb +1 -1
- data/lib/valise/errors.rb +2 -1
- data/lib/valise/path-matcher.rb +32 -107
- data/lib/valise/search-root.rb +12 -22
- data/lib/valise/set/definer.rb +2 -2
- data/lib/valise/set.rb +16 -8
- data/lib/valise/stack/extensions-decorator.rb +5 -4
- data/lib/valise/stack.rb +4 -4
- data/lib/valise/stem-decorator.rb +8 -5
- data/lib/valise/utils.rb +82 -63
- data/spec/fileset.rb +1 -1
- data/spec/population.rb +2 -2
- data/spec_help/spec_helper.rb +4 -0
- metadata +12 -13
- data/lib/valise/debugging.rb +0 -19
data/lib/valise/adapters/tilt.rb
CHANGED
data/lib/valise/errors.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Valise
|
2
2
|
module Errors
|
3
|
-
class Error < ::
|
3
|
+
class Error < ::StandardError; end
|
4
4
|
|
5
5
|
class PathOutsideOfRoot < Error; end
|
6
6
|
class PathNotInRoot < Error; end
|
@@ -11,6 +11,7 @@ module Valise
|
|
11
11
|
class MalformedTree < Error; end
|
12
12
|
class RootNotInSet < Error; end
|
13
13
|
class UnderIndented < Error; end
|
14
|
+
class NoMatchingPath < Error; end
|
14
15
|
|
15
16
|
class UnregisteredStrategy < Error
|
16
17
|
def initialize(klass, type)
|
data/lib/valise/path-matcher.rb
CHANGED
@@ -6,131 +6,56 @@ module Valise
|
|
6
6
|
include Enumerable
|
7
7
|
|
8
8
|
def self.build(path, value = true)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
when String, Array
|
13
|
-
matcher = PathMatcher.new
|
14
|
-
matcher[path] = value
|
15
|
-
return matcher
|
16
|
-
else
|
17
|
-
raise ArgumentError, "Path matchers can only be built from arrays or strings"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def initialize(segment = nil)
|
22
|
-
@children = []
|
23
|
-
@segment = segment
|
24
|
-
@value = nil
|
9
|
+
return path if PathMatcher === path
|
10
|
+
path = Unpath::make_pathname(path).to_s
|
11
|
+
self.new(path, value)
|
25
12
|
end
|
26
13
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
segments = prefix.dup
|
31
|
-
segments << @segment if @segment
|
32
|
-
@children.each do |child|
|
33
|
-
child.each_pair(segments) do |segments, value|
|
34
|
-
yield(segments, value)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
yield(segments, @value) if @value
|
38
|
-
end
|
39
|
-
|
40
|
-
def each(prefix = [])
|
41
|
-
each_pair do |segments, value|
|
42
|
-
yield(segments) if !!value
|
43
|
-
end
|
14
|
+
def initialize(first_pattern=nil, first_value=true)
|
15
|
+
@pattern_pairs = []
|
16
|
+
set(first_pattern, first_value) unless first_pattern.nil?
|
44
17
|
end
|
45
18
|
|
46
|
-
def
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
def [](path)
|
53
|
-
retreive(unpath(path))
|
19
|
+
def ===(path)
|
20
|
+
path = make_pathname(path)
|
21
|
+
fetch(path)
|
22
|
+
return true
|
23
|
+
rescue KeyError
|
24
|
+
return false
|
54
25
|
end
|
55
26
|
|
56
|
-
def
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
@children.each do |child|
|
61
|
-
val = child.access(segments)
|
62
|
-
return val unless val.nil?
|
27
|
+
def fetch(path)
|
28
|
+
@pattern_pairs.each do |pattern, value|
|
29
|
+
if path.fnmatch?(pattern)
|
30
|
+
return value
|
63
31
|
end
|
64
32
|
end
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
def access(segments)
|
69
|
-
return retreive(segments.drop(1)) if match?(segments.first)
|
70
|
-
return nil
|
33
|
+
raise KeyError, "No pattern matches #{path.to_s}"
|
71
34
|
end
|
72
35
|
|
73
|
-
def
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
def []=(pattern, result)
|
78
|
-
store(unpath(pattern), result)
|
79
|
-
end
|
80
|
-
|
81
|
-
def ===(path)
|
82
|
-
return !!self[path]
|
36
|
+
def [](path)
|
37
|
+
fetch(path)
|
38
|
+
rescue KeyError
|
39
|
+
nil
|
83
40
|
end
|
84
41
|
|
85
|
-
def
|
86
|
-
|
87
|
-
|
88
|
-
else
|
89
|
-
index = segments.shift
|
90
|
-
target = @children.find {|child| child.segment == index } ||
|
91
|
-
case index
|
92
|
-
when "**"; DirGlob.new.tap{|m| @children << m}
|
93
|
-
when /.*[*].*/; FileGlob.new(index).tap{|m| @children << m}
|
94
|
-
else; PathMatcher.new(index).tap{|m| @children.unshift m}
|
95
|
-
end
|
96
|
-
target.store(segments, result)
|
42
|
+
def set(pattern, value)
|
43
|
+
@pattern_pairs.delete_if do |old_pattern, _|
|
44
|
+
pattern == old_pattern
|
97
45
|
end
|
46
|
+
@pattern_pairs << [pattern.to_s, value]
|
98
47
|
end
|
99
|
-
|
100
|
-
|
101
|
-
class DirGlob < PathMatcher
|
102
|
-
def initialize
|
103
|
-
super('**')
|
104
|
-
end
|
48
|
+
alias []= set
|
105
49
|
|
106
|
-
def
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
def access(segments)
|
111
|
-
if segments.empty?
|
112
|
-
return @value
|
113
|
-
else
|
114
|
-
retreive(segments) || access(segments.drop(1))
|
50
|
+
def each_pair
|
51
|
+
@pattern_pairs.each do |pattern, value|
|
52
|
+
yield pattern, value
|
115
53
|
end
|
116
54
|
end
|
117
|
-
end
|
118
|
-
|
119
|
-
class FileGlob < PathMatcher
|
120
|
-
def initialize(segment)
|
121
|
-
super
|
122
|
-
@regex = %r{^#{segment.gsub(/[.]/, "[.]").gsub(/[*]/,".*")}$}
|
123
|
-
end
|
124
|
-
|
125
|
-
def match?(segment)
|
126
|
-
@regex =~ segment
|
127
|
-
end
|
128
55
|
|
129
|
-
def
|
130
|
-
|
131
|
-
|
132
|
-
else
|
133
|
-
raise ArgumentError, "File globs can only be used as suffixes"
|
56
|
+
def merge!(other)
|
57
|
+
other.each_pair do |pattern, value|
|
58
|
+
set(pattern, value)
|
134
59
|
end
|
135
60
|
end
|
136
61
|
end
|
data/lib/valise/search-root.rb
CHANGED
@@ -10,33 +10,23 @@ module Valise
|
|
10
10
|
include Enumerable
|
11
11
|
|
12
12
|
def initialize(path)
|
13
|
-
@segments =
|
13
|
+
@segments = make_pathname(path)
|
14
14
|
end
|
15
15
|
|
16
16
|
attr_accessor :segments
|
17
17
|
|
18
|
-
#ALL_FILES = PathMatcher.build('**')
|
19
18
|
def each(pathmatch = nil)
|
20
|
-
|
21
|
-
# files = pathmatch.fnmatchers(@segments).inject([]) do |list, fnmatch|
|
22
|
-
# list + Dir.glob(fnmatch).find_all{|path| File::file?(path)}
|
23
|
-
# end
|
24
|
-
# pathmatch.sort(files).each
|
25
|
-
#
|
26
|
-
#
|
27
|
-
paths = [[]]
|
19
|
+
paths = [make_pathname("")]
|
28
20
|
until paths.empty?
|
29
21
|
rel = paths.shift
|
30
|
-
path =
|
22
|
+
path = @segments + rel
|
31
23
|
#symlinks?
|
32
|
-
if
|
33
|
-
|
34
|
-
|
35
|
-
next if entry == ".."
|
36
|
-
paths.push(rel + [entry])
|
24
|
+
if path.directory?
|
25
|
+
paths += path.children(false).map do |child|
|
26
|
+
rel + child
|
37
27
|
end
|
38
|
-
elsif
|
39
|
-
yield
|
28
|
+
elsif path.file?
|
29
|
+
yield rel
|
40
30
|
end
|
41
31
|
end
|
42
32
|
end
|
@@ -50,7 +40,7 @@ module Valise
|
|
50
40
|
end
|
51
41
|
|
52
42
|
def full_path(segments)
|
53
|
-
|
43
|
+
(@segments + make_pathname(segments)).to_s
|
54
44
|
end
|
55
45
|
|
56
46
|
def write(item)
|
@@ -96,7 +86,7 @@ module Valise
|
|
96
86
|
end
|
97
87
|
|
98
88
|
def full_path(segments)
|
99
|
-
"<DEFAULTS>:" +
|
89
|
+
"<DEFAULTS>:" + segments.to_s
|
100
90
|
end
|
101
91
|
|
102
92
|
def present?(segments)
|
@@ -105,7 +95,7 @@ module Valise
|
|
105
95
|
|
106
96
|
def each
|
107
97
|
@files.each_key do |path|
|
108
|
-
yield(
|
98
|
+
yield(make_pathname(path))
|
109
99
|
end
|
110
100
|
end
|
111
101
|
|
@@ -133,7 +123,7 @@ module Valise
|
|
133
123
|
end
|
134
124
|
check_path.pop
|
135
125
|
end
|
136
|
-
@files[path] = contents
|
126
|
+
@files[make_pathname(path)] = contents
|
137
127
|
end
|
138
128
|
|
139
129
|
def add_dir(path)
|
data/lib/valise/set/definer.rb
CHANGED
@@ -7,7 +7,7 @@ module Valise
|
|
7
7
|
class StemmedDefiner
|
8
8
|
include Unpath
|
9
9
|
def initialize(path, set)
|
10
|
-
@segments =
|
10
|
+
@segments = make_pathname(path)
|
11
11
|
@target = set
|
12
12
|
end
|
13
13
|
|
@@ -43,7 +43,7 @@ module Valise
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def handle(path, serialization, merge_diff = nil)
|
46
|
-
@target.add_handler(
|
46
|
+
@target.add_handler(make_pathname(path),
|
47
47
|
serialization,
|
48
48
|
merge_diff)
|
49
49
|
end
|
data/lib/valise/set.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'valise/debugging'
|
2
1
|
require 'valise/errors'
|
3
2
|
require 'valise/search-root'
|
4
3
|
require 'valise/utils'
|
@@ -10,7 +9,6 @@ require 'valise/set/extensions-decorator'
|
|
10
9
|
|
11
10
|
module Valise
|
12
11
|
class Set
|
13
|
-
include Debugging
|
14
12
|
include Enumerable
|
15
13
|
include Unpath
|
16
14
|
|
@@ -24,8 +22,8 @@ module Valise
|
|
24
22
|
search_roots.inspect
|
25
23
|
end
|
26
24
|
|
27
|
-
def to_s
|
28
|
-
search_roots.map(&:to_s).join(":")
|
25
|
+
def to_s(joiner=nil)
|
26
|
+
search_roots.map(&:to_s).join(joiner||":")
|
29
27
|
end
|
30
28
|
|
31
29
|
def exts(*extensions)
|
@@ -49,7 +47,7 @@ module Valise
|
|
49
47
|
end
|
50
48
|
|
51
49
|
def sub_set(path)
|
52
|
-
segments =
|
50
|
+
segments = make_pathname(path)
|
53
51
|
transform do |roots|
|
54
52
|
roots.map do |root|
|
55
53
|
new_root = root.dup
|
@@ -60,7 +58,7 @@ module Valise
|
|
60
58
|
end
|
61
59
|
|
62
60
|
def stemmed(path)
|
63
|
-
segments =
|
61
|
+
segments = make_pathname(path)
|
64
62
|
transform do |roots|
|
65
63
|
roots.map do |root|
|
66
64
|
StemDecorator.new(segments, root)
|
@@ -102,7 +100,13 @@ module Valise
|
|
102
100
|
search_roots << search_root
|
103
101
|
end
|
104
102
|
|
103
|
+
def clean_pattern(pattern)
|
104
|
+
#deprecation warning maybe
|
105
|
+
pattern.sub(%r{^[*][*]/[*]}, '**')
|
106
|
+
end
|
107
|
+
|
105
108
|
def add_handler(segments, serialization_class, merge_diff_class)
|
109
|
+
segments = clean_pattern(segments)
|
106
110
|
add_serialization_handler(segments, serialization_class)
|
107
111
|
add_merge_handler(segments, merge_diff_class)
|
108
112
|
end
|
@@ -133,13 +137,13 @@ module Valise
|
|
133
137
|
:serialization=, :serialization
|
134
138
|
|
135
139
|
def merge_diff_for(stack)
|
136
|
-
type, options = *(merge_diff[
|
140
|
+
type, options = *(merge_diff[make_pathname(stack.segments)] || [])
|
137
141
|
options = (options || {}).merge(:stack => stack)
|
138
142
|
Strategies::MergeDiff.instance(type, options)
|
139
143
|
end
|
140
144
|
|
141
145
|
def serialization_for(stack)
|
142
|
-
type, options = *serialization[
|
146
|
+
type, options = *serialization[make_pathname(stack.segments)]
|
143
147
|
Strategies::Serialization.instance(type, options)
|
144
148
|
end
|
145
149
|
|
@@ -160,6 +164,10 @@ module Valise
|
|
160
164
|
get(path).find
|
161
165
|
end
|
162
166
|
|
167
|
+
def contents(path)
|
168
|
+
find(path).contents
|
169
|
+
end
|
170
|
+
|
163
171
|
def each(&block)
|
164
172
|
search_roots.each(&block)
|
165
173
|
end
|
@@ -6,7 +6,9 @@ module Valise
|
|
6
6
|
def initialize(stack)
|
7
7
|
@stack = stack
|
8
8
|
@extensions = []
|
9
|
-
@stacks = Hash.new
|
9
|
+
@stacks = Hash.new do |h,segments|
|
10
|
+
h[segments] = @stack.valise.get(segments)
|
11
|
+
end
|
10
12
|
end
|
11
13
|
|
12
14
|
attr_accessor :extensions
|
@@ -41,9 +43,8 @@ module Valise
|
|
41
43
|
return enum_for(:each) unless block_given?
|
42
44
|
@stack.each do |item|
|
43
45
|
@extensions.each do |ext|
|
44
|
-
dir = item.segments.
|
45
|
-
|
46
|
-
ext_stack = @stacks[dir + [file + ext]]
|
46
|
+
dir, file = *item.segments.split
|
47
|
+
ext_stack = @stacks[dir + (file.to_s + ext)]
|
47
48
|
yield(ext_stack.item_for(item.root))
|
48
49
|
end
|
49
50
|
end
|
data/lib/valise/stack.rb
CHANGED
@@ -9,18 +9,18 @@ module Valise
|
|
9
9
|
include ItemEnum
|
10
10
|
|
11
11
|
def inspect
|
12
|
-
"<default>:#{(@segments||%
|
12
|
+
"<default>:#{(@segments||%{?})} #{@valise.inspect}"
|
13
13
|
end
|
14
14
|
|
15
15
|
def initialize(path, set)
|
16
|
-
@segments =
|
16
|
+
@segments = make_pathname(path)
|
17
17
|
@valise = set
|
18
18
|
end
|
19
19
|
|
20
20
|
attr_reader :segments, :valise
|
21
21
|
|
22
22
|
def rel_path
|
23
|
-
|
23
|
+
@segments
|
24
24
|
end
|
25
25
|
|
26
26
|
def merge_diff
|
@@ -58,7 +58,7 @@ module Valise
|
|
58
58
|
def find
|
59
59
|
item = present.first
|
60
60
|
return item unless item.nil?
|
61
|
-
raise Errors::NotFound, "#{rel_path} not found in #{
|
61
|
+
raise Errors::NotFound, "'#{rel_path}' not found in #{valise.inspect}"
|
62
62
|
end
|
63
63
|
|
64
64
|
def exts(*extensions)
|
@@ -19,18 +19,21 @@ module Valise
|
|
19
19
|
@search_root.segments = segments
|
20
20
|
end
|
21
21
|
|
22
|
+
def stem_pattern
|
23
|
+
(@stem + "**").to_s
|
24
|
+
end
|
25
|
+
|
22
26
|
def under_stem(path)
|
23
|
-
segments =
|
24
|
-
|
25
|
-
|
26
|
-
return segments[@stem.length..-1]
|
27
|
+
segments = make_pathname(path)
|
28
|
+
if path.fnmatch?(stem_pattern)
|
29
|
+
return path.relative_path_from(@stem)
|
27
30
|
else
|
28
31
|
raise Errors::PathOutsideOfRoot
|
29
32
|
end
|
30
33
|
end
|
31
34
|
|
32
35
|
def inspect
|
33
|
-
"#{self.class.name.split(":").last}:[#{@stem.
|
36
|
+
"#{self.class.name.split(":").last}:[#{@stem.to_s}]#{@search_root.inspect}"
|
34
37
|
end
|
35
38
|
|
36
39
|
def each
|
data/lib/valise/utils.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'valise/errors'
|
3
|
+
|
1
4
|
module Valise
|
2
5
|
module StringTools
|
3
6
|
def align(string)
|
@@ -17,13 +20,8 @@ module Valise
|
|
17
20
|
module_function :align
|
18
21
|
end
|
19
22
|
|
20
|
-
#XXX This has been overtaken by std-lib Pathname and should be mostly
|
21
|
-
#refactored out
|
22
23
|
module Unpath
|
23
|
-
|
24
|
-
return string if string.empty?
|
25
|
-
string.split(::File::Separator)
|
26
|
-
end
|
24
|
+
extend self
|
27
25
|
|
28
26
|
def file_from_backtrace(line)
|
29
27
|
/(.*):\d+/.match(line)[1]
|
@@ -31,88 +29,109 @@ module Valise
|
|
31
29
|
|
32
30
|
def from_here(rel_path, base_path = nil)
|
33
31
|
base_path ||= file_from_backtrace(caller[0])
|
34
|
-
|
32
|
+
make_pathname(base_path) + make_pathname(rel_path)
|
33
|
+
end
|
34
|
+
|
35
|
+
def starting_directory
|
36
|
+
make_pathname(ENV['PWD'] || Dir.pwd)
|
37
|
+
#Otherwise symlinks won't behave as expected
|
38
|
+
end
|
39
|
+
alias start_dir starting_directory
|
40
|
+
|
41
|
+
def current_directory
|
42
|
+
make_pathname(Dir.pwd)
|
35
43
|
end
|
36
44
|
|
37
|
-
def up_to(up_to
|
45
|
+
def up_to(up_to=nil, base_path = nil)
|
38
46
|
base_path ||= file_from_backtrace(caller[0])
|
39
47
|
up_to ||= "lib"
|
40
48
|
|
41
|
-
|
42
|
-
|
43
|
-
until base_path.empty? or base_path.last == up_to
|
44
|
-
base_path.pop
|
49
|
+
up_until(base_path, "Path with basename #{up_to.inspect}") do |path|
|
50
|
+
path.basename.to_s == up_to
|
45
51
|
end
|
52
|
+
end
|
46
53
|
|
47
|
-
|
48
|
-
|
49
|
-
end
|
54
|
+
class WorkspaceFinder
|
55
|
+
include Unpath
|
50
56
|
|
51
|
-
|
52
|
-
end
|
57
|
+
attr_accessor :search_from, :workspace_children, :description, :fallback
|
53
58
|
|
54
|
-
|
55
|
-
|
56
|
-
parts = parts[0]
|
59
|
+
def search_from
|
60
|
+
@search_from ||= start_dir
|
57
61
|
end
|
58
62
|
|
59
|
-
|
60
|
-
|
61
|
-
if (parts.find{|part| not (String === part or Symbol === part)}.nil?)
|
62
|
-
parts = parts.map{|part| string_to_segments(part.to_s)}.flatten
|
63
|
-
else
|
64
|
-
raise ArgumentError, "path must be composed of strings or symbols"
|
65
|
-
end
|
66
|
-
when String
|
67
|
-
parts = string_to_segments(parts)
|
68
|
-
when Symbol
|
69
|
-
parts = string_to_segments(parts.to_s)
|
70
|
-
when ::File
|
71
|
-
parts = parts.path
|
72
|
-
parts = parts.split(::File::Separator)
|
73
|
-
else
|
74
|
-
raise ArgumentError, "path must be String, Array of Strings or File"
|
63
|
+
def workspace_children
|
64
|
+
@workspace_children ||= %w{.git .hg _MTN}
|
75
65
|
end
|
76
66
|
|
77
|
-
|
78
|
-
|
67
|
+
def description
|
68
|
+
@description ||= "Version control workspace"
|
79
69
|
end
|
80
70
|
|
81
|
-
|
82
|
-
|
71
|
+
def search_start
|
72
|
+
path = make_pathname(search_from)
|
73
|
+
path = path.realpath unless path.absolute?
|
74
|
+
path
|
75
|
+
end
|
83
76
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
if collapsed.empty?
|
91
|
-
collapsed.push segment
|
92
|
-
end
|
93
|
-
when '..'
|
94
|
-
if collapsed.empty?
|
95
|
-
collapsed.push segment
|
96
|
-
else
|
97
|
-
collapsed.pop
|
77
|
+
def find
|
78
|
+
up_until(search_start, description) do |path|
|
79
|
+
path.children(false).any? do |child|
|
80
|
+
workspace_children.any? do |vc_config|
|
81
|
+
child.fnmatch? vc_config
|
82
|
+
end
|
98
83
|
end
|
84
|
+
end
|
85
|
+
rescue Errors::NoMatchingPath
|
86
|
+
if fallback.nil?
|
87
|
+
raise
|
99
88
|
else
|
100
|
-
|
89
|
+
fallback
|
101
90
|
end
|
102
91
|
end
|
103
|
-
collapsed
|
104
92
|
end
|
105
93
|
|
106
|
-
def
|
107
|
-
|
94
|
+
def containing_workspace
|
95
|
+
finder = WorkspaceFinder.new
|
96
|
+
yield finder if block_given?
|
97
|
+
finder.find
|
98
|
+
end
|
99
|
+
|
100
|
+
def up_until(base_path = nil, description=nil)
|
101
|
+
base_path ||= file_from_backtrace(caller[0])
|
102
|
+
make_pathname(base_path).ascend do |path|
|
103
|
+
if yield(path)
|
104
|
+
return path
|
105
|
+
end
|
106
|
+
end
|
107
|
+
raise Errors::NoMatchingPath, "#{description || "Satisfactory path"} not found in #{base_path}"
|
108
|
+
end
|
109
|
+
|
110
|
+
def clean_pathname(pathname)
|
111
|
+
pathname.sub(/^~[^#{File::Separator}]*/) do |homedir|
|
112
|
+
File::expand_path(homedir)
|
113
|
+
end.cleanpath
|
114
|
+
end
|
115
|
+
|
116
|
+
def make_pathname(parts)
|
117
|
+
case parts
|
118
|
+
when Pathname
|
119
|
+
return clean_pathname(parts)
|
108
120
|
when Array
|
109
|
-
|
121
|
+
unless parts.any?{|part| not (String === part or Symbol === part)}
|
122
|
+
parts = File::join(parts.map{|part| part.to_s})
|
123
|
+
else
|
124
|
+
raise ArgumentError, "path must be composed of strings or symbols"
|
125
|
+
end
|
110
126
|
when String
|
111
|
-
|
127
|
+
when Symbol
|
128
|
+
parts = parts.to_s
|
129
|
+
when ::File
|
130
|
+
parts = parts.path
|
131
|
+
else
|
132
|
+
raise ArgumentError, "path must be String, Array of Strings or File"
|
112
133
|
end
|
134
|
+
pathname = clean_pathname(Pathname.new(parts))
|
113
135
|
end
|
114
|
-
|
115
|
-
module_function :from_here, :up_to, :unpath, :repath, :string_to_segments, :file_from_backtrace
|
116
|
-
public :from_here, :up_to, :file_from_backtrace
|
117
136
|
end
|
118
137
|
end
|
data/spec/fileset.rb
CHANGED
@@ -36,7 +36,7 @@ describe Valise do
|
|
36
36
|
|
37
37
|
describe "retrieving files" do
|
38
38
|
it "should get default text files" do
|
39
|
-
@valise.
|
39
|
+
@valise.contents("text").should == "Some text"
|
40
40
|
@valise.find(:text).contents.should == "Some text"
|
41
41
|
end
|
42
42
|
|
data/spec/population.rb
CHANGED
@@ -31,7 +31,7 @@ describe Valise do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should populate successfully" do
|
34
|
-
@to.
|
34
|
+
@to.contents("egg").should == "yolk"
|
35
35
|
@to.find("existed").contents.should == "TEST"
|
36
36
|
end
|
37
37
|
end
|
@@ -45,7 +45,7 @@ describe Valise do
|
|
45
45
|
|
46
46
|
it "should populate successfully" do
|
47
47
|
@to.find("egg").contents.should == "yolk"
|
48
|
-
@to.
|
48
|
+
@to.contents("existed").should == "TEST"
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
data/spec_help/spec_helper.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
require 'rspec'
|
2
|
+
#require 'cadre/rspec'
|
2
3
|
|
3
4
|
RSpec.configure do |config|
|
4
5
|
config.backtrace_clean_patterns.delete(/gems/)
|
6
|
+
config.run_all_when_everything_filtered = true
|
7
|
+
# config.add_formatter(Cadre::RSpec::NotifyOnCompleteFormatter)
|
8
|
+
# config.add_formatter(Cadre::RSpec::QuickfixFormatter)
|
5
9
|
end
|
metadata
CHANGED
@@ -1,32 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.1
|
5
4
|
prerelease:
|
5
|
+
version: 1.0.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Judson Lester
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
+
prerelease: false
|
16
|
+
type: :development
|
15
17
|
name: corundum
|
16
|
-
|
17
|
-
none: false
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
18
19
|
requirements:
|
19
20
|
- - ! '>='
|
20
21
|
- !ruby/object:Gem::Version
|
21
22
|
version: '0'
|
22
|
-
type: :development
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
23
|
none: false
|
24
|
+
requirement: !ruby/object:Gem::Requirement
|
26
25
|
requirements:
|
27
26
|
- - ! '>='
|
28
27
|
- !ruby/object:Gem::Version
|
29
28
|
version: '0'
|
29
|
+
none: false
|
30
30
|
description: ! " Valise provides an API for accessing configuration and data files
|
31
31
|
for your\n application, including the population of default values, and managing
|
32
32
|
search\n paths. Written to encourage a cross-platform approach to maintaining
|
@@ -107,7 +107,6 @@ files:
|
|
107
107
|
- doc/Specifications
|
108
108
|
- lib/valise.rb
|
109
109
|
- lib/valise/item-enum.rb
|
110
|
-
- lib/valise/debugging.rb
|
111
110
|
- lib/valise/utils.rb
|
112
111
|
- lib/valise/errors.rb
|
113
112
|
- lib/valise/adapters.rb
|
@@ -209,24 +208,24 @@ rdoc_options:
|
|
209
208
|
- --main
|
210
209
|
- doc/README
|
211
210
|
- --title
|
212
|
-
- valise-0.
|
211
|
+
- valise-1.0.0 RDoc
|
213
212
|
require_paths:
|
214
213
|
- lib/
|
215
214
|
required_ruby_version: !ruby/object:Gem::Requirement
|
216
|
-
none: false
|
217
215
|
requirements:
|
218
216
|
- - ! '>='
|
219
217
|
- !ruby/object:Gem::Version
|
220
|
-
version: '0'
|
221
218
|
segments:
|
222
219
|
- 0
|
223
|
-
hash:
|
224
|
-
|
220
|
+
hash: -884203725
|
221
|
+
version: '0'
|
225
222
|
none: false
|
223
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
226
224
|
requirements:
|
227
225
|
- - ! '>='
|
228
226
|
- !ruby/object:Gem::Version
|
229
227
|
version: '0'
|
228
|
+
none: false
|
230
229
|
requirements: []
|
231
230
|
rubyforge_project: valise
|
232
231
|
rubygems_version: 1.8.24
|
data/lib/valise/debugging.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Valise
|
2
|
-
module Debugging
|
3
|
-
def remark
|
4
|
-
end
|
5
|
-
|
6
|
-
class << self
|
7
|
-
attr_reader :remark_to
|
8
|
-
|
9
|
-
def enable(destination)
|
10
|
-
@remark_to = destination
|
11
|
-
class_eval do
|
12
|
-
def remark
|
13
|
-
self.class.remark_to.puts(yield)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|