Class: Batali::Origin::RemoteSite
- Inherits:
-
Batali::Origin
- Object
- Grimoire::Utility
- Utility
- Batali::Origin
- Batali::Origin::RemoteSite
- Includes:
- Bogo::Memoization
- Defined in:
- lib/batali/origin/remote_site.rb
Overview
Fetch unit information from remote site
Constant Summary collapse
- API_SUFFIX =
Site suffix for API endpoint
'api/v1/'
Instance Method Summary collapse
-
#cache_directory ⇒ String
Cache directory path.
-
#initialize(*_) ⇒ RemoteSite
constructor
A new instance of RemoteSite.
-
#units ⇒ Array<Unit>
All units.
Constructor Details
#initialize(*_) ⇒ RemoteSite
Returns a new instance of RemoteSite.
23 24 25 26 27 28 29 30 31 |
# File 'lib/batali/origin/remote_site.rb', line 23 def initialize(*_) super # NOTE: We currently don't require API_SUFFIX information # self.endpoint = URI.join(endpoint, API_SUFFIX).to_s self.identifier = Digest::SHA256.hexdigest(endpoint) unless(name?) self.name = identifier end end |
Instance Method Details
#cache_directory ⇒ String
Returns cache directory path.
34 35 36 37 38 39 40 |
# File 'lib/batali/origin/remote_site.rb', line 34 def cache_directory memoize(:cache_directory) do c_path = File.join(cache_path, 'remote_site', identifier) FileUtils.mkdir_p(c_path) c_path end end |
#units ⇒ Array<Unit>
Returns all units.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/batali/origin/remote_site.rb', line 43 def units memoize(:units) do items.map do |u_name, versions| versions.map do |version, info| Unit.new( :name => u_name, :version => version, :dependencies => info[:dependencies].to_a, :source => Smash.new( :type => :site, :url => info[:download_url], :version => version, :dependencies => info[:dependencies], :cache_path => cache_path ) ) end end.flatten end end |