Class: RuboCop::RemoteConfig Private
- Inherits:
-
Object
- Object
- RuboCop::RemoteConfig
- Defined in:
- lib/rubocop/remote_config.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Common methods and behaviors for dealing with remote config files.
Constant Summary collapse
- CACHE_LIFETIME =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
24 * 60 * 60
Instance Attribute Summary collapse
- #uri ⇒ Object readonly private
Instance Method Summary collapse
- #file ⇒ Object private
- #inherit_from_remote(file, path) ⇒ Object private
-
#initialize(url, base_dir) ⇒ RemoteConfig
constructor
private
A new instance of RemoteConfig.
Constructor Details
#initialize(url, base_dir) ⇒ RemoteConfig
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of RemoteConfig.
14 15 16 17 18 19 20 21 |
# File 'lib/rubocop/remote_config.rb', line 14 def initialize(url, base_dir) begin @uri = URI.parse(url) rescue URI::InvalidURIError raise ConfigNotFoundError, "Failed to resolve configuration: '#{url}' is not a valid URI" end @base_dir = base_dir end |
Instance Attribute Details
#uri ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 |
# File 'lib/rubocop/remote_config.rb', line 10 def uri @uri end |
Instance Method Details
#file ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rubocop/remote_config.rb', line 23 def file return cache_path unless cache_path_expired? request do |response| next if response.is_a?(Net::HTTPNotModified) next if response.is_a?(SocketError) File.write(cache_path, response.body) end cache_path end |
#inherit_from_remote(file, path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 39 40 |
# File 'lib/rubocop/remote_config.rb', line 36 def inherit_from_remote(file, path) new_uri = @uri.dup new_uri.path.gsub!(%r{/[^/]*$}, "/#{file.delete_prefix('./')}") RemoteConfig.new(new_uri.to_s, File.dirname(path)) end |