Class: Repositories::Sublime

Inherits:
Base
  • Object
show all
Defined in:
app/models/repositories/sublime.rb

Constant Summary collapse

HAS_VERSIONS =
true
HAS_DEPENDENCIES =
false
URL =
'https://packagecontrol.io'

Constants inherited from Base

Base::COLOR, Base::HIDDEN, Base::LIBRARIAN_PLANNED, Base::LIBRARIAN_SUPPORT, Base::SECURITY_PLANNED

Class Method Summary collapse

Methods inherited from Base

color, dependencies, download_dependencies, formatted_name, get, get_html, get_json, get_raw, import, import_async, import_new, import_new_async, import_recent, import_recent_async, new_names, package_link, repo_fallback, save, save_dependencies, update

Class Method Details

.mapping(project) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'app/models/repositories/sublime.rb', line 15

def self.mapping(project)
  {
    :name => project["name"],
    :description => project["description"],
    :homepage => project["homepage"],
    :repository_url => repo_fallback(parse_repo(project["issues"]),project["homepage"]),
    :keywords_array => Array.wrap(project["labels"])
  }
end

.parse_repo(url) ⇒ Object



33
34
35
36
# File 'app/models/repositories/sublime.rb', line 33

def self.parse_repo(url)
  return nil unless url
  url.gsub(/\/issues(\/)?/i, '')
end

.project(name) ⇒ Object



11
12
13
# File 'app/models/repositories/sublime.rb', line 11

def self.project(name)
  get("https://packagecontrol.io/packages/#{URI.escape(name)}.json")
end

.project_namesObject



7
8
9
# File 'app/models/repositories/sublime.rb', line 7

def self.project_names
  get("https://packagecontrol.io/channel.json")['packages_cache'].map{|k,v| v[0]['name']}
end

.versions(project) ⇒ Object



25
26
27
28
29
30
31
# File 'app/models/repositories/sublime.rb', line 25

def self.versions(project)
  project['versions'].map do |v|
    {
      :number => v['version']
    }
  end
end