lorax 0.2.0 → 0.3.0.rc1

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.
File without changes
@@ -1,5 +1,14 @@
1
1
  = Changelog
2
2
 
3
+ == 0.3.0 (unreleased)
4
+
5
+ * Human-readable diffs.
6
+
7
+ == 0.2.0 (2010-10-14)
8
+
9
+ * Better handling of whitespace: blank text nodes are ignored, as is
10
+ leading and trailing whitespace in text nodes. GH#2.
11
+
3
12
  == 0.1.0 (2010-03-09)
4
13
 
5
14
  * Happy Birthday!
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Mike Dalessio
1
+ Copyright (c) 2009-2012 Mike Dalessio
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -50,7 +50,7 @@ and apply the delta set as a patch to the original document:
50
50
 
51
51
  (The MIT License)
52
52
 
53
- Copyright (c) 2010 Mike Dalessio
53
+ Copyright (c) 2009-2012 Mike Dalessio
54
54
 
55
55
  Permission is hereby granted, free of charge, to any person obtaining
56
56
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -1,22 +1,23 @@
1
- # -*- ruby -*-
2
-
3
- require 'rubygems'
4
- gem 'hoe', '>= 2.5.0'
5
- require 'hoe'
1
+ require "rubygems"
2
+ require "hoe"
6
3
 
7
4
  Hoe.plugin :git
8
5
  Hoe.plugin :gemspec
6
+ Hoe.plugin :bundler
9
7
 
10
- Hoe.spec 'lorax' do
8
+ Hoe.spec "lorax" do
11
9
  developer "Mike Dalessio", "mike.dalessio@gmail.com"
12
10
 
13
11
  self.extra_rdoc_files = FileList["*.rdoc"]
14
12
  self.history_file = "CHANGELOG.rdoc"
15
13
  self.readme_file = "README.rdoc"
16
14
 
17
- extra_deps << ["nokogiri", ">= 1.4.0"]
18
- extra_dev_deps << ["rspec", ">= 1.2.9"]
19
- extra_dev_deps << ["rr", ">= 0.10.4"]
15
+ extra_deps << ["nokogiri", ">= 1.4"]
16
+ extra_dev_deps << ["rspec", "~> 2.11"]
17
+ extra_dev_deps << ["rr", ">= 1.0"]
18
+ extra_dev_deps << ["hoe-git", "> 0"]
19
+ extra_dev_deps << ["hoe-gemspec", "> 0"]
20
+ extra_dev_deps << ["hoe-bundler", "> 0"]
20
21
  end
21
22
 
22
23
  task :redocs => :fix_css
@@ -1,7 +1,7 @@
1
1
  require 'nokogiri'
2
2
 
3
3
  module Lorax
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0.rc1"
5
5
  REQUIRED_NOKOGIRI_VERSION = "1.4.0"
6
6
  raise LoadError, "lorax requires Nokogiri version #{REQUIRED_NOKOGIRI_VERSION} or higher" unless Nokogiri::VERSION >= REQUIRED_NOKOGIRI_VERSION
7
7
  end
@@ -20,6 +20,22 @@ module Lorax
20
20
  children[position].add_previous_sibling(node.dup)
21
21
  end
22
22
  end
23
+
24
+ def context_before node
25
+ if node.previous_sibling
26
+ node.previous_sibling.to_xml.gsub(/^/,' ').rstrip
27
+ else
28
+ " <#{node.parent.name}>"
29
+ end
30
+ end
31
+
32
+ def context_after node
33
+ if node.next_sibling
34
+ node.next_sibling.to_xml.gsub(/^/,' ').rstrip
35
+ else
36
+ " </#{node.parent.name}>"
37
+ end
38
+ end
23
39
  end
24
40
  end
25
41
 
@@ -15,5 +15,15 @@ module Lorax
15
15
  def descriptor
16
16
  [:delete, {:xpath => node.path, :content => node.to_s}]
17
17
  end
18
+
19
+ def to_s
20
+ response = []
21
+ response << "--- #{node.path}"
22
+ response << "+++"
23
+ response << context_before(node)
24
+ response << node.to_html.gsub(/^/,'- ').strip
25
+ response << context_after(node)
26
+ response.join("\n")
27
+ end
18
28
  end
19
29
  end
@@ -18,5 +18,15 @@ module Lorax
18
18
  def descriptor
