Class: LearnSubmit::Submission
- Inherits:
-
Object
- Object
- LearnSubmit::Submission
- Defined in:
- lib/learn_submit/submission.rb,
lib/learn_submit/submission/git_interactor.rb
Defined Under Namespace
Classes: GitInteractor
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#git ⇒ Object
readonly
Returns the value of attribute git.
Class Method Summary collapse
Instance Method Summary collapse
- #cleanup_tmp_file ⇒ Object
- #create ⇒ Object
-
#initialize(message:) ⇒ Submission
constructor
A new instance of Submission.
- #setup_tmp_file ⇒ Object
- #user ⇒ Object
Constructor Details
#initialize(message:) ⇒ Submission
Returns a new instance of Submission.
9 10 11 12 13 14 15 |
# File 'lib/learn_submit/submission.rb', line 9 def initialize(message:) _login, token = Netrc.read['learn-config'] @client = LearnWeb::Client.new(token: token) @git = LearnSubmit::Submission::GitInteractor.new(username: user.username, message: ) @file_path = File.('~/.learn-submit-tmp') end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
3 4 5 |
# File 'lib/learn_submit/submission.rb', line 3 def client @client end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
3 4 5 |
# File 'lib/learn_submit/submission.rb', line 3 def file_path @file_path end |
#git ⇒ Object (readonly)
Returns the value of attribute git.
3 4 5 |
# File 'lib/learn_submit/submission.rb', line 3 def git @git end |
Class Method Details
.create(message: nil) ⇒ Object
5 6 7 |
# File 'lib/learn_submit/submission.rb', line 5 def self.create(message: nil) new(message: ).create end |
Instance Method Details
#cleanup_tmp_file ⇒ Object
29 30 31 |
# File 'lib/learn_submit/submission.rb', line 29 def cleanup_tmp_file File.write(file_path, 'Done.') end |
#create ⇒ Object
17 18 19 20 21 22 |
# File 'lib/learn_submit/submission.rb', line 17 def create setup_tmp_file commit_and_push! submit! end |
#setup_tmp_file ⇒ Object
24 25 26 27 |
# File 'lib/learn_submit/submission.rb', line 24 def setup_tmp_file FileUtils.touch(file_path) File.write(file_path, '') end |
#user ⇒ Object
33 34 35 |
# File 'lib/learn_submit/submission.rb', line 33 def user @user ||= client.me end |