Class: Roboto::ContentProvider
- Inherits:
-
Object
- Object
- Roboto::ContentProvider
- Defined in:
- lib/roboto/content_provider.rb
Overview
provides the content of effective robots.txt file
Instance Method Summary collapse
-
#contents(custom_binding = nil) ⇒ String
Reads the contents of the effective robots.txt file.
-
#path ⇒ Path
Determines the most relevant robots.txt file.
Instance Method Details
#contents(custom_binding = nil) ⇒ String
Reads the contents of the effective robots.txt file
8 9 10 11 12 13 14 15 16 |
# File 'lib/roboto/content_provider.rb', line 8 def contents(custom_binding = nil) return @contents unless @contents.nil? @contents = File.read(path) if path.extname == '.erb' @contents = ERB.new(@contents, nil, '>').result(custom_binding ? custom_binding : binding) end @contents end |
#path ⇒ Path
Determines the most relevant robots.txt file.
It checks for the paths in the following order
- Rails.root/config/robots/
.txt (ie production.txt) - Rails.root/config/robots/default.txt
- The default, blank robots.txt provided by the gem
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/roboto/content_provider.rb', line 26 def path lookup_paths.each do |f| if FileTest.exist?(f) return f end end #this should never occur because we define a default in the gem raise "Robots file not found" end |