hx 0.8.4 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/hx.rb +5 -5
- data/lib/hx/backend/couchdb.rb +1 -1
- data/lib/hx/backend/rawfiles.rb +1 -1
- data/lib/hx/listing/paginate.rb +2 -2
- data/lib/hx/listing/recursiveindex.rb +1 -1
- data/lib/hx/output/liquidtemplate.rb +1 -1
- data/lib/hx/path.rb +10 -10
- data/spec/selector_spec.rb +18 -18
- data/spec/spec_helper.rb +3 -3
- metadata +5 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.9.0
|
data/lib/hx.rb
CHANGED
@@ -98,7 +98,7 @@ class PathSubset
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def edit_entry(path, prototype=nil)
|
101
|
-
if @selector.
|
101
|
+
if @selector.accept_path? path
|
102
102
|
@input.edit_entry(path, prototype) { |text| yield text }
|
103
103
|
else
|
104
104
|
raise EditingNotSupportedError, "Editing not supported for #{path}"
|
@@ -117,7 +117,7 @@ class PathSubset
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def get_entry(path)
|
120
|
-
raise NoSuchEntryError, path unless @selector.
|
120
|
+
raise NoSuchEntryError, path unless @selector.accept_path? path
|
121
121
|
@input.get_entry(path)
|
122
122
|
end
|
123
123
|
end
|
@@ -186,7 +186,7 @@ class AddPath
|
|
186
186
|
def each_entry_path(selector)
|
187
187
|
@input.each_entry_path(Path::ALL) do |path|
|
188
188
|
path = add_circumfix(path)
|
189
|
-
yield path if selector.
|
189
|
+
yield path if selector.accept_path? path
|
190
190
|
end
|
191
191
|
self
|
192
192
|
end
|
@@ -210,7 +210,7 @@ class StripPath
|
|
210
210
|
def each_entry_path(selector)
|
211
211
|
@input.each_entry_path(Path::ALL) do |path|
|
212
212
|
path = strip_circumfix(path)
|
213
|
-
yield path if path and selector.
|
213
|
+
yield path if path and selector.accept_path? path
|
214
214
|
end
|
215
215
|
self
|
216
216
|
end
|
@@ -250,7 +250,7 @@ class Cache
|
|
250
250
|
end
|
251
251
|
end
|
252
252
|
entries.each do |path, entry|
|
253
|
-
yield path, entry.dup if selector.
|
253
|
+
yield path, entry.dup if selector.accept_path? path
|
254
254
|
end
|
255
255
|
self
|
256
256
|
end
|
data/lib/hx/backend/couchdb.rb
CHANGED
data/lib/hx/backend/rawfiles.rb
CHANGED
data/lib/hx/listing/paginate.rb
CHANGED
@@ -41,7 +41,7 @@ class Paginate
|
|
41
41
|
index_entry = index_entry.dup
|
42
42
|
index_entry['pages'] = [index_entry]
|
43
43
|
index_entry['page_index'] = 0
|
44
|
-
yield index_path, index_entry if selector.
|
44
|
+
yield index_path, index_entry if selector.accept_path? index_path
|
45
45
|
else
|
46
46
|
pages = []
|
47
47
|
n_pages = (items.size + @page_size - 1) / @page_size
|
@@ -65,7 +65,7 @@ class Paginate
|
|
65
65
|
pages[-1]['entry'].delete('next_page')
|
66
66
|
pages.each do |page|
|
67
67
|
path = page['path']
|
68
|
-
yield path, page['entry'] if selector.
|
68
|
+
yield path, page['entry'] if selector.accept_path? path
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
@@ -82,7 +82,7 @@ class LiquidTemplate
|
|
82
82
|
def each_entry_path(selector)
|
83
83
|
@input.each_entry_path(Path::ALL) do |path|
|
84
84
|
path = "#{path}.#{@extension}" unless @extension.nil?
|
85
|
-
yield path if selector.
|
85
|
+
yield path if selector.accept_path? path
|
86
86
|
end
|
87
87
|
self
|
88
88
|
end
|
data/lib/hx/path.rb
CHANGED
@@ -25,8 +25,8 @@ module Hx
|
|
25
25
|
module Path
|
26
26
|
|
27
27
|
module Selector
|
28
|
-
def
|
29
|
-
raise NotImplementedError, "#{self.class}#
|
28
|
+
def accept_path?(path)
|
29
|
+
raise NotImplementedError, "#{self.class}#accept_path? not implemented"
|
30
30
|
end
|
31
31
|
|
32
32
|
def |(other)
|
@@ -44,7 +44,7 @@ end
|
|
44
44
|
|
45
45
|
class All
|
46
46
|
include Selector
|
47
|
-
def
|
47
|
+
def accept_path?(path) ; true ; end
|
48
48
|
end
|
49
49
|
|
50
50
|
ALL = All.new
|
@@ -62,7 +62,7 @@ class Pattern
|
|
62
62
|
}}$")
|
63
63
|
end
|
64
64
|
|
65
|
-
def
|
65
|
+
def accept_path?(path) ; !!(path =~ @regexp) ; end
|
66
66
|
end
|
67
67
|
|
68
68
|
def self.parse_pattern(pattern_string)
|
@@ -103,16 +103,16 @@ class Conjunction
|
|
103
103
|
super(*selectors)
|
104
104
|
end
|
105
105
|
|
106
|
-
def
|
107
|
-
@selectors.all? { |s| s.
|
106
|
+
def accept_path?(path)
|
107
|
+
@selectors.all? { |s| s.accept_path? path }
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
111
|
class Disjunction
|
112
112
|
include Connective
|
113
113
|
|
114
|
-
def
|
115
|
-
@selectors.any? { |s| s.
|
114
|
+
def accept_path?(path)
|
115
|
+
@selectors.any? { |s| s.accept_path? path }
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
@@ -123,8 +123,8 @@ class Negation
|
|
123
123
|
@selector = selector
|
124
124
|
end
|
125
125
|
|
126
|
-
def
|
127
|
-
not @selector.
|
126
|
+
def accept_path?(path)
|
127
|
+
not @selector.accept_path?(path)
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
data/spec/selector_spec.rb
CHANGED
@@ -9,22 +9,22 @@ describe Hx::Path::Pattern do
|
|
9
9
|
|
10
10
|
it "should accept or reject literal paths" do
|
11
11
|
pattern = Hx::Path.literal("foo/bar")
|
12
|
-
pattern.should
|
13
|
-
pattern.should_not
|
12
|
+
pattern.should accept_path("foo/bar")
|
13
|
+
pattern.should_not accept_path("foo/baz")
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should match single path components with stars" do
|
17
17
|
pattern = Hx::Path.parse_pattern("foo/*")
|
18
|
-
pattern.should_not
|
19
|
-
pattern.should
|
20
|
-
pattern.should_not
|
18
|
+
pattern.should_not accept_path("baz/eek")
|
19
|
+
pattern.should accept_path("foo/bar")
|
20
|
+
pattern.should_not accept_path("foo/bar/baz")
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should match multiple path components with double stars" do
|
24
24
|
pattern = Hx::Path.parse_pattern("foo/**")
|
25
|
-
pattern.should_not
|
26
|
-
pattern.should
|
27
|
-
pattern.should
|
25
|
+
pattern.should_not accept_path("baz/eek")
|
26
|
+
pattern.should accept_path("foo/bar")
|
27
|
+
pattern.should accept_path("foo/bar/baz")
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -38,9 +38,9 @@ describe "Hx::Path::Selector disjunctions" do
|
|
38
38
|
it "should accept and reject the right paths" do
|
39
39
|
filters = ["foo/bar", "abcdefg"].map { |p| Hx::Path.parse_pattern(p) }
|
40
40
|
filter = filters.inject { |a, b| a | b }
|
41
|
-
filter.should
|
42
|
-
filter.should
|
43
|
-
filter.should_not
|
41
|
+
filter.should accept_path("foo/bar")
|
42
|
+
filter.should accept_path("abcdefg")
|
43
|
+
filter.should_not accept_path("hoge")
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -54,8 +54,8 @@ describe "negated Hx::Path::Selectors" do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should reject what they match" do
|
57
|
-
@pattern.should_not
|
58
|
-
@pattern.should
|
57
|
+
@pattern.should_not accept_path("foobar")
|
58
|
+
@pattern.should accept_path("hoge")
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -69,11 +69,11 @@ describe "Hx::Path::Selector conjunctions" do
|
|
69
69
|
it "should accept only paths matching both filters" do
|
70
70
|
filters = ["foo*", "*bar"].map { |p| Hx::Path.parse_pattern(p) }
|
71
71
|
filter = filters.inject { |a, b| a & b }
|
72
|
-
filter.should
|
73
|
-
filter.should
|
74
|
-
filter.should_not
|
75
|
-
filter.should_not
|
76
|
-
filter.should_not
|
72
|
+
filter.should accept_path("foobar")
|
73
|
+
filter.should accept_path("fooxbar")
|
74
|
+
filter.should_not accept_path("lemur")
|
75
|
+
filter.should_not accept_path("foobear")
|
76
|
+
filter.should_not accept_path("rebar")
|
77
77
|
end
|
78
78
|
|
79
79
|
it "should optimize use of ALL" do
|
data/spec/spec_helper.rb
CHANGED
@@ -22,7 +22,7 @@ class FakeInput
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def each_entry_path(selector)
|
25
|
-
@entries.each_key { |path| yield path if selector.
|
25
|
+
@entries.each_key { |path| yield path if selector.accept_path? path }
|
26
26
|
self
|
27
27
|
end
|
28
28
|
|
@@ -35,8 +35,8 @@ class FakeInput
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
RSpec::Matchers.define :
|
38
|
+
RSpec::Matchers.define :accept_path do |value|
|
39
39
|
match do |acceptor|
|
40
|
-
acceptor.
|
40
|
+
acceptor.accept_path?(value)
|
41
41
|
end
|
42
42
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 9
|
9
|
+
- 0
|
10
|
+
version: 0.9.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- MenTaLguY
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-14 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|