alexrabarts-big_sitemap 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.5.0 / 2009-09-07
2
+
3
+ * Add support for lambdas when specifying lastmod
4
+
1
5
  === 0.4.0 / 2009-08-09
2
6
 
3
7
  * Use Bing instead of Live/MSN. Note, this breaks backwards compatibility as
data/README.rdoc CHANGED
@@ -71,13 +71,14 @@ To ping search engines, call <code>ping_search_engines</code> after you generate
71
71
  sitemap.generate
72
72
  sitemap.ping_search_engines
73
73
 
74
- === Change Frequency and Priority
74
+ === Change Frequency, Priority and Last Modified
75
75
 
76
- You can control "changefreq" and "priority" values for each record individually by passing lambdas instead of fixed values:
76
+ You can control "changefreq", "priority" and "lastmod" values for each record individually by passing lambdas instead of fixed values:
77
77
 
78
78
  sitemap.add(Posts,
79
79
  :change_frequency => lambda {|post| ... },
80
- :priority => lambda {|post| ... }
80
+ :priority => lambda {|post| ... },
81
+ :last_modified => lambda {|post| ... }
81
82
  )
82
83
 
83
84
  === Find Methods
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :major: 0
3
- :minor: 4
4
2
  :patch: 0
3
+ :major: 0
4
+ :minor: 5
data/lib/big_sitemap.rb CHANGED
@@ -112,8 +112,13 @@ class BigSitemap
112
112
  find_options.update(:limit => limit, :offset => offset) if num_batches > 1
113
113
 
114
114
  model.send(find_method, find_options).each do |record|
115
- last_mod_method = pick_method(record, TIMESTAMP_METHODS)
116
- last_mod = last_mod_method.nil? ? Time.now : record.send(last_mod_method)
115
+ last_mod = options[:last_modified]
116
+ if last_mod.is_a?(Proc)
117
+ last_mod = last_mod.call(record)
118
+ elsif last_mod.nil?
119
+ last_mod_method = pick_method(record, TIMESTAMP_METHODS)
120
+ last_mod = last_mod_method.nil? ? Time.now : record.send(last_mod_method)
121
+ end
117
122
 
118
123
  param_method = pick_method(record, PARAM_METHODS)
119
124
 
@@ -130,6 +130,11 @@ class BigSitemapTest < Test::Unit::TestCase
130
130
  assert_equal TestModel.new.priority.to_s, elements(first_sitemaps_model_file, 'priority').first.text
131
131
  end
132
132
 
133
+ should 'be able to use a lambda to specify lastmod' do
134
+ generate_one_sitemap_model_file(:last_modified => lambda {|m| m.updated_at})
135
+ assert_equal TestModel.new.updated_at.utc.strftime('%Y-%m-%dT%H:%M:%S+00:00'), elements(first_sitemaps_model_file, 'lastmod').first.text
136
+ end
137
+
133
138
  should 'contain two loc element' do
134
139
  generate_two_model_sitemap_files
135
140
  assert_equal 2, num_elements(first_sitemaps_model_file, 'loc')
@@ -11,6 +11,10 @@ class TestModel
11
11
  0.8
12
12
  end
13
13
 
14
+ def updated_at
15
+ Time.at(1000000000)
16
+ end
17
+
14
18
  class << self
15
19
  def count_for_sitemap
16
20
  self.find_for_sitemap.size
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alexrabarts-big_sitemap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Rabarts
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-09 00:00:00 -07:00
12
+ date: 2009-09-07 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -39,26 +39,26 @@ executables: []
39
39
  extensions: []
40
40
 
41
41
  extra_rdoc_files:
42
- - LICENSE
43
42
  - README.rdoc
43
+ - LICENSE
44
44
  files:
45
- - .gitignore
46
45
  - History.txt
47
- - LICENSE
48
46
  - README.rdoc
49
- - Rakefile
50
47
  - VERSION.yml
51
- - big_sitemap.gemspec
52
- - lib/big_sitemap.rb
48
+ - lib/big_sitemap
53
49
  - lib/big_sitemap/builder.rb
50
+ - lib/big_sitemap.rb
54
51
  - test/big_sitemap_test.rb
52
+ - test/fixtures
55
53
  - test/fixtures/test_model.rb
56
54
  - test/test_helper.rb
57
- has_rdoc: false
55
+ - LICENSE
56
+ has_rdoc: true
58
57
  homepage: http://github.com/alexrabarts/big_sitemap
59
58
  licenses:
60
59
  post_install_message:
61
60
  rdoc_options:
61
+ - --inline-source
62
62
  - --charset=UTF-8
63
63
  require_paths:
64
64
  - lib