19
19
  [:insert, {:xpath => xpath, :position => position, :content => node.to_s}]
20
20
  end
21
+
22
+ def to_s
23
+ response = []
24
+ response << "---"
25
+ response << "+++ #{node.path}"
26
+ response << context_before(node)
27
+ response << node.to_html.gsub(/^/,'+ ').strip
28
+ response << context_after(node)
29
+ response.join("\n")
30
+ end
21
31
  end
22
32
  end
@@ -41,6 +41,19 @@ module Lorax
41
41
  end
42
42
  end
43
43
 
44
+ def to_s
45
+ response = []
46
+ response << "--- #{node1.path}"
47
+ response << "+++ #{node2.path}"
48
+ response << context_before(node2)
49
+
50
+ response << node1.to_html.gsub(/^/,'- ').strip
51
+ response << node2.to_html.gsub(/^/,'+ ').strip
52
+
53
+ response << context_after(node2)
54
+ response.join("\n")
55
+ end
56
+
44
57
  private
45
58
 
46
59
  def attributes_hash(node)
@@ -20,5 +20,11 @@ module Lorax
20
20
  end
21
21
  document
22
22
  end
23
+
24
+ def to_s
25
+ deltas.collect do |delta|
26
+ delta.to_s
27
+ end.join("\n\n")
28
+ end
23
29
  end
24
30
  end
@@ -1,11 +1,6 @@
1
- require 'rubygems'
2
-
3
- $LOAD_PATH.unshift(File.dirname(__FILE__))
4
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
1
  require 'lorax'
6
2
 
7
- require 'spec'
8
- require 'spec/autorun'
3
+ require 'rspec'
9
4
  require 'rr'
10
5
  require 'pp'
11
6
 
@@ -36,7 +31,7 @@ module XmlBuilderHelper
36
31
  end
37
32
  end
38
33
 
39
- Spec::Runner.configure do |config|
34
+ RSpec.configure do |config|
40
35
  config.mock_with :rr
41
36
  config.include XmlBuilderHelper
42
37
  end
@@ -47,4 +47,8 @@ describe Lorax::DeleteDelta do
47
47
  describe "#descriptor" do
48
48
  it "needs a spec"
49
49
  end
50
+
51
+ describe "#to_s" do
52
+ it "needs a spec"
53
+ end
50
54
  end
@@ -106,4 +106,8 @@ describe Lorax::InsertDelta do
106
106
  describe "#descriptor" do
107
107
  it "needs a spec"
108
108
  end
109
+
110
+ describe "#to_s" do
111
+ it "needs a spec"
112
+ end
109
113
  end
@@ -91,4 +91,8 @@ describe Lorax::ModifyDelta do
91
91
  describe "#descriptor" do
92
92
  it "needs a spec"
93
93
  end
94
+
95
+ describe "#to_s" do
96
+ it "needs a spec"
97
+ end
94
98
  end
@@ -441,9 +441,9 @@ describe Lorax::Signature do
441
441
  a3("x" * 50_000)
442
442
  } }
443
443
  sig = Lorax::Signature.new(doc.root)
444
- sig.weight(doc.at_css("a1")).should be_close(2, 0.0005)
445
- sig.weight(doc.at_css("a2")).should be_close(2 + Math.log(500), 0.0005)
446
- sig.weight(doc.at_css("a3")).should be_close(2 + Math.log(50_000), 0.0005)
444
+ sig.weight(doc.at_css("a1")).should be_within(0.0005).of(2)
445
+ sig.weight(doc.at_css("a2")).should be_within(0.0005).of(2 + Math.log(500))
446
+ sig.weight(doc.at_css("a3")).should be_within(0.0005).of(2 + Math.log(50_000))
447
447
  end
448
448
  end
449
449
  end
metadata CHANGED
@@ -1,148 +1,175 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: lorax
3
- version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 2
9
- - 0
10
- version: 0.2.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0.rc1
5
+ prerelease: 6
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Mike Dalessio
14
9
  autorequire:
15
10
  bindir: bin
