Class: LearnOpen::Opener
- Inherits:
-
Object
- Object
- LearnOpen::Opener
- Defined in:
- lib/learn_open/opener.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#editor ⇒ Object
readonly
Returns the value of attribute editor.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#lesson ⇒ Object
Returns the value of attribute lesson.
-
#lesson_id ⇒ Object
Returns the value of attribute lesson_id.
-
#lesson_is_lab ⇒ Object
Returns the value of attribute lesson_is_lab.
-
#lessons_dir ⇒ Object
readonly
Returns the value of attribute lessons_dir.
-
#repo_dir ⇒ Object
Returns the value of attribute repo_dir.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(lesson, editor) ⇒ Opener
constructor
A new instance of Opener.
- #run ⇒ Object
Constructor Details
#initialize(lesson, editor) ⇒ Opener
Returns a new instance of Opener.
10 11 12 13 14 15 16 17 18 |
# File 'lib/learn_open/opener.rb', line 10 def initialize(lesson, editor) _login, token = Netrc.read['learn-config'] @client = LearnWeb::Client.new(token: token) @lesson = lesson @editor = editor @lessons_dir = YAML.load(File.read(File.('~/.learn-config')))[:learn_directory] @file_path = File.('~/.learn-open-tmp') end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
3 4 5 |
# File 'lib/learn_open/opener.rb', line 3 def client @client end |
#editor ⇒ Object (readonly)
Returns the value of attribute editor.
3 4 5 |
# File 'lib/learn_open/opener.rb', line 3 def editor @editor end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
3 4 5 |
# File 'lib/learn_open/opener.rb', line 3 def file_path @file_path end |
#lesson ⇒ Object
Returns the value of attribute lesson.
4 5 6 |
# File 'lib/learn_open/opener.rb', line 4 def lesson @lesson end |
#lesson_id ⇒ Object
Returns the value of attribute lesson_id.
4 5 6 |
# File 'lib/learn_open/opener.rb', line 4 def lesson_id @lesson_id end |
#lesson_is_lab ⇒ Object
Returns the value of attribute lesson_is_lab.
4 5 6 |
# File 'lib/learn_open/opener.rb', line 4 def lesson_is_lab @lesson_is_lab end |
#lessons_dir ⇒ Object (readonly)
Returns the value of attribute lessons_dir.
3 4 5 |
# File 'lib/learn_open/opener.rb', line 3 def lessons_dir @lessons_dir end |
#repo_dir ⇒ Object
Returns the value of attribute repo_dir.
4 5 6 |
# File 'lib/learn_open/opener.rb', line 4 def repo_dir @repo_dir end |
Class Method Details
.run(lesson:, editor_specified:) ⇒ Object
6 7 8 |
# File 'lib/learn_open/opener.rb', line 6 def self.run(lesson:, editor_specified:) new(lesson, editor_specified).run end |
Instance Method Details
#run ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/learn_open/opener.rb', line 20 def run setup_tmp_file set_lesson if lesson_is_readme? open_readme else fork_repo clone_repo bundle_install open_with_editor cd_to_lesson end cleanup_tmp_file end |