@@ -79,9 +79,7 @@ requirements: []
79
79
  rubyforge_project:
80
80
  rubygems_version: 1.3.5
81
81
  signing_key:
82
- specification_version: 3
82
+ specification_version: 2
83
83
  summary: A Sitemap generator specifically designed for large sites (although it works equally well with small sites)
84
- test_files:
85
- - test/big_sitemap_test.rb
86
- - test/fixtures/test_model.rb
87
- - test/test_helper.rb
84
+ test_files: []
85
+
data/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- ._*
2
- pkg
data/Rakefile DELETED
@@ -1,53 +0,0 @@
1
- require 'rake'
2
-
3
- begin
4
- require 'jeweler'
5
- Jeweler::Tasks.new do |s|
6
- s.name = "big_sitemap"
7
- s.summary = %Q{A Sitemap generator specifically designed for large sites (although it works equally well with small sites)}
8
- s.email = "alexrabarts@gmail.com"
9
- s.homepage = "http://github.com/alexrabarts/big_sitemap"
10
- s.description = "A Sitemap generator specifically designed for large sites (although it works equally well with small sites)"
11
- s.authors = ["Alex Rabarts"]
12
- s.add_dependency 'builder', ['>=2.1.2']
13
- s.add_dependency 'extlib', ['>=0.9.9']
14
- end
15
- rescue LoadError
16
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
17
- end
18
-
19
- require 'rake/rdoctask'
20
- Rake::RDocTask.new do |rdoc|
21
- rdoc.rdoc_dir = 'rdoc'
22
- rdoc.title = 'big_sitemap'
23
- rdoc.options << '--line-numbers' << '--inline-source'
24
- rdoc.rdoc_files.include('README*')
25
- rdoc.rdoc_files.include('lib/**/*.rb')
26
- end
27
-
28
- require 'rake/testtask'
29
- Rake::TestTask.new(:test) do |t|
30
- t.libs << 'lib' << 'test'
31
- t.pattern = 'test/**/*_test.rb'
32
- t.verbose = false
33
- end
34
-
35
- begin
36
- require 'rcov/rcovtask'
37
- Rcov::RcovTask.new do |t|
38
- t.libs << 'test'
39
- t.test_files = FileList['test/**/*_test.rb']
40
- t.verbose = true
41
- end
42
- rescue LoadError
43
- puts "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
44
- end
45
-
46
- begin
47
- require 'cucumber/rake/task'
48
- Cucumber::Rake::Task.new(:features)
49
- rescue LoadError
50
- puts "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
51
- end
52
-
53
- task :default => :test
data/big_sitemap.gemspec DELETED
@@ -1,56 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{big_sitemap}
5
- s.version = "0.4.0"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Alex Rabarts"]
9
- s.date = %q{2009-08-09}
10
- s.description = %q{A Sitemap generator specifically designed for large sites (although it works equally well with small sites)}
11
- s.email = %q{alexrabarts@gmail.com}
12
- s.extra_rdoc_files = [
13
- "LICENSE",
14
- "README.rdoc"
15
- ]
16
- s.files = [
17
- ".gitignore",
18
- "History.txt",
19
- "LICENSE",
20
- "README.rdoc",
21
- "Rakefile",
22
- "VERSION.yml",
23
- "big_sitemap.gemspec",
24
- "lib/big_sitemap.rb",
25
- "lib/big_sitemap/builder.rb",
26
- "test/big_sitemap_test.rb",
27
- "test/fixtures/test_model.rb",
28
- "test/test_helper.rb"
29
- ]
30
- s.homepage = %q{http://github.com/alexrabarts/big_sitemap}
31
- s.rdoc_options = ["--charset=UTF-8"]
32
- s.require_paths = ["lib"]
33
- s.rubygems_version = %q{1.3.4}
34
- s.summary = %q{A Sitemap generator specifically designed for large sites (although it works equally well with small sites)}
35
- s.test_files = [
36
- "test/big_sitemap_test.rb",
37
- "test/fixtures/test_model.rb",
38
- "test/test_helper.rb"
39
- ]
40
-
41
- if s.respond_to? :specification_version then
42
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
43
- s.specification_version = 3
44
-
45
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
46
- s.add_runtime_dependency(%q<builder>, [">= 2.1.2"])
47
- s.add_runtime_dependency(%q<extlib>, [">= 0.9.9"])
48
- else
49
- s.add_dependency(%q<builder>, [">= 2.1.2"])
50
- s.add_dependency(%q<extlib>, [">= 0.9.9"])
51
- end
52
- else
53
- s.add_dependency(%q<builder>, [">= 2.1.2"])
54
- s.add_dependency(%q<extlib>, [">= 0.9.9"])
55
- end
56
- end