ronin-web 0.2.1 → 0.3.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. data/.document +4 -0
  2. data/.gemtest +0 -0
  3. data/.rspec +1 -0
  4. data/.yardopts +1 -0
  5. data/COPYING.txt +674 -0
  6. data/{History.txt → ChangeLog.md} +39 -8
  7. data/Gemfile +49 -0
  8. data/{README.txt → README.md} +56 -40
  9. data/Rakefile +25 -24
  10. data/bin/ronin-web +18 -5
  11. data/gemspec.yml +30 -0
  12. data/lib/ronin/network/{helpers → mixins}/web.rb +74 -39
  13. data/lib/ronin/web.rb +7 -6
  14. data/lib/ronin/web/extensions.rb +7 -6
  15. data/lib/ronin/web/extensions/nokogiri.rb +22 -0
  16. data/lib/ronin/web/extensions/nokogiri/xml.rb +22 -0
  17. data/lib/ronin/web/extensions/nokogiri/xml/attr.rb +35 -1
  18. data/lib/ronin/web/extensions/nokogiri/xml/document.rb +34 -4
  19. data/lib/ronin/web/extensions/nokogiri/xml/element.rb +36 -2
  20. data/lib/ronin/web/extensions/nokogiri/xml/node.rb +59 -20
  21. data/lib/ronin/web/extensions/nokogiri/xml/text.rb +36 -2
  22. data/lib/ronin/web/middleware.rb +27 -0
  23. data/lib/ronin/web/middleware/base.rb +144 -0
  24. data/lib/ronin/web/middleware/directories.rb +177 -0
  25. data/lib/ronin/web/middleware/files.rb +142 -0
  26. data/lib/ronin/web/middleware/filters.rb +28 -0
  27. data/lib/ronin/web/middleware/filters/campaign_filter.rb +77 -0
  28. data/lib/ronin/web/middleware/filters/ip_filter.rb +73 -0
  29. data/lib/ronin/web/middleware/filters/path_filter.rb +73 -0
  30. data/lib/ronin/web/middleware/filters/referer_filter.rb +71 -0
  31. data/lib/ronin/web/middleware/filters/user_agent_filter.rb +71 -0
  32. data/lib/ronin/web/middleware/filters/vhost_filter.rb +71 -0
  33. data/lib/ronin/web/middleware/helpers.rb +145 -0
  34. data/lib/ronin/web/middleware/proxy.rb +265 -0
  35. data/lib/ronin/web/middleware/proxy_request.rb +262 -0
  36. data/lib/ronin/web/middleware/request.rb +58 -0
  37. data/lib/ronin/web/middleware/response.rb +33 -0
  38. data/lib/ronin/web/middleware/router.rb +167 -0
  39. data/lib/ronin/web/middleware/rule.rb +103 -0
  40. data/lib/ronin/web/proxy.rb +7 -6
  41. data/lib/ronin/web/proxy/app.rb +7 -6
  42. data/lib/ronin/web/proxy/base.rb +14 -9
  43. data/lib/ronin/web/proxy/web.rb +9 -6
  44. data/lib/ronin/web/server.rb +7 -6
  45. data/lib/ronin/web/server/app.rb +7 -6
  46. data/lib/ronin/web/server/base.rb +209 -82
  47. data/lib/ronin/web/server/web.rb +10 -6
  48. data/lib/ronin/web/spider.rb +38 -26
  49. data/lib/ronin/web/version.rb +8 -7
  50. data/lib/ronin/web/web.rb +122 -80
  51. data/ronin-web.gemspec +15 -0
  52. data/spec/helpers/output.rb +3 -0
  53. data/spec/spec_helper.rb +2 -3
  54. data/spec/web/extensions/nokogiri_spec.rb +7 -7
  55. data/spec/web/{server/helpers/server.rb → helpers/rack_app.rb} +3 -14
  56. data/spec/web/helpers/root.rb +15 -0
  57. data/spec/web/helpers/root/test1.txt +1 -0
  58. data/spec/web/helpers/root/test1/index.html +1 -0
  59. data/spec/web/helpers/root/test1/test1.txt +1 -0
  60. data/spec/web/helpers/root/test2.txt +1 -0
  61. data/spec/web/helpers/root/test2/test2.txt +1 -0
  62. data/spec/web/helpers/root/test3.txt +1 -0
  63. data/spec/web/helpers/root/test3/test3.txt +1 -0
  64. data/spec/web/middleware/directories_spec.rb +86 -0
  65. data/spec/web/middleware/files_spec.rb +57 -0
  66. data/spec/web/middleware/filters/campaign_filter_spec.rb +30 -0
  67. data/spec/web/middleware/filters/ip_filter_spec.rb +25 -0
  68. data/spec/web/middleware/filters/path_filter_spec.rb +29 -0
  69. data/spec/web/middleware/filters/referer_filter_spec.rb +25 -0
  70. data/spec/web/middleware/filters/user_agent_filter_spec.rb +25 -0
  71. data/spec/web/middleware/filters/vhost_filter_spec.rb +23 -0
  72. data/spec/web/middleware/proxy_spec.rb +67 -0
  73. data/spec/web/middleware/response_spec.rb +20 -0
  74. data/spec/web/middleware/router_spec.rb +65 -0
  75. data/spec/web/middleware/rule_spec.rb +37 -0
  76. data/spec/web/proxy/base_spec.rb +1 -2
  77. data/spec/web/server/base_spec.rb +4 -13
  78. data/spec/web/server/classes/sub_app.rb +2 -2
  79. data/spec/web/server/classes/test_app.rb +1 -1
  80. data/spec/web/web_spec.rb +57 -67
  81. metadata +171 -146
  82. data.tar.gz.sig +0 -0
  83. data/Manifest.txt +0 -64
  84. data/lib/ronin/scanners/web.rb +0 -52
  85. data/lib/ronin/web/server/files.rb +0 -92
  86. data/lib/ronin/web/server/helpers.rb +0 -25
  87. data/lib/ronin/web/server/helpers/files.rb +0 -126
  88. data/lib/ronin/web/server/helpers/hosts.rb +0 -72
  89. data/lib/ronin/web/server/helpers/proxy.rb +0 -153
  90. data/lib/ronin/web/server/helpers/rendering.rb +0 -36
  91. data/lib/ronin/web/server/hosts.rb +0 -86
  92. data/lib/ronin/web/server/proxy.rb +0 -116
  93. data/spec/scanners/web_spec.rb +0 -24
  94. data/spec/web/helpers/root/index.html +0 -1
  95. data/spec/web/helpers/root/test.txt +0 -1
  96. data/spec/web/helpers/server.rb +0 -10
  97. data/spec/web/server/classes/files/dir/file.txt +0 -1
  98. data/spec/web/server/classes/files/dir/index.html +0 -1
  99. data/spec/web/server/classes/files/dir2/file2.txt +0 -1
  100. data/spec/web/server/classes/files/dir3/page.xml +0 -4
  101. data/spec/web/server/classes/files/file.txt +0 -1
  102. data/spec/web/server/classes/files_app.rb +0 -27
  103. data/spec/web/server/classes/hosts_app.rb +0 -40
  104. data/spec/web/server/classes/proxy_app.rb +0 -45
  105. data/spec/web/server/files_spec.rb +0 -74
  106. data/spec/web/server/hosts_spec.rb +0 -55
  107. data/spec/web/server/proxy_spec.rb +0 -49
  108. data/tasks/spec.rb +0 -10
  109. data/tasks/yard.rb +0 -13
  110. metadata.gz.sig +0 -3
