cartographer 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/lib/cartographer.rb +4 -5
- data/test/test_cartographer.rb +4 -4
- metadata +1 -1
data/History.txt
CHANGED
data/lib/cartographer.rb
CHANGED
@@ -24,7 +24,7 @@ require 'nokogiri'
|
|
24
24
|
# See Cartographer and Cartographer::URL RDoc for more information.
|
25
25
|
#
|
26
26
|
class Cartographer
|
27
|
-
VERSION = '1.
|
27
|
+
VERSION = '1.2.0'
|
28
28
|
|
29
29
|
##
|
30
30
|
# List of Cartographer::URL objects
|
@@ -76,13 +76,12 @@ class Cartographer
|
|
76
76
|
#
|
77
77
|
def add_tree(base_path)
|
78
78
|
Find.find(base_path) do |path|
|
79
|
+
next if File.directory?(path)
|
80
|
+
|
79
81
|
new_path = path.sub %r!^#{Regexp.escape base_path}!, ''
|
80
82
|
uri = root_uri.dup
|
81
|
-
stat = File.stat(path)
|
82
83
|
|
83
|
-
|
84
|
-
new_path += "/"
|
85
|
-
end
|
84
|
+
stat = File.stat(path)
|
86
85
|
|
87
86
|
if block_given?
|
88
87
|
new_path = yield new_path
|
data/test/test_cartographer.rb
CHANGED
@@ -76,24 +76,24 @@ class TestCartographer < MiniTest::Unit::TestCase
|
|
76
76
|
sm.add_tree(File.expand_path("test"))
|
77
77
|
|
78
78
|
xml = Nokogiri::XML.parse(sm.to_xml)
|
79
|
-
assert_equal [ "http://example.org/
|
79
|
+
assert_equal [ "http://example.org/test_cartographer.rb" ],
|
80
80
|
xml.root.xpath('//xmlns:loc', xml.root.namespaces).map(&:content)
|
81
81
|
|
82
82
|
sm = Cartographer.new("http://example.org", "always")
|
83
83
|
sm.add_tree(File.expand_path("test"))
|
84
84
|
|
85
85
|
xml = Nokogiri::XML.parse(sm.to_xml)
|
86
|
-
assert_equal [ "http://example.org/
|
86
|
+
assert_equal [ "http://example.org/test_cartographer.rb" ],
|
87
87
|
xml.root.xpath('//xmlns:loc', xml.root.namespaces).map(&:content)
|
88
88
|
|
89
|
-
assert_equal [ "always"
|
89
|
+
assert_equal [ "always" ],
|
90
90
|
xml.root.xpath('//xmlns:changefreq', xml.root.namespaces).map(&:content)
|
91
91
|
|
92
92
|
sm = Cartographer.new("http://example.org")
|
93
93
|
sm.add_tree(File.expand_path("test")) { |x| x.sub(/\.rb$/, '/') }
|
94
94
|
|
95
95
|
xml = Nokogiri::XML.parse(sm.to_xml)
|
96
|
-
assert_equal [ "http://example.org/
|
96
|
+
assert_equal [ "http://example.org/test_cartographer/" ],
|
97
97
|
xml.root.xpath('//xmlns:loc', xml.root.namespaces).map(&:content)
|
98
98
|
end
|
99
99
|
|