code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
require 'rdoc/markup/to_rdoc'
##
# Outputs RDoc markup with hot backspace action! You will probably need a
# pager to use this output format.
#
# This formatter won't work on 1.8.6 because it lacks String#chars.
class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc
##
# Returns a new ToBs that is ready for hot backsp... | Ruby |
require 'rdoc/markup/formatter'
require 'rdoc/markup/inline'
##
# Extracts sections of text enclosed in plus, tt or code. Used to discover
# undocumented parameters.
class RDoc::Markup::ToTtOnly < RDoc::Markup::Formatter
##
# Stack of list types
attr_reader :list_type
##
# Output accumulator
attr_rea... | Ruby |
##
# A Document containing lists, headings, paragraphs, etc.
class RDoc::Markup::Document
##
# The file this document was created from. See also
# RDoc::ClassModule#add_comment
attr_accessor :file
##
# The parts of the Document
attr_reader :parts
##
# Creates a new Document with +parts+
def ... | Ruby |
##
# A List of ListItems
class RDoc::Markup::List
##
# The list's type
attr_accessor :type
##
# Items in the list
attr_reader :items
##
# Creates a new list of +type+ with +items+
def initialize type = nil, *items
@type = type
@items = []
@items.push(*items)
end
##
# Appends ... | Ruby |
##
# An empty line. This class is a singleton.
class RDoc::Markup::BlankLine
@instance = new
##
# RDoc::Markup::BlankLine is a singleton
def self.new
@instance
end
##
# Calls #accept_blank_line on +visitor+
def accept visitor
visitor.accept_blank_line self
end
def pretty_print q # :n... | Ruby |
require 'rdoc/markup'
##
# Base class for RDoc markup formatters
#
# Formatters use a visitor pattern to convert content into output.
#
# If you'd like to write your own Formatter use
# RDoc::Markup::FormatterTestCase. If you're writing a text-output formatter
# use RDoc::Markup::TextFormatterTestCase which provides ... | Ruby |
require 'rdoc/markup/formatter'
require 'rdoc/markup/inline'
require 'cgi'
##
# Outputs RDoc markup as HTML
class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
include RDoc::Text
# :section: Utilities
##
# Maps RDoc::Markup::Parser::LIST_TOKENS types to HTML tags
LIST_TYPE_TO_HTML = {
:BULLET => [... | Ruby |
##
# An Indented Paragraph of text
class RDoc::Markup::IndentedParagraph < RDoc::Markup::Raw
##
# The indent in number of spaces
attr_reader :indent
##
# Creates a new IndentedParagraph containing +parts+ indented with +indent+
# spaces
def initialize indent, *parts
@indent = indent
super(*p... | Ruby |
require 'rdoc/markup/to_rdoc'
##
# Outputs RDoc markup with vibrant ANSI color!
class RDoc::Markup::ToAnsi < RDoc::Markup::ToRdoc
##
# Creates a new ToAnsi visitor that is ready to output vibrant ANSI color!
def initialize markup = nil
super
@headings.clear
@headings[1] = ["\e[1;32m", "\e[m"] # b... | Ruby |
require 'rdoc/markup/formatter'
require 'rdoc/markup/inline'
##
# Outputs RDoc markup as RDoc markup! (mostly)
class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
##
# Current indent amount for output in characters
attr_accessor :indent
##
# Output width in characters
attr_accessor :width
##
# S... | Ruby |
require 'rdoc/markup'
require 'rdoc/encoding'
##
# Handle common directives that can occur in a block of text:
#
# \:include: filename
#
# Directives can be escaped by preceding them with a backslash.
#
# RDoc plugin authors can register additional directives to be handled by
# using RDoc::Markup::PreProcess::regist... | Ruby |
##
# A horizontal rule with a weight
class RDoc::Markup::Rule < Struct.new :weight
##
# Calls #accept_rule on +visitor+
def accept visitor
visitor.accept_rule self
end
def pretty_print q # :nodoc:
q.group 2, '[rule:', ']' do
q.pp weight
end
end
end
| Ruby |
##
# A section of verbatim text
class RDoc::Markup::Verbatim < RDoc::Markup::Raw
##
# Calls #accept_verbatim on +visitor+
def accept visitor
visitor.accept_verbatim self
end
##
# Collapses 3+ newlines into two newlines
def normalize
parts = []
newlines = 0
@parts.each do |part|
... | Ruby |
##
# A heading with a level (1-6) and text
class RDoc::Markup::Heading < Struct.new :level, :text
##
# Calls #accept_heading on +visitor+
def accept visitor
visitor.accept_heading self
end
def pretty_print q # :nodoc:
q.group 2, "[head: #{level} ", ']' do
q.pp text
end
end
end
| Ruby |
require 'rdoc/code_object'
##
# A Context is something that can hold modules, classes, methods, attributes,
# aliases, requires, and includes. Classes, modules, and files are all
# Contexts.
class RDoc::Context < RDoc::CodeObject
include Comparable
##
# Types of methods
TYPES = %w[class instance]
##
#... | Ruby |
require 'rdoc/context'
##
# A TopLevel context is a representation of the contents of a single file
class RDoc::TopLevel < RDoc::Context
##
# This TopLevel's File::Stat struct
attr_accessor :file_stat
##
# Relative name of this file
attr_accessor :relative_name
##
# Absolute name of this file
... | Ruby |
require 'rdoc/code_object'
##
# Represent an alias, which is an old_name/new_name pair associated with a
# particular context
#--
# TODO implement Alias as a proxy to a method/attribute, inheriting from
# MethodAttr
class RDoc::Alias < RDoc::CodeObject
##
# Aliased method's name
attr_reader :new_name
... | Ruby |
require 'rubygems'
require 'rubygems/user_interaction'
require 'fileutils'
require 'rdoc'
##
# Gem::RDoc provides methods to generate RDoc and ri data for installed gems
# upon gem installation.
#
# This file is automatically required by RubyGems 1.9 and newer.
class RDoc::RubygemsHook
include Gem::UserInteraction... | Ruby |
# We represent the various high-level code constructs that appear in Ruby
# programs: classes, modules, methods, and so on.
require 'rdoc/code_object'
require 'rdoc/context'
require 'rdoc/top_level'
require 'rdoc/class_module'
require 'rdoc/normal_class'
require 'rdoc/normal_module'
require 'rdoc/anon_class'
require ... | Ruby |
require 'rdoc/method_attr'
##
# An attribute created by \#attr, \#attr_reader, \#attr_writer or
# \#attr_accessor
class RDoc::Attr < RDoc::MethodAttr
MARSHAL_VERSION = 2 # :nodoc:
##
# Is the attribute readable ('R'), writable ('W') or both ('RW')?
attr_accessor :rw
##
# Creates a new Attr with body +... | Ruby |
##
# This file contains stuff stolen outright from:
#
# rtags.rb -
# ruby-lex.rb - ruby lexcal analyzer
# ruby-token.rb - ruby tokens
# by Keiju ISHITSUKA (Nippon Rational Inc.)
#
require 'rdoc/ruby_token'
require 'rdoc/ruby_lex'
require 'rdoc/code_objects'
require 'rdoc/token_stream'
require 'rdoc/markup... | Ruby |
##
# Parse a non-source file. We basically take the whole thing as one big
# comment.
class RDoc::Parser::Simple < RDoc::Parser
parse_files_matching(//)
attr_reader :content # :nodoc:
##
# Prepare to parse a plain file
def initialize(top_level, file_name, content, options, stats)
super
preproces... | Ruby |
##
# Collection of methods for writing parsers against RDoc::RubyLex and
# RDoc::RubyToken
module RDoc::Parser::RubyTools
include RDoc::RubyToken
##
# Adds a token listener +obj+, but you should probably use token_listener
def add_token_listener(obj)
@token_listeners ||= []
@token_listeners << obj
... | Ruby |
require 'rdoc/parser/ruby'
require 'rdoc/known_classes'
##
# RDoc::Parser::C attempts to parse C extension files. It looks for
# the standard patterns that you find in extensions: <tt>rb_define_class,
# rb_define_method</tt> and so on. It tries to find the corresponding
# C source for the methods and extract commen... | Ruby |
# coding: utf-8
##
# For RDoc::Text#to_html
require 'strscan'
##
# Methods for manipulating comment text
module RDoc::Text
##
# Maps an encoding to a Hash of characters properly transcoded for that
# encoding.
#
# See also encode_fallback.
TO_HTML_CHARACTERS = Hash.new do |h, encoding|
h[encoding]... | Ruby |
module RDoc
##
# Ruby's built-in classes, modules and exceptions
KNOWN_CLASSES = {
"rb_cArray" => "Array",
"rb_cBasicObject" => "BasicObject",
"rb_cBignum" => "Bignum",
"rb_cClass" => "Class",
"rb_cData" => "Data",
"rb_cDir" =... | Ruby |
#--
# irb/ruby-token.rb - ruby tokens
# $Release Version: 0.9.5$
# $Revision: 11708 $
# $Date: 2007-02-12 15:01:19 -0800 (Mon, 12 Feb 2007) $
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#++
# Definitions of all tokens involved in the lexical analysis.
#
# This class is not documented because it is so deep i... | Ruby |
# coding: US-ASCII
require 'rdoc'
##
# This class is a wrapper around File IO and Encoding that helps RDoc load
# files and convert them to the correct encoding.
module RDoc::Encoding
##
# Reads the contents of +filename+ and handles any encoding directives in
# the file.
#
# The content will be converted... | Ruby |
require 'rdoc/class_module'
##
# A singleton class
class RDoc::SingleClass < RDoc::ClassModule
##
# Adds the superclass to the included modules.
def ancestors
superclass ? super + [superclass] : super
end
##
# The definition of this singleton class, <tt>class << MyClassName</tt>
def definition
... | Ruby |
require 'rdoc'
require 'rdoc/text'
##
# Base class for the RDoc code tree.
#
# We contain the common stuff for contexts (which are containers) and other
# elements (methods, attributes and so on)
#
# Here's the tree of the CodeObject subclasses:
#
# * RDoc::Context
# * RDoc::TopLevel
# * RDoc::ClassModule
# * ... | Ruby |
#--
# Copyright (c) 2003, 2004 Jim Weirich, 2009 Eric Hodel
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modi... | Ruby |
require 'rdoc/ri'
##
# The directories where ri data lives.
module RDoc::RI::Paths
#:stopdoc:
require 'rbconfig'
version = RbConfig::CONFIG['ruby_version']
base = if RbConfig::CONFIG.key? 'ridir' then
File.join RbConfig::CONFIG['ridir'], version
else
File.join RbC... | Ruby |
require 'rdoc/code_objects'
require 'fileutils'
##
# A set of ri data.
#
# The store manages reading and writing ri data for a project (gem, path,
# etc.) and maintains a cache of methods, classes and ancestors in the
# store.
#
# The store maintains a #cache of its contents for faster lookup. After
# adding items to... | Ruby |
require 'abbrev'
require 'optparse'
begin
require 'readline'
rescue LoadError
end
begin
require 'win32console'
rescue LoadError
end
require 'rdoc/ri'
require 'rdoc/ri/paths'
require 'rdoc/markup'
require 'rdoc/markup/formatter'
require 'rdoc/text'
##
# For RubyGems backwards compatibility
require 'rdoc/ri/form... | Ruby |
##
# For RubyGems backwards compatibility
module RDoc::RI::Formatter # :nodoc:
end
| Ruby |
require 'rdoc/code_object'
##
# A Module include in a class with \#include
class RDoc::Include < RDoc::CodeObject
##
# Name of included module
attr_accessor :name
##
# Creates a new Include for +name+ with +comment+
def initialize(name, comment)
super()
@name = name
self.comment = comment
... | Ruby |
# coding: US-ASCII
#--
# irb/ruby-lex.rb - ruby lexcal analyzer
# $Release Version: 0.9.5$
# $Revision: 17979 $
# $Date: 2008-07-09 10:17:05 -0700 (Wed, 09 Jul 2008) $
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
#++
require "e2mmap"
require "irb/slex"
require "rdoc/ruby_token"
require "stringio"
##
# R... | Ruby |
require 'rdoc/code_object'
##
# A file loaded by \#require
class RDoc::Require < RDoc::CodeObject
##
# Name of the required file
attr_accessor :name
##
# Creates a new Require that loads +name+ with +comment+
def initialize(name, comment)
super()
@name = name.gsub(/'|"/, "") #'
@top_level ... | Ruby |
require 'rdoc'
require 'rdoc/encoding'
require 'rdoc/parser'
# Simple must come first
require 'rdoc/parser/simple'
require 'rdoc/parser/ruby'
require 'rdoc/parser/c'
require 'rdoc/stats'
require 'rdoc/options'
require 'find'
require 'fileutils'
require 'time'
##
# Encapsulate the production of rdoc documentation. ... | Ruby |
##
# A TokenStream is a list of tokens, gathered during the parse of some entity
# (say a method). Entities populate these streams by being registered with the
# lexer. Any class can collect tokens by including TokenStream. From the
# outside, you use such an object by calling the start_collecting_tokens
# method, foll... | Ruby |
#
# e2mmap.rb - for ruby 1.1
# $Release Version: 2.0$
# $Revision: 1.10 $
# by Keiju ISHITSUKA
#
# --
# Usage:
#
# U1)
# class Foo
# extend Exception2MessageMapper
# def_e2message ExistingExceptionClass, "message..."
# def_exception :NewExceptionClass, "message..."[, superclass]
# ... | Ruby |
# This class implements a pretty printing algorithm. It finds line breaks and
# nice indentations for grouped structure.
#
# By default, the class assumes that primitive elements are strings and each
# byte in the strings have single column in width. But it can be used for
# other situations by giving suitable argument... | Ruby |
# = ERB -- Ruby Templating
#
# Author:: Masatoshi SEKI
# Documentation:: James Edward Gray II, Gavin Sinclair, and Simon Chiang
#
# See ERB for primary documentation and ERB::Util for a couple of utility
# routines.
#
# Copyright (c) 1999-2000,2002,2003 Masatoshi SEKI
#
# You can redistribute it and/or modify it under ... | Ruby |
#
# shell/error.rb -
# $Release Version: 0.7 $
# $Revision: 31641 $
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
#
#
#
require "e2mmap"
class Shell
module Error
extend Exception2MessageMapper
def_e2message TypeError, "wrong argument type %s (expected %s)"
def_exception :DirStack... | Ruby |
#
# shell/builtin-command.rb -
# $Release Version: 0.7 $
# $Revision: 31641 $
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
#
#
#
require "shell/filter"
class Shell
class BuiltInCommand<Filter
def wait?
false
end
def active?
true
end
end
class Void < BuiltInCo... | Ruby |
#
# shell/system-command.rb -
# $Release Version: 0.7 $
# $Revision: 31641 $
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
#
#
#
require "shell/filter"
class Shell
class SystemCommand < Filter
def initialize(sh, command, *opts)
if t = opts.find{|opt| !opt.kind_of?(String) && opt.cla... | Ruby |
#
# shell/command-controller.rb -
# $Release Version: 0.7 $
# $Revision: 31641 $
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
#
#
#
require "e2mmap"
require "thread"
require "shell/error"
require "shell/filter"
require "shell/system-command"
require "shell/builtin-command"
class Shell
class... | Ruby |
#
# shell/filter.rb -
# $Release Version: 0.7 $
# $Revision: 31641 $
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
#
#
#
class Shell
#
# Filter
# A method to require
# each()
#
class Filter
include Enumerable
def initialize(sh)
@shell = sh # parent shell
... | Ruby |
#
# shell/process-controller.rb -
# $Release Version: 0.7 $
# $Revision: 31641 $
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
#
#
#
require "forwardable"
require "thread"
require "sync"
class Shell
class ProcessController
@ProcessControllers = {}
@ProcessControllersMonitor = Mutex.n... | Ruby |
#
# version.rb - shell version definition file
# $Release Version: 0.7$
# $Revision: 31641 $
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
#
#
#
class Shell
@RELEASE_VERSION = "0.7"
@LAST_UPDATE_DATE = "07/03/20"
end
| Ruby |
#
# shellwords.rb: Manipulates strings a la UNIX Bourne shell
#
#
# This module manipulates strings according to the word parsing rules
# of the UNIX Bourne shell.
#
# The shellwords() function was originally a port of shellwords.pl,
# but modified to conform to POSIX / SUSv3 (IEEE Std 1003.1-2001).
#
# Authors:
# -... | Ruby |
#
# shell.rb -
# $Release Version: 0.7 $
# $Revision: 1.9 $
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
#
#
#
require "e2mmap"
require "thread" unless defined?(Mutex)
require "forwardable"
require "shell/error"
require "shell/command-processor"
require "shell/process-controller"
class Shel... | Ruby |
# encoding: US-ASCII
# = csv.rb -- CSV Reading and Writing
#
# Created by James Edward Gray II on 2005-10-31.
# Copyright 2005 James Edward Gray II. You can redistribute or modify this code
# under the terms of Ruby's license.
#
# See CSV for documentation.
#
# == Description
#
# Welcome to the new and improved CSV.... | Ruby |
#
# optparse.rb - command-line option analysis with the OptionParser class.
#
# Author:: Nobu Nakada
# Documentation:: Nobu Nakada and Gavin Sinclair.
#
# See OptionParser for documentation.
#
# == Developer Documentation (not for RDoc output)
#
# === Class tree
#
# - OptionParser:: front end
# - OptionParser::Switch... | Ruby |
#
# = un.rb
#
# Copyright (c) 2003 WATANABE Hirofumi <eban@ruby-lang.org>
#
# This program is free software.
# You can distribute/modify this program under the same terms of Ruby.
#
# == Utilities to replace common UNIX commands in Makefiles etc
#
# == SYNOPSIS
#
# ruby -run -e cp -- [OPTION] SOURCE DEST
# ruby -ru... | Ruby |
# = monitor.rb
#
# Copyright (C) 2001 Shugo Maeda <shugo@ruby-lang.org>
#
# This library is distributed under the terms of the Ruby license.
# You can freely distribute/modify this library.
#
require 'thread'
#
# In concurrent programming, a monitor is an object or module intended to be
# used safely by more than on... | Ruby |
require 'thread'
# The Singleton module implements the Singleton pattern.
#
# == Usage
#
# To use Singleton, include the module in your class.
#
# class Klass
# include Singleton
# # ...
# end
#
# This ensures that only one instance of Klass can be created.
#
# a,b = Klass.instance, Klass.insta... | Ruby |
#
# ipaddr.rb - A class to manipulate an IP address
#
# Copyright (c) 2002 Hajimu UMEMOTO <ume@mahoroba.org>.
# Copyright (c) 2007, 2009, 2012 Akinori MUSHA <knu@iDaemons.org>.
# All rights reserved.
#
# You can redistribute and/or modify it under the same terms as Ruby.
#
# $Id: ipaddr.rb 35917 2012-06-05 05:04:19Z kn... | Ruby |
######################################################################
# This file is imported from the minitest project.
# DO NOT make modifications in this repo. They _will_ be reverted!
# File a patch instead and assign it to Ryan Davis.
######################################################################
class M... | Ruby |
######################################################################
# This file is imported from the minitest project.
# DO NOT make modifications in this repo. They _will_ be reverted!
# File a patch instead and assign it to Ryan Davis.
######################################################################
begin
... | Ruby |
######################################################################
# This file is imported from the minitest project.
# DO NOT make modifications in this repo. They _will_ be reverted!
# File a patch instead and assign it to Ryan Davis.
######################################################################
#!/usr/... | Ruby |
######################################################################
# This file is imported from the minitest project.
# DO NOT make modifications in this repo. They _will_ be reverted!
# File a patch instead and assign it to Ryan Davis.
######################################################################
require... | Ruby |
######################################################################
# This file is imported from the minitest project.
# DO NOT make modifications in this repo. They _will_ be reverted!
# File a patch instead and assign it to Ryan Davis.
######################################################################
require... | Ruby |
######################################################################
# This file is imported from the minitest project.
# DO NOT make modifications in this repo. They _will_ be reverted!
# File a patch instead and assign it to Ryan Davis.
######################################################################
require... | Ruby |
module Profiler__
# internal values
@@start = @@stack = @@map = nil
PROFILE_PROC = proc{|event, file, line, id, binding, klass|
case event
when "call", "c-call"
now = Process.times[0]
@@stack.push [now, 0.0]
when "return", "c-return"
now = Process.times[0]
key = [klass, id]
... | Ruby |
# = uri/ldap.rb
#
# License:: You can redistribute it and/or modify it under the same term as Ruby.
#
# See URI for general documentation
#
require 'uri/ldap'
module URI
# The default port for LDAPS URIs is 636, and the scheme is 'ldaps:' rather
# than 'ldap:'. Other than that, LDAPS URIs are identical to LDAP U... | Ruby |
#--
# = uri/common.rb
#
# Author:: Akira Yamada <akira@ruby-lang.org>
# Revision:: $Id: common.rb 34761 2012-02-23 05:45:08Z naruse $
# License::
# You can redistribute it and/or modify it under the same term as Ruby.
#
# See URI for general documentation
#
module URI
#
# Includes URI::REGEXP::PATTERN
#
modu... | Ruby |
# = uri/ftp.rb
#
# Author:: Akira Yamada <akira@ruby-lang.org>
# License:: You can redistribute it and/or modify it under the same term as Ruby.
# Revision:: $Id: ftp.rb 36857 2012-08-30 16:21:44Z naruse $
#
# See URI for general documentation
#
require 'uri/generic'
module URI
#
# FTP URI syntax is defined by R... | Ruby |
# = uri/http.rb
#
# Author:: Akira Yamada <akira@ruby-lang.org>
# License:: You can redistribute it and/or modify it under the same term as Ruby.
# Revision:: $Id: http.rb 31907 2011-06-03 00:32:25Z naruse $
#
# See URI for general documentation
#
require 'uri/generic'
module URI
#
# The syntax of HTTP URIs is d... | Ruby |
# = uri/generic.rb
#
# Author:: Akira Yamada <akira@ruby-lang.org>
# License:: You can redistribute it and/or modify it under the same term as Ruby.
# Revision:: $Id: generic.rb 32560 2011-07-15 21:32:02Z marcandre $
#
# See URI for general documentation
#
require 'uri/common'
module URI
#
# Base class for all U... | Ruby |
# = uri/ldap.rb
#
# Author::
# Takaaki Tateishi <ttate@jaist.ac.jp>
# Akira Yamada <akira@ruby-lang.org>
# License::
# URI::LDAP is copyrighted free software by Takaaki Tateishi and Akira Yamada.
# You can redistribute it and/or modify it under the same term as Ruby.
# Revision:: $Id: ldap.rb 31555 2011-05-13 20:... | Ruby |
# = uri/https.rb
#
# Author:: Akira Yamada <akira@ruby-lang.org>
# License:: You can redistribute it and/or modify it under the same term as Ruby.
# Revision:: $Id: https.rb 31555 2011-05-13 20:03:21Z drbrain $
#
# See URI for general documentation
#
require 'uri/http'
module URI
# The default port for HTTPS URIs ... | Ruby |
# = uri/mailto.rb
#
# Author:: Akira Yamada <akira@ruby-lang.org>
# License:: You can redistribute it and/or modify it under the same term as Ruby.
# Revision:: $Id: mailto.rb 31555 2011-05-13 20:03:21Z drbrain $
#
# See URI for general documentation
#
require 'uri/generic'
module URI
#
# RFC2368, The mailto URL... | Ruby |
##
# The YAML module allows you to use one of the two YAML engines that ship with
# ruby. By default Psych is used but the old and unmaintained Syck may be
# chosen.
#
# See Psych or Syck for usage and documentation.
#
# To set the YAML engine to syck:
#
# YAML::ENGINE.yamler = 'syck'
#
# To set the YAML engine back... | Ruby |
#
# Implementation of the _Observer_ object-oriented design pattern. The
# following documentation is copied, with modifications, from "Programming
# Ruby", by Hunt and Thomas; http://www.rubycentral.com/book/lib_patterns.html.
#
# See Observable for more info.
# The Observer pattern (also known as publish/subscribe)... | Ruby |
require 'optparse'
require 'time'
OptionParser.accept(Time) do |s,|
begin
(Time.httpdate(s) rescue Time.parse(s)) if s
rescue
raise OptionParser::InvalidArgument, s
end
end
| Ruby |
# -*- ruby -*-
require 'optparse'
require 'uri'
OptionParser.accept(URI) {|s,| URI.parse(s) if s}
| Ruby |
# -*- ruby -*-
require 'shellwords'
require 'optparse'
OptionParser.accept(Shellwords) {|s,| Shellwords.shellwords(s)}
| Ruby |
require 'optparse'
require 'date'
OptionParser.accept(DateTime) do |s,|
begin
DateTime.parse(s) if s
rescue ArgumentError
raise OptionParser::InvalidArgument, s
end
end
OptionParser.accept(Date) do |s,|
begin
Date.parse(s) if s
rescue ArgumentError
raise OptionParser::InvalidArgument, s
end... | Ruby |
# OptionParser internal utility
class << OptionParser
def show_version(*pkgs)
progname = ARGV.options.program_name
result = false
show = proc do |klass, cname, version|
str = "#{progname}"
unless klass == ::Object and cname == :VERSION
version = version.join(".") if Array === version
... | Ruby |
require 'rexml/encoding'
require 'rexml/source'
module REXML
# NEEDS DOCUMENTATION
class XMLDecl < Child
include Encoding
DEFAULT_VERSION = "1.0";
DEFAULT_ENCODING = "UTF-8";
DEFAULT_STANDALONE = "no";
START = '<\?xml';
STOP = '\?>';
attr_accessor :version, :standalone
attr_reader... | Ruby |
module REXML
class ParseException < RuntimeError
attr_accessor :source, :parser, :continued_exception
def initialize( message, source=nil, parser=nil, exception=nil )
super(message)
@source = source
@parser = parser
@continued_exception = exception
end
def to_s
# Quote ... | Ruby |
require 'rexml/encoding'
module REXML
class Output
include Encoding
attr_reader :encoding
def initialize real_IO, encd="iso-8859-1"
@output = real_IO
self.encoding = encd
@to_utf = encd != 'UTF-8'
end
def <<( content )
@output << (@to_utf ? self.encode(content) : conte... | Ruby |
require 'rexml/child'
require 'rexml/source'
require 'rexml/xmltokens'
module REXML
# God, I hate DTDs. I really do. Why this idiot standard still
# plagues us is beyond me.
class Entity < Child
include XMLTokens
PUBIDCHAR = "\x20\x0D\x0Aa-zA-Z0-9\\-()+,./:=?;!*@$_%#"
SYSTEMLITERAL = %Q{((?:"[^"]*"... | Ruby |
require "rexml/parent"
require "rexml/parseexception"
require "rexml/namespace"
require 'rexml/entity'
require 'rexml/attlistdecl'
require 'rexml/xmltokens'
module REXML
# Represents an XML DOCTYPE declaration; that is, the contents of <!DOCTYPE
# ... >. DOCTYPES can be used to declare the DTD of a document, as w... | Ruby |
module REXML
# A template for stream parser listeners.
# Note that the declarations (attlistdecl, elementdecl, etc) are trivially
# processed; REXML doesn't yet handle doctype entity declarations, so you
# have to parse them out yourself.
# === Missing methods from SAX2
# ignorable_whitespace
# === Metho... | Ruby |
require 'rexml/encoding'
module REXML
# Generates Source-s. USE THIS CLASS.
class SourceFactory
# Generates a Source object
# @param arg Either a String, or an IO
# @return a Source, or nil if a bad argument was given
def SourceFactory::create_from(arg)
if arg.respond_to? :read and
... | Ruby |
require "rexml/namespace"
require 'rexml/text'
module REXML
# Defines an Element Attribute; IE, a attribute=value pair, as in:
# <element attribute="value"/>. Attributes can be in their own
# namespaces. General users of REXML will not interact with the
# Attribute class much.
class Attribute
include N... | Ruby |
module REXML
class SyncEnumerator
include Enumerable
# Creates a new SyncEnumerator which enumerates rows of given
# Enumerable objects.
def initialize(*enums)
@gens = enums
@length = @gens.collect {|x| x.size }.max
end
# Returns the number of enumerated Enumerable objects, i.e. ... | Ruby |
module REXML
# A template for stream parser listeners.
# Note that the declarations (attlistdecl, elementdecl, etc) are trivially
# processed; REXML doesn't yet handle doctype entity declarations, so you
# have to parse them out yourself.
module StreamListener
# Called when a tag is encountered.
# @p ... | Ruby |
require "rexml/text"
module REXML
class CData < Text
START = '<![CDATA['
STOP = ']]>'
ILLEGAL = /(\]\]>)/
# Constructor. CData is data between <![CDATA[ ... ]]>
#
# _Examples_
# CData.new( source )
# CData.new( "Here is some CDATA" )
# CData.new( "Some unprocessed data", re... | Ruby |
module REXML
# If you add a method, keep in mind two things:
# (1) the first argument will always be a list of nodes from which to
# filter. In the case of context methods (such as position), the function
# should return an array with a value for each child in the array.
# (2) all method calls from XML will ... | Ruby |
require "rexml/child"
module REXML
# A parent has children, and has methods for accessing them. The Parent
# class is never encountered except as the superclass for some other
# object.
class Parent < Child
include Enumerable
# Constructor
# @param parent if supplied, will be set as the parent of... | Ruby |
require "rexml/node"
module REXML
##
# A Child object is something contained by a parent, and this class
# contains methods to support that. Most user code will not use this
# class directly.
class Child
include Node
attr_reader :parent # The Parent of this object
# Constructor. Any in... | Ruby |
#vim:ts=2 sw=2 noexpandtab:
require 'rexml/child'
require 'rexml/source'
module REXML
# This class needs:
# * Documentation
# * Work! Not all types of attlists are intelligently parsed, so we just
# spew back out what we get in. This works, but it would be better if
# we formatted the output ourselves.
#... | Ruby |
require "rexml/child"
module REXML
##
# Represents an XML comment; that is, text between \<!-- ... -->
class Comment < Child
include Comparable
START = "<!--"
STOP = "-->"
# The content text
attr_accessor :string
##
# Constructor. The first argument can be one of three types:
... | Ruby |
require "rexml/element"
require "rexml/xmldecl"
require "rexml/source"
require "rexml/comment"
require "rexml/doctype"
require "rexml/instruction"
require "rexml/rexml"
require "rexml/parseexception"
require "rexml/output"
require "rexml/parsers/baseparser"
require "rexml/parsers/streamparser"
require "rexml/parsers/tr... | Ruby |
require "rexml/child"
module REXML
module DTD
class AttlistDecl < Child
START = "<!ATTLIST"
START_RE = /^\s*#{START}/um
PATTERN_RE = /\s*(#{START}.*?>)/um
end
end
end
| Ruby |
require "rexml/dtd/elementdecl"
require "rexml/dtd/entitydecl"
require "rexml/comment"
require "rexml/dtd/notationdecl"
require "rexml/dtd/attlistdecl"
require "rexml/parent"
module REXML
module DTD
class Parser
def Parser.parse( input )
case input
when String
parse_helper input
... | Ruby |
require "rexml/child"
module REXML
module DTD
class EntityDecl < Child
START = "<!ENTITY"
START_RE = /^\s*#{START}/um
PUBLIC = /^\s*#{START}\s+(?:%\s+)?(\w+)\s+PUBLIC\s+((["']).*?\3)\s+((["']).*?\5)\s*>/um
SYSTEM = /^\s*#{START}\s+(?:%\s+)?(\w+)\s+SYSTEM\s+((["']).*?\3)(?:\s+NDATA\s+\w+)?\... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.