16
- cert_chain:
17
- - |
18
- -----BEGIN CERTIFICATE-----
19
- MIIDPDCCAiSgAwIBAgIBADANBgkqhkiG9w0BAQUFADBEMRYwFAYDVQQDDA1taWtl
20
- LmRhbGVzc2lvMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZ
21
- FgNjb20wHhcNMTAwOTMwMDYyNjQ3WhcNMTEwOTMwMDYyNjQ3WjBEMRYwFAYDVQQD
22
- DA1taWtlLmRhbGVzc2lvMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJ
23
- k/IsZAEZFgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDLv4nl
24
- BGRtliYy5s5MhlFO88UvkkETFcS79OCaGFKorxPTmcfDrR2/2x0mAySXJ6I1uPEU
25
- WSAWaPb1at61NEOvp5kRNzUNdwGakBA/fd1vZ1N2rwHRtjk/8t6DX8yiflr6T761
26
- 9ZMYPE+t85NvlPt0/WpT778imNZXwGQNcQJwNESDiBTgyjN8bOWpvRrVADVdOCme
27
- DW3AfJnF/kdMYuSiUuFMZpyOlULEbOsrvOfUoEKjoFaVNv7FJ28/kLH1UgmtucOD
28
- m5bZ/qy5b2+CWzzsmUfysaGnLQ4LjvAFpmgZGAjIE9TnyjU0jw+2e7dq8uRjdnFJ
29
- gfWQlnJuwAlZXR1nAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0G
30
- A1UdDgQWBBRbc4XnK6it228clp2DjyqaVjKW+DANBgkqhkiG9w0BAQUFAAOCAQEA
31
- xPtSPtMl9qsgNGcnSDLSTjwGouwsjOB19IbtdODFTabUpRPCk7OFHeYGdJik4iiZ
32
- fk10t3vzr6uWMAyOfwpWWFRnEYAvy9ZaMGDIZPKD8xWxaRTLwmi+pQsS8Lo2IpDC
33
- Lb+l0lUiRiYS3/Ez7tA6pS122cvuQroWfuqh5Mi3pNAi1nuBTlhCNJuR5XUaOjqs
34
- DAoZLfYEEW+4bmkAb6ky2TPUslaln56PO3/JG+IfWZwCvTFFVdKRBKXqLaAxO9rv
35
- 7nflCv7xpUSUGGZ6hoPG8dil+Mp/kKV8cb1kxZz+C8660hC93dJ3FQ3adX30ylvZ
36
- C4THW+6HEQDCdOkiArif8A==
37
- -----END CERTIFICATE-----
38
-
39
- date: 2010-10-14 00:00:00 -04:00
40
- default_executable:
41
- dependencies:
42
- - !ruby/object:Gem::Dependency
11
+ cert_chain: []
12
+ date: 2012-10-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
43
15
  name: nokogiri
44
- prerelease: false
45
- requirement: &id001 !ruby/object:Gem::Requirement
46
- none: false
47
- requirements:
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- hash: 7
51
- segments:
52
- - 1
53
- - 4
54
- - 0
55
- version: 1.4.0
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '1.4'
56
22
  type: :runtime
57
- version_requirements: *id001
58
- - !ruby/object:Gem::Dependency
59
- name: rubyforge
60
23
  prerelease: false
61
- requirement: &id002 !ruby/object:Gem::Requirement
62
- none: false
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- hash: 7
67
- segments:
68
- - 2
69
- - 0
70
- - 4
71
- version: 2.0.4
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '1.4'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rdoc
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '3.10'
72
38
  type: :development
73
- version_requirements: *id002
74
- - !ruby/object:Gem::Dependency
75
- name: rspec
76
39
  prerelease: false
77
- requirement: &id003 !ruby/object:Gem::Requirement
78
- none: false
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- hash: 13
83
- segments:
84
- - 1
85
- - 2
86
- - 9
87
- version: 1.2.9
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '3.10'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '2.11'
88
54
  type: :development
89
- version_requirements: *id003
90
- - !ruby/object:Gem::Dependency
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.11'
62
+ - !ruby/object:Gem::Dependency
91
63
  name: rr
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '1.0'
70
+ type: :development
92
71
  prerelease: false
93
- requirement: &id004 !ruby/object:Gem::Requirement
94
- none: false
95
- requirements:
96
- - - ">="
97
- - !ruby/object:Gem::Version
98
- hash: 63
99
- segments:
100
- - 0
101
- - 10
102
- - 4
103
- version: 0.10.4
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '1.0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: hoe-git
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>'
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>'
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: hoe-gemspec
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>'
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>'
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: hoe-bundler
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>'
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
104
118
  type: :development
