hx 0.8.4 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.4
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.accept? path
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.accept? path
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.accept? path
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.accept? path
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.accept? path
253
+ yield path, entry.dup if selector.accept_path? path
254
254
  end
255
255
  self
256
256
  end
@@ -84,7 +84,7 @@ class CouchDB
84
84
  listing = JSON.parse(get_document('_all_docs'))
85
85
  listing['rows'].each do |row|
86
86
  path = row['id']
87
- yield path if selector.accept? path
87
+ yield path if selector.accept_path? path
88
88
  end
89
89
  self
90
90
  end
@@ -59,7 +59,7 @@ class RawFiles
59
59
  Pathname.glob(@entry_dir + '**/*') do |pathname|
60
60
  next unless pathname.file?
61
61
  path = pathname_to_path(pathname)
62
- yield path if selector.accept? path
62
+ yield path if selector.accept_path? path
63
63
  end
64
64
  self
65
65
  end
@@ -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.accept? index_path
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.accept? path
68
+ yield path, page['entry'] if selector.accept_path? path
69
69
  end
70
70
  end
71
71
  end
@@ -70,7 +70,7 @@ class RecursiveIndex
70
70
  end
71
71
  end
72
72
  indexes.each do |path, entry|
73
- yield path, entry if selector.accept? path
73
+ yield path, entry if selector.accept_path? path
74
74
  end
75
75
  self
76
76
  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.accept? path
85
+ yield path if selector.accept_path? path
86
86
  end
87
87
  self
88
88
  end
@@ -25,8 +25,8 @@ module Hx
25
25
  module Path
26
26
 
27
27
  module Selector
28
- def accept?(path)
29
- raise NotImplementedError, "#{self.class}#accept? not implemented"
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 accept?(path) ; true ; end
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 accept?(path) ; !!(path =~ @regexp) ; end
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 accept?(path)
107
- @selectors.all? { |s| s.accept? path }
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 accept?(path)
115
- @selectors.any? { |s| s.accept? path }
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 accept?(path)
127
- not @selector.accept?(path)
126
+ def accept_path?(path)
127
+ not @selector.accept_path?(path)
128
128
  end
129
129
  end
130
130
 
@@ -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 accept("foo/bar")
13
- pattern.should_not accept("foo/baz")
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 accept("baz/eek")
19
- pattern.should accept("foo/bar")
20
- pattern.should_not accept("foo/bar/baz")
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 accept("baz/eek")
26
- pattern.should accept("foo/bar")
27
- pattern.should accept("foo/bar/baz")
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 accept("foo/bar")
42
- filter.should accept("abcdefg")
43
- filter.should_not accept("hoge")
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 accept("foobar")
58
- @pattern.should accept("hoge")
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 accept("foobar")
73
- filter.should accept("fooxbar")
74
- filter.should_not accept("lemur")
75
- filter.should_not accept("foobear")
76
- filter.should_not accept("rebar")
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
@@ -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.accept? path }
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 :accept do |value|
38
+ RSpec::Matchers.define :accept_path do |value|
39
39
  match do |acceptor|
40
- acceptor.accept?(value)
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: 55
4
+ hash: 59
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 8
9
- - 4
10
- version: 0.8.4
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-09 00:00:00 -08:00
18
+ date: 2011-02-14 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency