Module: PryNote
- Defined in:
- lib/pry-note.rb,
lib/pry-note/version.rb
Constant Summary collapse
- VERSION =
"0.2.7"
Class Method Summary collapse
-
.code_object_name(co) ⇒ String
The ‘name` of the code object.
- .export_notes(file_name = nil) ⇒ Object
- .load_notes(file_name = nil) ⇒ Object
- .notes ⇒ Object
- .notes=(o) ⇒ Object
-
.retrieve_code_object_safely(name, target, _pry_) ⇒ Pry::Method, ...
The code_object.
Class Method Details
.code_object_name(co) ⇒ String
Returns the ‘name` of the code object.
46 47 48 49 50 51 52 53 54 |
# File 'lib/pry-note.rb', line 46 def self.code_object_name(co) if co.is_a?(Pry::Method) co.name_with_owner elsif co.is_a?(Pry::WrappedModule) co.name elsif co <= Pry::Command co.command_name end end |
.export_notes(file_name = nil) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/pry-note.rb', line 21 def self.export_notes(file_name=nil) return if !file_name && !Pry.config.notes_file file_name ||= Pry.config.notes_file = File.(file_name) if PryNote.notes && PryNote.notes.any? File.open(, "w") { |f| f.puts YAML.dump(PryNote.notes) } end end |
.load_notes(file_name = nil) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/pry-note.rb', line 12 def self.load_notes(file_name=nil) return if !file_name && !Pry.config.notes_file file_name ||= Pry.config.notes_file = File.(file_name) if File.exists?() PryNote.notes = YAML.load File.read() end end |
.notes ⇒ Object
9 |
# File 'lib/pry-note.rb', line 9 def self.notes() @notes ||= {}; end |
.notes=(o) ⇒ Object
10 |
# File 'lib/pry-note.rb', line 10 def self.notes=(o) @notes = o; end |
.retrieve_code_object_safely(name, target, _pry_) ⇒ Pry::Method, ...
Returns The code_object.
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/pry-note.rb', line 32 def self.retrieve_code_object_safely(name, target, _pry_) code_object = Pry::Helpers::CommandHelpers.retrieve_code_object_from_string(name, target) || _pry_.commands.find_command(name) if !code_object raise Pry::CommandError, "No code object found named #{name}" elsif code_object.name.to_s == "" raise Pry::CommandError, "Object #{name} doesn't have a proper name, can't create note" end code_object end |