105
- version_requirements: *id004
106
- - !ruby/object:Gem::Dependency
107
- name: hoe
108
119
  prerelease: false
109
- requirement: &id005 !ruby/object:Gem::Requirement
110
- none: false
111
- requirements:
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- hash: 21
115
- segments:
116
- - 2
117
- - 6
118
- - 1
119
- version: 2.6.1
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>'
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: hoe
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: '3.1'
120
134
  type: :development
121
- version_requirements: *id005
122
- description: |-
123
- The Lorax is a full diff and patch library for XML/HTML documents, based on Nokogiri.
124
-
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: '3.1'
142
+ description: ! 'The Lorax is a full diff and patch library for XML/HTML documents,
143
+ based on Nokogiri.
144
+
145
+
125
146
  It can tell you whether two XML/HTML documents are identical, or if
126
- they're not, tell you what's different. In trivial cases, it can even
147
+
148
+ they''re not, tell you what''s different. In trivial cases, it can even
149
+
127
150
  apply the patch.
128
-
129
- It's based loosely on Gregory Cobena's master's thesis paper, which
151
+
152
+
153
+ It''s based loosely on Gregory Cobena''s master''s thesis paper, which
154
+
130
155
  generates deltas in less than O(n * log n) time, accepting some
156
+
131
157
  tradeoffs in the size of the delta set. You can find his paper at
158
+
132
159
  http://gregory.cobena.free.fr/www/Publications/thesis.html.
133
-
134
- "I am the Lorax, I speak for the trees."
135
- email:
160
+
161
+
162
+ "I am the Lorax, I speak for the trees."'
163
+ email:
136
164
  - mike.dalessio@gmail.com
137
- executables:
165
+ executables:
138
166
  - lorax
139
167
  extensions: []
140
-
141
- extra_rdoc_files:
142
- - Manifest.txt
168
+ extra_rdoc_files:
143
169
  - CHANGELOG.rdoc
170
+ - Manifest.txt
144
171
  - README.rdoc
145
- files:
172
+ files:
146
173
  - CHANGELOG.rdoc
147
174
  - LICENSE
148
175
  - Manifest.txt
@@ -180,40 +207,35 @@ files:
180
207
  - spec/unit/lorax_spec.rb
181
208
  - spec/unit/match_set_spec.rb
182
209
  - spec/unit/signature_spec.rb
183
- has_rdoc: true
210
+ - .gemtest
184
211
  homepage: http://github.com/flavorjones/lorax
185
212
  licenses: []
186
-
187
213
  post_install_message:
188
- rdoc_options:
214
+ rdoc_options:
189
215
  - --main
190
216
  - README.rdoc
191
- require_paths:
217
+ require_paths:
192
218
  - lib
193
- required_ruby_version: !ruby/object:Gem::Requirement
219
+ required_ruby_version: !ruby/object:Gem::Requirement
194
220
  none: false
195
- requirements:
196
- - - ">="
197
- - !ruby/object:Gem::Version
198
- hash: 3
199
- segments:
221
+ requirements:
222
+ - - ! '>='
223
+ - !ruby/object:Gem::Version
224
+ version: '0'
225
+ segments:
200
226
  - 0
201
- version: "0"
202
- required_rubygems_version: !ruby/object:Gem::Requirement
227
+ hash: -2415192576309333351
228
+ required_rubygems_version: !ruby/object:Gem::Requirement
203
229
  none: false
204
- requirements:
205
- - - ">="
206
- - !ruby/object:Gem::Version
207
- hash: 3
208
- segments:
209
- - 0
210
- version: "0"
230
+ requirements:
231
+ - - ! '>'
232
+ - !ruby/object:Gem::Version
233
+ version: 1.3.1
211
234
  requirements: []
212
-
213
235
  rubyforge_project: lorax
214
- rubygems_version: 1.3.7
236
+ rubygems_version: 1.8.24
215
237
  signing_key:
216
238
  specification_version: 3
217
- summary: The Lorax is a full diff and patch library for XML/HTML documents, based on Nokogiri
239
+ summary: The Lorax is a full diff and patch library for XML/HTML documents, based
240
+ on Nokogiri
218
241
  test_files: []
219
-
data.tar.gz.sig DELETED
Binary file
metadata.gz.sig DELETED
Binary file