@@ -2,43 +2,68 @@
2
2
  # Ronin Web - A Ruby library for Ronin that provides support for web
3
3
  # scraping and spidering functionality.
4
4
  #
5
- # Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
5
+ # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
6
6
  #
7
- # This program is free software; you can redistribute it and/or modify
7
+ # This file is part of Ronin Web.
8
+ #
9
+ # Ronin is free software: you can redistribute it and/or modify
8
10
  # it under the terms of the GNU General Public License as published by
9
- # the Free Software Foundation; either version 2 of the License, or
11
+ # the Free Software Foundation, either version 3 of the License, or
10
12
  # (at your option) any later version.
11
13
  #
12
- # This program is distributed in the hope that it will be useful,
14
+ # Ronin is distributed in the hope that it will be useful,
13
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
17
  # GNU General Public License for more details.
16
18
  #
17
19
  # You should have received a copy of the GNU General Public License
18
- # along with this program; if not, write to the Free Software
19
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
+ # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
20
21
  #
21
22
 
22
- require 'ronin/network/helpers/helper'
23
+ require 'ronin/ui/output/helpers'
23
24
  require 'ronin/network/http/proxy'
24
25
  require 'ronin/web/web'
26
+ require 'ronin/mixin'
27
+
28
+ require 'parameters'
25
29
 
