Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
c35463d5
Commit
c35463d5
authored
May 16, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Autolink package names in podspec.json
parent
190b7b45
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
137 additions
and
0 deletions
+137
-0
lib/gitlab/dependency_linker.rb
lib/gitlab/dependency_linker.rb
+1
-0
lib/gitlab/dependency_linker/podspec_json_linker.rb
lib/gitlab/dependency_linker/podspec_json_linker.rb
+32
-0
spec/lib/gitlab/dependency_linker/podspec_json_linker_spec.rb
.../lib/gitlab/dependency_linker/podspec_json_linker_spec.rb
+96
-0
spec/lib/gitlab/dependency_linker_spec.rb
spec/lib/gitlab/dependency_linker_spec.rb
+8
-0
No files found.
lib/gitlab/dependency_linker.rb
View file @
c35463d5
...
@@ -7,6 +7,7 @@ module Gitlab
...
@@ -7,6 +7,7 @@ module Gitlab
ComposerJsonLinker
,
ComposerJsonLinker
,
PodfileLinker
,
PodfileLinker
,
PodspecLinker
,
PodspecLinker
,
PodspecJsonLinker
,
].
freeze
].
freeze
def
self
.
linker
(
blob_name
)
def
self
.
linker
(
blob_name
)
...
...
lib/gitlab/dependency_linker/podspec_json_linker.rb
0 → 100644
View file @
c35463d5
module
Gitlab
module
DependencyLinker
class
PodspecJsonLinker
<
JsonLinker
include
Cocoapods
self
.
file_type
=
:podspec_json
private
def
link_dependencies
link_json
(
'name'
,
json
[
"name"
],
&
method
(
:package_url
))
link_json
(
'license'
,
&
method
(
:license_url
))
link_json
(
%w[homepage git]
,
URL_REGEX
,
&
:itself
)
link_packages_at_key
(
"dependencies"
,
&
method
(
:package_url
))
json
[
"subspecs"
]
&
.
each
do
|
subspec
|
link_packages_at_key
(
"dependencies"
,
subspec
,
&
method
(
:package_url
))
end
end
def
link_packages_at_key
(
key
,
root
=
json
,
&
url_proc
)
dependencies
=
root
[
key
]
return
unless
dependencies
dependencies
.
each
do
|
name
,
_
|
link_regex
(
/"(?<name>
#{
Regexp
.
escape
(
name
)
}
)":\s*\[/
,
&
url_proc
)
end
end
end
end
end
spec/lib/gitlab/dependency_linker/podspec_json_linker_spec.rb
0 → 100644
View file @
c35463d5
require
'rails_helper'
describe
Gitlab
::
DependencyLinker
::
PodspecJsonLinker
,
lib:
true
do
describe
'.support?'
do
it
'supports *.podspec.json'
do
expect
(
described_class
.
support?
(
'Reachability.podspec.json'
)).
to
be_truthy
end
it
'does not support other files'
do
expect
(
described_class
.
support?
(
'.podspec.json.example'
)).
to
be_falsey
end
end
describe
'#link'
do
let
(
:file_name
)
{
"AFNetworking.podspec.json"
}
let
(
:file_content
)
do
<<-
CONTENT
.
strip_heredoc
{
"name": "AFNetworking",
"version": "2.0.0",
"license": "MIT",
"summary": "A delightful iOS and OS X networking framework.",
"homepage": "https://github.com/AFNetworking/AFNetworking",
"authors": {
"Mattt Thompson": "m@mattt.me"
},
"source": {
"git": "https://github.com/AFNetworking/AFNetworking.git",
"tag": "2.0.0",
"submodules": true
},
"requires_arc": true,
"platforms": {
"ios": "6.0",
"osx": "10.8"
},
"public_header_files": "AFNetworking/*.h",
"subspecs": [
{
"name": "NSURLConnection",
"dependencies": {
"AFNetworking/Serialization": [
],
"AFNetworking/Reachability": [
],
"AFNetworking/Security": [
]
},
"source_files": [
"AFNetworking/AFURLConnectionOperation.{h,m}",
"AFNetworking/AFHTTPRequestOperation.{h,m}",
"AFNetworking/AFHTTPRequestOperationManager.{h,m}"
]
}
]
}
CONTENT
end
subject
{
Gitlab
::
Highlight
.
highlight
(
file_name
,
file_content
)
}
def
link
(
name
,
url
)
%{<a href="#{url}" rel="nofollow noreferrer noopener" target="_blank">#{name}</a>}
end
it
'links the gem name'
do
expect
(
subject
).
to
include
(
link
(
'AFNetworking'
,
'https://cocoapods.org/pods/AFNetworking'
))
end
it
'links the license'
do
expect
(
subject
).
to
include
(
link
(
'MIT'
,
'http://choosealicense.com/licenses/mit/'
))
end
it
'links the homepage'
do
expect
(
subject
).
to
include
(
link
(
'https://github.com/AFNetworking/AFNetworking'
,
'https://github.com/AFNetworking/AFNetworking'
))
end
it
'links the source URL'
do
expect
(
subject
).
to
include
(
link
(
'https://github.com/AFNetworking/AFNetworking.git'
,
'https://github.com/AFNetworking/AFNetworking.git'
))
end
it
'links dependencies'
do
expect
(
subject
).
to
include
(
link
(
'AFNetworking/Serialization'
,
'https://cocoapods.org/pods/AFNetworking'
))
expect
(
subject
).
to
include
(
link
(
'AFNetworking/Reachability'
,
'https://cocoapods.org/pods/AFNetworking'
))
expect
(
subject
).
to
include
(
link
(
'AFNetworking/Security'
,
'https://cocoapods.org/pods/AFNetworking'
))
end
it
'does not link subspec names'
do
expect
(
subject
).
not_to
include
(
link
(
'NSURLConnection'
,
'https://cocoapods.org/pods/NSURLConnection'
))
end
end
end
spec/lib/gitlab/dependency_linker_spec.rb
View file @
c35463d5
...
@@ -49,5 +49,13 @@ describe Gitlab::DependencyLinker, lib: true do
...
@@ -49,5 +49,13 @@ describe Gitlab::DependencyLinker, lib: true do
described_class
.
link
(
blob_name
,
nil
,
nil
)
described_class
.
link
(
blob_name
,
nil
,
nil
)
end
end
it
'links using PodspecJsonLinker'
do
blob_name
=
'AFNetworking.podspec.json'
expect
(
described_class
::
PodspecJsonLinker
).
to
receive
(
:link
)
described_class
.
link
(
blob_name
,
nil
,
nil
)
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment