Class: Gitlab::GithubGistsImport::Importer::GistImporter
- Inherits:
-
Object
- Object
- Gitlab::GithubGistsImport::Importer::GistImporter
- Defined in:
- lib/gitlab/github_gists_import/importer/gist_importer.rb
Constant Summary collapse
- FileCountLimitError =
Class.new(StandardError)
- RepoSizeLimitError =
Class.new(StandardError)
- SnippetRepositoryError =
Class.new(StandardError)
- FILE_COUNT_LIMIT_MESSAGE =
'Snippet maximum file count exceeded'
- REPO_SIZE_LIMIT_MESSAGE =
'Snippet repository size exceeded'
Instance Attribute Summary collapse
-
#gist ⇒ Object
readonly
Returns the value of attribute gist.
-
#snippet ⇒ Object
readonly
Returns the value of attribute snippet.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(gist, user_id) ⇒ GistImporter
constructor
gist - An instance of ‘Gitlab::GithubGistsImport::Representation::Gist`.
Constructor Details
#initialize(gist, user_id) ⇒ GistImporter
gist - An instance of ‘Gitlab::GithubGistsImport::Representation::Gist`.
16 17 18 19 |
# File 'lib/gitlab/github_gists_import/importer/gist_importer.rb', line 16 def initialize(gist, user_id) @gist = gist @user = User.find(user_id) end |
Instance Attribute Details
#gist ⇒ Object (readonly)
Returns the value of attribute gist.
7 8 9 |
# File 'lib/gitlab/github_gists_import/importer/gist_importer.rb', line 7 def gist @gist end |
#snippet ⇒ Object (readonly)
Returns the value of attribute snippet.
7 8 9 |
# File 'lib/gitlab/github_gists_import/importer/gist_importer.rb', line 7 def snippet @snippet end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
7 8 9 |
# File 'lib/gitlab/github_gists_import/importer/gist_importer.rb', line 7 def user @user end |
Instance Method Details
#execute ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gitlab/github_gists_import/importer/gist_importer.rb', line 21 def execute validate_gist! @snippet = build_snippet import_repository if snippet.save! validate_repository! ServiceResponse.success rescue FileCountLimitError, RepoSizeLimitError, SnippetRepositoryError => exception fail_and_track(snippet, exception) end |