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
190b7b45
Commit
190b7b45
authored
May 16, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Autolink package names in podspec
parent
03db4f11
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
102 additions
and
0 deletions
+102
-0
lib/gitlab/dependency_linker.rb
lib/gitlab/dependency_linker.rb
+1
-0
lib/gitlab/dependency_linker/podspec_linker.rb
lib/gitlab/dependency_linker/podspec_linker.rb
+24
-0
spec/lib/gitlab/dependency_linker/podspec_linker_spec.rb
spec/lib/gitlab/dependency_linker/podspec_linker_spec.rb
+69
-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 @
190b7b45
...
@@ -6,6 +6,7 @@ module Gitlab
...
@@ -6,6 +6,7 @@ module Gitlab
PackageJsonLinker
,
PackageJsonLinker
,
ComposerJsonLinker
,
ComposerJsonLinker
,
PodfileLinker
,
PodfileLinker
,
PodspecLinker
,
].
freeze
].
freeze
def
self
.
linker
(
blob_name
)
def
self
.
linker
(
blob_name
)
...
...
lib/gitlab/dependency_linker/podspec_linker.rb
0 → 100644
View file @
190b7b45
module
Gitlab
module
DependencyLinker
class
PodspecLinker
<
MethodLinker
include
Cocoapods
STRING_REGEX
=
/['"](?<name>[^'"]+)['"]/
.
freeze
self
.
file_type
=
:podspec
private
def
link_dependencies
link_method_call
(
'homepage'
,
URL_REGEX
,
&
:itself
)
link_regex
(
%r{(git:|:git
\s
*=>)
\s
*['"](?<name>
#{
URL_REGEX
}
)['"]}
,
&
:itself
)
link_method_call
(
'license'
,
&
method
(
:license_url
))
link_regex
(
/license\s*=\s*\{\s*(type:|:type\s*=>)\s*
#{
STRING_REGEX
}
/
,
&
method
(
:license_url
))
link_method_call
(
%w[name dependency]
,
&
method
(
:package_url
))
end
end
end
end
spec/lib/gitlab/dependency_linker/podspec_linker_spec.rb
0 → 100644
View file @
190b7b45
require
'rails_helper'
describe
Gitlab
::
DependencyLinker
::
PodspecLinker
,
lib:
true
do
describe
'.support?'
do
it
'supports *.podspec'
do
expect
(
described_class
.
support?
(
'Reachability.podspec'
)).
to
be_truthy
end
it
'does not support other files'
do
expect
(
described_class
.
support?
(
'.podspec.example'
)).
to
be_falsey
end
end
describe
'#link'
do
let
(
:file_name
)
{
"Reachability.podspec"
}
let
(
:file_content
)
do
<<-
CONTENT
.
strip_heredoc
Pod::Spec.new do |spec|
spec.name = 'Reachability'
spec.version = '3.1.0'
spec.license = { :type => 'GPL-3.0' }
spec.license = "MIT"
spec.license = { type: 'Apache-2.0' }
spec.homepage = 'https://github.com/tonymillion/Reachability'
spec.authors = { 'Tony Million' => 'tonymillion@gmail.com' }
spec.summary = 'ARC and GCD Compatible Reachability Class for iOS and OS X.'
spec.source = { :git => 'https://github.com/tonymillion/Reachability.git', :tag => 'v3.1.0' }
spec.source_files = 'Reachability.{h,m}'
spec.framework = 'SystemConfiguration'
spec.dependency 'AFNetworking', '~> 1.0'
spec.dependency 'RestKit/CoreData', '~> 0.20.0'
spec.ios.dependency 'MBProgressHUD', '~> 0.5'
end
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
(
'Reachability'
,
'https://cocoapods.org/pods/Reachability'
))
end
it
'links the license'
do
expect
(
subject
).
to
include
(
link
(
'GPL-3.0'
,
'http://choosealicense.com/licenses/gpl-3.0/'
))
expect
(
subject
).
to
include
(
link
(
'MIT'
,
'http://choosealicense.com/licenses/mit/'
))
expect
(
subject
).
to
include
(
link
(
'Apache-2.0'
,
'http://choosealicense.com/licenses/apache-2.0/'
))
end
it
'links the homepage'
do
expect
(
subject
).
to
include
(
link
(
'https://github.com/tonymillion/Reachability'
,
'https://github.com/tonymillion/Reachability'
))
end
it
'links the source URL'
do
expect
(
subject
).
to
include
(
link
(
'https://github.com/tonymillion/Reachability.git'
,
'https://github.com/tonymillion/Reachability.git'
))
end
it
'links dependencies'
do
expect
(
subject
).
to
include
(
link
(
'AFNetworking'
,
'https://cocoapods.org/pods/AFNetworking'
))
expect
(
subject
).
to
include
(
link
(
'RestKit/CoreData'
,
'https://cocoapods.org/pods/RestKit'
))
expect
(
subject
).
to
include
(
link
(
'MBProgressHUD'
,
'https://cocoapods.org/pods/MBProgressHUD'
))
end
end
end
spec/lib/gitlab/dependency_linker_spec.rb
View file @
190b7b45
...
@@ -41,5 +41,13 @@ describe Gitlab::DependencyLinker, lib: true do
...
@@ -41,5 +41,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 PodspecLinker'
do
blob_name
=
'Reachability.podspec'
expect
(
described_class
::
PodspecLinker
).
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