Fix required_ruby_version and required_rubygems_version.
This commit is contained in:
parent
78cb09deda
commit
d86492f3bd
|
@ -6,6 +6,7 @@ package rubygems
|
|||
import (
|
||||
"archive/tar"
|
||||
"compress/gzip"
|
||||
"fmt"
|
||||
"io"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
@ -41,8 +42,8 @@ type Metadata struct {
|
|||
Summary string `json:"summary,omitempty"`
|
||||
Authors []string `json:"authors,omitempty"`
|
||||
Licenses []string `json:"licenses,omitempty"`
|
||||
RequiredRubyVersion []VersionRequirement `json:"required_ruby_version,omitempty"`
|
||||
RequiredRubygemsVersion []VersionRequirement `json:"required_rubygems_version,omitempty"`
|
||||
RequiredRubyVersion VersionRequirementArray `json:"required_ruby_version,omitempty"`
|
||||
RequiredRubygemsVersion VersionRequirementArray `json:"required_rubygems_version,omitempty"`
|
||||
ProjectURL string `json:"project_url,omitempty"`
|
||||
RuntimeDependencies []Dependency `json:"runtime_dependencies,omitempty"`
|
||||
DevelopmentDependencies []Dependency `json:"development_dependencies,omitempty"`
|
||||
|
@ -54,10 +55,12 @@ type VersionRequirement struct {
|
|||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
type VersionRequirementArray []VersionRequirement
|
||||
|
||||
// Dependency represents a dependency of a RubyGems package
|
||||
type Dependency struct {
|
||||
Name string `json:"name"`
|
||||
Version []VersionRequirement `json:"version"`
|
||||
Version VersionRequirementArray `json:"version"`
|
||||
}
|
||||
|
||||
type gemspec struct {
|
||||
|
@ -108,9 +111,45 @@ type requirement struct {
|
|||
Requirements [][]any `yaml:"requirements"`
|
||||
}
|
||||
|
||||
// AsVersionRequirement converts into []VersionRequirement
|
||||
func (r requirement) AsVersionRequirement() []VersionRequirement {
|
||||
requirements := make([]VersionRequirement, 0, len(r.Requirements))
|
||||
func (vr VersionRequirement) String() string {
|
||||
return vr.Restriction + " " + vr.Version
|
||||
}
|
||||
|
||||
func (arr VersionRequirementArray) List() []string {
|
||||
arr_len := len(arr)
|
||||
str_arr := make([]string, arr_len)
|
||||
for i := 0; i < arr_len; i++ {
|
||||
str_arr[i] = arr[i].String()
|
||||
}
|
||||
return str_arr
|
||||
}
|
||||
|
||||
func (arr VersionRequirementArray) Dumps() RubyUserMarshal {
|
||||
arr_len := len(arr)
|
||||
val0 := make([][]any, 1)
|
||||
val0[0] = make([]any, arr_len)
|
||||
for i := 0; i < arr_len; i++ {
|
||||
val0[0][i] = []any{
|
||||
arr[i].Restriction,
|
||||
RubyUserMarshal{
|
||||
Name: "Gem::Version",
|
||||
Value: []any{
|
||||
arr[i].Version,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
val := RubyUserMarshal{
|
||||
Name: "Gem::Requirement",
|
||||
Value: val0,
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
// AsVersionRequirement converts into VersionRequirementArray
|
||||
func (r requirement) AsVersionRequirement() VersionRequirementArray {
|
||||
requirements := make(VersionRequirementArray, 0, len(r.Requirements))
|
||||
for _, req := range r.Requirements {
|
||||
if len(req) != 2 {
|
||||
continue
|
||||
|
|
|
@ -139,8 +139,8 @@ func ServePackageSpecification(ctx *context.Context) {
|
|||
},
|
||||
nil, // date
|
||||
metadata.Summary, // @summary
|
||||
nil, // @required_ruby_version
|
||||
nil, // @required_rubygems_version
|
||||
metadata.RequiredRubyVersion.Dumps(), // @required_ruby_version
|
||||
metadata.RequiredRubygemsVersion.Dumps(), // @required_rubygems_version
|
||||
metadata.Platform, // @original_platform
|
||||
[]any{}, // @dependencies
|
||||
nil, // rubyforge_project
|
||||
|
|
Loading…
Reference in New Issue