26
30
  module Ronin
27
31
  module Network
28
- module Helpers
32
+ module Mixins
29
33
  module Web
30
- include Helper
34
+
35
+ mixin UI::Output::Helpers, Parameters
36
+
37
+ mixin do
38
+ # The Web Proxy host to connect to
39
+ parameter :web_proxy_host, :type => String,
40
+ :description => 'Web Proxy host'
41
+
42
+ # The Web Proxy port to connect to
43
+ parameter :web_proxy_port, :type => Integer,
44
+ :description => 'Web Proxy port'
45
+
46
+ # The Web Proxy user to authenticate with
47
+ parameter :web_proxy_user, :type => String,
48
+ :description => 'Web Proxy authentication user'
49
+
50
+ # The Web Proxy password to authenticate with
51
+ parameter :web_proxy_password, :type => String,
52
+ :description => 'Web Proxy authentication password'
53
+ end
31
54
 
32
55
  protected
33
56
 
34
57
  #
35
- # Combines the proxy information set by the +@web_proxy_host+,
36
- # +@web_proxy_port+, +@web_proxy_user+ and +@web_proxy_password+
37
- # instance variables.
58
+ # Combines the proxy information set by the `web_proxy_host`,
59
+ # `web_proxy_port`, `web_proxy_user` and `web_proxy_password`
60
+ # parameters.
38
61
  #
39
62
  # @return [Network::HTTP::Proxy]
40
63
  # The current proxy information.
41
64
  #
65
+ # @api semipublic
66
+ #
42
67
  def web_proxy
