Class: Api::GithubRepositoriesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/api/github_repositories_controller.rb

Instance Method Summary collapse

Instance Method Details

#dependenciesObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/api/github_repositories_controller.rb', line 14

def dependencies
  dependencies = @github_repository.repository_dependencies || []

  deps = dependencies.map do |dependency|
    {
      project_name: dependency.project_name,
      name: dependency.project_name,
      platform: dependency.platform,
      requirements: dependency.requirements,
      latest_stable: dependency.try(:project).try(:latest_stable_release_number),
      latest: dependency.try(:project).try(:latest_release_number),
      deprecated: dependency.try(:project).try(:is_deprecated?),
      outdated: dependency.outdated?
    }
  end

  repo_json = @github_repository.as_json({
    except: [:id, :github_organisation_id, :owner_id]
  })
  repo_json[:dependencies] = deps

  render json: repo_json
end

#projectsObject



10
11
12
# File 'app/controllers/api/github_repositories_controller.rb', line 10

def projects
  render json: @github_repository.projects.paginate(page: page_number).as_json(only: Project::API_FIELDS, methods: [:package_manager_url, :stars, :keywords], include: {versions: {only: [:number, :published_at]} })
end

#showObject



4
5
6
7
8
# File 'app/controllers/api/github_repositories_controller.rb', line 4

def show
  render json: @github_repository.as_json({
    except: [:id, :github_organisation_id, :owner_id]
  })
end