ar_sitemapper 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +9 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/Changelog.rdoc +28 -0
  6. data/Gemfile +4 -0
  7. data/Gemfile.lock +98 -0
  8. data/LICENSE +24 -0
  9. data/README.rdoc +176 -0
  10. data/Rakefile +23 -0
  11. data/ar_sitemapper.gemspec +26 -0
  12. data/install.rb +5 -0
  13. data/lib/ar_sitemapper.rb +11 -0
  14. data/lib/sitemapper/active_record/builder.rb +54 -0
  15. data/lib/sitemapper/engine.rb +26 -0
  16. data/lib/sitemapper/generator.rb +100 -0
  17. data/lib/sitemapper/index.rb +84 -0
  18. data/lib/sitemapper/loader.rb +39 -0
  19. data/lib/sitemapper/pinger.rb +21 -0
  20. data/lib/sitemapper/sitemap.rb +22 -0
  21. data/lib/sitemapper/urlset.rb +76 -0
  22. data/lib/sitemapper/version.rb +5 -0
  23. data/lib/tasks/sitemapper.rake +26 -0
  24. data/templates/sitemaps.yml +34 -0
  25. data/test/dummy/README.rdoc +261 -0
  26. data/test/dummy/Rakefile +7 -0
  27. data/test/dummy/app/assets/javascripts/application.js +15 -0
  28. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  29. data/test/dummy/app/controllers/application_controller.rb +3 -0
  30. data/test/dummy/app/helpers/application_helper.rb +2 -0
  31. data/test/dummy/app/mailers/.gitkeep +0 -0
  32. data/test/dummy/app/models/.gitkeep +0 -0
  33. data/test/dummy/app/views/layouts/application.html.erb +24 -0
  34. data/test/dummy/config.ru +4 -0
  35. data/test/dummy/config/application.rb +50 -0
  36. data/test/dummy/config/boot.rb +10 -0
  37. data/test/dummy/config/database.yml +25 -0
  38. data/test/dummy/config/environment.rb +5 -0
  39. data/test/dummy/config/environments/development.rb +24 -0
  40. data/test/dummy/config/environments/production.rb +69 -0
  41. data/test/dummy/config/environments/test.rb +37 -0
  42. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  43. data/test/dummy/config/initializers/inflections.rb +15 -0
  44. data/test/dummy/config/initializers/mime_types.rb +5 -0
  45. data/test/dummy/config/initializers/secret_token.rb +7 -0
  46. data/test/dummy/config/initializers/session_store.rb +8 -0
  47. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  48. data/test/dummy/config/locales/en.yml +5 -0
  49. data/test/dummy/config/routes.rb +2 -0
  50. data/test/dummy/config/sitemaps.yml +36 -0
  51. data/test/dummy/db/schema.rb +74 -0
  52. data/test/dummy/lib/assets/.gitkeep +0 -0
  53. data/test/dummy/log/.gitkeep +0 -0
  54. data/test/dummy/public/404.html +26 -0
  55. data/test/dummy/public/422.html +26 -0
  56. data/test/dummy/public/500.html +25 -0
  57. data/test/dummy/public/favicon.ico +0 -0
  58. data/test/dummy/script/rails +6 -0
  59. data/test/support/app/models/foo_bar.rb +24 -0
  60. data/test/test_helper.rb +13 -0
  61. data/test/unit/engine_test.rb +19 -0
  62. data/test/unit/generator_test.rb +14 -0
  63. data/test/unit/loader_test.rb +21 -0
  64. data/test/unit/map_test.rb +9 -0
  65. data/test/unit/pinger_test.rb +11 -0
  66. data/test/unit/sitemapper_test.rb +22 -0
  67. data/test/unit/urlset_test.rb +9 -0
  68. metadata +221 -0
