html_surgeon 0.2.0 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 94d817ba0e3871c050f1d56fd80034cfc389562c
4
- data.tar.gz: aca28c4bcc429fd9e7ea1294c3f81896f641cda2
3
+ metadata.gz: 128a0133d9c441981b5488fcd23ce7d1d199b295
4
+ data.tar.gz: 80cbf114adcbbf71b74ca8c2edc42af26bf32ee6
5
5
  SHA512:
6
- metadata.gz: ebe07e4c500cdaa9b95b852abb1e3b894eb3805c6ebfa9fac34fa0a56d34f3488700a025ac3f0cb1a5df1d6f194634b9724afea8c9769a09428148ea7219e8e1
7
- data.tar.gz: c348f793ae6186dceb2f00db9269b45a0477d1e816b2084b672eb431b09d6d8e8a7d3147cff48ecb34bfc55ce35f12ec854ee6d28756eafb8f4bb068bcb3035e
6
+ metadata.gz: 383b56f154ac0bf797035ad02da5c9ce24bad52efc2d9e2e0659ff91cdce5df07654068845836b12a5cf36feb82f92f5766648424b835aea927ad50e4db8d818
7
+ data.tar.gz: 86d0f5ba4376e8337cb62ccf75341d46e72df559b422eca1ae3ac574d06eb58ce1237d08bbd5519677ef94d88ec0f60874e6270b0ca342444488080500ecffb2
data/README.md CHANGED
@@ -147,7 +147,7 @@ the attribute's value (formatted) is:
147
147
  ]
148
148
  ```
149
149
 
150
- it has a `change_set` with the UUID of the change set, `changed_at` with the moment it was applied, and the rest define the change.
150
+ it has a `change_set` with the ID of the change set, `changed_at` with the moment it was applied, and the rest define the change.
151
151
 
152
152
  ## Selecting the Node Set
153
153
 
@@ -161,8 +161,9 @@ change_set = surgeon.css('div.to-be-changed')
161
161
 
162
162
  ### using xpath
163
163
 
164
- not implemented yet.
165
-
164
+ ```ruby
165
+ change_set = surgeon.xpath("span") # note that we use Nokogiri's HTML Fragment and the use of self is special.
166
+ ```
166
167
 
167
168
  ## Available Changes
168
169
 
@@ -227,5 +228,10 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/eturin
227
228
 
228
229
  ## CHANGESET
229
230
 
230
- ### v 0.2.0
231
- - added `rollback support
231
+ ### v0.3.0
232
+
233
+ - added fluid ChangeSet ID setter
234
+ - added change_set xpath support
235
+
236
+ ### v0.2.0
237
+ - added rollback support
@@ -7,7 +7,7 @@ module HtmlSurgeon
7
7
 
8
8
  attr_reader :change_set
9
9
  delegate :audit?, to: :change_set
10
- delegate :uuid, :run_time, to: :change_set, prefix: true
10
+ delegate :id, :run_time, to: :change_set, prefix: true
11
11
 
12
12
  def initialize(change_set:)
13
13
  @change_set = change_set
@@ -34,7 +34,7 @@ module HtmlSurgeon
34
34
  private
35
35
  def basic_audit_data
36
36
  {
37
- change_set: change_set_uuid,
37
+ change_set: change_set_id,
38
38
  changed_at: change_set_run_time
39
39
  }
40
40
  end
@@ -1,7 +1,7 @@
1
1
  module HtmlSurgeon
2
2
 
3
3
  class ChangeSet
4
- attr_reader :node_set, :base, :change_list, :uuid, :run_time
4
+ attr_reader :node_set, :base, :change_list, :run_time
5
5
 
6
6
  def self.create(node_set, base)
7
7
  new_class.new node_set, base
@@ -19,7 +19,7 @@ module HtmlSurgeon
19
19
  @node_set = node_set
20
20
  @base = base
21
21
  @change_list = []
22
- @uuid = SecureRandom.uuid
22
+ @id = SecureRandom.uuid
23
23
  @run_time = nil
24
24
  end
25
25
 
@@ -27,6 +27,16 @@ module HtmlSurgeon
27
27
 
28
28
  # TODO: #preview, like run but in another doc, does not change it yet.
29
29
 
30
+ # chainable fluid ID setter
31
+ def id(custom_id = nil)
32
+ if custom_id
33
+ @id = custom_id
34
+ self
35
+ else
36
+ @id
37
+ end
38
+ end
39
+
30
40
  def run
31
41
  @run_time = Time.now.utc
32
42
 
@@ -21,6 +21,11 @@ module HtmlSurgeon
21
21
  ChangeSet.create(node_set, self)
22
22
  end
23
23
 
24
+ def xpath(xpath_selector)
25
+ node_set = doc.xpath(xpath_selector)
26
+ ChangeSet.create(node_set, self)
27
+ end
28
+
24
29
  def rollback(change_set: nil, changed_at: nil, changed_from: nil)
25
30
  doc.css("[#{DATA_CHANGE_AUDIT_ATTRIBUTE}]").each do |node|
26
31
  NodeReverser.new(node: node, change_set: change_set, changed_at: changed_at, changed_from: changed_from).call
@@ -1,3 +1,3 @@
1
1
  module HtmlSurgeon
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html_surgeon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo Turiño
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-02 00:00:00.000000000 Z
11
+ date: 2015-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri