Class: Gitlab::RobotsTxt::Parser
- Inherits:
-
Object
- Object
- Gitlab::RobotsTxt::Parser
- Defined in:
- lib/gitlab/robots_txt/parser.rb
Constant Summary collapse
- DISALLOW_REGEX =
/^disallow: /i
- ALLOW_REGEX =
/^allow: /i
Instance Attribute Summary collapse
-
#allow_rules ⇒ Object
readonly
Returns the value of attribute allow_rules.
-
#disallow_rules ⇒ Object
readonly
Returns the value of attribute disallow_rules.
Instance Method Summary collapse
- #disallowed?(path) ⇒ Boolean
-
#initialize(content) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(content) ⇒ Parser
Returns a new instance of Parser.
11 12 13 14 15 |
# File 'lib/gitlab/robots_txt/parser.rb', line 11 def initialize(content) @raw_content = content @disallow_rules, @allow_rules = parse_raw_content! end |
Instance Attribute Details
#allow_rules ⇒ Object (readonly)
Returns the value of attribute allow_rules.
9 10 11 |
# File 'lib/gitlab/robots_txt/parser.rb', line 9 def allow_rules @allow_rules end |
#disallow_rules ⇒ Object (readonly)
Returns the value of attribute disallow_rules.
9 10 11 |
# File 'lib/gitlab/robots_txt/parser.rb', line 9 def disallow_rules @disallow_rules end |
Instance Method Details
#disallowed?(path) ⇒ Boolean
17 18 19 20 21 |
# File 'lib/gitlab/robots_txt/parser.rb', line 17 def disallowed?(path) return false if allow_rules.any? { |rule| path =~ rule } disallow_rules.any? { |rule| path =~ rule } end |