Class: PryTheme::BasicEditor
- Inherits:
-
Object
- Object
- PryTheme::BasicEditor
- Defined in:
- lib/pry-theme/basic_editor.rb
Instance Attribute Summary collapse
-
#current_file ⇒ Object
readonly
Returns the value of attribute current_file.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(filename) ⇒ BasicEditor
constructor
A new instance of BasicEditor.
- #start_editing ⇒ Object
Constructor Details
#initialize(filename) ⇒ BasicEditor
Returns a new instance of BasicEditor.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/pry-theme/basic_editor.rb', line 15 def initialize(filename) @filename = filename theme_path = themify(filename) @editor = Pry.config.editor @new_theme = false @output = Pry.output @current_file = File.open(theme_path, 'r+') rescue Errno::ENOENT @new_theme = true @current_file = File.open(theme_path, 'w') end |
Instance Attribute Details
#current_file ⇒ Object (readonly)
Returns the value of attribute current_file.
13 14 15 |
# File 'lib/pry-theme/basic_editor.rb', line 13 def current_file @current_file end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
13 14 15 |
# File 'lib/pry-theme/basic_editor.rb', line 13 def output @output end |
Class Method Details
.edit(theme_name) ⇒ Object
7 8 9 10 |
# File 'lib/pry-theme/basic_editor.rb', line 7 def edit(theme_name) editor = new(theme_name) editor.start_editing end |
Instance Method Details
#start_editing ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/pry-theme/basic_editor.rb', line 28 def start_editing if @new_theme @output.puts 'Created a new theme.' @current_file.puts template @current_file.close end @output.puts "Opened in #{ @editor }: #{ themify(@filename) }" reload_theme! output_dashy_header("Current \"#@filename\"") Pry::Editor.invoke_editor(@current_file.path, 1) reload_theme! output_dashy_header("Edited \"#@filename\"") end |