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