43
68
  HTTP::Proxy.new(
44
69
  :host => @web_proxy_host,
@@ -57,12 +82,14 @@ module Ronin
57
82
  # @option options [Hash] :proxy (web_proxy)
58
83
  # Proxy information.
59
84
  #
60
- # @option options [String] :user_agent (+@web_user_agent+)
85
+ # @option options [String] :user_agent (web_user_agent)
61
86
  # User-Agent string to use.
62
87
  #
63
- # @return [WWW::Mechanize]
88
+ # @return [Mechanize]
64
89
  # The agent.
65
90
  #
91
+ # @api semipublic
92
+ #
66
93
  def web_agent(options={},&block)
67
94
  unless @web_agent
68
95
  options[:proxy] ||= web_proxy
@@ -86,23 +113,26 @@ module Ronin
86
113
  # @option options [Hash] :proxy (web_proxy)
87
114
  # Proxy information.
88
115
  #
89
- # @option options [String] :user_agent (+@web_user_agent+)
116
+ # @option options [String] :user_agent (web_user_agent)
90
117
  # User-Agent string to use.
91
118
  #
92
119
  # @yield [page]
93
120
  # If a block is given, it will be passed the page for the
94
121
  # requested URL.
95
122
  #
96
- # @yieldparam [WWW::Mechanize::Page] page
123
+ # @yieldparam [Mechanize::Page] page
97
124
  # The requested page.
98
125
  #
99
- # @return [WWW::Mechanize::Page]
126
+ # @return [Mechanize::Page]
100
127
  # The requested page.
101
128
  #
102
- def web_get(url,options={},&block)
129
+ # @api semipublic
130
+ #
131
+ def web_get(url,options={})
132
+ print_info "Requesting #{url}"
103
133
  page = web_agent(options).get(url)
104
134
 
105
- block.call(page) if block
135
+ yield page if block_given?
106
136
  return page
107
137
  end
108
138
 
@@ -119,7 +149,7 @@ module Ronin
119
149
  # @option options [Hash] :proxy (web_proxy)
120
150
  # Proxy information.
121
151
  #
122
- # @option options [String] :user_agent (+@web_user_agent+)
152
+ # @option options [String] :user_agent (web_user_agent)
123
153
  # User-Agent string to use.
124
154
  #
125
155
  # @yield [body]
@@ -131,13 +161,14 @@ module Ronin
131
161
  # @return [String]
132
162
  # The requested body of the page.
133
163
  #
134
- def web_get_body(url,options={},&block)
135
- web_get(url,options) do |page|
136
- body = page.body
164
+ # @api semipublic
165
+ #
166
+ def web_get_body(url,options={})
167
+ page = web_get(url,options)
168
+ body = page.body
137
169
 
138
- block.call(body) if block
139
- return body
140
- end
170
+ yield body if block_given?
171
+ return body
141
172
  end
142
173
 
143
174
  #
@@ -156,26 +187,29 @@ module Ronin
156
187
  # @option options [Hash] :proxy (web_proxy)
157
188
  # Proxy information.
158
189
  #
159
- # @option options [String] :user_agent (+@web_user_agent+)
190
+ # @option options [String] :user_agent (web_user_agent)
160
191
  # User-Agent string to use.
161
192
  #
162
193
  # @yield [page]
163
194
  # If a block is given, it will be passed the page for the
164
195
  # requested URL.
165
196
  #
166
- # @yieldparam [WWW::Mechanize::Page] page
197
+ # @yieldparam [Mechanize::Page] page
167
198
  # The requested page.
168
199
  #
169
- # @return [WWW::Mechanize::Page]
200
+ # @return [Mechanize::Page]
170
201
  # The requested page.
171
202
  #
172
- def web_post(url,options={},&block)
203
+ # @api semipublic
204
+ #
205
+ def web_post(url,options={})
173
206
  query = {}
174
207
  query.merge!(options[:query]) if options[:query]
175
208
 
209
+ print_info "Posting #{url}"
176
210
  page = web_agent(options).post(url)
177
211
 
178
- block.call(page) if block
212
+ yield page if block_given?
179
213
  return page
180
214
  end
181
215
 
@@ -195,25 +229,26 @@ module Ronin
195
229
  # @option options [Hash] :proxy (web_proxy)
196
230
  # Proxy information.
197
231
  #
198
- # @option options [String] :user_agent (+@web_user_agent+)
232
+ # @option options [String] :user_agent (web_user_agent)
199
233
  # User-Agent string to use.
200
234
  #
201
235
  # @yield [body]
202
236
  # If a block is given, it will be passed the body of the page.
203
237
  #
204
- # @yieldparam [WWW::Mechanize::Page] page
238
+ # @yieldparam [Mechanize::Page] page
205
239
  # The body of the requested page.
206
240
  #
207
241
  # @return [String]
208
242
  # The requested body of the page.
209
243
  #
210
- def web_post_body(url,options={},&block)
211
- web_post(url,options) do |page|
212
- body = page.body
244
+ # @api semipublic
245
+ #
246
+ def web_post_body(url,options={})
247
+ page = web_post(url,options)
248
+ body = page.body
213
249
 
214
- block.call(body) if block
215
- return body
216
- end
250
+ yield body if block_given?
251
+ return body
217
252
  end
218
253
  end
219
254
  end
@@ -2,21 +2,22 @@
2
2
  # Ronin Web - A Ruby library for Ronin that provides support for web
3
3
  # scraping and spidering functionality.
4
4
  #
5
- # Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
5
+ # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
6
6
  #
7
- # This program is free software; you can redistribute it and/or modify
7
+ # This file is part of Ronin Web.
8
+ #
9
+ # Ronin is free software: you can redistribute it and/or modify
8
10
  # it under the terms of the GNU General Public License as published by
9
- # the Free Software Foundation; either version 2 of the License, or
11
+ # the Free Software Foundation, either version 3 of the License, or
10
12
  # (at your option) any later version.
11
13
  #
12
- # This program is distributed in the hope that it will be useful,
14
+ # Ronin is distributed in the hope that it will be useful,
13
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
17
  # GNU General Public License for more details.
16
18
  #
17
19
  # You should have received a copy of the GNU General Public License
18
- # along with this program; if not, write to the Free Software
19
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
+ # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
20
21
  #
21
22
 
22
23
  require 'ronin/web/extensions'
@@ -2,21 +2,22 @@
2
2
  # Ronin Web - A Ruby library for Ronin that provides support for web
3
3
  # scraping and spidering functionality.
4
4
  #
5
- # Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
5
+ # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
6
6
  #
7
- # This program is free software; you can redistribute it and/or modify
7
+ # This file is part of Ronin Web.
8
+ #
9
+ # Ronin is free software: you can redistribute it and/or modify
8
10
  # it under the terms of the GNU General Public License as published by
9
- # the Free Software Foundation; either version 2 of the License, or
11
+ # the Free Software Foundation, either version 3 of the License, or
10
12
  # (at your option) any later version.
11
13
  #
12
- # This program is distributed in the hope that it will be useful,
14
+ # Ronin is distributed in the hope that it will be useful,
13
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
17
  # GNU General Public License for more details.
16
18
  #
17
19
  # You should have received a copy of the GNU General Public License
18
- # along with this program; if not, write to the Free Software
19
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
+ # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
20
21
  #
21
22
 
22
23
  require 'ronin/web/extensions/nokogiri'
@@ -1 +1,23 @@
1
+ #
2
+ # Ronin Web - A Ruby library for Ronin that provides support for web
3
+ # scraping and spidering functionality.
4
+ #
5
+ # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of Ronin Web.
8
+ #
9
+ # Ronin is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # Ronin is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
21
+ #
22
+
1
23
  require 'ronin/web/extensions/nokogiri/xml'
@@ -1,3 +1,25 @@
1
+ #
2
+ # Ronin Web - A Ruby library for Ronin that provides support for web
3
+ # scraping and spidering functionality.
4
+ #
5
+ # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of Ronin Web.
8
+ #
9
+ # Ronin is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # Ronin is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
21
+ #
22
+
1
23
  require 'ronin/web/extensions/nokogiri/xml/node'
2
24
  require 'ronin/web/extensions/nokogiri/xml/text'
3
25
  require 'ronin/web/extensions/nokogiri/xml/attr'
@@ -1,10 +1,44 @@
1
+ #
2
+ # Ronin Web - A Ruby library for Ronin that provides support for web
3
+ # scraping and spidering functionality.
4
+ #
5
+ # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of Ronin Web.
8
+ #
9
+ # Ronin is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # Ronin is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
21
+ #
22
+
1
23
  require 'nokogiri'
2
24
 
3
25
  module Nokogiri
4
26
  module XML
5
27
  class Attr < Node
6
28
 
7
- def similar?(other)
29
+ #
30
+ # Determines if the attribute is similar to another attribute.
31
+ #
32
+ # @param [Nokogiri::XML::Attr] other
33
+ # The other attribute.
34
+ #
35
+ # @return [Boolean]
36
+ # Specifies if the attribute is similar, in indentity or value,
37
+ # to the other attribute.
38
+ #
39
+ # @api public
40
+ #
41
+ def ==(other)
8
42
  super(other) && (self.value == other.value)
9
43
  end
10
44
 
@@ -1,3 +1,25 @@
1
+ #
2
+ # Ronin Web - A Ruby library for Ronin that provides support for web
3
+ # scraping and spidering functionality.
4
+ #
5
+ # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of Ronin Web.
8
+ #
9
+ # Ronin is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # Ronin is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
21
+ #
22
+
1
23
  require 'nokogiri'
2
24
 
3
25
  module Nokogiri
@@ -5,12 +27,20 @@ module Nokogiri
5
27
  class Document < Node
6
28
 
7
29
  #
8
- # Returns the total count of all sub-children of the document.
30
+ # Calculates the sum of all sub-children of the document.
31
+ #
32
+ # @return [Integer]
33
+ # The total number of children and sub-children of the document.
34
+ # Returns `0` if the document has no root element.
35
+ #
36
+ # @api public
9
37
  #
10
38
  def total_children
11
- return 0 unless root
12
-
13
- 1 + root.total_children
39
+ if root
40
+ 1 + root.total_children
41
+ else
42
+ 0
43
+ end
14
44
  end
15
45
 
16
46
  end
@@ -1,10 +1,44 @@
1
+ #
2
+ # Ronin Web - A Ruby library for Ronin that provides support for web
3
+ # scraping and spidering functionality.
4
+ #
5
+ # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of Ronin Web.
8
+ #
9
+ # Ronin is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # Ronin is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
21
+ #
22
+
1
23
  require 'nokogiri'
2
24
 
3
25
  module Nokogiri
4
26
  module XML
5
27
  class Element < Node
6
28
 
7
- def similar?(other)
29
+ #
30
+ # Determines if the element is similar to another element.
31
+ #
32
+ # @param [Nokogiri::XML::Element] other
33
+ # The other element.
34
+ #
35
+ # @return [Boolean]
36
+ # Specifies whether the element is equal, in identity or value, to
37
+ # another element.
38
+ #
39
+ # @api public
40
+ #
41
+ def ==(other)
8
42
  return false unless super(other)
9
43
  return false unless attribute_nodes.length == other.attribute_nodes.length
10
44
 
@@ -15,7 +49,7 @@ module Nokogiri
15
49
  return false unless attr1.similar?(attr2)
16
50
  end
17
51
 
18
- true
52
+ return true
19
53
  end
20
54
 
21
55
  end