Module: Para::SeoTools::Skeleton
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- lib/para/seo_tools/skeleton.rb,
lib/para/seo_tools/skeleton/job.rb,
lib/para/seo_tools/skeleton/site.rb,
lib/para/seo_tools/skeleton/page_builder.rb
Defined Under Namespace
Classes: Job, PageBuilder, ScopeAttributeUndefined, Site
Class Method Summary
collapse
Class Method Details
.build(load_skeleton: false) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/para/seo_tools/skeleton.rb', line 34
def self.build(load_skeleton: false)
return if migrating?
return unless ActiveRecord::Base.connection.table_exists?(Para::SeoTools::Page.table_name)
load if load_skeleton
log " * Building app skeleton pages ..."
site_options = options.merge(enable_logging: enable_logging)
self.site = Skeleton::Site.new(site_options)
site.instance_exec(&config)
ActiveRecord::Base.transaction do
site.save
destroy_deleted_pages!
end
end
|
.destroy_deleted_pages! ⇒ Object
66
67
68
69
70
|
# File 'lib/para/seo_tools/skeleton.rb', line 66
def self.destroy_deleted_pages!
pages = Para::SeoTools::Page.where.not(id: site.saved_pages_ids)
log " * Destroying old pages ..."
pages.delete_all
end
|
.draw(lazy: false, **options, &block) ⇒ Object
28
29
30
31
32
|
# File 'lib/para/seo_tools/skeleton.rb', line 28
def self.draw(lazy: false, **options, &block)
self.config = block
self.options = options
build unless lazy
end
|
.load ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/para/seo_tools/skeleton.rb', line 19
def self.load
Rails.application.reload_routes!
skeleton_path = Rails.root.join('config', 'skeleton.rb')
require skeleton_path if File.exists?(skeleton_path)
end
|
.log(message) ⇒ Object
Log messages when you’re not in rails
74
75
76
|
# File 'lib/para/seo_tools/skeleton.rb', line 74
def self.log(message)
Rails.logger.info(message) if enable_logging || !$0.end_with?('rails')
end
|
.migrating? ⇒ Boolean
58
59
60
61
62
63
64
|
# File 'lib/para/seo_tools/skeleton.rb', line 58
def self.migrating?
if ActiveRecord::Migrator.respond_to?(:needs_migration?)
ActiveRecord::Migrator.needs_migration?
else
ActiveRecord::Base.connection.migration_context.needs_migration?
end
end
|
.with_logging(&block) ⇒ Object
12
13
14
15
16
17
|
# File 'lib/para/seo_tools/skeleton.rb', line 12
def self.with_logging(&block)
self.enable_logging = true
block.call
ensure
self.enable_logging = false
end
|