@@ -71,6 +71,49 @@ module Shards
71
71
parse_dependency({foo: {git: " " , tag: " rc-1.0" }}).to_s.should eq(" foo (tag rc-1.0)" )
72
72
parse_dependency({foo: {git: " " , commit: " 4478d8afe8c728f44b47d3582a270423cd7fc07d" }}).to_s.should eq(" foo (commit 4478d8a)" )
73
73
end
74
+
75
+ it " .parts_from_cli" do
76
+ # GitHub short syntax
77
+ Dependency .parts_from_cli(" github:foo/bar" ).should eq({resolver_key: " github" , source: " foo/bar" , requirement: Any })
78
+ Dependency .parts_from_cli(
" github:Foo/[email protected] " ).should eq({
resolver_key: " github" ,
source: " Foo/Bar" ,
requirement: VersionReq .new(
" ~> 1.2.3" )})
79
+
80
+ # GitHub urls
81
+ Dependency .parts_from_cli(" https://github.com/foo/bar" ).should eq({resolver_key: " github" , source: " foo/bar" , requirement: Any })
82
+ Dependency .parts_from_cli(" https://github.com/Foo/Bar/commit/000000" ).should eq({resolver_key: " github" , source: " Foo/Bar" , requirement: GitCommitRef .new(" 000000" )})
83
+ Dependency .parts_from_cli(" https://github.com/Foo/Bar/tree/v1.2.3" ).should eq({resolver_key: " github" , source: " Foo/Bar" , requirement: GitTagRef .new(" v1.2.3" )})
84
+ Dependency .parts_from_cli(" https://github.com/Foo/Bar/tree/some/branch" ).should eq({resolver_key: " github" , source: " Foo/Bar" , requirement: GitBranchRef .new(" some/branch" )})
85
+
86
+ # GitLab short syntax
87
+ Dependency .parts_from_cli(" gitlab:foo/bar" ).should eq({resolver_key: " gitlab" , source: " foo/bar" , requirement: Any })
88
+
89
+ # GitLab urls
90
+ Dependency .parts_from_cli(" https://gitlab.com/foo/bar" ).should eq({resolver_key: " gitlab" , source: " foo/bar" , requirement: Any })
91
+
92
+ # Bitbucket short syntax
93
+ Dependency .parts_from_cli(" bitbucket:foo/bar" ).should eq({resolver_key: " bitbucket" , source: " foo/bar" , requirement: Any })
94
+
95
+ # bitbucket urls
96
+ Dependency .parts_from_cli(" https://bitbucket.com/foo/bar" ).should eq({resolver_key: " bitbucket" , source: " foo/bar" , requirement: Any })
97
+
98
+ # Git convenient syntax since resolver matches scheme
99
+ Dependency .parts_from_cli(" git://git.example.org/crystal-library.git" ).should eq({resolver_key: " git" , source: " git://git.example.org/crystal-library.git" , requirement: Any })
100
+
101
+ # Local paths
102
+ local_absolute = File .join(tmp_path, " local" )
103
+ local_relative = File .join(" spec" , " .repositories" , " local" ) # rel_path is relative to integration spec
104
+ Dir .mkdir_p(local_absolute)
105
+
106
+ # Path short syntax
107
+ Dependency .parts_from_cli(local_absolute).should eq({resolver_key: " path" , source: local_absolute, requirement: Any })
108
+ Dependency .parts_from_cli(local_relative).should eq({resolver_key: " path" , source: local_relative, requirement: Any })
109
+
110
+ # Path resolver syntax
111
+ Dependency .parts_from_cli(" path:#{ local_absolute } " ).should eq({resolver_key: " path" , source: local_absolute, requirement: Any })
112
+ Dependency .parts_from_cli(" path:#{ local_relative } " ).should eq({resolver_key: " path" , source: local_relative, requirement: Any })
113
+
114
+ # Other resolvers short
115
+ Dependency .parts_from_cli(" git:git://git.example.org/crystal-library.git" ).should eq({resolver_key: " git" , source: " git://git.example.org/crystal-library.git" , requirement: Any })
116
+ end
74
117
end
75
118
end
76
119
0 commit comments