Class: Yandex::Webmaster::Host
- Extended by:
- Forwardable
- Defined in:
- lib/yandex-webmaster/host.rb
Constant Summary
Constants included from Request
Request::METHODS, Request::METHODS_WITH_BODIES
Constants included from Connection
Connection::ACCEPT, Connection::ACCEPT_CHARSET, Connection::ALLOWED_OPTIONS, Connection::CONTENT_TYPE, Connection::USER_AGENT
Instance Attribute Summary
Attributes inherited from Base
Attributes included from Authorization
Class Method Summary collapse
Instance Method Summary collapse
-
#delete ⇒ Object
Delete information about the host from Yandex.Webmaster [RU] api.yandex.ru/webmaster/doc/dg/reference/hosts-delete.xml [EN] api.yandex.com/webmaster/doc/dg/reference/hosts-delete.xml.
- #deleted? ⇒ Boolean
-
#id ⇒ Integer
Id of the host.
-
#load_incoming_links ⇒ Yandex::Webmaster::Host
Load information about incoming links for the host [RU] api.yandex.ru/webmaster/doc/dg/reference/host-links.xml [EN] api.yandex.com/webmaster/doc/dg/reference/host-links.xml.
-
#load_indexed_urls ⇒ Yandex::Webmaster::Host
Load information about indexed urls for the host [RU] api.yandex.ru/webmaster/doc/dg/reference/hosts-indexed.xml [EN] api.yandex.com/webmaster/doc/dg/reference/hosts-indexed.xml.
- #load_sitemaps ⇒ Object
-
#load_stats ⇒ Yandex::Webmaster::Host
Load stats for the host [RU] api.yandex.ru/webmaster/doc/dg/reference/hosts-stats.xml [EN] api.yandex.com/webmaster/doc/dg/reference/hosts-stats.xml.
-
#load_top_queries ⇒ Yandex::Webmaster::Host
Load information about top queries for the host [RU] api.yandex.ru/webmaster/doc/dg/reference/host-tops.xml [EN] api.yandex.com/webmaster/doc/dg/reference/host-tops.xml.
- #load_verification ⇒ Object
-
#resources ⇒ Hash
Load information about resources that are available for the host.
-
#sitemaps(reload = false) ⇒ Yandex::Webmaster::Host
Get(load) list of sitemap files for the host [RU] api.yandex.ru/webmaster/doc/dg/reference/sitemaps.xml [EN] api.yandex.com/webmaster/doc/dg/reference/sitemaps.xml.
-
#verification(reload = false) ⇒ Yandex::Webmaster::Hosts::Verification
Information about verification for the host [RU] api.yandex.ru/webmaster/doc/dg/reference/hosts-verify.xml [EN] api.yandex.com/webmaster/doc/dg/reference/hosts-verify.xml.
-
#verify(type) ⇒ Object
Load information about verification for the host.
Methods inherited from Base
#attributes=, const_missing, define_attributes, #initialize, #method_missing
Methods included from Request
#delete_request, #get_request, #post_request, #put_request, #request
Methods included from Connection
Methods included from Authorization
#auth_code, #authenticate, #authenticated?, #authorize_url, #oauth, #token
Constructor Details
This class inherits a constructor from Yandex::Webmaster::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Yandex::Webmaster::Base
Class Method Details
.create(name, factory) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/yandex-webmaster/host.rb', line 44 def self.create(name, factory) xml = "<host><name>#{name}</name></host>" response = factory.request(:post, '/hosts', xml) if response.status.to_i == 201 self.new({ :href => response.headers['Location'], :configuration => factory.configuration }) end end |
Instance Method Details
#delete ⇒ Object
Delete information about the host from Yandex.Webmaster
78 79 80 81 82 |
# File 'lib/yandex-webmaster/host.rb', line 78 def delete response = self.request(:delete, self.href) @deleted = true if response.status.to_i == 204 self end |
#deleted? ⇒ Boolean
86 87 88 |
# File 'lib/yandex-webmaster/host.rb', line 86 def deleted? !!@deleted end |
#id ⇒ Integer
Id of the host
58 59 60 61 |
# File 'lib/yandex-webmaster/host.rb', line 58 def id return @id if defined?(@id) @id = self.href.match(/\/(\d+)\z/)[1].to_i end |
#load_incoming_links ⇒ Yandex::Webmaster::Host
Load information about incoming links for the host
146 147 148 149 150 151 |
# File 'lib/yandex-webmaster/host.rb', line 146 def load_incoming_links self.validate_resource!(:incoming_links) self.attributes = self.request(:get, self.resources[:incoming_links]).body self end |
#load_indexed_urls ⇒ Yandex::Webmaster::Host
Load information about indexed urls for the host
134 135 136 137 138 139 |
# File 'lib/yandex-webmaster/host.rb', line 134 def load_indexed_urls self.validate_resource!(:indexed_urls) self.attributes = self.request(:get, self.resources[:indexed_urls]).body self end |
#load_sitemaps ⇒ Object
175 176 177 178 179 180 |
# File 'lib/yandex-webmaster/host.rb', line 175 def load_sitemaps self.validate_resource!(:sitemaps) self.sitemaps = self.fetch_value(self.request(:get, self.resources[:sitemaps]), :sitemap) self end |
#load_stats ⇒ Yandex::Webmaster::Host
Load stats for the host
122 123 124 125 126 127 |
# File 'lib/yandex-webmaster/host.rb', line 122 def load_stats self.validate_resource!(:host_information) self.attributes = self.request(:get, self.resources[:host_information]).body self end |
#load_top_queries ⇒ Yandex::Webmaster::Host
Load information about top queries for the host
158 159 160 161 162 163 |
# File 'lib/yandex-webmaster/host.rb', line 158 def load_top_queries self.validate_resource!(:top_queries) self.attributes = self.fetch_value(self.request(:get, self.resources[:top_queries]), :top_queries) self end |
#load_verification ⇒ Object
110 111 112 113 114 115 |
# File 'lib/yandex-webmaster/host.rb', line 110 def load_verification self.validate_resource!(:verify_host) self.verification = self.fetch_value(self.request(:get, self.resources[:verify_host]), :verification) self end |
#resources ⇒ Hash
Load information about resources that are available for the host
66 67 68 69 70 71 72 |
# File 'lib/yandex-webmaster/host.rb', line 66 def resources return @resources if defined?(@resources) @resources = self.fetch_value(self.request(:get, self.href), :link).inject({}) do |h, resource| h[resource[:rel].underscore.to_sym] = resource[:href]; h end end |
#sitemaps(reload = false) ⇒ Yandex::Webmaster::Host
Get(load) list of sitemap files for the host
170 171 172 173 |
# File 'lib/yandex-webmaster/host.rb', line 170 def sitemaps(reload = false) self.load_sitemaps if reload || @sitemaps.nil? @sitemaps end |
#verification(reload = false) ⇒ Yandex::Webmaster::Hosts::Verification
Information about verification for the host
105 106 107 108 |
# File 'lib/yandex-webmaster/host.rb', line 105 def verification(reload = false) self.load_verification if reload || @verification.nil? @verification end |
#verify(type) ⇒ Object
Load information about verification for the host
92 93 94 95 96 97 98 99 |
# File 'lib/yandex-webmaster/host.rb', line 92 def verify(type) self.validate_resource!(:verify_host) status = self.verification.run(type) @verification = nil status end |