Class: Repositories::Bower

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

Constant Summary collapse

HAS_VERSIONS =
false
HAS_DEPENDENCIES =
false
LIBRARIAN_SUPPORT =
true
SECURITY_PLANNED =
true
URL =
'http://bower.io'
COLOR =
'#563d7c'

Constants inherited from Base

Repositories::Base::HIDDEN, Repositories::Base::LIBRARIAN_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


37
38
39
40
41
42
43
44
# File 'app/models/repositories/bower.rb', line 37

def self.mapping(project)
  {
    :name => project["name"],
    :description => project["description"],
    :keywords_array => Array.wrap(project["keywords"]),
    :repository_url => repo_fallback(project["website"], project["url"])
  }
end

.project(name) ⇒ Object


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

def self.project(name)
  projects[name.downcase]
end

.project_namesObject


10
11
12
# File 'app/models/repositories/bower.rb', line 10

def self.project_names
  projects.keys
end

.projectsObject


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/models/repositories/bower.rb', line 14

def self.projects
  @projects ||= begin
    projects = {}
    p1 = get("https://bower-component-list.herokuapp.com")
    p2 = get("https://bower.herokuapp.com/packages")

    p2.each do |hash|
      projects[hash['name'].downcase] = hash.slice('name', 'url', 'hits')
    end

    p1.each do |hash|
      if projects[hash['name'].downcase]
        projects[hash['name'].downcase].merge! hash.slice('description', "owner", "website", "forks", "stars", "created", "updated","keywords")
      end
    end
    projects
  end
end