Class: Gitlabuddy::Project
- Inherits:
-
Object
- Object
- Gitlabuddy::Project
- Defined in:
- lib/gitlabuddy/project.rb
Class Method Summary collapse
Class Method Details
.all ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/gitlabuddy/project.rb', line 6 def self.all projects = JSON.parse( Gitlabuddy::Request.new('https://gitlab.com/api/v3/projects') .send .body ) projects.to_json end |
.branches(project_id) ⇒ Object
35 36 37 38 39 |
# File 'lib/gitlabuddy/project.rb', line 35 def self.branches(project_id) Gitlabuddy::Request.new("https://gitlab.com/api/v3/projects/#{project_id}/repository/branches") .send .body end |
.dump ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/gitlabuddy/project.rb', line 41 def self.dump projects = JSON.parse( Gitlabuddy::Request.new('https://gitlab.com/api/v3/projects') .send .body ) dump = [] puts projects projects.each do |project| dump.push project.merge!(custom: { project_type: [], #project_type(project['id']), merge_requests: [], #JSON.parse(Gitlabuddy::MergeRequest.by_project(project['id'])), branches: [] #JSON.parse(branches(project['id'])) }) end dump.to_json end |
.project_type(project_id) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/gitlabuddy/project.rb', line 16 def self.project_type(project_id) files = JSON.parse( Gitlabuddy::Request.new("https://gitlab.com/api/v3/projects/#{project_id}/repository/tree") .send .body ) type = case files.to_s when /Gemfile/ 'ruby' when /metadata.rb/ 'cookbook' else 'unknown' end type end |