Class: Gitlab::GithubImport::Markdown::Attachment
- Inherits:
-
Object
- Object
- Gitlab::GithubImport::Markdown::Attachment
- Defined in:
- lib/gitlab/github_import/markdown/attachment.rb
Constant Summary collapse
- MEDIA_TYPES =
%w[gif jpeg jpg mov mp4 png svg webm].freeze
- DOC_TYPES =
%w[ csv docx fodg fodp fods fodt gz log md odf odg odp ods odt pdf pptx tgz txt xls xlsx zip ].freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
-
.from_markdown(markdown_node) ⇒ Object
markdown_node - CommonMarker::Node.
Instance Method Summary collapse
- #doc_belongs_to_project?(import_source) ⇒ Boolean
-
#initialize(name, url) ⇒ Attachment
constructor
A new instance of Attachment.
- #inspect ⇒ Object
- #media?(import_source) ⇒ Boolean
- #part_of_project_blob?(import_source) ⇒ Boolean
Constructor Details
#initialize(name, url) ⇒ Attachment
Returns a new instance of Attachment.
81 82 83 84 |
# File 'lib/gitlab/github_import/markdown/attachment.rb', line 81 def initialize(name, url) @name = name @url = url end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
79 80 81 |
# File 'lib/gitlab/github_import/markdown/attachment.rb', line 79 def name @name end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
79 80 81 |
# File 'lib/gitlab/github_import/markdown/attachment.rb', line 79 def url @url end |
Class Method Details
.from_markdown(markdown_node) ⇒ Object
markdown_node - CommonMarker::Node
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gitlab/github_import/markdown/attachment.rb', line 15 def from_markdown(markdown_node) case markdown_node.type when :html, :inline_html from_inline_html(markdown_node) when :image from_markdown_image(markdown_node) when :link from_markdown_link(markdown_node) end end |
Instance Method Details
#doc_belongs_to_project?(import_source) ⇒ Boolean
92 93 94 95 96 |
# File 'lib/gitlab/github_import/markdown/attachment.rb', line 92 def doc_belongs_to_project?(import_source) url.start_with?( "#{::Gitlab::GithubImport::MarkdownText.github_url}/#{import_source}/files" ) end |
#inspect ⇒ Object
105 106 107 |
# File 'lib/gitlab/github_import/markdown/attachment.rb', line 105 def inspect "<#{self.class.name}: { name: #{name}, url: #{url} }>" end |
#media?(import_source) ⇒ Boolean
98 99 100 101 102 103 |
# File 'lib/gitlab/github_import/markdown/attachment.rb', line 98 def media?(import_source) url.start_with?( "#{::Gitlab::GithubImport::MarkdownText.github_url}/#{import_source}/assets", ::Gitlab::GithubImport::MarkdownText::GITHUB_MEDIA_CDN ) end |
#part_of_project_blob?(import_source) ⇒ Boolean
86 87 88 89 90 |
# File 'lib/gitlab/github_import/markdown/attachment.rb', line 86 def part_of_project_blob?(import_source) url.start_with?( "#{::Gitlab::GithubImport::MarkdownText.github_url}/#{import_source}/blob" ) end |