cartographer 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ === 1.2.0 / 2011-03-29
2
+
3
+ * Directories are now skipped.
4
+
1
5
  === 1.1.1 / 2011-03-29
2
6
 
3
7
  * URI escaping for paths
@@ -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.1.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
- if File.directory?(path)
84
- new_path += "/"
85
- end
84
+ stat = File.stat(path)
86
85
 
87
86
  if block_given?
88
87
  new_path = yield new_path
@@ -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/", "http://example.org/test_cartographer.rb" ],
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/", "http://example.org/test_cartographer.rb" ],
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", "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/", "http://example.org/test_cartographer/" ],
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
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cartographer
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.1.1
5
+ version: 1.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Erik Hollensbe