BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
02ad8c0c
Commit
02ad8c0c
authored
May 16, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Autolink package names in gemspec
parent
aa24feed
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
94 additions
and
1 deletion
+94
-1
dependency_linker.rb
lib/gitlab/dependency_linker.rb
+2
-1
gemspec_linker.rb
lib/gitlab/dependency_linker/gemspec_linker.rb
+18
-0
gemspec_linker_spec.rb
spec/lib/gitlab/dependency_linker/gemspec_linker_spec.rb
+66
-0
dependency_linker_spec.rb
spec/lib/gitlab/dependency_linker_spec.rb
+8
-0
No files found.
lib/gitlab/dependency_linker.rb
View file @
02ad8c0c
module
Gitlab
module
DependencyLinker
LINKERS
=
[
GemfileLinker
GemfileLinker
,
GemspecLinker
,
].
freeze
def
self
.
linker
(
blob_name
)
...
...
lib/gitlab/dependency_linker/gemspec_linker.rb
0 → 100644
View file @
02ad8c0c
module
Gitlab
module
DependencyLinker
class
GemspecLinker
<
MethodLinker
self
.
file_type
=
:gemspec
private
def
link_dependencies
link_method_call
(
'homepage'
,
URL_REGEX
,
&
:itself
)
link_method_call
(
'license'
,
&
method
(
:license_url
))
link_method_call
(
%w[name add_dependency add_runtime_dependency add_development_dependency]
)
do
|
name
|
"https://rubygems.org/gems/
#{
name
}
"
end
end
end
end
end
spec/lib/gitlab/dependency_linker/gemspec_linker_spec.rb
0 → 100644
View file @
02ad8c0c
require
'rails_helper'
describe
Gitlab
::
DependencyLinker
::
GemspecLinker
,
lib:
true
do
describe
'.support?'
do
it
'supports *.gemspec'
do
expect
(
described_class
.
support?
(
'gitlab_git.gemspec'
)).
to
be_truthy
end
it
'does not support other files'
do
expect
(
described_class
.
support?
(
'.gemspec.example'
)).
to
be_falsey
end
end
describe
'#link'
do
let
(
:file_name
)
{
"gitlab_git.gemspec"
}
let
(
:file_content
)
do
<<-
CONTENT
.
strip_heredoc
Gem::Specification.new do |s|
s.name = 'gitlab_git'
s.version = `cat VERSION`
s.date = Time.now.strftime('%Y-%m-%d')
s.summary = "Gitlab::Git library"
s.description = "GitLab wrapper around git objects"
s.authors = ["Dmitriy Zaporozhets"]
s.email = 'dmitriy.zaporozhets@gmail.com'
s.license = 'MIT'
s.files = `git ls-files lib/`.split('
\n
') << 'VERSION'
s.homepage = 'https://gitlab.com/gitlab-org/gitlab_git'
s.add_dependency('github-linguist', '~> 4.7.0')
s.add_dependency('activesupport', '~> 4.0')
s.add_dependency('rugged', '~> 0.24.0')
s.add_runtime_dependency('charlock_holmes', '~> 0.7.3')
s.add_development_dependency('listen', '~> 3.0.6')
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
(
'gitlab_git'
,
'https://rubygems.org/gems/gitlab_git'
))
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://gitlab.com/gitlab-org/gitlab_git'
,
'https://gitlab.com/gitlab-org/gitlab_git'
))
end
it
'links dependencies'
do
expect
(
subject
).
to
include
(
link
(
'github-linguist'
,
'https://rubygems.org/gems/github-linguist'
))
expect
(
subject
).
to
include
(
link
(
'activesupport'
,
'https://rubygems.org/gems/activesupport'
))
expect
(
subject
).
to
include
(
link
(
'rugged'
,
'https://rubygems.org/gems/rugged'
))
expect
(
subject
).
to
include
(
link
(
'charlock_holmes'
,
'https://rubygems.org/gems/charlock_holmes'
))
expect
(
subject
).
to
include
(
link
(
'listen'
,
'https://rubygems.org/gems/listen'
))
end
end
end
spec/lib/gitlab/dependency_linker_spec.rb
View file @
02ad8c0c
...
...
@@ -9,5 +9,13 @@ describe Gitlab::DependencyLinker, lib: true do
described_class
.
link
(
blob_name
,
nil
,
nil
)
end
it
'links using GemspecLinker'
do
blob_name
=
'gitlab_git.gemspec'
expect
(
described_class
::
GemspecLinker
).
to
receive
(
:link
)
described_class
.
link
(
blob_name
,
nil
,
nil
)
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