@@ -0,0 +1,69 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # Code is not reloaded between requests
5
+ config.cache_classes = true
6
+
7
+ config.eager_load = true
8
+
9
+ # Full error reports are disabled and caching is turned on
10
+ config.consider_all_requests_local = false
11
+ config.action_controller.perform_caching = true
12
+
13
+ # Disable Rails's static asset server (Apache or nginx will already do this)
14
+ config.serve_static_assets = false
15
+
16
+ # Compress JavaScripts and CSS
17
+ config.assets.js_compressor = :uglifier
18
+
19
+ # Don't fallback to assets pipeline if a precompiled asset is missed
20
+ config.assets.compile = false
21
+
22
+ # Generate digests for assets URLs
23
+ config.assets.digest = true
24
+
25
+ # Defaults to nil and saved in location specified by config.assets.prefix
26
+ # config.assets.manifest = YOUR_PATH
27
+
28
+ # Specifies the header that your server uses for sending files
29
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
30
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
31
+
32
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
33
+ # config.force_ssl = true
34
+
35
+ # See everything in the log (default is :info)
36
+ # config.log_level = :debug
37
+
38
+ # Prepend all log lines with the following tags
39
+ # config.log_tags = [ :subdomain, :uuid ]
40
+
41
+ # Use a different logger for distributed setups
42
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
43
+
44
+ # Use a different cache store in production
45
+ # config.cache_store = :mem_cache_store
46
+
47
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
48
+ # config.action_controller.asset_host = "http://assets.example.com"
49
+
50
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
51
+ # config.assets.precompile += %w( search.js )
52
+
53
+ # Disable delivery errors, bad email addresses will be ignored
54
+ # config.action_mailer.raise_delivery_errors = false
55
+
56
+ # Enable threaded mode
57
+ # config.threadsafe!
58
+
59
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
60
+ # the I18n.default_locale when a translation can not be found)
61
+ config.i18n.fallbacks = true
62
+
63
+ # Send deprecation notices to registered listeners
64
+ config.active_support.deprecation = :notify
65
+
66
+ # Log the query plan for queries taking more than this (works
67
+ # with SQLite, MySQL, and PostgreSQL)
68
+ # config.active_record.auto_explain_threshold_in_seconds = 0.5
69
+ end
@@ -0,0 +1,37 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ config.eager_load = false
11
+
12
+ # Configure static asset server for tests with Cache-Control for performance
13
+ config.serve_static_assets = true
14
+ config.static_cache_control = "public, max-age=3600"
15
+
16
+ # Show full error reports and disable caching
17
+ config.consider_all_requests_local = true
18
+ config.action_controller.perform_caching = false
19
+
20
+ # Raise exceptions instead of rendering exception templates
21
+ config.action_dispatch.show_exceptions = false
22
+
23
+ # Disable request forgery protection in test environment
24
+ config.action_controller.allow_forgery_protection = false
25
+
26
+ # Tell Action Mailer not to deliver emails to the real world.
27
+ # The :test delivery method accumulates sent emails in the
28
+ # ActionMailer::Base.deliveries array.
29
+ config.action_mailer.delivery_method = :test
30
+
31
+ # Raise exception on mass assignment protection for Active Record models
32
+ # TODO remove
33
+ # config.active_record.mass_assignment_sanitizer = :strict
34
+
35
+ # Print deprecation notices to the stderr
36
+ config.active_support.deprecation = :stderr
37
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,15 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
11
+ #
12
+ # These inflection rules are supported but not enabled by default:
13
+ # ActiveSupport::Inflector.inflections do |inflect|
14
+ # inflect.acronym 'RESTful'
15
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ Dummy::Application.config.secret_key_base = '0440a625efa7cd76255bd10e2e4fb732aa70e18b00e02f9aaf2d13366d5d4a81cbb97e5d4b9d1f6a3f86dfb198633ab3a34cba8ee722b2c70b7f2d7d54ebee6f'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rails generate session_migration")
8
+ # Dummy::Application.config.session_store :active_record_store
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json]
9
+ end
10
+
11
+ # Disable root element in JSON by default.
12
+ ActiveSupport.on_load(:active_record) do
13
+ self.include_root_in_json = false
14
+ end
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,2 @@
1
+ Rails.application.routes.draw do
2
+ end
@@ -0,0 +1,36 @@
1
+ default_host: "www.example.com"
2
+ local_path: <%= File.join Rails.root, "public", "sitemaps" %>
3
+ ping: true
4
+
5
+ index:
6
+ sitemapfile: "sitemap_index.xml"
7
+ includes:
8
+ -
9
+ loc: foo_sitemap.xml
10
+ #static:
11
+ # sitemapfile: "sitemapfoobar.xml.gz"
12
+ # urlset:
13
+ # -
14
+ # loc: "http://www.example.com/static/page"
15
+ # changefreq: weekly
16
+ # priority: 0.1
17
+ # -
18
+ # loc: "http://www.example.com/important/static/page"
19
+ # changefreq: daily
20
+ # priority: 1.0
21
+ #
22
+ models:
23
+ foo_bar:
24
+ # conditions: "foo = 'bar'"
25
+ # sitemapfile: sitemap_foo_bars.xml.gz
26
+ # loc: Proc.new {|object| foo_bar_path(object) }
27
+ # changefreq: weekly
28
+ priority: 0.7
29
+ # acme:
30
+ # sitemapfile: sitemap_acmes.xml.gz
31
+ # loc: Proc.new {|object| acme_path(object) }
32
+ # changefreq: weekly
33
+ # priority: 0.8
34
+ #
35
+ pings:
36
+ - http://ping.example.com/ping?sitemap=
@@ -0,0 +1,74 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended to check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(:version => 20130606070947) do
15
+
16
+ create_table "access_rights", :force => true do |t|
17
+ t.integer "user_id"
18
+ t.integer "grantable_id"
19
+ t.string "grantable_type"
20
+ t.datetime "expired_at"
21
+ t.datetime "created_at", :null => false
22
+ t.datetime "updated_at", :null => false
23
+ end
24
+
25
+ add_index "access_rights", ["grantable_id", "grantable_type"], :name => "index_access_rights_on_grantable_id_and_grantable_type"
26
+ add_index "access_rights", ["user_id"], :name => "index_access_rights_on_user_id"
27
+
28
+ create_table "additional_rights", :force => true do |t|
29
+ t.string "title"
30
+ t.text "description"
31
+ t.datetime "created_at", :null => false
32
+ t.datetime "updated_at", :null => false
33
+ t.boolean "expires", :default => false
34
+ end
35
+
36
+ add_index "additional_rights", ["title"], :name => "index_additional_rights_on_title"
37
+
38
+ create_table "rights", :force => true do |t|
39
+ t.string "controller"
40
+ t.string "action"
41
+ t.datetime "created_at", :null => false
42
+ t.datetime "updated_at", :null => false
43
+ end
44
+
45
+ add_index "rights", ["action"], :name => "index_rights_on_action"
46
+ add_index "rights", ["controller"], :name => "index_rights_on_controller"
47
+
48
+ create_table "role_rights", :force => true do |t|
49
+ t.integer "role_id"
50
+ t.integer "right_id"
51
+ t.datetime "created_at", :null => false
52
+ t.datetime "updated_at", :null => false
53
+ end
54
+
55
+ add_index "role_rights", ["right_id"], :name => "index_role_rights_on_right_id"
56
+ add_index "role_rights", ["role_id"], :name => "index_role_rights_on_role_id"
57
+
58
+ create_table "roles", :force => true do |t|
59
+ t.string "title"
60
+ t.datetime "created_at", :null => false
61
+ t.datetime "updated_at", :null => false
62
+ end
63
+
64
+ add_index "roles", ["title"], :name => "index_roles_on_title"
65
+
66
+ create_table "users", :force => true do |t|
67
+ t.string "name"
68
+ t.integer "role_id"
69
+ t.datetime "created_at", :null => false
70
+ t.datetime "updated_at", :null => false
71
+ t.string "token"
72
+ end
73
+
74
+ end
File without changes
File without changes
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,24 @@
1
+ # Dummyclass to mock ActiveRecord::Base
2
+ class FooBar
3
+
4
+ attr_reader :id, :name
5
+
6
+ def initialize(*args)
7
+ @id = rand(4711)
8
+ end
9
+
10
+ def to_param; id; end
11
+
12
+ def self.all(*args)
13
+ 3.times.map { self.class.new }
14
+ end
15
+
16
+ def self.find(*args)
17
+ unless args.first.is_a?(Hash)
18
+ return self.class.all if args.first == :all
19
+ else
20
+ return self.class.new
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,13 @@
1
+ ENV["RAILS_ENV"] ||= 'test'
2
+
3
+ require File.expand_path('../dummy/config/environment.rb', __FILE__)
4
+
5
+ require 'test/unit'
6
+ require 'minitest/autorun'
7
+ require 'rubygems'
8
+ require 'bundler'
9
+ Bundler.require(:default, :development)
10
+
11
+ require 'erb'
12
+
13
+ Dir.glob(File.join(File.dirname(__FILE__) + 'support', 'app', '*') {|file| require file})
@@ -0,0 +1,19 @@
1
+ require 'test_helper'
2
+
3
+ describe AegisNet::Sitemapper::Engine do
4
+
5
+ it 'returns sets the default config path' do
6
+ AegisNet::Sitemapper.sitemap_file.must_equal "#{Rails.root}/config/sitemaps.yml"
7
+ end
8
+
9
+ it 'integrates with ActiveRecord' do
10
+ active_record_builder::SingletonMethods.instance_methods.each do |method|
11
+ ActiveRecord::Base.must_respond_to method
12
+ end
13
+ end
14
+
15
+ def active_record_builder
16
+ AegisNet::Sitemapper::ActiveRecord::Builder
17
+ end
18
+
19
+ end