-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathrubygems.go
More file actions
43 lines (35 loc) · 833 Bytes
/
rubygems.go
File metadata and controls
43 lines (35 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package dashboard
import (
"fmt"
"log"
)
type RubyGem struct {
Name string `json:"name"`
Version string `json:"version"`
Downloads int `json:"downloads"`
HomepageURI string `json:"homepage_uri"`
DocumentationURI string `json:"documentation_uri"`
}
func GetRubyGem(gem string) (*RubyGem, error) {
if gem == "" {
return nil, nil
}
info := &RubyGem{}
err := getRetry(5, fmt.Sprintf("https://rubygems.org/api/v1/gems/%s.json", gem), info)
if err != nil {
return nil, err
}
return info, nil
}
func rubygem(gem string) chan *RubyGem {
rubyGemChan := make(chan *RubyGem, 1)
go func() {
info, err := GetRubyGem(gem)
if err != nil {
log.Printf("error fetching rubygems info for %s: %v", gem, err)
}
rubyGemChan <- info
close(rubyGemChan)
}()
return rubyGemChan
}