nokolexbor 0.3.6-arm64-darwin → 0.4.0-arm64-darwin

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06e747c8e64eddc8246e3bdf6aedcb64b230f6880092baaffe706149a5351c10
4
- data.tar.gz: ca2f344f83e4708c513a716711683834084908fc8da2c515c6dc0d74956f5123
3
+ metadata.gz: '0904e00cbf32c9271ed152d1666d36188398b9ff3c847cfb848cbdb390f59908'
4
+ data.tar.gz: c413b06890f02679bcb6ea9617fcfcdf35c6e4ad05f21ef3f436e0231991d781
5
5
  SHA512:
6
- metadata.gz: 0fd46ba8e840166d8bf583c3a41ae5f11b2acf3380d6eddd40c0d8ebd6e753510fc528437f7f0e8281ef07d9430014871e15bae7c65ea4d627fdc3cc48a94350
7
- data.tar.gz: 5433db940e5958a17c1c142ef172fca4b4d1745e392aaf125446f70a30bd4c8f80bef70f7182e66dcca756a5afa7ffd672554ca99f169bf15e409d1d92b2a300
6
+ metadata.gz: 6a99dda38859ceaa61076c2884fdbf200cba56fbba9107eb0c68c3f3d490ab031afc878421b0e9dc56c066a5bd1712e3ba1f22e797bfe1de6262306ac8f8651f
7
+ data.tar.gz: e74596b7a5f1d8a385ed16eac86ff470bd7d150bd06c75068d0f8481c1745605e89971729738453d96c49a2a2eb1bbe1550a996070d5e6aab04580876bd35738
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -54,6 +54,16 @@ module Nokolexbor
54
54
  length == 0
55
55
  end
56
56
 
57
+ # Insert +node+ before the first Node in this NodeSet
58
+ def before(node)
59
+ first.before(node)
60
+ end
61
+
62
+ # Insert +node+ after the last Node in this NodeSet
63
+ def after(node)
64
+ last.after(node)
65
+ end
66
+
57
67
  # @return [Integer] The index of the first node in this NodeSet that is equal to +node+ or meets the given block. Returns nil if no match is found.
58
68
  def index(node = nil)
59
69
  if node
@@ -169,6 +179,75 @@ module Nokolexbor
169
179
  self
170
180
  end
171
181
 
182
+ # Add the class attribute +name+ to all containing nodes.
183
+ #
184
+ # @see Node#add_class
185
+ def add_class(name)
186
+ each do |el|
187
+ el.add_class(name)
188
+ end
189
+ self
190
+ end
191
+
192
+ # Append the class attribute +name+ to all containing nodes.
193
+ #
194
+ # @see Node#append_class
195
+ def append_class(name)
196
+ each do |el|
197
+ el.append_class(name)
198
+ end
199
+ self
200
+ end
201
+
202
+ # Remove the class attribute +name+ from all containing nodes.
203
+ #
204
+ # @see Node#remove_class
205
+ def remove_class(name = nil)
206
+ each do |el|
207
+ el.remove_class(name)
208
+ end
209
+ self
210
+ end
211
+
212
+ # Remove the attributed named +name+ from all containing nodes.
213
+ #
214
+ # @see Node#remove_attr
215
+ def remove_attr(name)
216
+ each { |el| el.delete(name) }
217
+ self
218
+ end
219
+ alias_method :remove_attribute, :remove_attr
220
+
221
+ # Set attributes on each Node in the NodeSet, or get an
222
+ # attribute from the first Node in the NodeSet.
223
+ #
224
+ # @example Get an attribute from the first Node in a NodeSet.
225
+ # node_set.attr("href")
226
+ #
227
+ # @example Set attributes on each node.
228
+ # node_set.attr("href" => "http://example.com", "class" => "a")
229
+ # node_set.attr("href", "http://example.com")
230
+ # node_set.attr("href") { |node| "http://example.com" }
231
+ #
232
+ # @return [NodeSet] +self+, to support chaining of calls.
233
+ def attr(key, value = nil, &block)
234
+ unless key.is_a?(Hash) || (key && (value || block))
235
+ return first&.attribute(key)
236
+ end
237
+
238
+ hash = key.is_a?(Hash) ? key : { key => value }
239
+
240
+ hash.each do |k, v|
241
+ each do |node|
242
+ node[k] = v || yield(node)
243
+ end
244
+ end
245
+
246
+ self
247
+ end
248
+ alias_method :set, :attr
249
+ alias_method :attribute, :attr
250
+
172
251
  # (see Node#xpath)
173
252
  def xpath(*args)
174
253
  paths, handler, ns, binds = extract_params(args)
@@ -196,6 +275,10 @@ module Nokolexbor
196
275
  end
197
276
  end
198
277
 
278
+ def inspect
279
+ "[#{map(&:inspect).join(', ')}]"
280
+ end
281
+
199
282
  private
200
283
 
201
284
  IMPLIED_XPATH_CONTEXTS = [".//", "self::"].freeze # :nodoc:
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nokolexbor
4
- VERSION = '0.3.6'
4
+ VERSION = '0.4.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokolexbor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.4.0
5
5
  platform: arm64-darwin
6
6
  authors:
7
7
  - Yicheng Zhou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-04 00:00:00.000000000 Z
11
+ date: 2023-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler