⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.13
Server IP:
109.199.105.153
Server:
Linux connect.inboxifs.com 5.15.0-152-generic #162-Ubuntu SMP Wed Jul 23 09:48:42 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.2.29
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
ri
/
3.0.0
/
system
/
Psych
/
Edit File: cdesc-Psych.ri
U:RDoc::NormalModule[iI" Psych:ET@0o:RDoc::Markup::Document:@parts[,o;;[]S:RDoc::Markup::Heading: leveli: textI" Overview;To:RDoc::Markup::BlankLine o:RDoc::Markup::Paragraph;[I")Psych is a YAML parser and emitter. ;TI"JPsych leverages libyaml [Home page: https://pyyaml.org/wiki/LibYAML] ;TI"Ior [HG repo: https://bitbucket.org/xi/libyaml] for its YAML parsing ;TI"Land emitting capabilities. In addition to wrapping libyaml, Psych also ;TI"Kknows how to serialize and de-serialize most Ruby objects to and from ;TI"the YAML format.;T@S; ; i;I",I NEED TO PARSE OR EMIT YAML RIGHT NOW!;T@o:RDoc::Markup::Verbatim;[I"# Parse some YAML ;TI"&Psych.load("--- foo") # => "foo" ;TI" ;TI"# Emit some YAML ;TI"1Psych.dump("foo") # => "--- foo\n...\n" ;TI"/{ :a => 'b'}.to_yaml # => "---\n:a: b\n" ;T:@format0o; ;[I"3Got more time on your hands? Keep on reading!;T@S; ; i;I"YAML Parsing;T@o; ;[ I"SPsych provides a range of interfaces for parsing a YAML document ranging from ;TI"Nlow level to high level, depending on your parsing needs. At the lowest ;TI"Plevel, is an event based parser. Mid level is access to the raw YAML AST, ;TI"Oand at the highest level is the ability to unmarshal YAML to Ruby objects.;T@S; ; i;I"YAML Emitting;T@o; ;[ I"MPsych provides a range of interfaces ranging from low to high level for ;TI"Sproducing YAML documents. Very similar to the YAML parsing interfaces, Psych ;TI"Pprovides at the lowest level, an event based system, mid-level is building ;TI"Oa YAML AST, and the highest level is converting a Ruby object straight to ;TI"a YAML document.;T@S; ; i;I"High-level API;T@S; ; i;I"Parsing;T@o; ;[I"QThe high level YAML parser provided by Psych simply takes YAML as input and ;TI"Treturns a Ruby data structure. For information on using the high level parser ;TI"see Psych.load;T@S; ; i ;I"Reading from a string;T@o;;[ I"3Psych.safe_load("--- a") # => 'a' ;TI":Psych.safe_load("---\n - a\n - b") # => ['a', 'b'] ;TI"# From a trusted string: ;TI"PPsych.load("--- !ruby/range\nbegin: 0\nend: 42\nexcl: false\n") # => 0..42 ;T;0S; ; i ;I"Reading from a file;T@o;;[I"APsych.safe_load_file("data.yml", permitted_classes: [Date]) ;TI"-Psych.load_file("trusted_database.yml") ;T;0S; ; i ;I"Exception handling;T@o;;[I"begin ;TI"A # The second argument changes only the exception contents ;TI"( Psych.parse("--- `", "file.txt") ;TI"%rescue Psych::SyntaxError => ex ;TI"" ex.file # => 'file.txt' ;TI"Q ex.message # => "(file.txt): found character that cannot start any token" ;TI" end ;T;0S; ; i;I" Emitting;T@o; ;[I"RThe high level emitter has the easiest interface. Psych simply takes a Ruby ;TI"Qdata structure and converts it to a YAML document. See Psych.dump for more ;TI"2information on dumping a Ruby data structure.;T@S; ; i ;I"Writing to a string;T@o;;[I"-# Dump an array, get back a YAML string ;TI"4Psych.dump(['a', 'b']) # => "---\n- a\n- b\n" ;TI" ;TI"%# Dump an array to an IO object ;TI"MPsych.dump(['a', 'b'], StringIO.new) # => #<StringIO:0x000001009d0890> ;TI" ;TI"*# Dump an array with indentation set ;TI"KPsych.dump(['a', ['b']], :indentation => 3) # => "---\n- a\n- - b\n" ;TI" ;TI"3# Dump an array to an IO with indentation set ;TI"?Psych.dump(['a', ['b']], StringIO.new, :indentation => 3) ;T;0S; ; i ;I"Writing to a file;T@o; ;[I"ICurrently there is no direct API for dumping Ruby structure to file:;T@o;;[I".File.open('database.yml', 'w') do |file| ;TI"* file.write(Psych.dump(['a', 'b'])) ;TI" end ;T;0S; ; i;I"Mid-level API;T@S; ; i;I"Parsing;T@o; ;[ I"RPsych provides access to an AST produced from parsing a YAML document. This ;TI"Ptree is built using the Psych::Parser and Psych::TreeBuilder. The AST can ;TI"Jbe examined and manipulated freely. Please see Psych::parse_stream, ;TI"OPsych::Nodes, and Psych::Nodes::Node for more information on dealing with ;TI"YAML syntax trees.;T@S; ; i ;I"Reading from a string;T@o;;[ I"$# Returns Psych::Nodes::Stream ;TI"+Psych.parse_stream("---\n - a\n - b") ;TI" ;TI"&# Returns Psych::Nodes::Document ;TI"$Psych.parse("---\n - a\n - b") ;T;0S; ; i ;I"Reading from a file;T@o;;[ I"$# Returns Psych::Nodes::Stream ;TI"3Psych.parse_stream(File.read('database.yml')) ;TI" ;TI"&# Returns Psych::Nodes::Document ;TI"&Psych.parse_file('database.yml') ;T;0S; ; i ;I"Exception handling;T@o;;[I"begin ;TI"A # The second argument changes only the exception contents ;TI"( Psych.parse("--- `", "file.txt") ;TI"%rescue Psych::SyntaxError => ex ;TI"" ex.file # => 'file.txt' ;TI"Q ex.message # => "(file.txt): found character that cannot start any token" ;TI" end ;T;0S; ; i;I" Emitting;T@o; ;[ I"SAt the mid level is building an AST. This AST is exactly the same as the AST ;TI"Pused when parsing a YAML document. Users can build an AST by hand and the ;TI"IAST knows how to emit itself as a YAML document. See Psych::Nodes, ;TI"QPsych::Nodes::Node, and Psych::TreeBuilder for more information on building ;TI"a YAML AST.;T@S; ; i ;I"Writing to a string;T@o;;[ I"A# We need Psych::Nodes::Stream (not Psych::Nodes::Document) ;TI"4stream = Psych.parse_stream("---\n - a\n - b") ;TI" ;TI"+stream.to_yaml # => "---\n- a\n- b\n" ;T;0S; ; i ;I"Writing to a file;T@o;;[I"A# We need Psych::Nodes::Stream (not Psych::Nodes::Document) ;TI"<stream = Psych.parse_stream(File.read('database.yml')) ;TI" ;TI".File.open('database.yml', 'w') do |file| ;TI"" file.write(stream.to_yaml) ;TI" end ;T;0S; ; i;I"Low-level API;T@S; ; i;I"Parsing;T@o; ;[ I"RThe lowest level parser should be used when the YAML input is already known, ;TI"Land the developer does not want to pay the price of building an AST or ;TI"Pautomatic detection and conversion to Ruby objects. See Psych::Parser for ;TI"6more information on using the event based parser.;T@S; ; i ;I".Reading to Psych::Nodes::Stream structure;T@o;;[I"Gparser = Psych::Parser.new(TreeBuilder.new) # => #<Psych::Parser> ;TI"Oparser = Psych.parser # it's an alias for the above ;TI" ;TI"Gparser.parse("---\n - a\n - b") # => #<Psych::Parser> ;TI"Lparser.handler # => #<Psych::TreeBuilder> ;TI"Nparser.handler.root # => #<Psych::Nodes::Stream> ;T;0S; ; i ;I"Receiving an events stream;T@o;;[I".recorder = Psych::Handlers::Recorder.new ;TI"*parser = Psych::Parser.new(recorder) ;TI" ;TI"%parser.parse("---\n - a\n - b") ;TI"8recorder.events # => [list of [event, args] lists] ;TI"? # event is one of: Psych::Handler::EVENTS ;TI"B # args are the arguments passed to the event ;T;0S; ; i;I" Emitting;T@o; ;[ I"NThe lowest level emitter is an event based system. Events are sent to a ;TI"SPsych::Emitter object. That object knows how to convert the events to a YAML ;TI"Odocument. This interface should be used when document format is known in ;TI"Madvance or speed is a concern. See Psych::Emitter for more information.;T@S; ; i ;I" Writing to a Ruby structure;T@o;;[I"=Psych.parser.parse("--- a") # => #<Psych::Parser> ;TI" ;TI"Dparser.handler.first # => #<Psych::Nodes::Stream> ;TI"2parser.handler.first.to_ruby # => ["a"] ;TI" ;TI"Fparser.handler.root.first # => #<Psych::Nodes::Document> ;TI"0parser.handler.root.first.to_ruby # => "a" ;TI" ;TI"/# You can instantiate an Emitter manually ;TI"CPsych::Visitors::ToRuby.new.accept(parser.handler.root.first) ;TI" # => "a";T;0: @fileI"ext/psych/lib/psych.rb;T:0@omit_headings_from_table_of_contents_below0o;;[ ;I"(ext/psych/lib/psych/class_loader.rb;T;0o;;[ ;I"!ext/psych/lib/psych/coder.rb;T;0o;;[ ;I"%ext/psych/lib/psych/exception.rb;T;0o;;[ ;I"#ext/psych/lib/psych/handler.rb;T;0o;;[ ;I"4ext/psych/lib/psych/handlers/document_stream.rb;T;0o;;[ ;I"-ext/psych/lib/psych/handlers/recorder.rb;T;0o;;[ ;I",ext/psych/lib/psych/json/ruby_events.rb;T;0o;;[ ;I"'ext/psych/lib/psych/json/stream.rb;T;0o;;[ ;I"-ext/psych/lib/psych/json/tree_builder.rb;T;0o;;[ ;I",ext/psych/lib/psych/json/yaml_events.rb;T;0o;;[ ;I"!ext/psych/lib/psych/nodes.rb;T;0o;;[ ;I"'ext/psych/lib/psych/nodes/alias.rb;T;0o;;[ ;I"*ext/psych/lib/psych/nodes/document.rb;T;0o;;[ ;I")ext/psych/lib/psych/nodes/mapping.rb;T;0o;;[ ;I"&ext/psych/lib/psych/nodes/node.rb;T;0o;;[ ;I"(ext/psych/lib/psych/nodes/scalar.rb;T;0o;;[ ;I"*ext/psych/lib/psych/nodes/sequence.rb;T;0o;;[ ;I"(ext/psych/lib/psych/nodes/stream.rb;T;0o;;[ ;I" ext/psych/lib/psych/omap.rb;T;0o;;[ ;I""ext/psych/lib/psych/parser.rb;T;0o;;[ ;I"*ext/psych/lib/psych/scalar_scanner.rb;T;0o;;[ ;I"ext/psych/lib/psych/set.rb;T;0o;;[ ;I""ext/psych/lib/psych/stream.rb;T;0o;;[ ;I"%ext/psych/lib/psych/streaming.rb;T;0o;;[ ;I"(ext/psych/lib/psych/syntax_error.rb;T;0o;;[ ;I"(ext/psych/lib/psych/tree_builder.rb;T;0o;;[ ;I"$ext/psych/lib/psych/versions.rb;T;0o;;[ ;I"0ext/psych/lib/psych/visitors/depth_first.rb;T;0o;;[ ;I",ext/psych/lib/psych/visitors/emitter.rb;T;0o;;[ ;I".ext/psych/lib/psych/visitors/json_tree.rb;T;0o;;[ ;I",ext/psych/lib/psych/visitors/to_ruby.rb;T;0o;;[ ;I",ext/psych/lib/psych/visitors/visitor.rb;T;0o;;[ ;I".ext/psych/lib/psych/visitors/yaml_tree.rb;T;0o;;[ ;I"ext/psych/psych.c;T;0o;;[ ;I"ext/psych/psych_emitter.c;T;0o;;[ ;I"ext/psych/psych_parser.c;T;0o;;[ ;I"ext/psych/psych_to_ruby.c;T;0o;;[ ;I" ext/psych/psych_yaml_tree.c;T;0;0;0[ [ U:RDoc::Constant[i I"LIBYAML_VERSION;TI"Psych::LIBYAML_VERSION;T:public0o;;[o; ;[I"*The version of libyaml Psych is using;T;@�;0@�@cRDoc::NormalModule0U;[i I"NOT_GIVEN;TI"Psych::NOT_GIVEN;T:private0o;;[o; ;[I"Deprecation guard;T;@�;0@�@@i0U;[i I"VERSION;TI"Psych::VERSION;T;0o;;[o; ;[I"'The version of Psych you are using;T;@<;0@<@@i0U;[i I"DEFAULT_SNAKEYAML_VERSION;TI"%Psych::DEFAULT_SNAKEYAML_VERSION;T;0o;;[ ;@<;0@<@@i0[ [[I" class;T[[;[[I" dump;TI"ext/psych/lib/psych.rb;T[I"dump_stream;T@�[I"libyaml_version;TI"ext/psych/psych.c;T[I" load;T@�[I"load_file;T@�[I"load_stream;T@�[I" parse;T@�[I"parse_file;T@�[I"parse_stream;T@�[I"parser;T@�[I"safe_load;T@�[I"safe_load_file;T@�[I"to_json;T@�[:protected[ [;[ [I" instance;T[[;[ [;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ;0;0[1@�@�@�@�@�@�@�@ @@@ @@@@@@@@!@$@'@*@-@0@3@6@9@<@?@B@E@H@K@N@Q@T@W@Z@]I" lib/rubygems/config_file.rb;TI"$lib/rubygems/psych_additions.rb;TI"lib/rubygems/psych_tree.rb;TI"lib/rubygems/safe_yaml.rb;TI""lib/rubygems/specification.rb;T@�cRDoc::TopLevel
Simpan