repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/tk/lib/tkextlib/tkDND/shape.rb
<reponame>arnab0073/idea # # tkextlib/tkDND/shape.rb # by <NAME> (<EMAIL>) # require 'tk' # call setup script for general 'tkextlib' libraries require 'tkextlib/setup.rb' # call setup script require 'tkextlib/tkDND/setup.rb' # TkPackage.require('Shape', '0.3') TkPackage.require('Shape') module Tk module TkDND module Shape extend TkCore PACKAGE_NAME = 'Shape'.freeze def self.package_name PACKAGE_NAME end =begin def self.package_version begin TkPackage.require('Shape') rescue '' end end =end class << self def package_version Tk.tk_call('set', 'shape_version') end alias shape_version package_version def package_patchlevel Tk.tk_call('set', 'shape_patchLevel') end alias shape_patchlevel package_patchlevel def version tk_call('shape', 'version') end alias xshape_version version end ############################ def shape_bounds(kind=nil) if kind ret = tk_call('shape', 'bounds', @path, "-#{kind}") else ret = tk_call('shape', 'bounds', @path) end if ret == "" nil else list(ret) end end def shape_get(kind=nil) if kind list(tk_call('shape', 'get', @path, "-#{kind}")) else list(tk_call('shape', 'get', @path)) end end def shape_offset(x, y, kind=nil) if kind tk_call('shape', 'get', @path, "-#{kind}", x, y) else tk_call('shape', 'get', @path, x, y) end self end def _parse_shapespec_param(args) cmd = [] kind_keys = ['bounding', 'clip', 'both'] offset_keys = ['offset'] srckind_keys = ['bitmap', 'rectangles', 'reset', 'test', 'window'] cmd << "-#{args.shift}" if kind_keys.member?(args[0].to_s) if offset_keys.member?(args[0].to_s) cmd << "-#{args.shift}" cmd << args.shift # xOffset cmd << args.shift # yOffset end if srckind_keys.member?(args[0].to_s) cmd << "-#{args.shift}" end cmd.concat(args) cmd end private :_parse_shapespec_param def shape_set(*args) # ?kind? ?offset <x> <y>? srckind ?arg ...? tk_call('shape', 'set', @path, *(_parse_shapespec_param(args))) self end def shape_update(op, *args) # ?kind? ?offset <x> <y>? srckind ?arg ...? tk_call('shape', 'update', @path, op, *(_parse_shapespec_param(args))) self end end end end class TkWindow include Tk::TkDND::Shape end
arnab0073/idea
.rvm/src/ruby-2.3.0/lib/rdoc/stats/verbose.rb
<filename>.rvm/src/ruby-2.3.0/lib/rdoc/stats/verbose.rb # frozen_string_literal: false ## # Stats printer that prints everything documented, including the documented # status class RDoc::Stats::Verbose < RDoc::Stats::Normal ## # Returns a marker for RDoc::CodeObject +co+ being undocumented def nodoc co " (undocumented)" unless co.documented? end def print_alias as # :nodoc: puts " alias #{as.new_name} #{as.old_name}#{nodoc as}" end def print_attribute attribute # :nodoc: puts " #{attribute.definition} #{attribute.name}#{nodoc attribute}" end def print_class(klass) # :nodoc: puts " class #{klass.full_name}#{nodoc klass}" end def print_constant(constant) # :nodoc: puts " #{constant.name}#{nodoc constant}" end def print_file(files_so_far, file) # :nodoc: super puts end def print_method(method) # :nodoc: puts " #{method.singleton ? '::' : '#'}#{method.name}#{nodoc method}" end def print_module(mod) # :nodoc: puts " module #{mod.full_name}#{nodoc mod}" end end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/sample/dualstack-fetch.rb
# simple webpage fetcher # The code demonstrates how a multi-protocol client should be written. # TCPSocket is using getaddrinfo() internally, so there should be no problem. require "socket" if ARGV.size != 1 STDERR.print "requires URL\n" exit end url = ARGV[0] if url !~ /^http:\/\/([^\/]+)(\/.*)$/ STDERR.print "only http with full hostname is supported\n" exit end # split URL into host, port and path hostport = $1 path = $2 if (hostport =~ /^(.*):([0-9]+)$/) host = $1 port = $2 else host = hostport port = 80 end if host =~ /^\[(.*)\]$/ host = $1 end #STDERR.print "url=<#{ARGV[0]}>\n" #STDERR.print "host=<#{host}>\n" #STDERR.print "port=<#{port}>\n" #STDERR.print "path=<#{path}>\n" STDERR.print "conntecting to #{host} port #{port}\n" c = TCPSocket.new(host, port) dest = Socket.getnameinfo(c.getpeername, Socket::NI_NUMERICHOST|Socket::NI_NUMERICSERV) STDERR.print "conntected to #{dest[0]} port #{dest[1]}\n" c.print "GET #{path} HTTP/1.0\n" c.print "Host: #{host}\n" c.print "\n" while c.gets print end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/digest/sha2/extconf.rb
# $RoughId: extconf.rb,v 1.4 2001/08/14 19:54:51 knu Exp $ # $Id: extconf.rb 35653 2012-05-15 16:10:46Z tenderlove $ require "mkmf" $defs << "-DHAVE_CONFIG_H" $INCFLAGS << " -I$(srcdir)/.." $objs = [ "sha2init.#{$OBJEXT}" ] dir_config("openssl") pkg_config("openssl") if !with_config("bundled-sha2") && have_library("crypto") && %w[SHA256 SHA512].all? {|d| have_func("#{d}_Transform", "openssl/sha.h")} && %w[SHA256 SHA512].all? {|d| have_type("#{d}_CTX", "openssl/sha.h")} $objs << "sha2ossl.#{$OBJEXT}" $defs << "-DSHA2_USE_OPENSSL" else have_type("u_int8_t") $objs << "sha2.#{$OBJEXT}" end have_header("sys/cdefs.h") $preload = %w[digest] if have_type("uint64_t", "defs.h", $defs.join(' ')) create_makefile("digest/sha2") end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/test/socket/test_socket.rb
begin require "socket" require "tmpdir" require "test/unit" rescue LoadError end class TestSocket < Test::Unit::TestCase def test_socket_new s = Socket.new(:INET, :STREAM) assert_kind_of(Socket, s) end def test_unpack_sockaddr sockaddr_in = Socket.sockaddr_in(80, "") assert_raise(ArgumentError) { Socket.unpack_sockaddr_un(sockaddr_in) } sockaddr_un = Socket.sockaddr_un("/testdir/s") assert_raise(ArgumentError) { Socket.unpack_sockaddr_in(sockaddr_un) } assert_raise(ArgumentError) { Socket.unpack_sockaddr_in("") } assert_raise(ArgumentError) { Socket.unpack_sockaddr_un("") } end if Socket.respond_to?(:sockaddr_un) def test_sysaccept serv = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0) serv.bind(Socket.sockaddr_in(0, "127.0.0.1")) serv.listen 5 c = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0) c.connect(serv.getsockname) fd, peeraddr = serv.sysaccept assert_equal(c.getsockname, peeraddr.to_sockaddr) ensure serv.close if serv c.close if c IO.for_fd(fd).close if fd end def test_initialize Socket.open(Socket::AF_INET, Socket::SOCK_STREAM, 0) {|s| s.bind(Socket.sockaddr_in(0, "127.0.0.1")) addr = s.getsockname assert_nothing_raised { Socket.unpack_sockaddr_in(addr) } assert_raise(ArgumentError, NoMethodError) { Socket.unpack_sockaddr_un(addr) } } Socket.open("AF_INET", "SOCK_STREAM", 0) {|s| s.bind(Socket.sockaddr_in(0, "127.0.0.1")) addr = s.getsockname assert_nothing_raised { Socket.unpack_sockaddr_in(addr) } assert_raise(ArgumentError, NoMethodError) { Socket.unpack_sockaddr_un(addr) } } Socket.open(:AF_INET, :SOCK_STREAM, 0) {|s| s.bind(Socket.sockaddr_in(0, "127.0.0.1")) addr = s.getsockname assert_nothing_raised { Socket.unpack_sockaddr_in(addr) } assert_raise(ArgumentError, NoMethodError) { Socket.unpack_sockaddr_un(addr) } } end def test_getaddrinfo # This should not send a DNS query because AF_UNIX. assert_raise(SocketError) { Socket.getaddrinfo("www.kame.net", 80, "AF_UNIX") } end def test_getaddrinfo_raises_no_errors_on_port_argument_of_0 # [ruby-core:29427] assert_nothing_raised('[ruby-core:29427]'){ Socket.getaddrinfo('localhost', 0, Socket::AF_INET, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME) } assert_nothing_raised('[ruby-core:29427]'){ Socket.getaddrinfo('localhost', '0', Socket::AF_INET, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME) } assert_nothing_raised('[ruby-core:29427]'){ Socket.getaddrinfo('localhost', '00', Socket::AF_INET, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME) } assert_raise(SocketError, '[ruby-core:29427]'){ Socket.getaddrinfo(nil, nil, Socket::AF_INET, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME) } assert_nothing_raised('[ruby-core:29427]'){ TCPServer.open('localhost', 0) {} } end def test_getnameinfo assert_raise(SocketError) { Socket.getnameinfo(["AF_UNIX", 80, "0.0.0.0"]) } end def test_ip_address_list begin list = Socket.ip_address_list rescue NotImplementedError return end list.each {|ai| assert_instance_of(Addrinfo, ai) assert(ai.ip?) } end def test_tcp TCPServer.open(0) {|serv| addr = serv.connect_address addr.connect {|s1| s2 = serv.accept begin assert_equal(s2.remote_address.ip_unpack, s1.local_address.ip_unpack) ensure s2.close end } } end def random_port # IANA suggests dynamic port for 49152 to 65535 # http://www.iana.org/assignments/port-numbers 49152 + rand(65535-49152+1) end def errors_addrinuse [Errno::EADDRINUSE] end def test_tcp_server_sockets port = random_port begin sockets = Socket.tcp_server_sockets(port) rescue *errors_addrinuse return # not test failure end begin sockets.each {|s| assert_equal(port, s.local_address.ip_port) } ensure sockets.each {|s| s.close } end end def test_tcp_server_sockets_port0 sockets = Socket.tcp_server_sockets(0) ports = sockets.map {|s| s.local_address.ip_port } the_port = ports.first ports.each {|port| assert_equal(the_port, port) } ensure if sockets sockets.each {|s| s.close } end end if defined? UNIXSocket def test_unix Dir.mktmpdir {|tmpdir| path = "#{tmpdir}/sock" UNIXServer.open(path) {|serv| Socket.unix(path) {|s1| s2 = serv.accept begin s2raddr = s2.remote_address s1laddr = s1.local_address assert(s2raddr.to_sockaddr.empty? || s1laddr.to_sockaddr.empty? || s2raddr.unix_path == s1laddr.unix_path) ensure s2.close end } } } end def test_unix_server_socket Dir.mktmpdir {|tmpdir| path = "#{tmpdir}/sock" 2.times { serv = Socket.unix_server_socket(path) begin assert_kind_of(Socket, serv) assert(File.socket?(path)) assert_equal(path, serv.local_address.unix_path) ensure serv.close end } } end def test_accept_loop_with_unix Dir.mktmpdir {|tmpdir| tcp_servers = [] clients = [] accepted = [] begin tcp_servers = Socket.tcp_server_sockets(0) unix_server = Socket.unix_server_socket("#{tmpdir}/sock") tcp_servers.each {|s| addr = s.connect_address assert_nothing_raised("connect to #{addr.inspect}") { clients << addr.connect } } addr = unix_server.connect_address assert_nothing_raised("connect to #{addr.inspect}") { clients << addr.connect } Socket.accept_loop(tcp_servers, unix_server) {|s| accepted << s break if clients.length == accepted.length } assert_equal(clients.length, accepted.length) ensure tcp_servers.each {|s| s.close if !s.closed? } unix_server.close if unix_server && !unix_server.closed? clients.each {|s| s.close if !s.closed? } accepted.each {|s| s.close if !s.closed? } end } end end def test_accept_loop servers = [] begin servers = Socket.tcp_server_sockets(0) port = servers[0].local_address.ip_port Socket.tcp("localhost", port) {|s1| Socket.accept_loop(servers) {|s2, client_ai| begin assert_equal(s1.local_address.ip_unpack, client_ai.ip_unpack) ensure s2.close end break } } ensure servers.each {|s| s.close if !s.closed? } end end def test_accept_loop_multi_port servers = [] begin servers = Socket.tcp_server_sockets(0) port = servers[0].local_address.ip_port servers2 = Socket.tcp_server_sockets(0) servers.concat servers2 port2 = servers2[0].local_address.ip_port Socket.tcp("localhost", port) {|s1| Socket.accept_loop(servers) {|s2, client_ai| begin assert_equal(s1.local_address.ip_unpack, client_ai.ip_unpack) ensure s2.close end break } } Socket.tcp("localhost", port2) {|s1| Socket.accept_loop(servers) {|s2, client_ai| begin assert_equal(s1.local_address.ip_unpack, client_ai.ip_unpack) ensure s2.close end break } } ensure servers.each {|s| s.close if !s.closed? } end end def test_udp_server begin ip_addrs = Socket.ip_address_list rescue NotImplementedError skip "Socket.ip_address_list not implemented" end Socket.udp_server_sockets(0) {|sockets| famlies = {} sockets.each {|s| famlies[s.local_address.afamily] = s } ip_addrs.reject! {|ai| s = famlies[ai.afamily] next true unless s case RUBY_PLATFORM when /linux/ if ai.ip_address.include?('%') and (`uname -r`[/[0-9.]+/].split('.').map(&:to_i) <=> [2,6,18]) <= 0 # Cent OS 5.6 (2.6.18-238.19.1.el5xen) doesn't correctly work # sendmsg with pktinfo for link-local ipv6 addresses next true end when /freebsd/ if ifr_name = ai.ip_address[/%(.*)/, 1] # FreeBSD 9.0 with default setting (ipv6_activate_all_interfaces # is not YES) sets IFDISABLED to interfaces which don't have # global IPv6 address. # Link-local IPv6 addresses on those interfaces don't work. ulSIOCGIFINFO_IN6 = -1068996244 bIFDISABLED = 4 in6_ifreq = ifr_name s.ioctl(ulSIOCGIFINFO_IN6, in6_ifreq) next true if in6_ifreq.unpack('A16L6').last[bIFDISABLED-1] == 1 end end } skipped = false begin port = sockets.first.local_address.ip_port th = Thread.new { Socket.udp_server_loop_on(sockets) {|msg, msg_src| break if msg == "exit" rmsg = Marshal.dump([msg, msg_src.remote_address, msg_src.local_address]) msg_src.reply rmsg } } ip_addrs.each {|ai| Addrinfo.udp(ai.ip_address, port).connect {|s| msg1 = "<<<#{ai.inspect}>>>" s.sendmsg msg1 unless IO.select([s], nil, nil, 10) raise "no response from #{ai.inspect}" end msg2, addr = s.recvmsg msg2, remote_address, local_address = Marshal.load(msg2) assert_equal(msg1, msg2) assert_equal(ai.ip_address, addr.ip_address) } } rescue NotImplementedError, Errno::ENOSYS skipped = true skip "need sendmsg and recvmsg" ensure if th if skipped Thread.kill th unless th.join(10) else Addrinfo.udp("127.0.0.1", port).connect {|s| s.sendmsg "exit" } unless th.join(10) Thread.kill th th.join(10) raise "thread killed" end end end end } end def test_linger opt = Socket::Option.linger(true, 0) assert_equal([true, 0], opt.linger) Addrinfo.tcp("127.0.0.1", 0).listen {|serv| serv.local_address.connect {|s1| s2, _ = serv.accept begin s1.setsockopt(opt) s1.close assert_raise(Errno::ECONNRESET) { s2.read } ensure s2.close end } } end def test_timestamp return if /linux|freebsd|netbsd|openbsd|solaris|darwin/ !~ RUBY_PLATFORM return if !defined?(Socket::AncillaryData) t1 = Time.now.strftime("%Y-%m-%d") stamp = nil Addrinfo.udp("127.0.0.1", 0).bind {|s1| Addrinfo.udp("127.0.0.1", 0).bind {|s2| s1.setsockopt(:SOCKET, :TIMESTAMP, true) s2.send "a", 0, s1.local_address msg, addr, rflags, stamp = s1.recvmsg assert_equal("a", msg) assert(stamp.cmsg_is?(:SOCKET, :TIMESTAMP)) } } t2 = Time.now.strftime("%Y-%m-%d") pat = Regexp.union([t1, t2].uniq) assert_match(pat, stamp.inspect) t = stamp.timestamp assert_match(pat, t.strftime("%Y-%m-%d")) pat = /\.#{"%06d" % t.usec}/ assert_match(pat, stamp.inspect) end def test_timestampns return if /linux/ !~ RUBY_PLATFORM || !defined?(Socket::SO_TIMESTAMPNS) t1 = Time.now.strftime("%Y-%m-%d") stamp = nil Addrinfo.udp("127.0.0.1", 0).bind {|s1| Addrinfo.udp("127.0.0.1", 0).bind {|s2| begin s1.setsockopt(:SOCKET, :TIMESTAMPNS, true) rescue Errno::ENOPROTOOPT # SO_TIMESTAMPNS is available since Linux 2.6.22 return end s2.send "a", 0, s1.local_address msg, addr, rflags, stamp = s1.recvmsg assert_equal("a", msg) assert(stamp.cmsg_is?(:SOCKET, :TIMESTAMPNS)) } } t2 = Time.now.strftime("%Y-%m-%d") pat = Regexp.union([t1, t2].uniq) assert_match(pat, stamp.inspect) t = stamp.timestamp assert_match(pat, t.strftime("%Y-%m-%d")) pat = /\.#{"%09d" % t.nsec}/ assert_match(pat, stamp.inspect) end def test_bintime return if /freebsd/ !~ RUBY_PLATFORM t1 = Time.now.strftime("%Y-%m-%d") stamp = nil Addrinfo.udp("127.0.0.1", 0).bind {|s1| Addrinfo.udp("127.0.0.1", 0).bind {|s2| s1.setsockopt(:SOCKET, :BINTIME, true) s2.send "a", 0, s1.local_address msg, addr, rflags, stamp = s1.recvmsg assert_equal("a", msg) assert(stamp.cmsg_is?(:SOCKET, :BINTIME)) } } t2 = Time.now.strftime("%Y-%m-%d") pat = Regexp.union([t1, t2].uniq) assert_match(pat, stamp.inspect) t = stamp.timestamp assert_match(pat, t.strftime("%Y-%m-%d")) assert_equal(stamp.data[-8,8].unpack("Q")[0], t.subsec * 2**64) end def test_closed_read require 'timeout' require 'socket' bug4390 = '[ruby-core:35203]' server = TCPServer.new("localhost", 0) serv_thread = Thread.new {server.accept} begin sleep(0.1) end until serv_thread.stop? sock = TCPSocket.new("localhost", server.addr[1]) client_thread = Thread.new do sock.readline end begin sleep(0.1) end until client_thread.stop? Timeout.timeout(1) do sock.close sock = nil assert_raise(IOError, bug4390) {client_thread.join} end ensure server.close end def test_connect_in_rescue serv = Addrinfo.tcp(nil, 0).listen addr = serv.connect_address begin raise "dummy error" rescue s = addr.connect assert(!s.closed?) end ensure serv.close if serv && !serv.closed? s.close if s && !s.closed? end def test_bind_in_rescue begin raise "dummy error" rescue s = Addrinfo.tcp(nil, 0).bind assert(!s.closed?) end ensure s.close if s && !s.closed? end def test_listen_in_rescue begin raise "dummy error" rescue s = Addrinfo.tcp(nil, 0).listen assert(!s.closed?) end ensure s.close if s && !s.closed? end def test_udp_server_sockets_in_rescue begin raise "dummy error" rescue ss = Socket.udp_server_sockets(0) ss.each {|s| assert(!s.closed?) } end ensure if ss ss.each {|s| s.close if !s.closed? } end end def test_tcp_server_sockets_in_rescue begin raise "dummy error" rescue ss = Socket.tcp_server_sockets(0) ss.each {|s| assert(!s.closed?) } end ensure if ss ss.each {|s| s.close if !s.closed? } end end end if defined?(Socket)
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/rubyntlm-0.6.0/spec/lib/net/ntlm/target_info_spec.rb
<reponame>arnab0073/idea require 'spec_helper' describe Net::NTLM::TargetInfo do let(:key1) { Net::NTLM::TargetInfo::MSV_AV_NB_COMPUTER_NAME } let(:value1) { 'some data' } let(:key2) { Net::NTLM::TargetInfo::MSV_AV_NB_DOMAIN_NAME } let(:value2) { 'some other data' } let(:data) do dt = key1.dup dt << [value1.length].pack('S') dt << value1 dt << key2.dup dt << [value2.length].pack('S') dt << value2 dt << Net::NTLM::TargetInfo::MSV_AV_EOL dt << [0].pack('S') dt.force_encoding(Encoding::ASCII_8BIT) end subject { Net::NTLM::TargetInfo.new(data) } describe 'invalid data' do context 'invalid pair id' do let(:data) { "\xFF\x00" } it 'returns an error' do expect{subject}.to raise_error Net::NTLM::InvalidTargetDataError end end end describe '#av_pairs' do it 'returns the pair values with the given keys' do expect(subject.av_pairs[key1]).to eq value1 expect(subject.av_pairs[key2]).to eq value2 end context "target data is nil" do subject { Net::NTLM::TargetInfo.new(nil) } it 'returns the pair values with the given keys' do expect(subject.av_pairs).to be_empty end end end describe '#to_s' do let(:data) do dt = key1.dup dt << [value1.length].pack('S') dt << value1 dt << key2.dup dt << [value2.length].pack('S') dt << value2 dt.force_encoding(Encoding::ASCII_8BIT) end let(:new_key) { Net::NTLM::TargetInfo::MSV_AV_CHANNEL_BINDINGS } let(:new_value) { 'bindings' } let(:new_data) do dt = data dt << new_key dt << [new_value.length].pack('S') dt << new_value dt << Net::NTLM::TargetInfo::MSV_AV_EOL dt << [0].pack('S') dt.force_encoding(Encoding::ASCII_8BIT) end it 'returns bytes with any new data added' do subject.av_pairs[new_key] = new_value expect(subject.to_s).to eq new_data end end end
arnab0073/idea
.rvm/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/gem-wrappers-1.2.7/test/gem-wrappers/specification_and_version_test.rb
<gh_stars>1-10 require 'test_helper' require 'gem-wrappers/specification' require 'gem-wrappers/version' describe GemWrappers::Specification do before do GemWrappers::Specification.instance_variable_set(:@gem_wrappers_spec, nil) end it "finds specification" do GemWrappers::Specification.find.name.must_equal("gem-wrappers") end it "gets specification version" do GemWrappers::Specification.version.must_equal(GemWrappers::VERSION) end it "does not find imaginary gems" do GemWrappers::Specification.find("imaginary-gem").must_equal(nil) end end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/lib/webrick/htmlutils.rb
<reponame>arnab0073/idea #-- # htmlutils.rb -- HTMLUtils Module # # Author: IPR -- Internet Programming with Ruby -- writers # Copyright (c) 2000, 2001 <NAME>, <NAME> # Copyright (c) 2002 Internet Programming with Ruby writers. All rights # reserved. # # $IPR: htmlutils.rb,v 1.7 2002/09/21 12:23:35 gotoyuzo Exp $ module WEBrick module HTMLUtils ## # Escapes &, ", > and < in +string+ def escape(string) return "" unless string str = string.dup.force_encoding('binary') str.gsub!(/&/n, '&amp;') str.gsub!(/\"/n, '&quot;') str.gsub!(/>/n, '&gt;') str.gsub!(/</n, '&lt;') str.force_encoding(string.encoding) end module_function :escape end end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/rest-client-1.6.9/spec/integration/request_spec.rb
require File.join( File.dirname(File.expand_path(__FILE__)), '../base') describe RestClient::Request do describe "ssl verification" do it "is successful with the correct ca_file" do request = RestClient::Request.new( :method => :get, :url => 'https://www.mozilla.org', :verify_ssl => OpenSSL::SSL::VERIFY_PEER, :ssl_ca_file => File.join(File.dirname(__FILE__), "certs", "digicert.crt") ) expect { request.execute }.to_not raise_error end # I don' think this feature is useful anymore (under 1.9.3 at the very least). # # Exceptions in verify_callback are ignored; RestClient has to catch OpenSSL::SSL::SSLError # and either re-throw it as is, or throw SSLCertificateNotVerified # based on the contents of the message field of the original exception #. # The client has to handle OpenSSL::SSL::SSLError exceptions anyway, # why make them handle both OpenSSL *AND* RestClient exceptions??? # # also see https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl.c#L237 it "is unsuccessful with an incorrect ca_file" do request = RestClient::Request.new( :method => :get, :url => 'https://www.mozilla.com', :verify_ssl => OpenSSL::SSL::VERIFY_PEER, :ssl_ca_file => File.join(File.dirname(__FILE__), "certs", "verisign.crt") ) expect { request.execute }.to raise_error(RestClient::SSLCertificateNotVerified) end it "executes the verify_callback" do ran_callback = false request = RestClient::Request.new( :method => :get, :url => 'https://www.mozilla.org', :verify_ssl => true, :ssl_verify_callback => lambda { |preverify_ok, store_ctx| ran_callback = true preverify_ok }, :ssl_ca_file => File.join(File.dirname(__FILE__), "certs", "digicert.crt") ) expect {request.execute }.to_not raise_error ran_callback.should eq(true) end it "fails verification when the callback returns false", :unless => RestClient::Platform.mac? do request = RestClient::Request.new( :method => :get, :url => 'https://www.mozilla.org', :verify_ssl => true, :ssl_verify_callback => lambda { |preverify_ok, store_ctx| false }, :ssl_ca_file => File.join(File.dirname(__FILE__), "certs", "digicert.crt") ) expect { request.execute }.to raise_error(RestClient::SSLCertificateNotVerified) end it "succeeds verification when the callback returns true", :unless => RestClient::Platform.mac? do request = RestClient::Request.new( :method => :get, :url => 'https://www.mozilla.org', :verify_ssl => true, :ssl_ca_file => File.join(File.dirname(__FILE__), "certs", "verisign.crt"), :ssl_verify_callback => lambda { |preverify_ok, store_ctx| true } ) expect { request.execute }.to_not raise_error end end end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/logging-2.1.0/examples/layouts.rb
<reponame>arnab0073/idea # :stopdoc: # # The formatting of log messages is controlled by the layout given to the # appender. By default all appenders use the Basic layout. It's pretty # basic. However, a more sophisticated Pattern layout can be used or one of # the Parseable layouts -- JSON or YAML. # # The available layouts are: # # Logging.layouts.basic # Logging.layouts.pattern # Logging.layouts.json # Logging.layouts.yaml # # In this example we'll demonstrate use of different layouts and setting log # levels in the appenders to filter out events. # require 'logging' # only show "info" or higher messages on STDOUT using the Basic layout Logging.appenders.stdout(:level => :info) # send all log events to the development log (including debug) as JSON Logging.appenders.rolling_file( 'development.log', :age => 'daily', :layout => Logging.layouts.json ) log = Logging.logger['Foo::Bar'] log.add_appenders 'stdout', 'development.log' log.level = :debug log.debug "a very nice little debug message" log.info "things are operating nominally" log.warn "this is your last warning" log.error StandardError.new("something went horribly wrong") log.fatal "I Die!" # :startdoc:
arnab0073/idea
.rvm/src/ruby-2.3.0/test/rubygems/test_gem_commands_build_command.rb
# frozen_string_literal: false require 'rubygems/test_case' require 'rubygems/commands/build_command' require 'rubygems/package' class TestGemCommandsBuildCommand < Gem::TestCase def setup super @gem = util_spec 'some_gem' do |s| s.rubyforge_project = 'example' end @cmd = Gem::Commands::BuildCommand.new end def test_execute gemspec_file = File.join(@tempdir, @gem.spec_name) File.open gemspec_file, 'w' do |gs| gs.write @gem.to_ruby end util_test_build_gem @gem, gemspec_file end def test_execute_bad_spec @gem.date = "2010-11-08" gemspec_file = File.join(@tempdir, @gem.spec_name) File.open gemspec_file, 'w' do |gs| gs.write @gem.to_ruby.sub(/11-08/, "11-8") end @cmd.options[:args] = [gemspec_file] out, err = use_ui @ui do capture_io do assert_raises Gem::MockGemUi::TermError do @cmd.execute end end end assert_equal "", out assert_match(/invalid date format in specification/, err) assert_equal '', @ui.output assert_equal "ERROR: Error loading gemspec. Aborting.\n", @ui.error end def test_execute_missing_file @cmd.options[:args] = %w[some_gem] use_ui @ui do assert_raises Gem::MockGemUi::TermError do @cmd.execute end end assert_equal '', @ui.output assert_equal "ERROR: Gemspec file not found: some_gem\n", @ui.error end def util_test_build_gem(gem, gemspec_file, check_licenses=true) @cmd.options[:args] = [gemspec_file] use_ui @ui do Dir.chdir @tempdir do @cmd.execute end end output = @ui.output.split "\n" assert_equal " Successfully built RubyGem", output.shift assert_equal " Name: some_gem", output.shift assert_equal " Version: 2", output.shift assert_equal " File: some_gem-2.gem", output.shift assert_equal [], output if check_licenses assert_match "WARNING: licenses is empty", @ui.error end gem_file = File.join @tempdir, File.basename(gem.cache_file) assert File.exist?(gem_file) spec = Gem::Package.new(gem_file).spec assert_equal "some_gem", spec.name assert_equal "this is a summary", spec.summary end def test_execute_force gemspec_file = File.join(@tempdir, @gem.spec_name) @gem.send :remove_instance_variable, :@rubygems_version File.open gemspec_file, 'w' do |gs| gs.write @gem.to_ruby end @cmd.options[:args] = [gemspec_file] @cmd.options[:force] = true util_test_build_gem @gem, gemspec_file, false end end
arnab0073/idea
.rvm/src/ruby-2.3.0/ext/tk/lib/tkextlib/iwidgets/entryfield.rb
<gh_stars>0 # frozen_string_literal: false # # tkextlib/iwidgets/entryfield.rb # by <NAME> (<EMAIL>) # require 'tk' require 'tkextlib/iwidgets.rb' module Tk module Iwidgets class Entryfield < Tk::Iwidgets::Labeledwidget end end end class Tk::Iwidgets::Entryfield TkCommandNames = ['::iwidgets::entryfield'.freeze].freeze WidgetClassName = 'Entryfield'.freeze WidgetClassNames[WidgetClassName] ||= self def __font_optkeys super() << 'textfont' end private :__font_optkeys #################################### include Tk::ValidateConfigure class EntryfieldValidate < TkValidateCommand #class CalCmdArgs < TkUtil::CallbackSubst class ValidateArgs < TkUtil::CallbackSubst KEY_TBL = [ [ ?c, ?s, :char ], [ ?P, ?s, :post ], [ ?S, ?s, :current ], [ ?W, ?w, :widget ], nil ] PROC_TBL = [ [ ?s, TkComm.method(:string) ], [ ?w, TkComm.method(:window) ], nil ] =begin # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) ) KEY_TBL.map!{|inf| if inf.kind_of?(Array) inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String) inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String) end inf } PROC_TBL.map!{|inf| if inf.kind_of?(Array) inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String) end inf } =end _setup_subst_table(KEY_TBL, PROC_TBL); end def self._config_keys ['validate', 'invalid'] end end def __validation_class_list super() << EntryfieldValidate end Tk::ValidateConfigure.__def_validcmd(binding, EntryfieldValidate) =begin def validate(cmd = Proc.new, args = nil) if cmd.kind_of?(ValidateCmd) configure('validate', cmd) elsif args configure('validate', [cmd, args]) else configure('validate', cmd) end end def invalid(cmd = Proc.new, args = nil) if cmd.kind_of?(ValidateCmd) configure('invalid', cmd) elsif args configure('invalid', [cmd, args]) else configure('invalid', cmd) end end =end #################################### def clear tk_call(@path, 'clear') self end def delete(first, last=None) tk_send_without_enc('delete', first, last) self end def value _fromUTF8(tk_send_without_enc('get')) end def value= (val) tk_send_without_enc('delete', 0, 'end') tk_send_without_enc('insert', 0, _get_eval_enc_str(val)) val end alias get value alias set value= def cursor=(index) tk_send_without_enc('icursor', index) #self index end alias icursor cursor= def index(index) number(tk_send_without_enc('index', index)) end def insert(pos,text) tk_send_without_enc('insert', pos, _get_eval_enc_str(text)) self end def mark(pos) tk_send_without_enc('scan', 'mark', pos) self end def dragto(pos) tk_send_without_enc('scan', 'dragto', pos) self end def selection_adjust(index) tk_send_without_enc('selection', 'adjust', index) self end def selection_clear tk_send_without_enc('selection', 'clear') self end def selection_from(index) tk_send_without_enc('selection', 'from', index) self end def selection_present() bool(tk_send_without_enc('selection', 'present')) end def selection_range(s, e) tk_send_without_enc('selection', 'range', s, e) self end def selection_to(index) tk_send_without_enc('selection', 'to', index) self end # based on tk/scrollable.rb def xview(*index) if index.size == 0 list(tk_send_without_enc('xview')) else tk_send_without_enc('xview', *index) self end end def xview_moveto(*index) xview('moveto', *index) end def xview_scroll(*index) xview('scroll', *index) end end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/ohai-6.18.0/lib/ohai/plugins/network_listeners.rb
<filename>.rvm/gems/ruby-2.3.0/gems/ohai-6.18.0/lib/ohai/plugins/network_listeners.rb # # Author:: <NAME> <<EMAIL>> # Copyright:: Copyright (c) 2009 VMware, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # require 'sigar' provides "network/listeners" require_plugin "network" flags = Sigar::NETCONN_TCP|Sigar::NETCONN_SERVER listeners = Mash.new sigar = Sigar.new sigar.net_connection_list(flags).each do |conn| port = conn.local_port addr = conn.local_address.to_s if addr == "0.0.0.0" || addr == "::" addr = "*" end listeners[port] = Mash.new listeners[port][:address] = addr begin pid = sigar.proc_port(conn.type, port) listeners[port][:pid] = pid listeners[port][:name] = sigar.proc_state(pid).name rescue end end network[:listeners] = Mash.new network[:listeners][:tcp] = listeners
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/mathn/complex/extconf.rb
<filename>.rvm/src/ruby-1.9.3-p551/ext/mathn/complex/extconf.rb require "mkmf" create_makefile "mathn/complex"
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/winrm-1.8.1/lib/winrm/output.rb
# encoding: UTF-8 # # Copyright 2014 <NAME> <<EMAIL>> # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. module WinRM # This class holds raw output as a hash, and has convenience methods to parse. class Output < Hash def initialize super self[:data] = [] end def output self[:data].flat_map do |line| [line[:stdout], line[:stderr]] end.compact.join end def stdout self[:data].map do |line| line[:stdout] end.compact.join end def stderr self[:data].map do |line| line[:stderr] end.compact.join end end end
arnab0073/idea
.rvm/src/ruby-2.3.0/tool/asm_parse.rb
<reponame>arnab0073/idea<gh_stars>0 stat = {} while line = ARGF.gets if /\[start\] (\w+)/ =~ line name = $1 puts '--------------------------------------------------------------' puts line size = 0 len = 0 while line = ARGF.gets if /\[start\] (\w+)/ =~ line puts "\t; # length: #{len}, size: #{size}" puts "\t; # !!" stat[name] = [len, size] # name = $1 puts '--------------------------------------------------------------' puts line size = 0 len = 0 next end unless /(\ALM)|(\ALB)|(\A\.)|(\A\/)/ =~ line puts line if /\[length = (\d+)\]/ =~ line len += $1.to_i size += 1 end end if /__NEXT_INSN__/ !~ line && /\[end \] (\w+)/ =~ line ename = $1 if name != ename puts "!! start with #{name}, but end with #{ename}" end stat[ename] = [len, size] puts "\t; # length: #{len}, size: #{size}" break end end end end stat.sort_by{|a, b| -b[0] * 1000 - a[0]}.each{|a, b| puts "#{a}\t#{b.join("\t")}" } puts "total length :\t#{stat.inject(0){|r, e| r+e[1][0]}}" puts "total size :\t#{stat.inject(0){|r, e| r+e[1][1]}}"
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/tk/lib/tkextlib/bwidget/scrollview.rb
# # tkextlib/bwidget/scrollview.rb # by <NAME> (<EMAIL>) # require 'tk' require 'tkextlib/bwidget.rb' module Tk module BWidget class ScrollView < TkWindow end end end class Tk::BWidget::ScrollView TkCommandNames = ['ScrollView'.freeze].freeze WidgetClassName = 'ScrollView'.freeze WidgetClassNames[WidgetClassName] ||= self def __strval_optkeys super() << 'fill' end private :__strval_optkeys end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/logging-2.1.0/examples/lazy.rb
# :stopdoc: # # It happens sometimes that it is very expensive to construct a logging # message; for example, if a large object structure has to be traversed # during executing of an `object.to_s` method. It would be convenient to # delay creation of the message until the log event actually takes place. # # For example, with a logger configured only to show WARN messages and higher, # creating the log message for an INFO message would be wasteful. The INFO log # event would never be generated in this case. # # Log message creation can be performed lazily by wrapping the expensive # message generation code in a block and passing that to the logging method. require 'logging' Logging.logger.root.appenders = Logging.appenders.stdout Logging.logger.root.level = :info # We use this dummy method in order to see if the method gets called, but in practice, # this method might do complicated string operations to construct a log message. def expensive_method puts "Called!" "Expensive message" end log = Logging.logger['Lazy'] # If you log this message the usual way, expensive_method gets called before # debug, hence the Logging framework has no chance to stop it from being executed # immediately. log.info("Normal") log.debug(expensive_method) # If we put the message into a block, then the block is not executed, if # the message is not needed with the current log level. log.info("Block unused") log.debug { expensive_method } # If the log message is needed with the current log level, then the block is of # course executed and the log message appears as expected. log.info("Block used") log.warn { expensive_method } # :startdoc:
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/tk/lib/tkextlib/bwidget/button.rb
<gh_stars>1-10 # # tkextlib/bwidget/button.rb # by <NAME> (<EMAIL>) # require 'tk' require 'tk/button' require 'tkextlib/bwidget.rb' module Tk module BWidget class Button < Tk::Button end end end class Tk::BWidget::Button TkCommandNames = ['Button'.freeze].freeze WidgetClassName = 'Button'.freeze WidgetClassNames[WidgetClassName] ||= self def __strval_optkeys super() << 'helptext' end private :__strval_optkeys def __tkvariable_optkeys super() << 'helpvar' end private :__tkvariable_optkeys end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/knife-ec2-0.12.0/spec/unit/s3_source_deps_spec.rb
<gh_stars>0 require File.expand_path('../../spec_helper', __FILE__) #This spec can only be run separately from the rest due to inclusion of fog library in other specs. #rspec spec/unit/s3_source_deps_spec.rb describe 'Check Dependencies', :exclude => Object.constants.include?(:Fog) do before(:each) do end it 'should not load fog by default' do begin Fog::Storage::AWS.new() rescue Exception => e expect(e).to be_a_kind_of(NameError) end end it 'lazy loads fog' do begin Chef::Knife::S3Source.fetch('test') rescue Exception => e expect(e).to be_a_kind_of(ArgumentError) end end end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/logging-2.1.0/lib/logging/appenders/console.rb
module Logging::Appenders # This class is provides an Appender base class for writing to the standard IO # stream - STDOUT and STDERR. This class should not be instantiated directly. # The `Stdout` and `Stderr` subclasses should be used. class Console < ::Logging::Appenders::IO # call-seq: # Stdout.new( name = 'stdout' ) # Stderr.new( :layout => layout ) # Stdout.new( name = 'stdout', :level => 'info' ) # # Creates a new Stdout/Stderr Appender. The name 'stdout'/'stderr' will be # used unless another is given. Optionally, a layout can be given for the # appender to use (otherwise a basic appender will be created) and a log # level can be specified. # # Options: # # :layout => the layout to use when formatting log events # :level => the level at which to log # def initialize( *args ) name = self.class.name.split("::").last.downcase io = Object.const_get(name.upcase) opts = Hash === args.last ? args.pop : {} name = args.shift unless args.empty? opts[:encoding] = io.external_encoding if io.respond_to? :external_encoding super(name, io, opts) rescue NameError raise RuntimeError, "Please do not use the `Logging::Appenders::Console` class directly - " + "use `Logging::Appenders::Stdout` and `Logging::Appenders::Stderr` instead" end end # This class provides an Appender that can write to STDOUT. Stdout = Class.new(Console) # This class provides an Appender that can write to STDERR. Stderr = Class.new(Console) # Accessor / Factory for the Stdout appender. # def self.stdout( *args ) if args.empty? return self['stdout'] || ::Logging::Appenders::Stdout.new end ::Logging::Appenders::Stdout.new(*args) end # Accessor / Factory for the Stderr appender. # def self.stderr( *args ) if args.empty? return self['stderr'] || ::Logging::Appenders::Stderr.new end ::Logging::Appenders::Stderr.new(*args) end end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/benchmark/bm_vm3_clearmethodcache.rb
i=0 while i<200_000 i+=1 Class.new{ def m; end } end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/fog-1.29.0/lib/fog/vsphere/requests/compute/list_clusters.rb
module Fog module Compute class Vsphere class Real def list_clusters(filters = { }) datacenter_name = filters[:datacenter] raw_clusters(datacenter_name).map do |cluster| cluster_attributes(cluster, datacenter_name) end end def raw_clusters(datacenter) folder ||= find_raw_datacenter(datacenter).hostFolder @raw_clusters = get_raw_clusters_from_folder(folder) end protected def get_raw_clusters_from_folder(folder) folder.childEntity.map do |child_entity| if child_entity.is_a? RbVmomi::VIM::ComputeResource child_entity elsif child_entity.is_a? RbVmomi::VIM::Folder get_raw_clusters_from_folder(child_entity) end end.flatten end def cluster_attributes cluster, datacenter_name { :id => managed_obj_id(cluster), :name => cluster.name, :full_path => cluster_path(cluster, datacenter_name), :num_host => cluster.summary.numHosts, :num_cpu_cores => cluster.summary.numCpuCores, :overall_status => cluster.summary.overallStatus, :datacenter => datacenter_name || parent_attribute(cluster.path, :datacenter)[1], } end def cluster_path(cluster, datacenter_name) datacenter = find_raw_datacenter(datacenter_name) cluster.pretty_path.gsub(/(#{datacenter.name}|#{datacenter.hostFolder.name})\//,'') end end class Mock def list_clusters(filters = { }) raw_clusters.map do |cluster| cluster end end def raw_clusters folder = self.data[:clusters] @raw_clusters = get_raw_clusters_from_folder(folder) end def get_raw_clusters_from_folder(folder) folder.map do |child| if child[:klass] == "RbVmomi::VIM::ComputeResource" child elsif child[:klass] == "RbVmomi::VIM::Folder" get_raw_clusters_from_folder(child[:clusters]) end end.flatten end end end end end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/benchmark/bm_vm2_super.rb
class C def m 1 end end class CC < C def m super() end end obj = CC.new i = 0 while i<6_000_000 # benchmark loop 2 obj.m i+=1 end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/tk/lib/tk/image.rb
<gh_stars>0 # # tk/image.rb : treat Tk image objects # require 'tk' class TkImage<TkObject include Tk TkCommandNames = ['image'.freeze].freeze Tk_IMGTBL = TkCore::INTERP.create_table (Tk_Image_ID = ['i'.freeze, TkUtil.untrust('00000')]).instance_eval{ @mutex = Mutex.new def mutex; @mutex; end freeze } TkCore::INTERP.init_ip_env{ Tk_IMGTBL.mutex.synchronize{ Tk_IMGTBL.clear } } def self.new(keys=nil) if keys.kind_of?(Hash) name = nil if keys.key?(:imagename) name = keys[:imagename] elsif keys.key?('imagename') name = keys['imagename'] end if name if name.kind_of?(TkImage) obj = name else name = _get_eval_string(name) obj = nil Tk_IMGTBL.mutex.synchronize{ obj = Tk_IMGTBL[name] } end if obj if !(keys[:without_creating] || keys['without_creating']) keys = _symbolkey2str(keys) keys.delete('imagename') keys.delete('without_creating') obj.instance_eval{ tk_call_without_enc('image', 'create', @type, @path, *hash_kv(keys, true)) } end return obj end end end (obj = self.allocate).instance_eval{ Tk_IMGTBL.mutex.synchronize{ initialize(keys) Tk_IMGTBL[@path] = self } } obj end def initialize(keys=nil) @path = nil without_creating = false if keys.kind_of?(Hash) keys = _symbolkey2str(keys) @path = keys.delete('imagename') without_creating = keys.delete('without_creating') end unless @path Tk_Image_ID.mutex.synchronize{ @path = Tk_Image_ID.join(TkCore::INTERP._ip_id_) Tk_Image_ID[1].succ! } end unless without_creating tk_call_without_enc('image', 'create', @type, @path, *hash_kv(keys, true)) end end def delete Tk_IMGTBL.mutex.synchronize{ Tk_IMGTBL.delete(@id) if @id } tk_call_without_enc('image', 'delete', @path) self end def height number(tk_call_without_enc('image', 'height', @path)) end def inuse bool(tk_call_without_enc('image', 'inuse', @path)) end def itemtype tk_call_without_enc('image', 'type', @path) end def width number(tk_call_without_enc('image', 'width', @path)) end def TkImage.names Tk_IMGTBL.mutex.synchronize{ Tk.tk_call_without_enc('image', 'names').split.collect!{|id| (Tk_IMGTBL[id])? Tk_IMGTBL[id] : id } } end def TkImage.types Tk.tk_call_without_enc('image', 'types').split end end class TkBitmapImage<TkImage def __strval_optkeys super() + ['maskdata', 'maskfile'] end private :__strval_optkeys def initialize(*args) @type = 'bitmap' super(*args) end end # A photo is an image whose pixels can display any color or be transparent. # At present, only GIF and PPM/PGM formats are supported, but an interface # exists to allow additional image file formats to be added easily. # # This class documentation is a copy from the original Tcl/Tk at # http://www.tcl.tk/man/tcl8.5/TkCmd/photo.htm with some rewrited parts. class TkPhotoImage<TkImage NullArgOptionKeys = [ "shrink", "grayscale" ] def _photo_hash_kv(keys) keys = _symbolkey2str(keys) NullArgOptionKeys.collect{|opt| if keys[opt] keys[opt] = None else keys.delete(opt) end } keys.collect{|k,v| ['-' << k, v] }.flatten end private :_photo_hash_kv # Create a new image with the given options. # == Examples of use : # === Create an empty image of 300x200 pixels # # image = TkPhotoImage.new(:height => 200, :width => 300) # # === Create an image from a file # # image = TkPhotoImage.new(:file: => 'my_image.gif') # # == Options # Photos support the following options: # * :data # Specifies the contents of the image as a string. # * :format # Specifies the name of the file format for the data. # * :file # Gives the name of a file that is to be read to supply data for the image. # * :gamma # Specifies that the colors allocated for displaying this image in a window # should be corrected for a non-linear display with the specified gamma # exponent value. # * height # Specifies the height of the image, in pixels. This option is useful # primarily in situations where the user wishes to build up the contents of # the image piece by piece. A value of zero (the default) allows the image # to expand or shrink vertically to fit the data stored in it. # * palette # Specifies the resolution of the color cube to be allocated for displaying # this image. # * width # Specifies the width of the image, in pixels. This option is useful # primarily in situations where the user wishes to build up the contents of # the image piece by piece. A value of zero (the default) allows the image # to expand or shrink horizontally to fit the data stored in it. def initialize(*args) @type = 'photo' super(*args) end # Blank the image; that is, set the entire image to have no data, so it will # be displayed as transparent, and the background of whatever window it is # displayed in will show through. def blank tk_send_without_enc('blank') self end def cget_strict(option) case option.to_s when 'data', 'file' tk_send 'cget', '-' << option.to_s else tk_tcl2ruby(tk_send('cget', '-' << option.to_s)) end end # Returns the current value of the configuration option given by option. # Example, display name of the file from which <tt>image</tt> was created: # puts image.cget :file def cget(option) unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__ cget_strict(option) else begin cget_strict(option) rescue => e if current_configinfo.has_key?(option.to_s) # error on known option fail e else # unknown option nil end end end end # Copies a region from the image called source to the image called # destination, possibly with pixel zooming and/or subsampling. If no options # are specified, this method copies the whole of source into destination, # starting at coordinates (0,0) in destination. The following options may be # specified: # # * :from [x1, y1, x2, y2] # Specifies a rectangular sub-region of the source image to be copied. # (x1,y1) and (x2,y2) specify diagonally opposite corners of the rectangle. # If x2 and y2 are not specified, the default value is the bottom-right # corner of the source image. The pixels copied will include the left and # top edges of the specified rectangle but not the bottom or right edges. # If the :from option is not given, the default is the whole source image. # * :to [x1, y1, x2, y2] # Specifies a rectangular sub-region of the destination image to be # affected. (x1,y1) and (x2,y2) specify diagonally opposite corners of the # rectangle. If x2 and y2 are not specified, the default value is (x1,y1) # plus the size of the source region (after subsampling and zooming, if # specified). If x2 and y2 are specified, the source region will be # replicated if necessary to fill the destination region in a tiled fashion. # * :shrink # Specifies that the size of the destination image should be reduced, if # necessary, so that the region being copied into is at the bottom-right # corner of the image. This option will not affect the width or height of # the image if the user has specified a non-zero value for the :width or # :height configuration option, respectively. # * :zoom [x, y] # Specifies that the source region should be magnified by a factor of x # in the X direction and y in the Y direction. If y is not given, the # default value is the same as x. With this option, each pixel in the # source image will be expanded into a block of x x y pixels in the # destination image, all the same color. x and y must be greater than 0. # * :subsample [x, y] # Specifies that the source image should be reduced in size by using only # every xth pixel in the X direction and yth pixel in the Y direction. # Negative values will cause the image to be flipped about the Y or X axes, # respectively. If y is not given, the default value is the same as x. # * :compositingrule rule # Specifies how transparent pixels in the source image are combined with # the destination image. When a compositing rule of <tt>overlay</tt> is set, # the old contents of the destination image are visible, as if the source # image were printed on a piece of transparent film and placed over the # top of the destination. When a compositing rule of <tt>set</tt> is set, # the old contents of the destination image are discarded and the source # image is used as-is. The default compositing rule is <tt>overlay</tt>. def copy(src, *opts) if opts.size == 0 tk_send('copy', src) elsif opts.size == 1 && opts[0].kind_of?(Hash) tk_send('copy', src, *_photo_hash_kv(opts[0])) else # for backward compatibility args = opts.collect{|term| if term.kind_of?(String) && term.include?(?\s) term.split else term end }.flatten tk_send('copy', src, *args) end self end # Returns image data in the form of a string. The following options may be # specified: # * :background color # If the color is specified, the data will not contain any transparency # information. In all transparent pixels the color will be replaced by the # specified color. # * :format format-name # Specifies the name of the image file format handler to be used. # Specifically, this subcommand searches for the first handler whose name # matches an initial substring of format-name and which has the capability # to read this image data. If this option is not given, this subcommand # uses the first handler that has the capability to read the image data. # * :from [x1, y1, x2, y2] # Specifies a rectangular region of imageName to be returned. If only x1 # and y1 are specified, the region extends from (x1,y1) to the bottom-right # corner of imageName. If all four coordinates are given, they specify # diagonally opposite corners of the rectangular region, including x1,y1 # and excluding x2,y2. The default, if this option is not given, is the # whole image. # * :grayscale # If this options is specified, the data will not contain color information. # All pixel data will be transformed into grayscale. def data(keys={}) tk_split_list(tk_send('data', *_photo_hash_kv(keys))) end # Returns the color of the pixel at coordinates (x,y) in the image as a list # of three integers between 0 and 255, representing the red, green and blue # components respectively. def get(x, y) tk_send('get', x, y).split.collect{|n| n.to_i} end def put(data, *opts) if opts.empty? tk_send('put', data) elsif opts.size == 1 && opts[0].kind_of?(Hash) tk_send('put', data, *_photo_hash_kv(opts[0])) else # for backward compatibility tk_send('put', data, '-to', *opts) end self end def read(file, *opts) if opts.size == 0 tk_send('read', file) elsif opts.size == 1 && opts[0].kind_of?(Hash) tk_send('read', file, *_photo_hash_kv(opts[0])) else # for backward compatibility args = opts.collect{|term| if term.kind_of?(String) && term.include?(?\s) term.split else term end }.flatten tk_send('read', file, *args) end self end def redither tk_send 'redither' self end # Returns a boolean indicating if the pixel at (x,y) is transparent. def get_transparency(x, y) bool(tk_send('transparency', 'get', x, y)) end # Makes the pixel at (x,y) transparent if <tt>state</tt> is true, and makes # that pixel opaque otherwise. def set_transparency(x, y, state) tk_send('transparency', 'set', x, y, state) self end def write(file, *opts) if opts.size == 0 tk_send('write', file) elsif opts.size == 1 && opts[0].kind_of?(Hash) tk_send('write', file, *_photo_hash_kv(opts[0])) else # for backward compatibility args = opts.collect{|term| if term.kind_of?(String) && term.include?(?\s) term.split else term end }.flatten tk_send('write', file, *args) end self end end
arnab0073/idea
.rvm/src/ruby-2.3.0/lib/rdoc/markup/include.rb
<gh_stars>10-100 # frozen_string_literal: false ## # A file included at generation time. Objects of this class are created by # RDoc::RD for an extension-less include. # # This implementation in incomplete. class RDoc::Markup::Include ## # The filename to be included, without extension attr_reader :file ## # Directories to search for #file attr_reader :include_path ## # Creates a new include that will import +file+ from +include_path+ def initialize file, include_path @file = file @include_path = include_path end def == other # :nodoc: self.class === other and @file == other.file and @include_path == other.include_path end def pretty_print q # :nodoc: q.group 2, '[incl ', ']' do q.text file q.breakable q.text 'from ' q.pp include_path end end end
arnab0073/idea
.rvm/src/ruby-2.3.0/test/lib/profile_test_all.rb
<gh_stars>10-100 # frozen_string_literal: false # # purpose: # Profile memory usage of each tests. # # usage: # RUBY_TEST_ALL_PROFILE=[file] make test-all # # output: # [file] specified by RUBY_TEST_ALL_PROFILE # If [file] is 'true', then it is ./test_all_profile # # collected information: # - ObjectSpace.memsize_of_all # - GC.stat # - /proc/meminfo (some fields, if exists) # - /proc/self/status (some fields, if exists) # - /proc/self/statm (if exists) # require 'objspace' class MiniTest::Unit::TestCase alias orig_run run file = ENV['RUBY_TEST_ALL_PROFILE'] file = 'test-all-profile-result' if file == 'true' TEST_ALL_PROFILE_OUT = open(file, 'w') TEST_ALL_PROFILE_GC_STAT_HASH = {} TEST_ALL_PROFILE_BANNER = ['name'] TEST_ALL_PROFILE_PROCS = [] def self.add *name, &b TEST_ALL_PROFILE_BANNER.concat name TEST_ALL_PROFILE_PROCS << b end add 'failed?' do |result, tc| result << (tc.passed? ? 0 : 1) end add 'memsize_of_all' do |result, *| result << ObjectSpace.memsize_of_all end add *GC.stat.keys do |result, *| GC.stat(TEST_ALL_PROFILE_GC_STAT_HASH) result.concat TEST_ALL_PROFILE_GC_STAT_HASH.values end def self.add_proc_meminfo file, fields return unless FileTest.exist?(file) regexp = /(#{fields.join("|")}):\s*(\d+) kB/ # check = {}; fields.each{|e| check[e] = true} add *fields do |result, *| text = File.read(file) text.scan(regexp){ # check.delete $1 result << $2 '' } # raise check.inspect unless check.empty? end end add_proc_meminfo '/proc/meminfo', %w(MemTotal MemFree) add_proc_meminfo '/proc/self/status', %w(VmPeak VmSize VmHWM VmRSS) if FileTest.exist?('/proc/self/statm') add *%w(size resident share text lib data dt) do |result, *| result.concat File.read('/proc/self/statm').split(/\s+/) end end def memprofile_test_all_result_result result = ["#{self.class}\##{self.__name__.to_s.gsub(/\s+/, '')}"] TEST_ALL_PROFILE_PROCS.each{|proc| proc.call(result, self) } result.join("\t") end def run runner result = orig_run(runner) TEST_ALL_PROFILE_OUT.puts memprofile_test_all_result_result TEST_ALL_PROFILE_OUT.flush result end TEST_ALL_PROFILE_OUT.puts TEST_ALL_PROFILE_BANNER.join("\t") end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/date/extconf.rb
<filename>.rvm/src/ruby-1.9.3-p551/ext/date/extconf.rb require 'mkmf' create_makefile('date_core')
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/logging-2.1.0/test/performance.rb
<reponame>arnab0073/idea # # The peformance script is used to output a performance analysis page for the # Logging framework. You can run this script simply: # # ruby test/performance.rb # # This will write a file called "performance.html" that you can open in your web # browser. You will need the `ruby-prof` gem installed in order to run this # script. # ------------------------------------------------------------------------------ require 'rubygems' libpath = File.expand_path('../../lib', __FILE__) $:.unshift libpath require 'logging' begin gem 'log4r' require 'log4r' $log4r = true rescue LoadError $log4r = false end require 'logger' require 'ruby-prof' module Logging class Performance # number of iterations attr_reader :this_many # performance output file name attr_reader :output_file def initialize @this_many = 300_000 @output_file = "performance.html" end def run pattern = Logging.layouts.pattern \ :pattern => '%.1l, [%d#%p] %5l -- %c: %m\n', :date_pattern => "%Y-%m-%dT%H:%M:%S.%s" Logging.appenders.string_io("sio", :layout => pattern) logger = ::Logging.logger["Performance"] logger.level = :warn logger.appenders = "sio" result = RubyProf.profile do this_many.times {logger.warn 'logged'} end printer = RubyProf::GraphHtmlPrinter.new(result) File.open(output_file, "w") { |fd| printer.print(fd) } end end end if __FILE__ == $0 perf = Logging::Performance.new perf.run end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/curses/extconf.rb
<reponame>arnab0073/idea require 'mkmf' dir_config('curses') dir_config('ncurses') dir_config('termcap') make=false headers = [] have_library("mytinfo", "tgetent") if /bow/ =~ RUBY_PLATFORM have_library("tinfo", "tgetent") or have_library("termcap", "tgetent") if have_header(*curses=%w"ncurses.h") and (have_library("ncursesw", "initscr") or have_library("ncurses", "initscr")) make=true elsif have_header(*curses=%w"ncurses/curses.h") and have_library("ncurses", "initscr") make=true elsif have_header(*curses=%w"curses_colr/curses.h") and have_library("cur_colr", "initscr") curses.unshift("varargs.h") make=true elsif have_header(*curses=%w"curses.h") and (have_library("curses", "initscr") || have_library("pdcurses", "initscr")) make=true end if make for f in %w(beep bkgd bkgdset curs_set deleteln doupdate flash getbkgd getnstr init isendwin keyname keypad resizeterm scrl set setscrreg ungetch wattroff wattron wattrset wbkgd wbkgdset wdeleteln wgetnstr wresize wscrl wsetscrreg def_prog_mode reset_prog_mode timeout wtimeout nodelay init_color wcolor_set use_default_colors) have_func(f) || (have_macro(f, curses) && $defs.push(format("-DHAVE_%s", f.upcase))) end flag = "-D_XOPEN_SOURCE_EXTENDED" if try_static_assert("sizeof(char*)>sizeof(int)", %w[stdio.h stdlib.h]+curses , flag) $defs << flag end have_var("ESCDELAY", curses) have_var("TABSIZE", curses) have_var("COLORS", curses) have_var("COLOR_PAIRS", curses) create_makefile("curses") end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/puma-1.6.3/examples/config.rb
state_path "puma.state" activate_control_app rackup "test/lobster.ru" threads 3, 10
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/mixlib-shellout-2.2.6/mixlib-shellout-windows.gemspec
gemspec = eval(File.read(File.expand_path("../mixlib-shellout.gemspec", __FILE__))) gemspec.platform = Gem::Platform.new(["universal", "mingw32"]) gemspec.add_dependency "win32-process", "~> 0.8.2" gemspec.add_dependency "wmi-lite", "~> 1.0" gemspec
arnab0073/idea
.rvm/src/ruby-2.3.0/test/-ext-/path_to_class/test_path_to_class.rb
# frozen_string_literal: false require 'test/unit' class Test_PathToClass < Test::Unit::TestCase require '-test-/path_to_class/path_to_class' def test_path_to_class bug5691 = '[ruby-core:41410]' assert_raise(ArgumentError, bug5691) { Test_PathToClass.path_to_class("Test_PathToClass::Object") } end end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/systemu-2.6.5/test/testing.rb
<filename>.rvm/gems/ruby-2.3.0/gems/systemu-2.6.5/test/testing.rb require 'test/unit' testdir = File.expand_path(File.dirname(__FILE__)) rootdir = File.dirname(testdir) libdir = File.join(rootdir, 'lib') STDOUT.sync = true $:.unshift(testdir) unless $:.include?(testdir) $:.unshift(libdir) unless $:.include?(libdir) $:.unshift(rootdir) unless $:.include?(rootdir) class Testing class Slug < ::String def Slug.for(*args) string = args.flatten.compact.join('-') words = string.to_s.scan(%r/\w+/) words.map!{|word| word.gsub %r/[^0-9a-zA-Z_-]/, ''} words.delete_if{|word| word.nil? or word.strip.empty?} new(words.join('-').downcase) end end class Context attr_accessor :name def initialize(name, *args) @name = name end def to_s Slug.for(name) end end end def Testing(*args, &block) Class.new(::Test::Unit::TestCase) do ## class methods # class << self def contexts @contexts ||= [] end def context(*args, &block) return contexts.last if(args.empty? and block.nil?) context = Testing::Context.new(*args) contexts.push(context) begin block.call(context) ensure contexts.pop end end def slug_for(*args) string = [context, args].flatten.compact.join('-') words = string.to_s.scan(%r/\w+/) words.map!{|word| word.gsub %r/[^0-9a-zA-Z_-]/, ''} words.delete_if{|word| word.nil? or word.strip.empty?} words.join('-').downcase.sub(/_$/, '') end def name() const_get(:Name) end def testno() '%05d' % (@testno ||= 0) ensure @testno += 1 end def testing(*args, &block) method = ["test", testno, slug_for(*args)].delete_if{|part| part.empty?}.join('_') define_method(method, &block) end def test(*args, &block) testing(*args, &block) end def setup(&block) define_method(:setup, &block) if block end def teardown(&block) define_method(:teardown, &block) if block end def prepare(&block) @prepare ||= [] @prepare.push(block) if block @prepare end def cleanup(&block) @cleanup ||= [] @cleanup.push(block) if block @cleanup end end ## configure the subclass! # const_set(:Testno, '0') slug = slug_for(*args).gsub(%r/-/,'_') name = ['TESTING', '%03d' % const_get(:Testno), slug].delete_if{|part| part.empty?}.join('_') name = name.upcase! const_set(:Name, name) const_set(:Missing, Object.new.freeze) ## instance methods # alias_method('__assert__', 'assert') def assert(*args, &block) if args.size == 1 and args.first.is_a?(Hash) options = args.first expected = getopt(:expected, options){ missing } actual = getopt(:actual, options){ missing } if expected == missing and actual == missing actual, expected, *ignored = options.to_a.flatten end expected = expected.call() if expected.respond_to?(:call) actual = actual.call() if actual.respond_to?(:call) assert_equal(expected, actual) end if block label = "assert(#{ args.join(' ') })" result = nil assert_nothing_raised{ result = block.call } __assert__(result, label) result else result = args.shift label = "assert(#{ args.join(' ') })" __assert__(result, label) result end end def missing self.class.const_get(:Missing) end def getopt(opt, hash, options = nil, &block) [opt.to_s, opt.to_s.to_sym].each do |key| return hash[key] if hash.has_key?(key) end default = if block block.call else options.is_a?(Hash) ? options[:default] : nil end return default end def subclass_of exception class << exception def ==(other) super or self > other end end exception end ## # module_eval(&block) self.setup() self.prepare.each{|b| b.call()} at_exit{ self.teardown() self.cleanup.each{|b| b.call()} } self end end if $0 == __FILE__ Testing 'Testing' do testing('foo'){ assert true } test{ assert true } p instance_methods.grep(/test/) end end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/tk/lib/tkextlib/winico/winico.rb
<gh_stars>1-10 # # tkextlib/winico/winico.rb # by <NAME> (<EMAIL>) # require 'tk' # call setup script for general 'tkextlib' libraries require 'tkextlib/setup.rb' # call setup script require 'tkextlib/winico/setup.rb' # TkPackage.require('winico', '0.5') # TkPackage.require('winico', '0.6') TkPackage.require('winico') module Tk class Winico < TkObject PACKAGE_NAME = 'winico'.freeze def self.package_name PACKAGE_NAME end def self.package_version begin TkPackage.require('winico') rescue '' end end end end class Tk::Winico WinicoID_TBL = TkCore::INTERP.create_table TkCore::INTERP.init_ip_env{ WinicoID_TBL.mutex.synchronize{ WinicoID_TBL.clear } } def self.id2obj(id) WinicoID_TBL.mutex.synchronize{ (WinicoID_TBL.key?(id))? WinicoID_TBL[id] : id } end def self.info simplelist(Tk.tk_call('winico', 'info')).collect{|id| Tk::Winico.id2obj(id) } end def self.icon_info(id) simplelist(Tk.tk_call('winico', 'info', id)).collect{|inf| h = Hash[*list(inf)] h.keys.each{|k| h[k[1..-1]] = h.delete(k)} } end ################################# def self.new_from_file(file_name) self.new(file_name) end def self.new_from_resource(resource_name, file_name = nil) self.new(file_name, resource_name) end def initialize(file_name, resource_name=nil, winico_id=nil) if resource_name # from resource if file_name @id = Tk.tk_call('winico', 'load', resource_name, file_name) else @id = Tk.tk_call('winico', 'load', resource_name) end elsif file_name # from .ico file @id = Tk.tk_call('winico', 'createfrom', file_name) elsif winico_id @id = winico_id else fail ArgumentError, "must be given proper information from where loading icons" end @path = @id WinicoID_TBL.mutex.synchronize{ WinicoID_TBL[@id] = self } end def id @id end def set_window(win_id, *opts) # opts := ?'big'|'small'?, ?pos? # NOTE:: the window, which is denoted by win_id, MUST BE MAPPED. # If not, then this may fail or crash. tk_call('winico', 'setwindow', win_id, @id, *opts) end def delete tk_call('winico', 'delete', @id) WinicoID_TBL.mutex.synchronize{ WinicoID_TBL.delete(@id) } self end alias destroy delete def info Tk::Winico.icon_info(@id) end ################################# class Winico_callback < TkValidateCommand class ValidateArgs < TkUtil::CallbackSubst KEY_TBL = [ [ ?m, ?s, :message ], [ ?i, ?x, :icon ], [ ?x, ?n, :x ], [ ?y, ?n, :y ], [ ?X, ?n, :last_x ], [ ?Y, ?n, :last_y ], [ ?t, ?n, :tickcount ], [ ?w, ?n, :icon_idnum ], [ ?l, ?n, :msg_idnum ], nil ] PROC_TBL = [ [ ?n, TkComm.method(:number) ], [ ?s, TkComm.method(:string) ], [ ?x, proc{|id| Tk::Winico::WinicoID_TBL.mutex.synchronize{ if Tk::Winico::WinicoID_TBL.key?(id) obj = Tk::Winico::WinicoID_TBL[id] else # Tk::Winico.new(nil, nil, id) obj = Tk::Winico.allocate obj.instance_eval{ @path = @id = id } Tk::Winico::WinicoID_TBL[id] = obj end obj } } ], nil ] =begin # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) ) KEY_TBL.map!{|inf| if inf.kind_of?(Array) inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String) inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String) end inf } PROC_TBL.map!{|inf| if inf.kind_of?(Array) inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String) end inf } =end _setup_subst_table(KEY_TBL, PROC_TBL); def self.ret_val(val) val end end def self._config_keys ['callback'] end end ################################# def add_to_taskbar(keys = {}) keys = _symbolkey2str(keys) Winico_callback._config_keys.each{|k| if keys[k].kind_of?(Array) cmd, *args = keys[k] #keys[k] = Winico_callback.new(cmd, args.join(' ')) keys[k] = Winico_callback.new(cmd, *args) # elsif keys[k].kind_of?(Proc) elsif TkComm._callback_entry?(keys[k]) keys[k] = Winico_callback.new(keys[k]) end } tk_call('winico', 'taskbar', 'add', @id, *(hash_kv(keys))) self end alias taskbar_add add_to_taskbar def modify_taskbar(keys = {}) keys = _symbolkey2str(keys) Winico_callback._config_keys.each{|k| if keys[k].kind_of?(Array) cmd, *args = keys[k] #keys[k] = Winico_callback.new(cmd, args.join(' ')) keys[k] = Winico_callback.new(cmd, *args) # elsif keys[k].kind_of?(Proc) elsif TkComm._callback_entry?(keys[k]) keys[k] = Winico_callback.new(keys[k]) end } tk_call('winico', 'taskbar', 'modify', @id, *(hash_kv(keys))) self end alias taskbar_modify modify_taskbar def delete_from_taskbar tk_call('winico', 'taskbar', 'delete', @id) self end alias taskbar_delete delete_from_taskbar end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/io/console/io-console.gemspec
<filename>.rvm/src/ruby-1.9.3-p551/ext/io/console/io-console.gemspec # -*- ruby -*- _VERSION = "0.3" Gem::Specification.new do |s| s.name = "io-console" s.version = _VERSION s.date = "2011-06-24" s.summary = "Console interface" s.email = "<EMAIL>" s.description = "add console capabilities to IO instances." s.authors = ["<NAME>"] s.require_path = %[.] s.files = %w[console.c extconf.rb lib/console/size.rb] s.extensions = %w[extconf.rb] end
arnab0073/idea
.rvm/src/ruby-2.3.0/ext/tk/sample/tkextlib/treectrl/help.rb
# frozen_string_literal: false # # Demo: Help contents # def demoHelpContents(t) height = t.font.metrics(:linespace) height = 18 if height < 18 t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false, :itemheight=>height, :selectmode=>:browse) init_pics('help-*') if $Version_1_1_OrLater t.column_create(:text=>'Help Contents') else # TreeCtrl 1.0 t.column_configure(0, :text=>'Help Contents') end # Define a new item state t.state_define('mouseover') t.element_create('e1', :image, :image=>@images['help-page']) t.element_create('e2', :image, :image=>[ @images['help-book-open'], ['open'], @images['help-book-closed'], [], ]) t.element_create('e3', :text, :font=>[t.font.dup.underline(true), ['mouseover']], :fill=>[ @SystemHighlightText, ['selected', 'focus'], 'blue', ['mouseover'] ]) t.element_create('e4', :rect, :showfocus=>true, :fill=>[@SystemHighlight, ['selected', 'focus']]) # book s = t.style_create('s1') t.style_elements(s, ['e4', 'e1', 'e3']) t.style_layout(s, 'e1', :padx=>[0,4], :expand=>:ns) t.style_layout(s, 'e3', :expand=>:ns) t.style_layout(s, 'e4', :union=>['e3'], :iexpand=>:ns, :ipadx=>2) # page s = t.style_create('s2') t.style_elements(s, ['e4', 'e2', 'e3']) t.style_layout(s, 'e2', :padx=>[0,4], :expand=>:ns) t.style_layout(s, 'e3', :expand=>:ns) t.style_layout(s, 'e4', :union=>['e3'], :iexpand=>:ns, :ipadx=>2) parentList = [:root, '', '', '', '', '', ''] parent = :root [ [0, 's1', "Welcome to Help"], [0, 's2', "Introducing Windows 98"], [1, 's2', "How to Use Help"], [2, 's1', "Find a topic"], [2, 's1', "Get more out of help"], [1, 's2', "Register Your Software"], [2, 's1', "Registering Windows 98 online"], [1, 's2', "What's New in Windows 98"], [2, 's1', "Innovative, easy-to-use features"], [2, 's1', "Improved reliability"], [2, 's1', "A faster operating system"], [2, 's1', "True Web integration"], [2, 's1', "More entertaining and fun"], [1, 's2', "If You're New to Windows 98"], [2, 's2', "Tips for Macintosh Users"], [3, 's1', "Why does the mouse have two buttons?"] ].each{|depth, style, text| item = t.item_create t.item_style_set(item, 0, style) t.item_element_configure(item, 0, 'e3', :text=>text) if $Version_1_1_OrLater t.item_collapse(item) else # TreeCtrl 1.0 t.collapse(item) end t.item_lastchild(parentList[depth], item) depth += 1 parentList[depth] = item } treeCtrlHelp = TkBindTag.new treeCtrlHelp.bind('Double-ButtonPress-1', proc{|w, x, y| if w.identify(x, y)[0] == 'header' Tk::TreeCtrl::BindCallback.doubleButton1(w, x, y) else helpButton1(w, x, y) end Tk.callback_break }, '%W %x %y') treeCtrlHelp.bind('ButtonPress-1', proc{|w, x, y| helpButton1(w, x, y) Tk.callback_break }, '%W %x %y') treeCtrlHelp.bind('Button1-Motion', proc{|w, x, y| helpMotion1(w, x, y) Tk.callback_break }, '%W %x %y') treeCtrlHelp.bind('Button1-Leave', proc{|w, x, y| helpLeave1(w, x, y) Tk.callback_break }, '%W %x %y') treeCtrlHelp.bind('ButtonRelease-1', proc{|w, x, y| helpRelease1(w, x, y) Tk.callback_break }, '%W %x %y') treeCtrlHelp.bind('Motion', proc{|w, x, y| helpMotion(w, x, y) }, '%W %x %y') treeCtrlHelp.bind('Leave', proc{|w, x, y| helpMotion(w, x, y) }, '%W %x %y') treeCtrlHelp.bind('KeyPress-Return', proc{|w, x, y| if w.selection_get.length == 1 if $Version_1_1_OrLater w.item_toggle(w.selection_get[0]) else # TreeCtrl 1.0 w.toggle(w.selection_get[0]) end end Tk.callback_break }, '%W %x %y') @Priv[:help, :prev] = '' t.bindtags = [ t, treeCtrlHelp, Tk::TreeCtrl, t.winfo_toplevel, :all ] end # This is an alternate implementation that does not define a new item state # to change the appearance of the item under the cursor. def demoHelpContents2(t) height = t.font.metrics(:linespace) height = 18 if height < 18 t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false, :itemheight=>height, :selectmode=>:browse) init_pics('help-*') if $Version_1_1_OrLater t.column_create(:text=>'Help Contents') else # TreeCtrl 1.0 t.column_configure(0, :text=>'Help Contents') end t.element_create('e1', :image, :image=>@images['help-page']) t.element_create('e2', :image, :image=>[ @images['help-book-open'], ['open'], @images['help-book-closed'], [], ]) t.element_create('e3', :text, :fill=>[ @SystemHighlightText, ['selected', 'focus'], 'blue', [] ]) t.element_create('e4', :rect, :showfocus=>true, :fill=>[@SystemHighligh, ['selected', 'focus']]) t.element_create('e5', :text, :font=>t.font.dup.underline(true), :fill=>[ @SystemHighlightText, ['selected', 'focus'], 'blue', [] ]) # book s = t.style_create('s1') t.style_elements(s, ['e4', 'e1', 'e3']) t.style_layout(s, 'e1', :padx=>[0,4], :expand=>:ns) t.style_layout(s, 'e3', :expand=>:ns) t.style_layout(s, 'e4', :union=>['e3'], :iexpand=>:ns, :ipadx=>2) # page s = t.style_create('s2') t.style_elements(s, ['e4', 'e2', 'e3']) t.style_layout(s, 'e2', :padx=>[0,4], :expand=>:ns) t.style_layout(s, 'e3', :expand=>:ns) t.style_layout(s, 'e4', :union=>['e3'], :iexpand=>:ns, :ipadx=>2) # book (focus) s = t.style_create('s1.f') t.style_elements(s, ['e4', 'e1', 'e5']) t.style_layout(s, 'e1', :padx=>[0,4], :expand=>:ns) t.style_layout(s, 'e5', :expand=>:ns) t.style_layout(s, 'e4', :union=>['e5'], :iexpand=>:ns, :ipadx=>2) # page (focus) s = t.style_create('s2') t.style_elements(s, ['e4', 'e2', 'e5']) t.style_layout(s, 'e2', :padx=>[0,4], :expand=>:ns) t.style_layout(s, 'e5', :expand=>:ns) t.style_layout(s, 'e4', :union=>['e5'], :iexpand=>:ns, :ipadx=>2) parentList = [:root, '', '', '', '', '', ''] parent = :root [ [0, 's1', "Welcome to Help"], [0, 's2', "Introducing Windows 98"], [1, 's2', "How to Use Help"], [2, 's1' "Find a topic"], [2, 's1', "Get more out of help"], [1, 's2', "Register Your Software"], [2, 's1', "Registering Windows 98 online"], [1, 's2', "What's New in Windows 98"], [2, 's1', "Innovative, easy-to-use features"], [2, 's1', "Improved reliability"], [2, 's1', "A faster operating system"], [2, 's1', "True Web integration"], [2, 's1', "More entertaining and fun"], [1, 's2', "If You're New to Windows 98"], [2, 's2', "Tips for Macintosh Users"], [3, 's1', "Why does the mouse have two buttons?"] ].each{|depth, style, text| item = t.item_create t.item_style_set(item, 0, style) t.item_element_configure(item, 0, 'e3', :text=>text) if $Version_1_1_OrLater t.item_collapse(item) else # TreeCtrl 1.0 t.collapse(item) end t.item_lastchild(parentList[depth], item) depth += 1 parentList[depth] = item } treeCtrlHelp = TkBindTag.new treeCtrlHelp.bind('Double-ButtonPress-1', proc{|w, x, y| if w.identify(x, y)[0] == 'header' Tk::TreeCtrl::BindCallback.doubleButton1(w, x, y) else helpButton1(w, x, y) end Tk.callback_break }, '%W %x %y') treeCtrlHelp.bind('ButtonPress-1', proc{|w, x, y| helpButton1(w, x, y) Tk.callback_break }, '%W %x %y') treeCtrlHelp.bind('Button1-Motion', proc{|w, x, y| helpMotion1(w, x, y) Tk.callback_break }, '%W %x %y') treeCtrlHelp.bind('Button1-Leave', proc{|w, x, y| helpLeave1(w, x, y) Tk.callback_break }, '%W %x %y') treeCtrlHelp.bind('ButtonRelease-1', proc{|w, x, y| helpRelease1(w, x, y) Tk.callback_break }, '%W %x %y') treeCtrlHelp.bind('Motion', proc{|w, x, y| helpMotion(w, x, y) }, '%W %x %y') treeCtrlHelp.bind('Leave', proc{|w, x, y| helpMotion(w, x, y) }, '%W %x %y') treeCtrlHelp.bind('KeyPress-Return', proc{|w, x, y| if w.selection_get.length == 1 w.item_toggle(w.selection_get[0]) end Tk.callback_break }, '%W %x %y') @Priv[:help, :prev] = '' t.bindtags = [ t, treeCtrlHelp, Tk::TreeCtrl, t.winfo_toplevel, :all ] end def helpButton1(w, x, y) w.set_focus id = w.identify(x, y) @Priv['buttonMode'] = '' if id[0] == 'header' Tk::TreeCtrl::BindCallback.buttonPress1(w, x, y) elsif id[0] == 'item' item = id[1] # didn't click an element return if id.length != 6 if w.selection_includes(item) w.toggle(item) return end if w.selection_get.length > 0 item2 = w.selection_get[0] if $Version_1_1_OrLater w.item_collapse(item2) else # TreeCtrl 1.0 w.collapse(item2) end w.item_ancestors(item2).each{|i| if $Version_1_1_OrLater w.item_collapse(i) if w.compare(item, '!=', i) else # TreeCtrl 1.0 w.collapse(i) if w.compare(item, '!=', i) end } end w.activate(item) if $Version_1_1_OrLater w.item_ancestors(item).each{|i| w.item_expand(i) } w.item_toggle(item) else # TreeCtrl 1.0 w.expand(*(w.item_ancestors(item))) w.toggle(item) end w.selection_modify(item, :all) end end def helpMotion1(w, x, y) case @Priv['buttonMode'] when 'resize', 'header' Tk::TreeCtrl::BindCallback.motion1(w, x, y) end end def helpLeave1(w, x, y) # This is called when I do ButtonPress-1 on Unix for some reason, # and buttonMode is undefined. return unless @Priv.exist?('buttonMode') case @Priv['buttonMode'] when 'header' w.column_configure(@Priv['column'], :sunken=>false) end end def helpRelease1(w, x, y) case @Priv['buttonMode'] when 'resize', 'header' Tk::TreeCtrl::BindCallback.release1(w, x, y) end @Priv['buttonMode'] = '' end def helpMotion(w, x, y) id = w.identify(x, y) if id.empty? elsif id[0] == 'header' elsif id[0] == 'item' item = id[1] if id.length == 6 if @Priv[:help, :prev] != TkComm._get_eval_string(item) if @Priv[:help, :prev] != '' w.item_state_set(@Priv[:help, :prev], '!mouseover') end w.item_state_set(item, 'mouseover') @Priv[:help, :prev] = item end return end end if @Priv[:help, :prev] != '' w.item_state_set(@Priv[:help, :prev], '!mouseover') @Priv[:help, :prev] = '' end end # Alternate implementation doesn't rely on mouseover state def helpMotion2(w, x, y) id = w.identify(x, y) if id[0] == 'header' elsif !id.empty? item = id[1] if id.kength == 6 if @Priv[:help, :prev] != TkComm._get_eval_string(item) if @Priv[:help, :prev] != '' style = w.item_style_set(@Priv[:help, :prev], 0) style.sub!(/\.f$/, '') w.item_style_map(@Priv[:help, :prev], 0, style, ['e5', 'e3']) end style = w.item_style_set(item, 0) w.item_style_map(item, 0, style + '.f', ['e3', 'e5']) @Priv[:help, :prev] = item end return end end if @Priv[:help, :prev] != '' style = w.item_style_set(@Priv[:help, :prev], 0) style.sub!(/\.f$/, '') w.item_style_map(@Priv[:help, :prev], 0, style, ['e5', 'e3']) @Priv[:help, :prev] = '' end end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/tk/sample/tkbiff.rb
#!/usr/bin/env ruby if ARGV[0] != '-d' unless $DEBUG exit if fork end else ARGV.shift end if ARGV.length == 0 if ENV['MAIL'] $spool = ENV['MAIL'] else $spool = '/var/spool/mail/' + ENV['USER'] end else $spool = ARGV[0] end require "parsedate" require "base64" include ParseDate class Mail def Mail.new(f) if !f.kind_of?(IO) f = open(f, "r") me = super f.close else me = super end return me end def initialize(f) @header = {} @body = [] while line = f.gets() line.chop! next if /^From / =~ line # skip From-line break if /^$/ =~ line # end of header if /^(\S+):\s*(.*)/ =~ line @header[attr = $1.capitalize] = $2 elsif attr sub(/^\s*/, '') @header[attr] += "\n" + $_ end end return unless $_ while line = f.gets() break if /^From / =~ line @body.push($_) end end def header return @header end def body return @body end end require "tkscrollbox" my_appname = Tk.appname('tkbiff') $top = TkRoot.new if ((TkWinfo.interps($top) - [my_appname]).find{|ip| ip =~ /^tkbiff/}) STDERR.print("Probably other 'tkbiff's are running. Bye.\n") exit end $top.withdraw $list = TkScrollbox.new($top) { relief 'raised' width 80 height 8 setgrid 'yes' pack } TkButton.new($top) { text 'Dismiss' command proc {$top.withdraw} pack('fill'=>'both','expand'=>'yes') } $top.bind "Control-c", proc{exit} $top.bind "Control-q", proc{exit} $top.bind "space", proc{exit} $spool_size = 0 $check_time = Time.now def check $check_time = Time.now size = File.size($spool) if size and size != $spool_size $spool_size = size pop_up if size > 0 end Tk.after 5000, proc{check} end if defined? Thread Thread.start do loop do sleep 600 if Time.now - $check_time > 200 Tk.after 5000, proc{check} end end end end def pop_up outcount = 0; $list.delete 0, 'end' f = open($spool, "r") while !f.eof? mail = Mail.new(f) date, from, subj = mail.header['Date'], mail.header['From'], mail.header['Subject'] next if !date y = m = d = 0 y, m, d = parsedate(date) if date from = "<EMAIL>" if ! from subj = "(nil)" if ! subj from = decode_b(from) subj = decode_b(subj) $list.insert 'end', format('%-02d/%02d/%02d [%-28.28s] %s',y,m,d,from,subj) outcount += 1 end f.close if outcount == 0 $list.insert 'end', "You have no mail." else $list.see 'end' end $top.deiconify Tk.after 2000, proc{$top.iconify} end $list.insert 'end', "You have no mail." check Tk.after 2000, proc{$top.iconify} begin Tk.mainloop rescue `echo #$! > /tmp/tkbiff` end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/tk/lib/tk/txtwin_abst.rb
<gh_stars>10-100 # # tk/txtwin_abst.rb : TkTextWin abstruct class # require 'tk' class TkTextWin<TkWindow TkCommandNames = [].freeze #def create_self # fail RuntimeError, "TkTextWin is an abstract class" #end #private :create_self def bbox(index) list(tk_send_without_enc('bbox', index)) end def delete(first, last=None) tk_send_without_enc('delete', first, last) self end def get(*index) _fromUTF8(tk_send_without_enc('get', *index)) end def insert(index, *args) tk_send('insert', index, *args) self end def scan_mark(x, y) tk_send_without_enc('scan', 'mark', x, y) self end def scan_dragto(x, y) tk_send_without_enc('scan', 'dragto', x, y) self end def see(index) tk_send_without_enc('see', index) self end end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/fog-aws-0.9.2/lib/fog/aws/models/rds/cluster.rb
<reponame>arnab0073/idea module Fog module AWS class RDS class Cluster < Fog::Model identity :id, :aliases => 'DBClusterIdentifier' attribute :allocated_storage, :aliases => 'AllocatedStorage', :type => :integer attribute :backup_retention_period, :aliases => 'BackupRetentionPeriod', :type => :integer attribute :db_cluster_members, :aliases => 'DBClusterMembers', :type => :array attribute :db_cluster_parameter_group, :aliases => 'DBClusterParameterGroup' attribute :db_subnet_group, :aliases => 'DBSubnetGroup' attribute :endpoint, :aliases => 'Endpoint' attribute :engine, :aliases => 'Engine' attribute :engine_version, :aliases => 'EngineVersion' attribute :password, :aliases => '<PASSWORD>' attribute :master_username, :aliases => 'MasterUsername' attribute :port, :aliases => 'Port', :type => :integer attribute :preferred_backup_window, :aliases => 'PreferredBackupWindow' attribute :preferred_maintenance_window, :aliases => 'PreferredMaintenanceWindow' attribute :state, :aliases => 'Status' attribute :vpc_security_groups, :aliases => 'VpcSecurityGroups' attr_accessor :storage_encrypted #not in the response def ready? state == "available" end def snapshots requires :id service.cluster_snapshots(:cluster => self) end def servers(set=db_cluster_members) set.map do |member| service.servers.get(member['DBInstanceIdentifier']) end end def master db_cluster_members.detect { |member| member["master"] } end def replicas servers(db_cluster_members.select { |member| !member["master"] }) end def has_replica?(replica_name) replicas.detect { |replica| replica.id == replica_name } end def destroy(snapshot_identifier=nil) requires :id service.delete_db_cluster(id, snapshot_identifier, snapshot_identifier.nil?) true end def save requires :id requires :engine requires :master_username requires :password data = service.create_db_cluster(id, attributes_to_params) merge_attributes(data.body['CreateDBClusterResult']['DBCluster']) true end def attributes_to_params options = { 'AllocatedStorage' => allocated_storage, 'BackupRetentionPeriod' => backup_retention_period, 'DBClusterIdentifier' => identity, 'DBClusterParameterGroup' => db_cluster_parameter_group, 'DBSubnetGroup' => db_subnet_group, 'Endpoint' => endpoint, 'Engine' => engine, 'EngineVersion' => engine_version, 'MasterUserPassword' => password, 'MasterUsername' => master_username, 'PreferredBackupWindow' => preferred_backup_window, 'PreferredMaintenanceWindow' => preferred_maintenance_window, 'Status' => state, 'StorageEncrypted' => storage_encrypted, 'VpcSecurityGroups' => vpc_security_groups, } options.delete_if { |key,value| value.nil? } end end end end end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/knife-windows-1.4.1/lib/chef/knife/core/windows_bootstrap_context.rb
<gh_stars>0 # # Author:: <NAME> (<<EMAIL>>) # Copyright:: Copyright (c) 2011-2016 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # require 'chef/knife/core/bootstrap_context' # Chef::Util::PathHelper in Chef 11 is a bit juvenile still require 'knife-windows/path_helper' # require 'chef/util/path_helper' class Chef class Knife module Core # Instances of BootstrapContext are the context objects (i.e., +self+) for # bootstrap templates. For backwards compatability, they +must+ set the # following instance variables: # * @config - a hash of knife's config values # * @run_list - the run list for the node to boostrap # class WindowsBootstrapContext < BootstrapContext PathHelper = ::Knife::Windows::PathHelper attr_accessor :client_pem def initialize(config, run_list, chef_config, secret=nil) @config = config @run_list = run_list @chef_config = chef_config @secret = secret # Compatibility with Chef 12 and Chef 11 versions begin # Pass along the secret parameter for Chef 12 super(config, run_list, chef_config, secret) rescue ArgumentError # The Chef 11 base class only has parameters for initialize super(config, run_list, chef_config) end end def validation_key if File.exist?(File.expand_path(@chef_config[:validation_key])) IO.read(File.expand_path(@chef_config[:validation_key])) else false end end def secret escape_and_echo(@config[:secret]) end def trusted_certs_script @trusted_certs_script ||= trusted_certs_content end def config_content client_rb = <<-CONFIG log_level :info log_location STDOUT chef_server_url "#{@chef_config[:chef_server_url]}" validation_client_name "#{@chef_config[:validation_client_name]}" file_cache_path "c:/chef/cache" file_backup_path "c:/chef/backup" cache_options ({:path => "c:/chef/cache/checksums", :skip_expires => true}) CONFIG if @config[:chef_node_name] client_rb << %Q{node_name "#{@config[:chef_node_name]}"\n} else client_rb << "# Using default node name (fqdn)\n" end # We configure :verify_api_cert only when it's overridden on the CLI # or when specified in the knife config. if !@config[:node_verify_api_cert].nil? || knife_config.has_key?(:verify_api_cert) value = @config[:node_verify_api_cert].nil? ? knife_config[:verify_api_cert] : @config[:node_verify_api_cert] client_rb << %Q{verify_api_cert #{value}\n} end # We configure :ssl_verify_mode only when it's overridden on the CLI # or when specified in the knife config. if @config[:node_ssl_verify_mode] || knife_config.has_key?(:ssl_verify_mode) value = case @config[:node_ssl_verify_mode] when "peer" :verify_peer when "none" :verify_none when nil knife_config[:ssl_verify_mode] else nil end if value client_rb << %Q{ssl_verify_mode :#{value}\n} end end if @config[:ssl_verify_mode] client_rb << %Q{ssl_verify_mode :#{knife_config[:ssl_verify_mode]}\n} end if knife_config[:bootstrap_proxy] client_rb << "\n" client_rb << %Q{http_proxy "#{knife_config[:bootstrap_proxy]}"\n} client_rb << %Q{https_proxy "#{knife_config[:bootstrap_proxy]}"\n} client_rb << %Q{no_proxy "#{knife_config[:bootstrap_no_proxy]}"\n} if knife_config[:bootstrap_no_proxy] end if knife_config[:bootstrap_no_proxy] client_rb << %Q{no_proxy "#{knife_config[:bootstrap_no_proxy]}"\n} end if @config[:secret] client_rb << %Q{encrypted_data_bag_secret "c:/chef/encrypted_data_bag_secret"\n} end unless trusted_certs_script.empty? client_rb << %Q{trusted_certs_dir "c:/chef/trusted_certs"\n} end if Chef::Config[:fips] client_rb << <<-CONFIG fips true chef_version = ::Chef::VERSION.split(".") unless chef_version[0].to_i > 12 || (chef_version[0].to_i == 12 && chef_version[1].to_i >= 8) raise "FIPS Mode requested but not supported by this client" end CONFIG end escape_and_echo(client_rb) end def start_chef bootstrap_environment_option = bootstrap_environment.nil? ? '' : " -E #{bootstrap_environment}" start_chef = "SET \"PATH=%PATH%;C:\\ruby\\bin;C:\\opscode\\chef\\bin;C:\\opscode\\chef\\embedded\\bin\"\n" start_chef << "chef-client -c c:/chef/client.rb -j c:/chef/first-boot.json#{bootstrap_environment_option}\n" end def latest_current_windows_chef_version_query installer_version_string = nil if @config[:prerelease] installer_version_string = "&prerelease=true" else chef_version_string = if knife_config[:bootstrap_version] knife_config[:bootstrap_version] else Chef::VERSION.split(".").first end installer_version_string = "&v=#{chef_version_string}" # If bootstrapping a pre-release version add the prerelease query string if chef_version_string.split(".").length > 3 installer_version_string << "&prerelease=true" end end installer_version_string end def win_wget # I tried my best to figure out how to properly url decode and switch / to \ # but this is VBScript - so I don't really care that badly. win_wget = <<-WGET url = WScript.Arguments.Named("url") path = WScript.Arguments.Named("path") proxy = null '* Vaguely attempt to handle file:// scheme urls by url unescaping and switching all '* / into \. Also assume that file:/// is a local absolute path and that file://<foo> '* is possibly a network file path. If InStr(url, "file://") = 1 Then url = Unescape(url) If InStr(url, "file:///") = 1 Then sourcePath = Mid(url, Len("file:///") + 1) Else sourcePath = Mid(url, Len("file:") + 1) End If sourcePath = Replace(sourcePath, "/", "\\") Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.Fileexists(path) Then objFSO.DeleteFile path objFSO.CopyFile sourcePath, path, true Set objFSO = Nothing Else Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP") Set wshShell = CreateObject( "WScript.Shell" ) Set objUserVariables = wshShell.Environment("USER") rem http proxy is optional rem attempt to read from HTTP_PROXY env var first On Error Resume Next If NOT (objUserVariables("HTTP_PROXY") = "") Then proxy = objUserVariables("HTTP_PROXY") rem fall back to named arg ElseIf NOT (WScript.Arguments.Named("proxy") = "") Then proxy = WScript.Arguments.Named("proxy") End If If NOT isNull(proxy) Then rem setProxy method is only available on ServerXMLHTTP 6.0+ Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0") objXMLHTTP.setProxy 2, proxy End If On Error Goto 0 objXMLHTTP.open "GET", url, false objXMLHTTP.send() If objXMLHTTP.Status = 200 Then Set objADOStream = CreateObject("ADODB.Stream") objADOStream.Open objADOStream.Type = 1 objADOStream.Write objXMLHTTP.ResponseBody objADOStream.Position = 0 Set objFSO = Createobject("Scripting.FileSystemObject") If objFSO.Fileexists(path) Then objFSO.DeleteFile path Set objFSO = Nothing objADOStream.SaveToFile path objADOStream.Close Set objADOStream = Nothing End If Set objXMLHTTP = Nothing End If WGET escape_and_echo(win_wget) end def win_wget_ps win_wget_ps = <<-WGET_PS param( [String] $remoteUrl, [String] $localPath ) $ProxyUrl = $env:http_proxy; $webClient = new-object System.Net.WebClient; if ($ProxyUrl -ne '') { $WebProxy = New-Object System.Net.WebProxy($ProxyUrl,$true) $WebClient.Proxy = $WebProxy } $webClient.DownloadFile($remoteUrl, $localPath); WGET_PS escape_and_echo(win_wget_ps) end def install_chef # The normal install command uses regular double quotes in # the install command, so request such a string from install_command install_chef = install_command('"') + "\n" + fallback_install_task_command end def bootstrap_directory bootstrap_directory = "C:\\chef" end def local_download_path local_download_path = "%TEMP%\\chef-client-latest.msi" end def msi_url(machine_os=nil, machine_arch=nil, download_context=nil) # The default msi path has a number of url query parameters - we attempt to substitute # such parameters in as long as they are provided by the template. if @config[:msi_url].nil? || @config[:msi_url].empty? url = "https://www.chef.io/chef/download?p=windows" url += "&pv=#{machine_os}" unless machine_os.nil? url += "&m=#{machine_arch}" unless machine_arch.nil? url += "&DownloadContext=#{download_context}" unless download_context.nil? url += latest_current_windows_chef_version_query else @config[:msi_url] end end def first_boot escape_and_echo(super.to_json) end # escape WIN BATCH special chars # and prefixes each line with an # echo def escape_and_echo(file_contents) file_contents.gsub(/^(.*)$/, 'echo.\1').gsub(/([(<|>)^])/, '^\1') end private def install_command(executor_quote) if @config[:install_as_service] "msiexec /qn /log #{executor_quote}%CHEF_CLIENT_MSI_LOG_PATH%#{executor_quote} /i #{executor_quote}%LOCAL_DESTINATION_MSI_PATH%#{executor_quote} ADDLOCAL=#{executor_quote}ChefClientFeature,ChefServiceFeature#{executor_quote}" else "msiexec /qn /log #{executor_quote}%CHEF_CLIENT_MSI_LOG_PATH%#{executor_quote} /i #{executor_quote}%LOCAL_DESTINATION_MSI_PATH%#{executor_quote}" end end # Returns a string for copying the trusted certificates on the workstation to the system being bootstrapped # This string should contain both the commands necessary to both create the files, as well as their content def trusted_certs_content content = "" if @chef_config[:trusted_certs_dir] Dir.glob(File.join(PathHelper.escape_glob(@chef_config[:trusted_certs_dir]), "*.{crt,pem}")).each do |cert| content << "> #{bootstrap_directory}/trusted_certs/#{File.basename(cert)} (\n" + escape_and_echo(IO.read(File.expand_path(cert))) + "\n)\n" end end content end def fallback_install_task_command # This command will be executed by schtasks.exe in the batch # code below. To handle tasks that contain arguments that # need to be double quoted, schtasks allows the use of single # quotes that will later be converted to double quotes command = install_command('\'') <<-EOH @set MSIERRORCODE=!ERRORLEVEL! @if ERRORLEVEL 1 ( @echo WARNING: Failed to install Chef Client MSI package in remote context with status code !MSIERRORCODE!. @echo WARNING: This may be due to a defect in operating system update KB2918614: http://support.microsoft.com/kb/2918614 @set OLDLOGLOCATION="%CHEF_CLIENT_MSI_LOG_PATH%-fail.log" @move "%CHEF_CLIENT_MSI_LOG_PATH%" "!OLDLOGLOCATION!" > NUL @echo WARNING: Saving installation log of failure at !OLDLOGLOCATION! @echo WARNING: Retrying installation with local context... @schtasks /create /f /sc once /st 00:00:00 /tn chefclientbootstraptask /ru SYSTEM /rl HIGHEST /tr \"cmd /c #{command} & sleep 2 & waitfor /s %computername% /si chefclientinstalldone\" @if ERRORLEVEL 1 ( @echo ERROR: Failed to create Chef Client installation scheduled task with status code !ERRORLEVEL! > "&2" ) else ( @echo Successfully created scheduled task to install Chef Client. @schtasks /run /tn chefclientbootstraptask @if ERRORLEVEL 1 ( @echo ERROR: Failed to execut Chef Client installation scheduled task with status code !ERRORLEVEL!. > "&2" ) else ( @echo Successfully started Chef Client installation scheduled task. @echo Waiting for installation to complete -- this may take a few minutes... waitfor chefclientinstalldone /t 600 if ERRORLEVEL 1 ( @echo ERROR: Timed out waiting for Chef Client package to install ) else ( @echo Finished waiting for Chef Client package to install. ) @schtasks /delete /f /tn chefclientbootstraptask > NUL ) ) ) else ( @echo Successfully installed Chef Client package. ) EOH end end end end end
arnab0073/idea
.rvm/src/ruby-2.3.0/test/-ext-/postponed_job/test_postponed_job.rb
# frozen_string_literal: false require 'test/unit' require 'thread' require '-test-/postponed_job' module Bug def self.postponed_job_call_direct_wrapper(*args) postponed_job_call_direct(*args) end def self.postponed_job_register_wrapper(*args) postponed_job_register(*args) end end class TestPostponed_job < Test::Unit::TestCase def test_register direct, registered = [], [] Bug.postponed_job_call_direct_wrapper(direct) Bug.postponed_job_register_wrapper(registered) assert_match( /postponed_job_call_direct_wrapper/, direct.join) assert_not_match( /postponed_job_register_wrapper/, registered.join) Bug.postponed_job_register_one(ary = []) assert_equal [1], ary end end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/rubyntlm-0.6.0/spec/spec_helper.rb
require 'simplecov' require 'pathname' SimpleCov.start do add_filter '/spec/' add_filter '/config/' add_filter '/vendor/' end if ENV["COVERAGE"] require 'rspec' require 'net/ntlm' # add project lib directory to load path spec_pathname = Pathname.new(__FILE__).dirname root_pathname = spec_pathname.join('..').expand_path # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. support_glob = root_pathname.join('spec', 'support', '**', '*.rb') Dir.glob(support_glob) do |path| require path end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/benchmark/bm_vm_thread_create_join.rb
i=0 while i<100_000 # benchmark loop 3 i+=1 Thread.new{ }.join end
arnab0073/idea
.rvm/src/ruby-2.3.0/test/rubygems/test_gem_resolver_composed_set.rb
# frozen_string_literal: false require 'rubygems/test_case' class TestGemResolverComposedSet < Gem::TestCase def test_errors index_set = Gem::Resolver::IndexSet.new current_set = Gem::Resolver::CurrentSet.new set = Gem::Resolver::ComposedSet.new index_set, current_set set.instance_variable_get(:@errors) << :a current_set.errors << :b assert_includes set.errors, :a assert_includes set.errors, :b assert_includes set.errors, index_set.errors.first end def test_prerelease_equals best_set = Gem::Resolver::BestSet.new current_set = Gem::Resolver::CurrentSet.new set = Gem::Resolver::ComposedSet.new best_set, current_set set.prerelease = true assert set.prerelease assert best_set.prerelease assert current_set.prerelease end def test_remote_equals best_set = Gem::Resolver::BestSet.new current_set = Gem::Resolver::CurrentSet.new set = Gem::Resolver::ComposedSet.new best_set, current_set set.remote = false refute best_set.remote? refute current_set.remote? end end
arnab0073/idea
.rvm/src/ruby-2.3.0/lib/rdoc/markup/formatter.rb
<reponame>arnab0073/idea # frozen_string_literal: false ## # Base class for RDoc markup formatters # # Formatters are a visitor that converts an RDoc::Markup tree (from a comment) # into some kind of output. RDoc ships with formatters for converting back to # rdoc, ANSI text, HTML, a Table of Contents and other formats. # # 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 extra test cases. class RDoc::Markup::Formatter ## # Tag for inline markup containing a +bit+ for the bitmask and the +on+ and # +off+ triggers. InlineTag = Struct.new(:bit, :on, :off) ## # Converts a target url to one that is relative to a given path def self.gen_relative_url path, target from = File.dirname path to, to_file = File.split target from = from.split "/" to = to.split "/" from.delete '.' to.delete '.' while from.size > 0 and to.size > 0 and from[0] == to[0] do from.shift to.shift end from.fill ".." from.concat to from << to_file File.join(*from) end ## # Creates a new Formatter def initialize options, markup = nil @options = options @markup = markup || RDoc::Markup.new @am = @markup.attribute_manager @am.add_special(/<br>/, :HARD_BREAK) @attributes = @am.attributes @attr_tags = [] @in_tt = 0 @tt_bit = @attributes.bitmap_for :TT @hard_break = '' @from_path = '.' end ## # Adds +document+ to the output def accept_document document document.parts.each do |item| case item when RDoc::Markup::Document then # HACK accept_document item else item.accept self end end end ## # Adds a special for links of the form rdoc-...: def add_special_RDOCLINK @markup.add_special(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK) end ## # Adds a special for links of the form {<text>}[<url>] and <word>[<url>] def add_special_TIDYLINK @markup.add_special(/(?: \{.*?\} | # multi-word label \b[^\s{}]+? # single-word label ) \[\S+?\] # link target /x, :TIDYLINK) end ## # Add a new set of tags for an attribute. We allow separate start and end # tags for flexibility def add_tag(name, start, stop) attr = @attributes.bitmap_for name @attr_tags << InlineTag.new(attr, start, stop) end ## # Allows +tag+ to be decorated with additional information. def annotate(tag) tag end ## # Marks up +content+ def convert content @markup.convert content, self end ## # Converts flow items +flow+ def convert_flow(flow) res = [] flow.each do |item| case item when String then res << convert_string(item) when RDoc::Markup::AttrChanger then off_tags res, item on_tags res, item when RDoc::Markup::Special then res << convert_special(item) else raise "Unknown flow element: #{item.inspect}" end end res.join end ## # Converts added specials. See RDoc::Markup#add_special def convert_special special return special.text if in_tt? handled = false @attributes.each_name_of special.type do |name| method_name = "handle_special_#{name}" if respond_to? method_name then special.text = send method_name, special handled = true end end unless handled then special_name = @attributes.as_string special.type raise RDoc::Error, "Unhandled special #{special_name}: #{special}" end special.text end ## # Converts a string to be fancier if desired def convert_string string string end ## # Use ignore in your subclass to ignore the content of a node. # # ## # # We don't support raw nodes in ToNoRaw # # alias accept_raw ignore def ignore *node end ## # Are we currently inside tt tags? def in_tt? @in_tt > 0 end ## # Turns on tags for +item+ on +res+ def on_tags res, item attr_mask = item.turn_on return if attr_mask.zero? @attr_tags.each do |tag| if attr_mask & tag.bit != 0 then res << annotate(tag.on) @in_tt += 1 if tt? tag end end end ## # Turns off tags for +item+ on +res+ def off_tags res, item attr_mask = item.turn_off return if attr_mask.zero? @attr_tags.reverse_each do |tag| if attr_mask & tag.bit != 0 then @in_tt -= 1 if tt? tag res << annotate(tag.off) end end end ## # Extracts and a scheme, url and an anchor id from +url+ and returns them. def parse_url url case url when /^rdoc-label:([^:]*)(?::(.*))?/ then scheme = 'link' path = "##{$1}" id = " id=\"#{$2}\"" if $2 when /([A-Za-z]+):(.*)/ then scheme = $1.downcase path = $2 when /^#/ then else scheme = 'http' path = url url = url end if scheme == 'link' then url = if path[0, 1] == '#' then # is this meaningful? path else self.class.gen_relative_url @from_path, path end end [scheme, url, id] end ## # Is +tag+ a tt tag? def tt? tag tag.bit == @tt_bit end end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/winrm-1.8.1/spec/cmd_spec.rb
# encoding: UTF-8 describe 'winrm client cmd', integration: true do before(:all) do @winrm = winrm_connection end describe 'empty string' do subject(:output) { @winrm.cmd('') } it { should have_exit_code 0 } it { should have_no_stdout } it { should have_no_stderr } end describe 'ipconfig' do subject(:output) { @winrm.cmd('ipconfig') } it { should have_exit_code 0 } it { should have_stdout_match(/Windows IP Configuration/) } it { should have_no_stderr } end describe 'echo \'hello world\' using apostrophes' do subject(:output) { @winrm.cmd("echo 'hello world'") } it { should have_exit_code 0 } it { should have_stdout_match(/'hello world'/) } it { should have_no_stderr } end describe 'echo "string with trailing \\" using double quotes' do # This is a regression test for #131. " is converted to &quot; when serializing # the command to SOAP/XML. Any naive substitution performed on such a serialized # string can result in any \& sequence being interpreted as a back-substitution. subject(:output) { @winrm.cmd('echo "string with trailing \\"') } it { should have_exit_code 0 } it { should have_stdout_match(/string with trailing \\/) } it { should have_no_stderr } end describe 'capturing output from stdout and stderr' do subject(:output) do # Note: Multiple lines doesn't work: # script = <<-eos # echo Hello # echo , world! 1>&2 # eos script = 'echo Hello & echo , world! 1>&2' @captured_stdout = '' @captured_stderr = '' @winrm.cmd(script) do |stdout, stderr| @captured_stdout << stdout if stdout @captured_stderr << stderr if stderr end end it 'should have stdout' do expect(output.stdout).to eq("Hello \r\n") expect(output.stdout).to eq(@captured_stdout) end it 'should have stderr' do expect(output.stderr).to eq(", world! \r\n") expect(output.stderr).to eq(@captured_stderr) end it 'should have output' do expect(output.output).to eq("Hello \r\n, world! \r\n") end end describe 'ipconfig with /all argument' do subject(:output) { @winrm.cmd('ipconfig', %w(/all)) } it { should have_exit_code 0 } it { should have_stdout_match(/Windows IP Configuration/) } it { should have_no_stderr } end describe 'dir with incorrect argument /z' do subject(:output) { @winrm.cmd('dir /z') } it { should have_exit_code 1 } it { should have_no_stdout } it { should have_stderr_match(/Invalid switch/) } end describe 'ipconfig && echo error 1>&2' do subject(:output) { @winrm.cmd('ipconfig && echo error 1>&2') } it { should have_exit_code 0 } it { should have_stdout_match(/Windows IP Configuration/) } it { should have_stderr_match(/error/) } end describe 'ipconfig with a block' do subject(:stdout) do outvar = '' @winrm.cmd('ipconfig') do |stdout, _stderr| outvar << stdout end outvar end it { should match(/Windows IP Configuration/) } end end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/tk/sample/tkextlib/vu/oscilloscope.rb
<reponame>arnab0073/idea<filename>.rvm/src/ruby-1.9.3-p551/ext/tk/sample/tkextlib/vu/oscilloscope.rb #!/usr/bin/env ruby require 'tk' require 'tkextlib/vu/charts' #---USAGE info = "...the heart of a Realtime Oscilloscope, where the PCIs joystick port gives 4 digtal inputs and 4 analog 8 bit values with an resolution of ~1 millisecond (!!!) running Realtime Linux. <p> creates DEMO.ps <B1-Motion> see what happens" puts info #---GEOMETRY geo_fr = [10, 10, 210, 180] geo_ch0 = [10, 10, 210, 90] geo_ch1 = [10, 90, 210, 180] geo_t1 = [15, 88] #---GUI c = TkCanvas.new(:width=>220, :height=>190).pack(:fill=>:both, :expand=>true) #---background TkcRectangle.new(c, geo_fr, :width=>4, :fill=>'aquamarine3', :tags=>['osc', 'frbg']) #---channel 0 ch0 = Tk::Vu::TkcStripchart.new(c, geo_ch0, :fill=>'', :jumpscroll=>false, :outline=>'', :scaleline=>'', :stripline=>'cyan', :tags=>['osc', 'ch0']) #---channel 1 ch1 = Tk::Vu::TkcStripchart.new(c, geo_ch1, :fill=>'', :jumpscroll=>0, :outline=>'', :scaleline=>'', :stripline=>'red', :tags=>['osc', 'ch1']) #---frame TkcRectangle.new(c, geo_fr, :width=>4, :tags=>['osc', 'frfg']) #---position txt1 = TkcText.new(c, geo_t1, :text=>"B1-Motion: X:%X\tY:%Y", :anchor=>:nw, :tags=>['osc', 'txt1']) #---BINDINGS c.bind('B1-Motion', proc{|x, y, xx, yy| ch0[:values] = x ch1[:values] = y txt1[:text] = "B1-Motion: X:#{xx}\tY:#{yy}" }, '%x %y %X %Y') Tk.root.bind('v', proc{ puts ch0[:values].join(' ') puts ch0[:values].size }) Tk.root.bind('p', proc{ c.postscript(:file=>'DEMO.ps') puts "DEMO.ps printed" }) Tk.root.bind('q', proc{exit}) ##################### Tk.mainloop
arnab0073/idea
.rvm/src/ruby-2.3.0/lib/rdoc/top_level.rb
<filename>.rvm/src/ruby-2.3.0/lib/rdoc/top_level.rb # frozen_string_literal: false ## # A TopLevel context is a representation of the contents of a single file class RDoc::TopLevel < RDoc::Context MARSHAL_VERSION = 0 # :nodoc: ## # This TopLevel's File::Stat struct attr_accessor :file_stat ## # Relative name of this file attr_accessor :relative_name ## # Absolute name of this file attr_accessor :absolute_name ## # All the classes or modules that were declared in # this file. These are assigned to either +#classes_hash+ # or +#modules_hash+ once we know what they really are. attr_reader :classes_or_modules attr_accessor :diagram # :nodoc: ## # The parser class that processed this file attr_accessor :parser ## # Creates a new TopLevel for the file at +absolute_name+. If documentation # is being generated outside the source dir +relative_name+ is relative to # the source directory. def initialize absolute_name, relative_name = absolute_name super() @name = nil @absolute_name = absolute_name @relative_name = relative_name @file_stat = File.stat(absolute_name) rescue nil # HACK for testing @diagram = nil @parser = nil @classes_or_modules = [] end ## # An RDoc::TopLevel is equal to another with the same relative_name def == other self.class === other and @relative_name == other.relative_name end alias eql? == ## # Adds +an_alias+ to +Object+ instead of +self+. def add_alias(an_alias) object_class.record_location self return an_alias unless @document_self object_class.add_alias an_alias end ## # Adds +constant+ to +Object+ instead of +self+. def add_constant constant object_class.record_location self return constant unless @document_self object_class.add_constant constant end ## # Adds +include+ to +Object+ instead of +self+. def add_include(include) object_class.record_location self return include unless @document_self object_class.add_include include end ## # Adds +method+ to +Object+ instead of +self+. def add_method(method) object_class.record_location self return method unless @document_self object_class.add_method method end ## # Adds class or module +mod+. Used in the building phase # by the Ruby parser. def add_to_classes_or_modules mod @classes_or_modules << mod end ## # Base name of this file def base_name File.basename @relative_name end alias name base_name ## # Only a TopLevel that contains text file) will be displayed. See also # RDoc::CodeObject#display? def display? text? and super end ## # See RDoc::TopLevel::find_class_or_module #-- # TODO Why do we search through all classes/modules found, not just the # ones of this instance? def find_class_or_module name @store.find_class_or_module name end ## # Finds a class or module named +symbol+ def find_local_symbol(symbol) find_class_or_module(symbol) || super end ## # Finds a module or class with +name+ def find_module_named(name) find_class_or_module(name) end ## # Returns the relative name of this file def full_name @relative_name end ## # An RDoc::TopLevel has the same hash as another with the same # relative_name def hash @relative_name.hash end ## # URL for this with a +prefix+ def http_url(prefix) path = [prefix, @relative_name.tr('.', '_')] File.join(*path.compact) + '.html' end def inspect # :nodoc: "#<%s:0x%x %p modules: %p classes: %p>" % [ self.class, object_id, base_name, @modules.map { |n,m| m }, @classes.map { |n,c| c } ] end ## # Time this file was last modified, if known def last_modified @file_stat ? file_stat.mtime : nil end ## # Dumps this TopLevel for use by ri. See also #marshal_load def marshal_dump [ MARSHAL_VERSION, @relative_name, @parser, parse(@comment), ] end ## # Loads this TopLevel from +array+. def marshal_load array # :nodoc: initialize array[1] @parser = array[2] @comment = array[3] @file_stat = nil end ## # Returns the NormalClass "Object", creating it if not found. # # Records +self+ as a location in "Object". def object_class @object_class ||= begin oc = @store.find_class_named('Object') || add_class(RDoc::NormalClass, 'Object') oc.record_location self oc end end ## # Base name of this file without the extension def page_name basename = File.basename @relative_name basename =~ /\.(rb|rdoc|txt|md)$/i $` || basename end ## # Path to this file for use with HTML generator output. def path http_url @store.rdoc.generator.file_dir end def pretty_print q # :nodoc: q.group 2, "[#{self.class}: ", "]" do q.text "base name: #{base_name.inspect}" q.breakable items = @modules.map { |n,m| m } items.concat @modules.map { |n,c| c } q.seplist items do |mod| q.pp mod end end end ## # Search record used by RDoc::Generator::JsonIndex def search_record return unless @parser < RDoc::Parser::Text [ page_name, '', page_name, '', path, '', snippet(@comment), ] end ## # Is this TopLevel from a text file instead of a source code file? def text? @parser and @parser.ancestors.include? RDoc::Parser::Text end def to_s # :nodoc: "file #{full_name}" end end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/lib/yaml.rb
<filename>.rvm/src/ruby-1.9.3-p551/lib/yaml.rb # YAML Ain't Markup Language # # This module provides a Ruby interface for data serialization in YAML format. # # You can choose from one of two YAML engines that ship with Ruby 1.9. By # default Psych is used but the old unmaintained Syck may chosen. # # == Usage # # Working with YAML can be very simple, for example: # # require 'yaml' # STEP ONE, REQUIRE YAML! # # Parse a YAML string # YAML.load("--- foo") #=> "foo" # # # Emit some YAML # YAML.dump("foo") # => "--- foo\n...\n" # { :a => 'b'}.to_yaml # => "---\n:a: b\n" # # == Security # # Do not use YAML to load untrusted data. Doing so is unsafe and could allow # malicious input to execute arbitrary code inside your application. Please see # doc/security.rdoc for more information. # # == Syck # # Syck was the original for YAML implementation in Ruby's standard library # developed by why the lucky stiff. # # If you prefer, you can still use Syck by changing the YAML::ENGINE like so: # # YAML::ENGINE.yamler = 'syck' # # switch back to the default Psych # YAML::ENGINE.yamler = 'psych' # # In older Ruby versions, ie. <= 1.9, Syck is still provided, however it was # completely removed with the release of Ruby 2.0.0. # # == More info # # For more advanced details on the implementation see Psych, and also check out # http://yaml.org for spec details and other helpful information. module YAML class EngineManager # :nodoc: attr_reader :yamler def initialize @yamler = nil end def syck? 'syck' == @yamler end def yamler= engine raise(ArgumentError, "bad engine") unless %w{syck psych}.include?(engine) require engine unless (engine == 'syck' ? Syck : Psych).const_defined?(:VERSION) Object.class_eval <<-eorb, __FILE__, __LINE__ + 1 remove_const 'YAML' YAML = #{engine.capitalize} remove_method :to_yaml alias :to_yaml :#{engine}_to_yaml eorb @yamler = engine engine end end ## # Allows changing the current YAML engine. See YAML for details. ENGINE = YAML::EngineManager.new # :nodoc: end if defined?(Psych) engine = 'psych' elsif defined?(Syck) engine = 'syck' else begin require 'psych' engine = 'psych' rescue LoadError warn "#{caller[0]}:" warn "It seems your ruby installation is missing psych (for YAML output)." warn "To eliminate this warning, please install libyaml and reinstall your ruby." require 'syck' engine = 'syck' end end module Syck # :nodoc: ENGINE = YAML::ENGINE end module Psych # :nodoc: ENGINE = YAML::ENGINE end YAML::ENGINE.yamler = engine
arnab0073/idea
.rvm/src/ruby-2.3.0/ext/psych/lib/psych/nodes/stream.rb
# frozen_string_literal: false module Psych module Nodes ### # Represents a YAML stream. This is the root node for any YAML parse # tree. This node must have one or more child nodes. The only valid # child node for a Psych::Nodes::Stream node is Psych::Nodes::Document. class Stream < Psych::Nodes::Node # Encodings supported by Psych (and libyaml) # Any encoding ANY = Psych::Parser::ANY # UTF-8 encoding UTF8 = Psych::Parser::UTF8 # UTF-16LE encoding UTF16LE = Psych::Parser::UTF16LE # UTF-16BE encoding UTF16BE = Psych::Parser::UTF16BE # The encoding used for this stream attr_accessor :encoding ### # Create a new Psych::Nodes::Stream node with an +encoding+ that # defaults to Psych::Nodes::Stream::UTF8. # # See also Psych::Handler#start_stream def initialize encoding = UTF8 super() @encoding = encoding end end end end
arnab0073/idea
.rvm/src/ruby-2.3.0/test/ruby/test_file_exhaustive.rb
<reponame>arnab0073/idea<filename>.rvm/src/ruby-2.3.0/test/ruby/test_file_exhaustive.rb # frozen_string_literal: false require "test/unit" require "fileutils" require "tmpdir" require "socket" class TestFileExhaustive < Test::Unit::TestCase DRIVE = Dir.pwd[%r'\A(?:[a-z]:|//[^/]+/[^/]+)'i] POSIX = /cygwin|mswin|bccwin|mingw|emx/ !~ RUBY_PLATFORM NTFS = !(/cygwin|mingw|mswin|bccwin/ !~ RUBY_PLATFORM) def assert_incompatible_encoding d = "\u{3042}\u{3044}".encode("utf-16le") assert_raise(Encoding::CompatibilityError) {yield d} m = Class.new {define_method(:to_path) {d}} assert_raise(Encoding::CompatibilityError) {yield m.new} end def setup @dir = Dir.mktmpdir("rubytest-file") File.chown(-1, Process.gid, @dir) end def teardown GC.start FileUtils.remove_entry_secure @dir end def make_tmp_filename(prefix) "#{@dir}/#{prefix}.test" end def rootdir return @rootdir if defined? @rootdir @rootdir = "#{DRIVE}/" @rootdir end def nofile return @nofile if defined? @nofile @nofile = make_tmp_filename("nofile") @nofile end def make_file(content, file) open(file, "w") {|fh| fh << content } end def zerofile return @zerofile if defined? @zerofile @zerofile = make_tmp_filename("zerofile") make_file("", @zerofile) @zerofile end def regular_file return @file if defined? @file @file = make_tmp_filename("file") make_file("foo", @file) @file end def notownedfile return @notownedfile if defined? @notownedfile if Process.euid != 0 @notownedfile = '/' else @notownedfile = nil end @notownedfile end def suidfile return @suidfile if defined? @suidfile if POSIX @suidfile = make_tmp_filename("suidfile") make_file("", @suidfile) File.chmod 04500, @suidfile @suidfile else @suidfile = nil end end def sgidfile return @sgidfile if defined? @sgidfile if POSIX @sgidfile = make_tmp_filename("sgidfile") make_file("", @sgidfile) File.chmod 02500, @sgidfile @sgidfile else @sgidfile = nil end end def stickyfile return @stickyfile if defined? @stickyfile if POSIX @stickyfile = make_tmp_filename("stickyfile") Dir.mkdir(@stickyfile) File.chmod 01500, @stickyfile @stickyfile else @stickyfile = nil end end def symlinkfile return @symlinkfile if @symlinkfile @symlinkfile = make_tmp_filename("symlinkfile") begin File.symlink(regular_file, @symlinkfile) rescue NotImplementedError, Errno::EACCES @symlinkfile = nil end @symlinkfile end def hardlinkfile return @hardlinkfile if defined? @hardlinkfile @hardlinkfile = make_tmp_filename("hardlinkfile") begin File.link(regular_file, @hardlinkfile) rescue NotImplementedError, Errno::EINVAL # EINVAL for Windows Vista @hardlinkfile = nil end @hardlinkfile end def fifo return @fifo if defined? @fifo if POSIX fn = make_tmp_filename("fifo") File.mkfifo(fn) @fifo = fn else @fifo = nil end @fifo end def socket return @socket if defined? @socket if defined? UNIXServer socket = make_tmp_filename("s") UNIXServer.open(socket).close @socket = socket else @socket = nil end end def chardev return @chardev if defined? @chardev @chardev = File::NULL == "/dev/null" ? "/dev/null" : nil @chardev end def blockdev return @blockdev if defined? @blockdev if /linux/ =~ RUBY_PLATFORM @blockdev = %w[/dev/loop0 /dev/sda /dev/vda /dev/xvda1].find {|f| File.exist? f } else @blockdev = nil end @blockdev end def test_path file = regular_file assert_equal(file, File.open(file) {|f| f.path}) assert_equal(file, File.path(file)) o = Object.new class << o; self; end.class_eval do define_method(:to_path) { file } end assert_equal(file, File.path(o)) end def assert_integer(n) assert_kind_of(Integer, n) end def assert_integer_or_nil(n) msg = ->{"#{n.inspect} is neither Fixnum nor nil."} if n assert_kind_of(Integer, n, msg) else assert_nil(n, msg) end end def test_stat fn1 = regular_file hardlinkfile sleep(1.1) fn2 = fn1 + "2" make_file("foo", fn2) fs1, fs2 = File.stat(fn1), File.stat(fn2) assert_nothing_raised do assert_equal(0, fs1 <=> fs1) assert_equal(-1, fs1 <=> fs2) assert_equal(1, fs2 <=> fs1) assert_nil(fs1 <=> nil) assert_integer(fs1.dev) assert_integer_or_nil(fs1.rdev) assert_integer_or_nil(fs1.dev_major) assert_integer_or_nil(fs1.dev_minor) assert_integer_or_nil(fs1.rdev_major) assert_integer_or_nil(fs1.rdev_minor) assert_integer(fs1.ino) assert_integer(fs1.mode) unless /emx|mswin|mingw/ =~ RUBY_PLATFORM # on Windows, nlink is always 1. but this behavior will be changed # in the future. assert_equal(hardlinkfile ? 2 : 1, fs1.nlink) end assert_integer(fs1.uid) assert_integer(fs1.gid) assert_equal(3, fs1.size) assert_integer_or_nil(fs1.blksize) assert_integer_or_nil(fs1.blocks) assert_kind_of(Time, fs1.atime) assert_kind_of(Time, fs1.mtime) assert_kind_of(Time, fs1.ctime) assert_kind_of(String, fs1.inspect) end assert_raise(Errno::ENOENT) { File.stat(nofile) } assert_kind_of(File::Stat, File.open(fn1) {|f| f.stat}) assert_raise(Errno::ENOENT) { File.lstat(nofile) } assert_kind_of(File::Stat, File.open(fn1) {|f| f.lstat}) end def test_stat_drive_root assert_nothing_raised { File.stat(DRIVE + "/") } assert_nothing_raised { File.stat(DRIVE + "/.") } assert_nothing_raised { File.stat(DRIVE + "/..") } assert_raise(Errno::ENOENT) { File.stat(DRIVE + "/...") } # want to test the root of empty drive, but there is no method to test it... end if DRIVE def test_stat_dotted_prefix Dir.mktmpdir do |dir| prefix = File.join(dir, "...a") Dir.mkdir(prefix) assert_file.exist?(prefix) assert_nothing_raised { File.stat(prefix) } Dir.chdir(dir) do assert_nothing_raised { File.stat(File.basename(prefix)) } end end end if NTFS def test_directory_p assert_file.directory?(@dir) assert_file.not_directory?(@dir+"/...") assert_file.not_directory?(regular_file) assert_file.not_directory?(nofile) end def test_pipe_p assert_file.not_pipe?(@dir) assert_file.not_pipe?(regular_file) assert_file.not_pipe?(nofile) assert_file.pipe?(fifo) if fifo end def test_symlink_p assert_file.not_symlink?(@dir) assert_file.not_symlink?(regular_file) assert_file.symlink?(symlinkfile) if symlinkfile assert_file.not_symlink?(hardlinkfile) if hardlinkfile assert_file.not_symlink?(nofile) end def test_socket_p assert_file.not_socket?(@dir) assert_file.not_socket?(regular_file) assert_file.not_socket?(nofile) assert_file.socket?(socket) if socket end def test_blockdev_p assert_file.not_blockdev?(@dir) assert_file.not_blockdev?(regular_file) assert_file.not_blockdev?(nofile) assert_file.blockdev?(blockdev) if blockdev end def test_chardev_p assert_file.not_chardev?(@dir) assert_file.not_chardev?(regular_file) assert_file.not_chardev?(nofile) assert_file.chardev?(chardev) if chardev end def test_exist_p assert_file.exist?(@dir) assert_file.exist?(regular_file) assert_file.not_exist?(nofile) end def test_readable_p return if Process.euid == 0 File.chmod(0200, regular_file) assert_file.not_readable?(regular_file) File.chmod(0600, regular_file) assert_file.readable?(regular_file) assert_file.not_readable?(nofile) end if POSIX def test_readable_real_p return if Process.euid == 0 File.chmod(0200, regular_file) assert_file.not_readable_real?(regular_file) File.chmod(0600, regular_file) assert_file.readable_real?(regular_file) assert_file.not_readable_real?(nofile) end if POSIX def test_world_readable_p File.chmod(0006, regular_file) assert_file.world_readable?(regular_file) File.chmod(0060, regular_file) assert_file.not_world_readable?(regular_file) File.chmod(0600, regular_file) assert_file.not_world_readable?(regular_file) assert_file.not_world_readable?(nofile) end if POSIX def test_writable_p return if Process.euid == 0 File.chmod(0400, regular_file) assert_file.not_writable?(regular_file) File.chmod(0600, regular_file) assert_file.writable?(regular_file) assert_file.not_writable?(nofile) end if POSIX def test_writable_real_p return if Process.euid == 0 File.chmod(0400, regular_file) assert_file.not_writable_real?(regular_file) File.chmod(0600, regular_file) assert_file.writable_real?(regular_file) assert_file.not_writable_real?(nofile) end if POSIX def test_world_writable_p File.chmod(0006, regular_file) assert_file.world_writable?(regular_file) File.chmod(0060, regular_file) assert_file.not_world_writable?(regular_file) File.chmod(0600, regular_file) assert_file.not_world_writable?(regular_file) assert_file.not_world_writable?(nofile) end if POSIX def test_executable_p File.chmod(0100, regular_file) assert_file.executable?(regular_file) File.chmod(0600, regular_file) assert_file.not_executable?(regular_file) assert_file.not_executable?(nofile) end if POSIX def test_executable_real_p File.chmod(0100, regular_file) assert_file.executable_real?(regular_file) File.chmod(0600, regular_file) assert_file.not_executable_real?(regular_file) assert_file.not_executable_real?(nofile) end if POSIX def test_file_p assert_file.not_file?(@dir) assert_file.file?(regular_file) assert_file.not_file?(nofile) end def test_zero_p assert_nothing_raised { File.zero?(@dir) } assert_file.not_zero?(regular_file) assert_file.zero?(zerofile) assert_file.not_zero?(nofile) end def test_size_p assert_nothing_raised { File.size?(@dir) } assert_equal(3, File.size?(regular_file)) assert_file.not_size?(zerofile) assert_file.not_size?(nofile) end def test_owned_p assert_file.owned?(regular_file) assert_file.not_owned?(notownedfile) if notownedfile end if POSIX def test_grpowned_p ## xxx assert_file.grpowned?(regular_file) end if POSIX def test_suid assert_file.not_setuid?(regular_file) assert_file.setuid?(suidfile) if suidfile end def test_sgid assert_file.not_setgid?(regular_file) assert_file.setgid?(sgidfile) if sgidfile end def test_sticky assert_file.not_sticky?(regular_file) assert_file.sticky?(stickyfile) if stickyfile end def test_path_identical_p assert_file.identical?(regular_file, regular_file) assert_file.not_identical?(regular_file, zerofile) assert_file.not_identical?(regular_file, nofile) assert_file.not_identical?(nofile, regular_file) end def test_io_identical_p open(regular_file) {|f| assert_file.identical?(f, f) assert_file.identical?(regular_file, f) assert_file.identical?(f, regular_file) } end def test_closed_io_identical_p io = open(regular_file) {|f| f} assert_raise(IOError) { File.identical?(regular_file, io) } File.unlink(regular_file) assert_file.not_exist?(regular_file) end def test_s_size assert_integer(File.size(@dir)) assert_equal(3, File.size(regular_file)) assert_equal(0, File.size(zerofile)) assert_raise(Errno::ENOENT) { File.size(nofile) } end def test_ftype assert_equal("directory", File.ftype(@dir)) assert_equal("file", File.ftype(regular_file)) assert_equal("link", File.ftype(symlinkfile)) if symlinkfile assert_equal("file", File.ftype(hardlinkfile)) if hardlinkfile assert_raise(Errno::ENOENT) { File.ftype(nofile) } end def test_atime t1 = File.atime(regular_file) t2 = File.open(regular_file) {|f| f.atime} assert_kind_of(Time, t1) assert_kind_of(Time, t2) assert_equal(t1, t2) assert_raise(Errno::ENOENT) { File.atime(nofile) } end def test_mtime t1 = File.mtime(regular_file) t2 = File.open(regular_file) {|f| f.mtime} assert_kind_of(Time, t1) assert_kind_of(Time, t2) assert_equal(t1, t2) assert_raise(Errno::ENOENT) { File.mtime(nofile) } end def test_ctime t1 = File.ctime(regular_file) t2 = File.open(regular_file) {|f| f.ctime} assert_kind_of(Time, t1) assert_kind_of(Time, t2) assert_equal(t1, t2) assert_raise(Errno::ENOENT) { File.ctime(nofile) } end def test_chmod assert_equal(1, File.chmod(0444, regular_file)) assert_equal(0444, File.stat(regular_file).mode % 01000) assert_equal(0, File.open(regular_file) {|f| f.chmod(0222)}) assert_equal(0222, File.stat(regular_file).mode % 01000) File.chmod(0600, regular_file) assert_raise(Errno::ENOENT) { File.chmod(0600, nofile) } end if POSIX def test_lchmod assert_equal(1, File.lchmod(0444, regular_file)) assert_equal(0444, File.stat(regular_file).mode % 01000) File.lchmod(0600, regular_file) assert_raise(Errno::ENOENT) { File.lchmod(0600, nofile) } rescue NotImplementedError end if POSIX def test_chown ## xxx end def test_lchown ## xxx end def test_symlink return unless symlinkfile assert_equal("link", File.ftype(symlinkfile)) assert_raise(Errno::EEXIST) { File.symlink(regular_file, regular_file) } end def test_utime t = Time.local(2000) File.utime(t + 1, t + 2, zerofile) assert_equal(t + 1, File.atime(zerofile)) assert_equal(t + 2, File.mtime(zerofile)) end def test_hardlink return unless hardlinkfile assert_equal("file", File.ftype(hardlinkfile)) assert_raise(Errno::EEXIST) { File.link(regular_file, regular_file) } end def test_readlink return unless symlinkfile assert_equal(regular_file, File.readlink(symlinkfile)) assert_raise(Errno::EINVAL) { File.readlink(regular_file) } assert_raise(Errno::ENOENT) { File.readlink(nofile) } if fs = Encoding.find("filesystem") assert_equal(fs, File.readlink(symlinkfile).encoding) end rescue NotImplementedError end def test_readlink_long_path return unless symlinkfile bug9157 = '[ruby-core:58592] [Bug #9157]' assert_separately(["-", symlinkfile, bug9157], <<-"end;") symlinkfile, bug9157 = *ARGV 100.step(1000, 100) do |n| File.unlink(symlinkfile) link = "foo"*n begin File.symlink(link, symlinkfile) rescue Errno::ENAMETOOLONG break end assert_equal(link, File.readlink(symlinkfile), bug9157) end end; end def test_unlink assert_equal(1, File.unlink(regular_file)) make_file("foo", regular_file) assert_raise(Errno::ENOENT) { File.unlink(nofile) } end def test_rename assert_equal(0, File.rename(regular_file, nofile)) assert_file.not_exist?(regular_file) assert_file.exist?(nofile) assert_equal(0, File.rename(nofile, regular_file)) assert_raise(Errno::ENOENT) { File.rename(nofile, regular_file) } end def test_umask prev = File.umask(0777) assert_equal(0777, File.umask) open(nofile, "w") { } assert_equal(0, File.stat(nofile).mode % 01000) File.unlink(nofile) assert_equal(0777, File.umask(prev)) assert_raise(ArgumentError) { File.umask(0, 1, 2) } end if POSIX def test_expand_path assert_equal(regular_file, File.expand_path(File.basename(regular_file), File.dirname(regular_file))) if NTFS assert_equal(regular_file, File.expand_path(regular_file + " ")) assert_equal(regular_file, File.expand_path(regular_file + ".")) assert_equal(regular_file, File.expand_path(regular_file + "::$DATA")) assert_match(/\Ac:\//i, File.expand_path('c:'), '[ruby-core:31591]') assert_match(/\Ac:\//i, File.expand_path('c:foo', 'd:/bar')) assert_match(/\Ae:\//i, File.expand_path('e:foo', 'd:/bar')) assert_match(%r'\Ac:/bar/foo\z'i, File.expand_path('c:foo', 'c:/bar')) end case RUBY_PLATFORM when /darwin/ ["\u{feff}", *"\u{2000}"..."\u{2100}"].each do |c| file = regular_file + c begin open(file) {} rescue assert_equal(file, File.expand_path(file), c.dump) else assert_equal(regular_file, File.expand_path(file), c.dump) end end end if DRIVE assert_match(%r"\Az:/foo\z"i, File.expand_path('/foo', "z:/bar")) assert_match(%r"\A//host/share/foo\z"i, File.expand_path('/foo', "//host/share/bar")) assert_match(%r"\A#{DRIVE}/foo\z"i, File.expand_path('/foo')) else assert_equal("/foo", File.expand_path('/foo')) end end def test_expand_path_memsize bug9934 = '[ruby-core:63114] [Bug #9934]' require "objspace" path = File.expand_path("/foo") assert_operator(ObjectSpace.memsize_of(path), :<=, path.bytesize + GC::INTERNAL_CONSTANTS[:RVALUE_SIZE], bug9934) path = File.expand_path("/a"*25) assert_equal(path.bytesize+1 + GC::INTERNAL_CONSTANTS[:RVALUE_SIZE], ObjectSpace.memsize_of(path), bug9934) end def test_expand_path_encoding drive = (DRIVE ? 'C:' : '') if Encoding.find("filesystem") == Encoding::CP1251 a = "#{drive}/\u3042\u3044\u3046\u3048\u304a".encode("cp932") else a = "#{drive}/\u043f\u0440\u0438\u0432\u0435\u0442".encode("cp1251") end assert_equal(a, File.expand_path(a)) a = "#{drive}/\225\\\\" if File::ALT_SEPARATOR == '\\' [%W"cp437 #{drive}/\225", %W"cp932 #{drive}/\225\\"] else [["cp437", a], ["cp932", a]] end.each do |cp, expected| assert_equal(expected.force_encoding(cp), File.expand_path(a.dup.force_encoding(cp)), cp) end path = "\u3042\u3044\u3046\u3048\u304a".encode("EUC-JP") assert_equal("#{Dir.pwd}/#{path}".encode("CP932"), File.expand_path(path).encode("CP932")) path = "\u3042\u3044\u3046\u3048\u304a".encode("CP51932") assert_equal("#{Dir.pwd}/#{path}", File.expand_path(path)) assert_incompatible_encoding {|d| File.expand_path(d)} end def test_expand_path_encoding_filesystem home = ENV["HOME"] ENV["HOME"] = "#{DRIVE}/UserHome" path = "~".encode("US-ASCII") dir = "C:/".encode("IBM437") fs = Encoding.find("filesystem") assert_equal fs, File.expand_path(path).encoding assert_equal fs, File.expand_path(path, dir).encoding ensure ENV["HOME"] = home end UnknownUserHome = "~foo_bar_baz_unknown_user_wahaha".freeze def test_expand_path_home assert_kind_of(String, File.expand_path("~")) if ENV["HOME"] assert_raise(ArgumentError) { File.expand_path(UnknownUserHome) } assert_raise(ArgumentError) { File.expand_path(UnknownUserHome, "/") } begin bug3630 = '[ruby-core:31537]' home = ENV["HOME"] home_drive = ENV["HOMEDRIVE"] home_path = ENV["HOMEPATH"] user_profile = ENV["USERPROFILE"] ENV["HOME"] = nil ENV["HOMEDRIVE"] = nil ENV["HOMEPATH"] = nil ENV["USERPROFILE"] = nil assert_raise(ArgumentError) { File.expand_path("~") } ENV["HOME"] = "~" assert_raise(ArgumentError, bug3630) { File.expand_path("~") } ENV["HOME"] = "." assert_raise(ArgumentError, bug3630) { File.expand_path("~") } ensure ENV["HOME"] = home ENV["HOMEDRIVE"] = home_drive ENV["HOMEPATH"] = home_path ENV["USERPROFILE"] = user_profile end end def test_expand_path_home_dir_string home = ENV["HOME"] new_home = "#{DRIVE}/UserHome" ENV["HOME"] = new_home bug8034 = "[ruby-core:53168]" assert_equal File.join(new_home, "foo"), File.expand_path("foo", "~"), bug8034 assert_equal File.join(new_home, "bar", "foo"), File.expand_path("foo", "~/bar"), bug8034 assert_raise(ArgumentError) { File.expand_path(".", UnknownUserHome) } assert_nothing_raised(ArgumentError) { File.expand_path("#{DRIVE}/", UnknownUserHome) } ensure ENV["HOME"] = home end if /mswin|mingw/ =~ RUBY_PLATFORM def test_expand_path_home_memory_leak_in_path assert_no_memory_leak_at_expand_path_home('', 'in path') end def test_expand_path_home_memory_leak_in_base assert_no_memory_leak_at_expand_path_home('".",', 'in base') end def assert_no_memory_leak_at_expand_path_home(arg, message) prep = 'ENV["HOME"] = "foo"*100' assert_no_memory_leak([], prep, <<-TRY, "memory leaked at non-absolute home #{message}") 10000.times do begin File.expand_path(#{arg}"~/a") rescue ArgumentError => e next ensure abort("ArgumentError (non-absolute home) expected") unless e end end GC.start TRY end end def test_expand_path_remove_trailing_alternative_data assert_equal File.join(rootdir, "aaa"), File.expand_path("#{rootdir}/aaa::$DATA") assert_equal File.join(rootdir, "aa:a"), File.expand_path("#{rootdir}/aa:a:$DATA") assert_equal File.join(rootdir, "aaa:$DATA"), File.expand_path("#{rootdir}/aaa:$DATA") end if DRIVE def test_expand_path_resolve_empty_string_current_directory assert_equal(Dir.pwd, File.expand_path("")) end def test_expand_path_resolve_dot_current_directory assert_equal(Dir.pwd, File.expand_path(".")) end def test_expand_path_resolve_file_name_relative_current_directory assert_equal(File.join(Dir.pwd, "foo"), File.expand_path("foo")) end def test_ignore_nil_dir_string assert_equal(File.join(Dir.pwd, "foo"), File.expand_path("foo", nil)) end def test_expand_path_resolve_file_name_and_dir_string_relative assert_equal(File.join(Dir.pwd, "bar", "foo"), File.expand_path("foo", "bar")) end def test_expand_path_cleanup_dots_file_name bug = "[ruby-talk:18512]" assert_equal(File.join(Dir.pwd, ".a"), File.expand_path(".a"), bug) assert_equal(File.join(Dir.pwd, "..a"), File.expand_path("..a"), bug) if DRIVE # cleanup dots only on Windows assert_equal(File.join(Dir.pwd, "a"), File.expand_path("a."), bug) assert_equal(File.join(Dir.pwd, "a"), File.expand_path("a.."), bug) else assert_equal(File.join(Dir.pwd, "a."), File.expand_path("a."), bug) assert_equal(File.join(Dir.pwd, "a.."), File.expand_path("a.."), bug) end end def test_expand_path_converts_a_pathname_to_an_absolute_pathname_using_a_complete_path assert_equal(@dir, File.expand_path("", "#{@dir}")) assert_equal(File.join(@dir, "a"), File.expand_path("a", "#{@dir}")) assert_equal(File.join(@dir, "a"), File.expand_path("../a", "#{@dir}/xxx")) assert_equal(rootdir, File.expand_path(".", "#{rootdir}")) end def test_expand_path_ignores_supplied_dir_if_path_contains_a_drive_letter assert_equal(rootdir, File.expand_path(rootdir, "D:/")) end if DRIVE def test_expand_path_removes_trailing_slashes_from_absolute_path assert_equal(File.join(rootdir, "foo"), File.expand_path("#{rootdir}foo/")) assert_equal(File.join(rootdir, "foo.rb"), File.expand_path("#{rootdir}foo.rb/")) end def test_expand_path_removes_trailing_spaces_from_absolute_path assert_equal(File.join(rootdir, "a"), File.expand_path("#{rootdir}a ")) end if DRIVE def test_expand_path_converts_a_pathname_which_starts_with_a_slash_using_dir_s_drive assert_match(%r"\Az:/foo\z"i, File.expand_path('/foo', "z:/bar")) end if DRIVE def test_expand_path_converts_a_pathname_which_starts_with_a_slash_and_unc_pathname assert_equal("//foo", File.expand_path('//foo', "//bar")) assert_equal("//bar/foo", File.expand_path('/foo', "//bar")) assert_equal("//foo", File.expand_path('//foo', "/bar")) end if DRIVE def test_expand_path_converts_a_dot_with_unc_dir assert_equal("//", File.expand_path('.', "//")) end def test_expand_path_preserves_unc_path_root assert_equal("//", File.expand_path("//")) assert_equal("//", File.expand_path("//.")) assert_equal("//", File.expand_path("//..")) end def test_expand_path_converts_a_pathname_which_starts_with_a_slash_using_host_share assert_match(%r"\A//host/share/foo\z"i, File.expand_path('/foo', "//host/share/bar")) end if DRIVE def test_expand_path_converts_a_pathname_which_starts_with_a_slash_using_a_current_drive assert_match(%r"\A#{DRIVE}/foo\z"i, File.expand_path('/foo')) end def test_expand_path_returns_tainted_strings_or_not assert_equal(true, File.expand_path('foo').tainted?) assert_equal(true, File.expand_path('foo'.taint).tainted?) assert_equal(true, File.expand_path('/foo'.taint).tainted?) assert_equal(true, File.expand_path('foo', 'bar').tainted?) assert_equal(true, File.expand_path('foo', '/bar'.taint).tainted?) assert_equal(true, File.expand_path('foo'.taint, '/bar').tainted?) assert_equal(true, File.expand_path('~').tainted?) if ENV["HOME"] if DRIVE assert_equal(true, File.expand_path('/foo').tainted?) assert_equal(false, File.expand_path('//foo').tainted?) assert_equal(true, File.expand_path('C:/foo'.taint).tainted?) assert_equal(false, File.expand_path('C:/foo').tainted?) assert_equal(true, File.expand_path('foo', '/bar').tainted?) assert_equal(true, File.expand_path('foo', 'C:/bar'.taint).tainted?) assert_equal(true, File.expand_path('foo'.taint, 'C:/bar').tainted?) assert_equal(false, File.expand_path('foo', 'C:/bar').tainted?) assert_equal(false, File.expand_path('C:/foo/../bar').tainted?) assert_equal(false, File.expand_path('foo', '//bar').tainted?) else assert_equal(false, File.expand_path('/foo').tainted?) assert_equal(false, File.expand_path('foo', '/bar').tainted?) end end def test_expand_path_converts_a_pathname_to_an_absolute_pathname_using_home_as_base old_home = ENV["HOME"] home = ENV["HOME"] = "#{DRIVE}/UserHome" assert_equal(home, File.expand_path("~")) assert_equal(home, File.expand_path("~", "C:/FooBar")) assert_equal(File.join(home, "a"), File.expand_path("~/a", "C:/FooBar")) ensure ENV["HOME"] = old_home end def test_expand_path_converts_a_pathname_to_an_absolute_pathname_using_unc_home old_home = ENV["HOME"] unc_home = ENV["HOME"] = "//UserHome" assert_equal(unc_home, File.expand_path("~")) ensure ENV["HOME"] = old_home end if DRIVE def test_expand_path_does_not_modify_a_home_string_argument old_home = ENV["HOME"] home = ENV["HOME"] = "#{DRIVE}/UserHome" str = "~/a" assert_equal("#{home}/a", File.expand_path(str)) assert_equal("~/a", str) ensure ENV["HOME"] = old_home end def test_expand_path_raises_argument_error_for_any_supplied_username bug = '[ruby-core:39597]' assert_raise(ArgumentError, bug) { File.expand_path("~anything") } end if DRIVE def test_expand_path_for_existent_username user = ENV['USER'] skip "ENV['USER'] is not set" unless user assert_equal(ENV['HOME'], File.expand_path("~#{user}")) end unless DRIVE def test_expand_path_error_for_nonexistent_username user = "\u{3086 3046 3066 3044}:\u{307F 3084 304A 3046}" assert_raise_with_message(ArgumentError, /#{user}/) {File.expand_path("~#{user}")} end unless DRIVE def test_expand_path_error_for_non_absolute_home old_home = ENV["HOME"] ENV["HOME"] = "./UserHome" assert_raise_with_message(ArgumentError, /non-absolute home/) {File.expand_path("~")} ensure ENV["HOME"] = old_home end def test_expand_path_raises_a_type_error_if_not_passed_a_string_type assert_raise(TypeError) { File.expand_path(1) } assert_raise(TypeError) { File.expand_path(nil) } assert_raise(TypeError) { File.expand_path(true) } end def test_expand_path_expands_dot_dir assert_equal("#{DRIVE}/dir", File.expand_path("#{DRIVE}/./dir")) end def test_expand_path_does_not_expand_wildcards assert_equal("#{DRIVE}/*", File.expand_path("./*", "#{DRIVE}/")) assert_equal("#{Dir.pwd}/*", File.expand_path("./*", Dir.pwd)) assert_equal("#{DRIVE}/?", File.expand_path("./?", "#{DRIVE}/")) assert_equal("#{Dir.pwd}/?", File.expand_path("./?", Dir.pwd)) end if DRIVE def test_expand_path_does_not_modify_the_string_argument str = "./a/b/../c" assert_equal("#{Dir.pwd}/a/c", File.expand_path(str, Dir.pwd)) assert_equal("./a/b/../c", str) end def test_expand_path_returns_a_string_when_passed_a_string_subclass sub = Class.new(String) str = sub.new "./a/b/../c" path = File.expand_path(str, Dir.pwd) assert_equal("#{Dir.pwd}/a/c", path) assert_instance_of(String, path) end def test_expand_path_accepts_objects_that_have_a_to_path_method klass = Class.new { def to_path; "a/b/c"; end } obj = klass.new assert_equal("#{Dir.pwd}/a/b/c", File.expand_path(obj)) end def test_expand_path_with_drive_letter bug10858 = '[ruby-core:68130] [Bug #10858]' assert_match(%r'/bar/foo\z'i, File.expand_path('z:foo', 'bar'), bug10858) assert_equal('z:/bar/foo', File.expand_path('z:foo', '/bar'), bug10858) end if DRIVE def test_basename assert_equal(File.basename(regular_file).sub(/\.test$/, ""), File.basename(regular_file, ".test")) assert_equal("", s = File.basename("")) assert_not_predicate(s, :frozen?, '[ruby-core:24199]') assert_equal("foo", s = File.basename("foo")) assert_not_predicate(s, :frozen?, '[ruby-core:24199]') assert_equal("foo", File.basename("foo", ".ext")) assert_equal("foo", File.basename("foo.ext", ".ext")) assert_equal("foo", File.basename("foo.ext", ".*")) if NTFS basename = File.basename(regular_file) assert_equal(basename, File.basename(regular_file + " ")) assert_equal(basename, File.basename(regular_file + ".")) assert_equal(basename, File.basename(regular_file + "::$DATA")) basename.chomp!(".test") assert_equal(basename, File.basename(regular_file + " ", ".test")) assert_equal(basename, File.basename(regular_file + ".", ".test")) assert_equal(basename, File.basename(regular_file + "::$DATA", ".test")) assert_equal(basename, File.basename(regular_file + " ", ".*")) assert_equal(basename, File.basename(regular_file + ".", ".*")) assert_equal(basename, File.basename(regular_file + "::$DATA", ".*")) end if File::ALT_SEPARATOR == '\\' a = "foo/\225\\\\" [%W"cp437 \225", %W"cp932 \225\\"].each do |cp, expected| assert_equal(expected.force_encoding(cp), File.basename(a.dup.force_encoding(cp)), cp) end end assert_incompatible_encoding {|d| File.basename(d)} assert_incompatible_encoding {|d| File.basename(d, ".*")} assert_raise(Encoding::CompatibilityError) {File.basename("foo.ext", ".*".encode("utf-16le"))} s = "foo\x93_a".force_encoding("cp932") assert_equal(s, File.basename(s, "_a")) s = "\u4032.\u3024" assert_equal(s, File.basename(s, ".\x95\\".force_encoding("cp932"))) end def test_dirname assert(regular_file.start_with?(File.dirname(regular_file))) assert_equal(".", File.dirname("")) assert_incompatible_encoding {|d| File.dirname(d)} if File::ALT_SEPARATOR == '\\' a = "\225\\\\foo" [%W"cp437 \225", %W"cp932 \225\\"].each do |cp, expected| assert_equal(expected.force_encoding(cp), File.dirname(a.dup.force_encoding(cp)), cp) end end end def test_extname assert_equal(".test", File.extname(regular_file)) prefixes = ["", "/", ".", "/.", "bar/.", "/bar/."] infixes = ["", " ", "."] infixes2 = infixes + [".ext "] appendixes = [""] if NTFS appendixes << " " << "." << "::$DATA" << "::$DATA.bar" end prefixes.each do |prefix| appendixes.each do |appendix| infixes.each do |infix| path = "#{prefix}foo#{infix}#{appendix}" assert_equal("", File.extname(path), "File.extname(#{path.inspect})") end infixes2.each do |infix| path = "#{prefix}foo#{infix}.ext#{appendix}" assert_equal(".ext", File.extname(path), "File.extname(#{path.inspect})") end end end bug3175 = '[ruby-core:29627]' assert_equal(".rb", File.extname("/tmp//bla.rb"), bug3175) assert_incompatible_encoding {|d| File.extname(d)} end def test_split d, b = File.split(regular_file) assert_equal(File.dirname(regular_file), d) assert_equal(File.basename(regular_file), b) end def test_join s = "foo" + File::SEPARATOR + "bar" + File::SEPARATOR + "baz" assert_equal(s, File.join("foo", "bar", "baz")) assert_equal(s, File.join(["foo", "bar", "baz"])) o = Object.new def o.to_path; "foo"; end assert_equal(s, File.join(o, "bar", "baz")) assert_equal(s, File.join("foo" + File::SEPARATOR, "bar", File::SEPARATOR + "baz")) end def test_join_alt_separator if File::ALT_SEPARATOR == '\\' a = "\225\\" b = "foo" [%W"cp437 \225\\foo", %W"cp932 \225\\/foo"].each do |cp, expected| assert_equal(expected.force_encoding(cp), File.join(a.dup.force_encoding(cp), b.dup.force_encoding(cp)), cp) end end end def test_join_ascii_incompatible bug7168 = '[ruby-core:48012]' names = %w"a b".map {|s| s.encode(Encoding::UTF_16LE)} assert_raise(Encoding::CompatibilityError, bug7168) {File.join(*names)} assert_raise(Encoding::CompatibilityError, bug7168) {File.join(names)} a = Object.new b = names[1] names = [a, "b"] a.singleton_class.class_eval do define_method(:to_path) do names[1] = b "a" end end assert_raise(Encoding::CompatibilityError, bug7168) {File.join(names)} end def test_truncate assert_equal(0, File.truncate(regular_file, 1)) assert_file.exist?(regular_file) assert_equal(1, File.size(regular_file)) assert_equal(0, File.truncate(regular_file, 0)) assert_file.exist?(regular_file) assert_file.zero?(regular_file) make_file("foo", regular_file) assert_raise(Errno::ENOENT) { File.truncate(nofile, 0) } f = File.new(regular_file, "w") assert_equal(0, f.truncate(2)) assert_file.exist?(regular_file) assert_equal(2, File.size(regular_file)) assert_equal(0, f.truncate(0)) assert_file.exist?(regular_file) assert_file.zero?(regular_file) f.close make_file("foo", regular_file) assert_raise(IOError) { File.open(regular_file) {|ff| ff.truncate(0)} } rescue NotImplementedError end def test_flock ## xxx f = File.new(regular_file, "r+") f.flock(File::LOCK_EX) f.flock(File::LOCK_SH) f.flock(File::LOCK_UN) f.close rescue NotImplementedError end def test_test fn1 = regular_file hardlinkfile sleep(1.1) fn2 = fn1 + "2" make_file("foo", fn2) [ @dir, fn1, zerofile, notownedfile, suidfile, sgidfile, stickyfile, symlinkfile, hardlinkfile, chardev, blockdev, fifo, socket ].compact.each do |f| assert_equal(File.atime(f), test(?A, f)) assert_equal(File.ctime(f), test(?C, f)) assert_equal(File.mtime(f), test(?M, f)) assert_equal(File.blockdev?(f), test(?b, f)) assert_equal(File.chardev?(f), test(?c, f)) assert_equal(File.directory?(f), test(?d, f)) assert_equal(File.exist?(f), test(?e, f)) assert_equal(File.file?(f), test(?f, f)) assert_equal(File.setgid?(f), test(?g, f)) assert_equal(File.grpowned?(f), test(?G, f)) assert_equal(File.sticky?(f), test(?k, f)) assert_equal(File.symlink?(f), test(?l, f)) assert_equal(File.owned?(f), test(?o, f)) assert_nothing_raised { test(?O, f) } assert_equal(File.pipe?(f), test(?p, f)) assert_equal(File.readable?(f), test(?r, f)) assert_equal(File.readable_real?(f), test(?R, f)) assert_equal(File.size?(f), test(?s, f)) assert_equal(File.socket?(f), test(?S, f)) assert_equal(File.setuid?(f), test(?u, f)) assert_equal(File.writable?(f), test(?w, f)) assert_equal(File.writable_real?(f), test(?W, f)) assert_equal(File.executable?(f), test(?x, f)) assert_equal(File.executable_real?(f), test(?X, f)) assert_equal(File.zero?(f), test(?z, f)) end assert_equal(false, test(?-, @dir, fn1)) assert_equal(true, test(?-, fn1, fn1)) assert_equal(true, test(?=, fn1, fn1)) assert_equal(false, test(?>, fn1, fn1)) assert_equal(false, test(?<, fn1, fn1)) unless /cygwin/ =~ RUBY_PLATFORM assert_equal(false, test(?=, fn1, fn2)) assert_equal(false, test(?>, fn1, fn2)) assert_equal(true, test(?>, fn2, fn1)) assert_equal(true, test(?<, fn1, fn2)) assert_equal(false, test(?<, fn2, fn1)) end assert_raise(ArgumentError) { test } assert_raise(Errno::ENOENT) { test(?A, nofile) } assert_raise(ArgumentError) { test(?a) } assert_raise(ArgumentError) { test("\0".ord) } end def test_stat_init fn1 = regular_file hardlinkfile sleep(1.1) fn2 = fn1 + "2" make_file("foo", fn2) fs1, fs2 = File::Stat.new(fn1), File::Stat.new(fn2) assert_nothing_raised do assert_equal(0, fs1 <=> fs1) assert_equal(-1, fs1 <=> fs2) assert_equal(1, fs2 <=> fs1) assert_nil(fs1 <=> nil) assert_integer(fs1.dev) assert_integer_or_nil(fs1.rdev) assert_integer_or_nil(fs1.dev_major) assert_integer_or_nil(fs1.dev_minor) assert_integer_or_nil(fs1.rdev_major) assert_integer_or_nil(fs1.rdev_minor) assert_integer(fs1.ino) assert_integer(fs1.mode) unless /emx|mswin|mingw/ =~ RUBY_PLATFORM # on Windows, nlink is always 1. but this behavior will be changed # in the future. assert_equal(hardlinkfile ? 2 : 1, fs1.nlink) end assert_integer(fs1.uid) assert_integer(fs1.gid) assert_equal(3, fs1.size) assert_integer_or_nil(fs1.blksize) assert_integer_or_nil(fs1.blocks) assert_kind_of(Time, fs1.atime) assert_kind_of(Time, fs1.mtime) assert_kind_of(Time, fs1.ctime) assert_kind_of(String, fs1.inspect) end assert_raise(Errno::ENOENT) { File::Stat.new(nofile) } assert_kind_of(File::Stat, File::Stat.new(fn1).dup) assert_raise(TypeError) do File::Stat.new(fn1).instance_eval { initialize_copy(0) } end end def test_stat_ftype assert_equal("directory", File::Stat.new(@dir).ftype) assert_equal("file", File::Stat.new(regular_file).ftype) # File::Stat uses stat assert_equal("file", File::Stat.new(symlinkfile).ftype) if symlinkfile assert_equal("file", File::Stat.new(hardlinkfile).ftype) if hardlinkfile end def test_stat_directory_p assert_predicate(File::Stat.new(@dir), :directory?) assert_not_predicate(File::Stat.new(regular_file), :directory?) end def test_stat_pipe_p assert_not_predicate(File::Stat.new(@dir), :pipe?) assert_not_predicate(File::Stat.new(regular_file), :pipe?) assert_predicate(File::Stat.new(fifo), :pipe?) if fifo IO.pipe {|r, w| assert_predicate(r.stat, :pipe?) assert_predicate(w.stat, :pipe?) } end def test_stat_symlink_p assert_not_predicate(File::Stat.new(@dir), :symlink?) assert_not_predicate(File::Stat.new(regular_file), :symlink?) # File::Stat uses stat assert_not_predicate(File::Stat.new(symlinkfile), :symlink?) if symlinkfile assert_not_predicate(File::Stat.new(hardlinkfile), :symlink?) if hardlinkfile end def test_stat_socket_p assert_not_predicate(File::Stat.new(@dir), :socket?) assert_not_predicate(File::Stat.new(regular_file), :socket?) assert_predicate(File::Stat.new(socket), :socket?) if socket end def test_stat_blockdev_p assert_not_predicate(File::Stat.new(@dir), :blockdev?) assert_not_predicate(File::Stat.new(regular_file), :blockdev?) assert_predicate(File::Stat.new(blockdev), :blockdev?) if blockdev end def test_stat_chardev_p assert_not_predicate(File::Stat.new(@dir), :chardev?) assert_not_predicate(File::Stat.new(regular_file), :chardev?) assert_predicate(File::Stat.new(chardev), :chardev?) if chardev end def test_stat_readable_p return if Process.euid == 0 File.chmod(0200, regular_file) assert_not_predicate(File::Stat.new(regular_file), :readable?) File.chmod(0600, regular_file) assert_predicate(File::Stat.new(regular_file), :readable?) end if POSIX def test_stat_readable_real_p return if Process.euid == 0 File.chmod(0200, regular_file) assert_not_predicate(File::Stat.new(regular_file), :readable_real?) File.chmod(0600, regular_file) assert_predicate(File::Stat.new(regular_file), :readable_real?) end if POSIX def test_stat_world_readable_p File.chmod(0006, regular_file) assert_predicate(File::Stat.new(regular_file), :world_readable?) File.chmod(0060, regular_file) assert_not_predicate(File::Stat.new(regular_file), :world_readable?) File.chmod(0600, regular_file) assert_not_predicate(File::Stat.new(regular_file), :world_readable?) end if POSIX def test_stat_writable_p return if Process.euid == 0 File.chmod(0400, regular_file) assert_not_predicate(File::Stat.new(regular_file), :writable?) File.chmod(0600, regular_file) assert_predicate(File::Stat.new(regular_file), :writable?) end if POSIX def test_stat_writable_real_p return if Process.euid == 0 File.chmod(0400, regular_file) assert_not_predicate(File::Stat.new(regular_file), :writable_real?) File.chmod(0600, regular_file) assert_predicate(File::Stat.new(regular_file), :writable_real?) end if POSIX def test_stat_world_writable_p File.chmod(0006, regular_file) assert_predicate(File::Stat.new(regular_file), :world_writable?) File.chmod(0060, regular_file) assert_not_predicate(File::Stat.new(regular_file), :world_writable?) File.chmod(0600, regular_file) assert_not_predicate(File::Stat.new(regular_file), :world_writable?) end if POSIX def test_stat_executable_p File.chmod(0100, regular_file) assert_predicate(File::Stat.new(regular_file), :executable?) File.chmod(0600, regular_file) assert_not_predicate(File::Stat.new(regular_file), :executable?) end if POSIX def test_stat_executable_real_p File.chmod(0100, regular_file) assert_predicate(File::Stat.new(regular_file), :executable_real?) File.chmod(0600, regular_file) assert_not_predicate(File::Stat.new(regular_file), :executable_real?) end if POSIX def test_stat_file_p assert_not_predicate(File::Stat.new(@dir), :file?) assert_predicate(File::Stat.new(regular_file), :file?) end def test_stat_zero_p assert_nothing_raised { File::Stat.new(@dir).zero? } assert_not_predicate(File::Stat.new(regular_file), :zero?) assert_predicate(File::Stat.new(zerofile), :zero?) end def test_stat_size_p assert_nothing_raised { File::Stat.new(@dir).size? } assert_equal(3, File::Stat.new(regular_file).size?) assert_not_predicate(File::Stat.new(zerofile), :size?) end def test_stat_owned_p assert_predicate(File::Stat.new(regular_file), :owned?) assert_not_predicate(File::Stat.new(notownedfile), :owned?) if notownedfile end if POSIX def test_stat_grpowned_p ## xxx assert_predicate(File::Stat.new(regular_file), :grpowned?) end if POSIX def test_stat_suid assert_not_predicate(File::Stat.new(regular_file), :setuid?) assert_predicate(File::Stat.new(suidfile), :setuid?) if suidfile end def test_stat_sgid assert_not_predicate(File::Stat.new(regular_file), :setgid?) assert_predicate(File::Stat.new(sgidfile), :setgid?) if sgidfile end def test_stat_sticky assert_not_predicate(File::Stat.new(regular_file), :sticky?) assert_predicate(File::Stat.new(stickyfile), :sticky?) if stickyfile end def test_stat_size assert_integer(File::Stat.new(@dir).size) assert_equal(3, File::Stat.new(regular_file).size) assert_equal(0, File::Stat.new(zerofile).size) end def test_stat_special_file # test for special files such as pagefile.sys on Windows assert_nothing_raised do Dir::glob("C:/*.sys") {|f| File::Stat.new(f) } end end if DRIVE def test_path_check assert_nothing_raised { ENV["PATH"] } end def test_size assert_equal(3, File.open(regular_file) {|f| f.size }) File.open(regular_file, "a") do |f| f.write("bar") assert_equal(6, f.size) end end def test_absolute_path assert_equal(File.join(Dir.pwd, "~foo"), File.absolute_path("~foo")) dir = File.expand_path("/bar") assert_equal(File.join(dir, "~foo"), File.absolute_path("~foo", dir)) end end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/rubyntlm-0.6.0/spec/lib/net/ntlm/security_buffer_spec.rb
require 'spec_helper' describe Net::NTLM::SecurityBuffer do fields = [ { :name => :length, :class => Net::NTLM::Int16LE, :value => 0, :active => true }, { :name => :allocated, :class => Net::NTLM::Int16LE, :value => 0, :active => true }, { :name => :offset, :class => Net::NTLM::Int32LE, :value => 0, :active => true }, ] it_behaves_like 'a fieldset', fields it_behaves_like 'a field', 'WORKSTATION', true subject(:domain_security_buffer) do Net::NTLM::SecurityBuffer.new({ :value => 'WORKSTATION', :active => true }) end context 'when setting the value directly' do before(:each) do domain_security_buffer.value = 'DOMAIN1' end it 'should change the value' do expect(domain_security_buffer.value).to eq('DOMAIN1') end it 'should adjust the length field to the size of the new value' do expect(domain_security_buffer.length).to eq(7) end it 'should adjust the allocated field to the size of the new value' do expect(domain_security_buffer.allocated).to eq(7) end end context '#data_size' do it 'should return the size of the value if active' do expect(domain_security_buffer.data_size).to eq(11) end it 'should return 0 if inactive' do domain_security_buffer.active = false expect(domain_security_buffer.data_size).to eq(0) end end context '#parse' do it 'should read in a properly formatted string' do # Length of the string is 8 length = "\x08\x00" # Space allocated is 8 allocated = "\x08\x00" # The offset that the actual value begins at is also 8 offset = "\x08\x00\x00\x00" string_to_parse = "#{length}#{allocated}#{offset}FooBarBaz" expect(domain_security_buffer.parse(string_to_parse)).to eq(8) expect(domain_security_buffer.value).to eq('FooBarBa') end end end
arnab0073/idea
.rvm/src/ruby-2.3.0/test/-ext-/string/test_set_len.rb
<filename>.rvm/src/ruby-2.3.0/test/-ext-/string/test_set_len.rb # frozen_string_literal: false require 'test/unit' require "-test-/string" class Test_StrSetLen < Test::Unit::TestCase def setup @s0 = [*"a".."z"].join("").freeze @s1 = Bug::String.new(@s0) end def teardown orig = [*"a".."z"].join("") assert_equal(orig, @s0) end def test_non_shared @s1.modify! assert_equal("abc", @s1.set_len(3)) end def test_shared assert_raise(RuntimeError) { assert_equal("abc", @s1.set_len(3)) } end end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/tk/sample/tkextlib/blt/graph7b.rb
<filename>.rvm/src/ruby-1.9.3-p551/ext/tk/sample/tkextlib/blt/graph7b.rb #!/usr/bin/env ruby require 'tk' require 'tkextlib/blt' length = 250000 graph = Tk::BLT::Graph.new(:title=>"Scatter Plot\n#{length} points") graph.xaxis_configure(:loose=>false, :title=>'X Axis Label') graph.yaxis_configure(:title=>'Y Axis Label') graph.legend_configure(:activerelief=>:sunken, :background=>'') Tk::BLT::Table.add(Tk.root, graph, [0,0], :fill=>:both) x = Array.new(length) y = Array.new(length) (0...length).each{|i| x[i] = rand y[i] = rand } plot = Tk::BLT::PlotComponent::Element.new(graph, :symbol=>:square, :color=>'green4', :fill=>'green2', :linewidth=>0, :outlinewidth=>1, :pixels=>4, :label=>'plot', :xdata=>x, :ydata=>y) Tk.root.minsize(0, 0) #graph.zoom_stack #graph.crosshairs #graph.active_legend #graph.closest_point Tk::BLT.zoom_stack(graph) Tk::BLT.crosshairs(graph) Tk::BLT.active_legend(graph) Tk::BLT.closest_point(graph) Tk::BLT::Busy.hold(graph) Tk.update Tk::BLT::Busy.release(graph) Tk.mainloop
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/fcntl/extconf.rb
require 'mkmf' create_makefile('fcntl')
arnab0073/idea
.rvm/src/ruby-2.3.0/test/openssl/test_ssl.rb
<filename>.rvm/src/ruby-2.3.0/test/openssl/test_ssl.rb # frozen_string_literal: false require_relative "utils" if defined?(OpenSSL::TestUtils) class OpenSSL::TestSSL < OpenSSL::SSLTestCase def test_ctx_setup ctx = OpenSSL::SSL::SSLContext.new assert_equal(ctx.setup, true) assert_equal(ctx.setup, nil) end def test_ctx_setup_invalid m = OpenSSL::SSL::SSLContext::METHODS.first assert_raise_with_message(ArgumentError, /null/) { OpenSSL::SSL::SSLContext.new("#{m}\0") } assert_raise_with_message(ArgumentError, /\u{ff33 ff33 ff2c}/) { OpenSSL::SSL::SSLContext.new("\u{ff33 ff33 ff2c}") } end def test_options_defaults_to_OP_ALL_on ctx = OpenSSL::SSL::SSLContext.new assert_equal(OpenSSL::SSL::OP_ALL, (OpenSSL::SSL::OP_ALL & ctx.options)) end def test_setting_twice ctx = OpenSSL::SSL::SSLContext.new ctx.options = 4 assert_equal 4, (ctx.options & OpenSSL::SSL::OP_ALL) ctx.options = OpenSSL::SSL::OP_ALL assert_equal OpenSSL::SSL::OP_ALL, (ctx.options & OpenSSL::SSL::OP_ALL) end def test_options_setting_nil_means_all ctx = OpenSSL::SSL::SSLContext.new ctx.options = nil assert_equal(OpenSSL::SSL::OP_ALL, (OpenSSL::SSL::OP_ALL & ctx.options)) end def test_setting_options_raises_after_setup ctx = OpenSSL::SSL::SSLContext.new options = ctx.options ctx.setup assert_raise(RuntimeError) do ctx.options = options end end def test_ctx_setup_no_compression ctx = OpenSSL::SSL::SSLContext.new ctx.options = OpenSSL::SSL::OP_ALL | OpenSSL::SSL::OP_NO_COMPRESSION assert_equal(ctx.setup, true) assert_equal(ctx.setup, nil) assert_equal(OpenSSL::SSL::OP_NO_COMPRESSION, ctx.options & OpenSSL::SSL::OP_NO_COMPRESSION) end if defined?(OpenSSL::SSL::OP_NO_COMPRESSION) def test_ctx_setup_with_extra_chain_cert ctx = OpenSSL::SSL::SSLContext.new ctx.extra_chain_cert = [@ca_cert, @cli_cert] assert_equal(ctx.setup, true) assert_equal(ctx.setup, nil) end def test_not_started_session skip "non socket argument of SSLSocket.new is not supported on this platform" if /mswin|mingw/ =~ RUBY_PLATFORM open(__FILE__) do |f| assert_nil OpenSSL::SSL::SSLSocket.new(f).cert end end def test_ssl_gets start_server(OpenSSL::SSL::VERIFY_NONE, true) { |server, port| server_connect(port) { |ssl| ssl.write "abc\n" IO.select [ssl] line = ssl.gets assert_equal "abc\n", line assert_equal Encoding::BINARY, line.encoding } } end def test_ssl_read_nonblock start_server(OpenSSL::SSL::VERIFY_NONE, true) { |server, port| server_connect(port) { |ssl| assert_raise(IO::WaitReadable) { ssl.read_nonblock(100) } ssl.write("abc\n") IO.select [ssl] assert_equal('a', ssl.read_nonblock(1)) assert_equal("bc\n", ssl.read_nonblock(100)) assert_raise(IO::WaitReadable) { ssl.read_nonblock(100) } } } end def test_ssl_sysread_blocking_error start_server(OpenSSL::SSL::VERIFY_NONE, true) { |server, port| server_connect(port) { |ssl| ssl.write("abc\n") assert_raise(TypeError) { ssl.sysread(4, exception: false) } buf = '' assert_raise(ArgumentError) { ssl.sysread(4, buf, exception: false) } assert_equal '', buf assert_equal buf.object_id, ssl.sysread(4, buf).object_id assert_equal "abc\n", buf } } end def test_connect_and_close start_server(OpenSSL::SSL::VERIFY_NONE, true){|server, port| sock = TCPSocket.new("127.0.0.1", port) ssl = OpenSSL::SSL::SSLSocket.new(sock) assert(ssl.connect) ssl.close assert(!sock.closed?) sock.close sock = TCPSocket.new("127.0.0.1", port) ssl = OpenSSL::SSL::SSLSocket.new(sock) ssl.sync_close = true # !! assert(ssl.connect) ssl.close assert(sock.closed?) } end def test_read_and_write start_server(OpenSSL::SSL::VERIFY_NONE, true){|server, port| server_connect(port) { |ssl| # syswrite and sysread ITERATIONS.times{|i| str = "x" * 100 + "\n" ssl.syswrite(str) newstr = '' newstr << ssl.sysread(str.size - newstr.size) until newstr.size == str.size assert_equal(str, newstr) str = "x" * i * 100 + "\n" buf = "" ssl.syswrite(str) assert_equal(buf.object_id, ssl.sysread(str.size, buf).object_id) newstr = buf newstr << ssl.sysread(str.size - newstr.size) until newstr.size == str.size assert_equal(str, newstr) } # puts and gets ITERATIONS.times{ str = "x" * 100 + "\n" ssl.puts(str) assert_equal(str, ssl.gets) str = "x" * 100 ssl.puts(str) assert_equal(str, ssl.gets("\n", 100)) assert_equal("\n", ssl.gets) } # read and write ITERATIONS.times{|i| str = "x" * 100 + "\n" ssl.write(str) assert_equal(str, ssl.read(str.size)) str = "x" * i * 100 + "\n" buf = "" ssl.write(str) assert_equal(buf.object_id, ssl.read(str.size, buf).object_id) assert_equal(str, buf) } } } end def test_copy_stream start_server(OpenSSL::SSL::VERIFY_NONE, true) do |server, port| server_connect(port) do |ssl| IO.pipe do |r, w| str = "hello world\n" w.write(str) IO.copy_stream(r, ssl, str.bytesize) IO.copy_stream(ssl, w, str.bytesize) assert_equal str, r.read(str.bytesize) end end end end def test_client_auth_failure vflag = OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT start_server(vflag, true, :ignore_listener_error => true){|server, port| assert_raise(OpenSSL::SSL::SSLError, Errno::ECONNRESET){ sock = TCPSocket.new("127.0.0.1", port) ssl = OpenSSL::SSL::SSLSocket.new(sock) ssl.sync_close = true begin ssl.connect ensure ssl.close end } } end def test_client_auth_success vflag = OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT start_server(vflag, true){|server, port| ctx = OpenSSL::SSL::SSLContext.new ctx.key = @cli_key ctx.cert = @cli_cert server_connect(port, ctx) { |ssl| ssl.puts("foo") assert_equal("foo\n", ssl.gets) } called = nil ctx = OpenSSL::SSL::SSLContext.new ctx.client_cert_cb = Proc.new{ |sslconn| called = true [@cli_cert, @cli_key] } server_connect(port, ctx) { |ssl| assert(called) ssl.puts("foo") assert_equal("foo\n", ssl.gets) } } end def test_client_ca ctx_proc = Proc.new do |ctx| ctx.client_ca = [@ca_cert] end vflag = OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT start_server(vflag, true, :ctx_proc => ctx_proc){|server, port| ctx = OpenSSL::SSL::SSLContext.new client_ca_from_server = nil ctx.client_cert_cb = Proc.new do |sslconn| client_ca_from_server = sslconn.client_ca [@cli_cert, @cli_key] end server_connect(port, ctx) { |ssl| assert_equal([@ca], client_ca_from_server) } } end def test_read_nonblock_without_session OpenSSL::TestUtils.silent do start_server(OpenSSL::SSL::VERIFY_NONE, false){|server, port| sock = TCPSocket.new("127.0.0.1", port) ssl = OpenSSL::SSL::SSLSocket.new(sock) ssl.sync_close = true assert_equal :wait_readable, ssl.read_nonblock(100, exception: false) ssl.write("abc\n") IO.select [ssl] assert_equal('a', ssl.read_nonblock(1)) assert_equal("bc\n", ssl.read_nonblock(100)) assert_equal :wait_readable, ssl.read_nonblock(100, exception: false) ssl.close } end end def test_starttls OpenSSL::TestUtils.silent do start_server(OpenSSL::SSL::VERIFY_NONE, false){|server, port| sock = TCPSocket.new("127.0.0.1", port) ssl = OpenSSL::SSL::SSLSocket.new(sock) ssl.sync_close = true str = "x" * 1000 + "\n" ITERATIONS.times{ ssl.puts(str) assert_equal(str, ssl.gets) } starttls(ssl) ITERATIONS.times{ ssl.puts(str) assert_equal(str, ssl.gets) } ssl.close } end end def test_parallel GC.start start_server(OpenSSL::SSL::VERIFY_NONE, true){|server, port| ssls = [] 10.times{ sock = TCPSocket.new("127.0.0.1", port) ssl = OpenSSL::SSL::SSLSocket.new(sock) ssl.connect ssl.sync_close = true ssls << ssl } str = "x" * 1000 + "\n" ITERATIONS.times{ ssls.each{|ssl| ssl.puts(str) assert_equal(str, ssl.gets) } } ssls.each{|ssl| ssl.close } } end def test_verify_result start_server(OpenSSL::SSL::VERIFY_NONE, true, :ignore_listener_error => true){|server, port| sock = TCPSocket.new("127.0.0.1", port) ctx = OpenSSL::SSL::SSLContext.new ctx.set_params ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx) ssl.sync_close = true begin assert_raise(OpenSSL::SSL::SSLError){ ssl.connect } assert_equal(OpenSSL::X509::V_ERR_SELF_SIGNED_CERT_IN_CHAIN, ssl.verify_result) ensure ssl.close end } start_server(OpenSSL::SSL::VERIFY_NONE, true){|server, port| sock = TCPSocket.new("127.0.0.1", port) ctx = OpenSSL::SSL::SSLContext.new ctx.set_params( :verify_callback => Proc.new do |preverify_ok, store_ctx| store_ctx.error = OpenSSL::X509::V_OK true end ) ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx) ssl.sync_close = true begin ssl.connect assert_equal(OpenSSL::X509::V_OK, ssl.verify_result) ensure ssl.close end } start_server(OpenSSL::SSL::VERIFY_NONE, true, :ignore_listener_error => true){|server, port| sock = TCPSocket.new("127.0.0.1", port) ctx = OpenSSL::SSL::SSLContext.new ctx.set_params( :verify_callback => Proc.new do |preverify_ok, store_ctx| store_ctx.error = OpenSSL::X509::V_ERR_APPLICATION_VERIFICATION false end ) ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx) ssl.sync_close = true begin assert_raise(OpenSSL::SSL::SSLError){ ssl.connect } assert_equal(OpenSSL::X509::V_ERR_APPLICATION_VERIFICATION, ssl.verify_result) ensure ssl.close end } end def test_exception_in_verify_callback_is_ignored start_server(OpenSSL::SSL::VERIFY_NONE, true, :ignore_listener_error => true){|server, port| sock = TCPSocket.new("127.0.0.1", port) ctx = OpenSSL::SSL::SSLContext.new ctx.set_params( :verify_callback => Proc.new do |preverify_ok, store_ctx| store_ctx.error = OpenSSL::X509::V_OK raise RuntimeError end ) ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx) ssl.sync_close = true begin OpenSSL::TestUtils.silent do # SSLError, not RuntimeError assert_raise(OpenSSL::SSL::SSLError) { ssl.connect } end assert_equal(OpenSSL::X509::V_ERR_CERT_REJECTED, ssl.verify_result) ensure ssl.close end } end def test_sslctx_set_params start_server(OpenSSL::SSL::VERIFY_NONE, true, :ignore_listener_error => true){|server, port| sock = TCPSocket.new("127.0.0.1", port) ctx = OpenSSL::SSL::SSLContext.new ctx.set_params assert_equal(OpenSSL::SSL::VERIFY_PEER, ctx.verify_mode) assert_equal(OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:options], ctx.options) ciphers = ctx.ciphers ciphers_versions = ciphers.collect{|_, v, _, _| v } ciphers_names = ciphers.collect{|v, _, _, _| v } assert(ciphers_names.all?{|v| /ADH/ !~ v }) assert(ciphers_versions.all?{|v| /SSLv2/ !~ v }) ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx) ssl.sync_close = true begin assert_raise(OpenSSL::SSL::SSLError){ ssl.connect } assert_equal(OpenSSL::X509::V_ERR_SELF_SIGNED_CERT_IN_CHAIN, ssl.verify_result) ensure ssl.close end } end def test_post_connect_check_with_anon_ciphers sslerr = OpenSSL::SSL::SSLError start_server(OpenSSL::SSL::VERIFY_NONE, true, {use_anon_cipher: true}){|server, port| ctx = OpenSSL::SSL::SSLContext.new ctx.ciphers = "aNULL" server_connect(port, ctx) { |ssl| msg = "Peer verification enabled, but no certificate received. Anonymous cipher suite " \ "ADH-AES256-GCM-SHA384 was negotiated. Anonymous suites must be disabled to use peer verification." assert_raise_with_message(sslerr,msg){ssl.post_connection_check("localhost.localdomain")} } } end if OpenSSL::ExtConfig::TLS_DH_anon_WITH_AES_256_GCM_SHA384 def test_post_connection_check sslerr = OpenSSL::SSL::SSLError start_server(OpenSSL::SSL::VERIFY_NONE, true){|server, port| server_connect(port) { |ssl| assert_raise(sslerr){ssl.post_connection_check("localhost.localdomain")} assert_raise(sslerr){ssl.post_connection_check("127.0.0.1")} assert(ssl.post_connection_check("localhost")) assert_raise(sslerr){ssl.post_connection_check("foo.example.com")} cert = ssl.peer_cert assert(!OpenSSL::SSL.verify_certificate_identity(cert, "localhost.localdomain")) assert(!OpenSSL::SSL.verify_certificate_identity(cert, "127.0.0.1")) assert(OpenSSL::SSL.verify_certificate_identity(cert, "localhost")) assert(!OpenSSL::SSL.verify_certificate_identity(cert, "foo.example.com")) } } now = Time.now exts = [ ["keyUsage","keyEncipherment,digitalSignature",true], ["subjectAltName","DNS:localhost.localdomain",false], ["subjectAltName","IP:127.0.0.1",false], ] @svr_cert = issue_cert(@svr, @svr_key, 4, now, now+1800, exts, @ca_cert, @ca_key, OpenSSL::Digest::SHA1.new) start_server(OpenSSL::SSL::VERIFY_NONE, true){|server, port| server_connect(port) { |ssl| assert(ssl.post_connection_check("localhost.localdomain")) assert(ssl.post_connection_check("127.0.0.1")) assert_raise(sslerr){ssl.post_connection_check("localhost")} assert_raise(sslerr){ssl.post_connection_check("foo.example.com")} cert = ssl.peer_cert assert(OpenSSL::SSL.verify_certificate_identity(cert, "localhost.localdomain")) assert(OpenSSL::SSL.verify_certificate_identity(cert, "127.0.0.1")) assert(!OpenSSL::SSL.verify_certificate_identity(cert, "localhost")) assert(!OpenSSL::SSL.verify_certificate_identity(cert, "foo.example.com")) } } now = Time.now exts = [ ["keyUsage","keyEncipherment,digitalSignature",true], ["subjectAltName","DNS:*.localdomain",false], ] @svr_cert = issue_cert(@svr, @svr_key, 5, now, now+1800, exts, @ca_cert, @ca_key, OpenSSL::Digest::SHA1.new) start_server(OpenSSL::SSL::VERIFY_NONE, true){|server, port| server_connect(port) { |ssl| assert(ssl.post_connection_check("localhost.localdomain")) assert_raise(sslerr){ssl.post_connection_check("127.0.0.1")} assert_raise(sslerr){ssl.post_connection_check("localhost")} assert_raise(sslerr){ssl.post_connection_check("foo.example.com")} cert = ssl.peer_cert assert(OpenSSL::SSL.verify_certificate_identity(cert, "localhost.localdomain")) assert(!OpenSSL::SSL.verify_certificate_identity(cert, "127.0.0.1")) assert(!OpenSSL::SSL.verify_certificate_identity(cert, "localhost")) assert(!OpenSSL::SSL.verify_certificate_identity(cert, "foo.example.com")) } } end def test_verify_certificate_identity [true, false].each do |criticality| cert = create_null_byte_SAN_certificate(criticality) assert_equal(false, OpenSSL::SSL.verify_certificate_identity(cert, 'www.example.com')) assert_equal(true, OpenSSL::SSL.verify_certificate_identity(cert, "www.example.com\0.evil.com")) assert_equal(false, OpenSSL::SSL.verify_certificate_identity(cert, '192.168.7.255')) assert_equal(true, OpenSSL::SSL.verify_certificate_identity(cert, '192.168.7.1')) assert_equal(false, OpenSSL::SSL.verify_certificate_identity(cert, 'fdf8:f53e:61e4::18')) assert_equal(true, OpenSSL::SSL.verify_certificate_identity(cert, 'fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b')) end end def test_verify_hostname assert_equal(true, OpenSSL::SSL.verify_hostname("www.example.com", "*.example.com")) assert_equal(false, OpenSSL::SSL.verify_hostname("www.subdomain.example.com", "*.example.com")) end def test_verify_wildcard assert_equal(false, OpenSSL::SSL.verify_wildcard("foo", "x*")) assert_equal(true, OpenSSL::SSL.verify_wildcard("foo", "foo")) assert_equal(true, OpenSSL::SSL.verify_wildcard("foo", "f*")) assert_equal(true, OpenSSL::SSL.verify_wildcard("foo", "*")) assert_equal(false, OpenSSL::SSL.verify_wildcard("abc*bcd", "abcd")) assert_equal(false, OpenSSL::SSL.verify_wildcard("xn--qdk4b9b", "x*")) assert_equal(false, OpenSSL::SSL.verify_wildcard("xn--qdk4b9b", "*--qdk4b9b")) assert_equal(true, OpenSSL::SSL.verify_wildcard("xn--qdk4b9b", "xn--qdk4b9b")) end # Comments in this test is excerpted from http://tools.ietf.org/html/rfc6125#page-27 def test_post_connection_check_wildcard_san # case-insensitive ASCII comparison # RFC 6125, section 6.4.1 # # "..matching of the reference identifier against the presented identifier # is performed by comparing the set of domain name labels using a # case-insensitive ASCII comparison, as clarified by [DNS-CASE] (e.g., # "WWW.Example.Com" would be lower-cased to "www.example.com" for # comparison purposes) assert_equal(true, OpenSSL::SSL.verify_certificate_identity( create_cert_with_san('DNS:*.example.com'), 'www.example.com')) assert_equal(true, OpenSSL::SSL.verify_certificate_identity( create_cert_with_san('DNS:*.Example.COM'), 'www.example.com')) assert_equal(true, OpenSSL::SSL.verify_certificate_identity( create_cert_with_san('DNS:*.example.com'), 'WWW.Example.COM')) # 1. The client SHOULD NOT attempt to match a presented identifier in # which the wildcard character comprises a label other than the # left-most label (e.g., do not match bar.*.example.net). assert_equal(false, OpenSSL::SSL.verify_certificate_identity( create_cert_with_san('DNS:www.*.com'), 'www.example.com')) # 2. If the wildcard character is the only character of the left-most # label in the presented identifier, the client SHOULD NOT compare # against anything but the left-most label of the reference # identifier (e.g., *.example.com would match foo.example.com but # not bar.foo.example.com or example.com). assert_equal(true, OpenSSL::SSL.verify_certificate_identity( create_cert_with_san('DNS:*.example.com'), 'foo.example.com')) assert_equal(false, OpenSSL::SSL.verify_certificate_identity( create_cert_with_san('DNS:*.example.com'), 'bar.foo.example.com')) # 3. The client MAY match a presented identifier in which the wildcard # character is not the only character of the label (e.g., # baz*.example.net and *baz.example.net and b*z.example.net would # be taken to match baz1.example.net and foobaz.example.net and # buzz.example.net, respectively). ... assert_equal(true, OpenSSL::SSL.verify_certificate_identity( create_cert_with_san('DNS:baz*.example.com'), 'baz1.example.com')) assert_equal(true, OpenSSL::SSL.verify_certificate_identity( create_cert_with_san('DNS:*baz.example.com'), 'foobaz.example.com')) assert_equal(true, OpenSSL::SSL.verify_certificate_identity( create_cert_with_san('DNS:b*z.example.com'), 'buzz.example.com')) # Section 6.4.3 of RFC6125 states that client should NOT match identifier # where wildcard is other than left-most label. # # Also implicitly mentions the wildcard character only in singular form, # and discourages matching against more than one wildcard. # # See RFC 6125, section 7.2, subitem 2. assert_equal(false, OpenSSL::SSL.verify_certificate_identity( create_cert_with_san('DNS:*b*.example.com'), 'abc.example.com')) assert_equal(false, OpenSSL::SSL.verify_certificate_identity( create_cert_with_san('DNS:*b*.example.com'), 'ab.example.com')) assert_equal(false, OpenSSL::SSL.verify_certificate_identity( create_cert_with_san('DNS:*b*.example.com'), 'bc.example.com')) # ... However, the client SHOULD NOT # attempt to match a presented identifier where the wildcard # character is embedded within an A-label or U-label [IDNA-DEFS] of # an internationalized domain name [IDNA-PROTO]. assert_equal(true, OpenSSL::SSL.verify_certificate_identity( create_cert_with_san('DNS:xn*.example.com'), 'xn1ca.example.com')) # part of A-label assert_equal(false, OpenSSL::SSL.verify_certificate_identity( create_cert_with_san('DNS:xn--*.example.com'), 'xn--1ca.example.com')) # part of U-label # dNSName in RFC5280 is an IA5String so U-label should NOT be allowed # regardless of wildcard. # # See Section 7.2 of RFC 5280: # IA5String is limited to the set of ASCII characters. assert_equal(false, OpenSSL::SSL.verify_certificate_identity( create_cert_with_san('DNS:á*.example.com'), 'á1.example.com')) end def test_post_connection_check_wildcard_cn assert_equal(true, OpenSSL::SSL.verify_certificate_identity( create_cert_with_name('*.example.com'), 'www.example.com')) assert_equal(true, OpenSSL::SSL.verify_certificate_identity( create_cert_with_name('*.Example.COM'), 'www.example.com')) assert_equal(true, OpenSSL::SSL.verify_certificate_identity( create_cert_with_name('*.example.com'), 'WWW.Example.COM')) assert_equal(false, OpenSSL::SSL.verify_certificate_identity( create_cert_with_name('www.*.com'), 'www.example.com')) assert_equal(true, OpenSSL::SSL.verify_certificate_identity( create_cert_with_name('*.example.com'), 'foo.example.com')) assert_equal(false, OpenSSL::SSL.verify_certificate_identity( create_cert_with_name('*.example.com'), 'bar.foo.example.com')) assert_equal(true, OpenSSL::SSL.verify_certificate_identity( create_cert_with_name('baz*.example.com'), 'baz1.example.com')) assert_equal(true, OpenSSL::SSL.verify_certificate_identity( create_cert_with_name('*baz.example.com'), 'foobaz.example.com')) assert_equal(true, OpenSSL::SSL.verify_certificate_identity( create_cert_with_name('b*z.example.com'), 'buzz.example.com')) # Section 6.4.3 of RFC6125 states that client should NOT match identifier # where wildcard is other than left-most label. # # Also implicitly mentions the wildcard character only in singular form, # and discourages matching against more than one wildcard. # # See RFC 6125, section 7.2, subitem 2. assert_equal(false, OpenSSL::SSL.verify_certificate_identity( create_cert_with_name('*b*.example.com'), 'abc.example.com')) assert_equal(false, OpenSSL::SSL.verify_certificate_identity( create_cert_with_name('*b*.example.com'), 'ab.example.com')) assert_equal(false, OpenSSL::SSL.verify_certificate_identity( create_cert_with_name('*b*.example.com'), 'bc.example.com')) assert_equal(true, OpenSSL::SSL.verify_certificate_identity( create_cert_with_name('xn*.example.com'), 'xn1ca.example.com')) assert_equal(false, OpenSSL::SSL.verify_certificate_identity( create_cert_with_name('xn--*.example.com'), 'xn--1ca.example.com')) # part of U-label # Subject in RFC5280 states case-insensitive ASCII comparison. # # See Section 7.2 of RFC 5280: # IA5String is limited to the set of ASCII characters. assert_equal(false, OpenSSL::SSL.verify_certificate_identity( create_cert_with_name('á*.example.com'), 'á1.example.com')) end def create_cert_with_san(san) ef = OpenSSL::X509::ExtensionFactory.new cert = OpenSSL::X509::Certificate.new cert.subject = OpenSSL::X509::Name.parse("/DC=some/DC=site/CN=Some Site") ext = ef.create_ext('subjectAltName', san) cert.add_extension(ext) cert end def create_cert_with_name(name) cert = OpenSSL::X509::Certificate.new cert.subject = OpenSSL::X509::Name.new([['DC', 'some'], ['DC', 'site'], ['CN', name]]) cert end # Create NULL byte SAN certificate def create_null_byte_SAN_certificate(critical = false) ef = OpenSSL::X509::ExtensionFactory.new cert = OpenSSL::X509::Certificate.new cert.subject = OpenSSL::X509::Name.parse "/DC=some/DC=site/CN=Some Site" ext = ef.create_ext('subjectAltName', 'DNS:placeholder,IP:192.168.7.1,IP:fdf8:f53e:61e4::18', critical) ext_asn1 = OpenSSL::ASN1.decode(ext.to_der) san_list_der = ext_asn1.value.reduce(nil) { |memo,val| val.tag == 4 ? val.value : memo } san_list_asn1 = OpenSSL::ASN1.decode(san_list_der) san_list_asn1.value[0].value = "www.example.com\0.evil.com" pos = critical ? 2 : 1 ext_asn1.value[pos].value = san_list_asn1.to_der real_ext = OpenSSL::X509::Extension.new ext_asn1 cert.add_extension(real_ext) cert end def socketpair if defined? UNIXSocket UNIXSocket.pair else Socket.pair(Socket::AF_INET, Socket::SOCK_STREAM, 0) end end def test_servername_cb_sets_context_on_the_socket hostname = 'example.org' ctx3 = OpenSSL::SSL::SSLContext.new ctx3.ciphers = "DH" ctx2 = OpenSSL::SSL::SSLContext.new ctx2.ciphers = "DH" ctx2.servername_cb = lambda { |args| ctx3 } sock1, sock2 = socketpair s2 = OpenSSL::SSL::SSLSocket.new(sock2, ctx2) ctx1 = OpenSSL::SSL::SSLContext.new ctx1.ciphers = "DH" s1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx1) s1.hostname = hostname t = Thread.new { s1.connect } assert_equal ctx2, s2.context accepted = s2.accept assert_equal ctx3, s2.context assert t.value ensure s1.close if s1 s2.close if s2 sock1.close if sock1 sock2.close if sock2 accepted.close if accepted.respond_to?(:close) end def test_servername_cb_raises_an_exception_on_unknown_objects hostname = 'example.org' ctx2 = OpenSSL::SSL::SSLContext.new ctx2.ciphers = "DH" ctx2.servername_cb = lambda { |args| Object.new } sock1, sock2 = socketpair s2 = OpenSSL::SSL::SSLSocket.new(sock2, ctx2) ctx1 = OpenSSL::SSL::SSLContext.new ctx1.ciphers = "DH" s1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx1) s1.hostname = hostname t = Thread.new { assert_raise(OpenSSL::SSL::SSLError) do s1.connect end } assert_raise(ArgumentError) do s2.accept end assert t.join ensure sock1.close if sock1 sock2.close if sock2 end def test_servername_cb_calls_setup_on_returned_ctx hostname = 'example.org' ctx3 = OpenSSL::SSL::SSLContext.new ctx3.ciphers = "DH" refute_predicate ctx3, :frozen? ctx2 = OpenSSL::SSL::SSLContext.new ctx2.ciphers = "DH" ctx2.servername_cb = lambda { |args| ctx3 } sock1, sock2 = socketpair s2 = OpenSSL::SSL::SSLSocket.new(sock2, ctx2) ctx1 = OpenSSL::SSL::SSLContext.new ctx1.ciphers = "DH" s1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx1) s1.hostname = hostname t = Thread.new { s1.connect } accepted = s2.accept assert t.value assert_predicate ctx3, :frozen? ensure s1.close if s1 s2.close if s2 sock1.close if sock1 sock2.close if sock2 accepted.close if accepted.respond_to?(:close) end def test_servername_cb_can_return_nil hostname = 'example.org' ctx2 = OpenSSL::SSL::SSLContext.new ctx2.ciphers = "DH" ctx2.servername_cb = lambda { |args| nil } sock1, sock2 = socketpair s2 = OpenSSL::SSL::SSLSocket.new(sock2, ctx2) ctx1 = OpenSSL::SSL::SSLContext.new ctx1.ciphers = "DH" s1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx1) s1.hostname = hostname t = Thread.new { s1.connect } accepted = s2.accept assert t.value ensure s1.close if s1 s2.close if s2 sock1.close if sock1 sock2.close if sock2 accepted.close if accepted.respond_to?(:close) end def test_servername_cb lambda_called = nil cb_socket = nil hostname = 'example.org' ctx2 = OpenSSL::SSL::SSLContext.new ctx2.ciphers = "DH" ctx2.servername_cb = lambda do |args| cb_socket = args[0] lambda_called = args[1] ctx2 end sock1, sock2 = socketpair s2 = OpenSSL::SSL::SSLSocket.new(sock2, ctx2) ctx1 = OpenSSL::SSL::SSLContext.new ctx1.ciphers = "DH" s1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx1) s1.hostname = hostname t = Thread.new { s1.connect } accepted = s2.accept assert t.value assert_equal hostname, lambda_called assert_equal s2, cb_socket ensure s1.close if s1 s2.close if s2 sock1.close if sock1 sock2.close if sock2 accepted.close if accepted.respond_to?(:close) end def test_tlsext_hostname return unless OpenSSL::SSL::SSLSocket.instance_methods.include?(:hostname) ctx_proc = Proc.new do |ctx, ssl| foo_ctx = ctx.dup ctx.servername_cb = Proc.new do |ssl2, hostname| case hostname when 'foo.example.com' foo_ctx when 'bar.example.com' nil else raise "unknown hostname #{hostname.inspect}" end end end server_proc = Proc.new do |ctx, ssl| readwrite_loop(ctx, ssl) end start_server(OpenSSL::SSL::VERIFY_NONE, true, :ctx_proc => ctx_proc, :server_proc => server_proc) do |server, port| 2.times do |i| ctx = OpenSSL::SSL::SSLContext.new if defined?(OpenSSL::SSL::OP_NO_TICKET) # disable RFC4507 support ctx.options = OpenSSL::SSL::OP_NO_TICKET end server_connect(port, ctx) { |ssl| ssl.hostname = (i & 1 == 0) ? 'foo.example.com' : 'bar.example.com' str = "x" * 100 + "\n" ssl.puts(str) assert_equal(str, ssl.gets) } end end end def test_multibyte_read_write #German a umlaut auml = [%w{ C3 A4 }.join('')].pack('H*') auml.force_encoding(Encoding::UTF_8) [10, 1000, 100000].each {|i| str = nil num_written = nil server_proc = Proc.new {|ctx, ssl| cmp = ssl.read raw_size = cmp.size cmp.force_encoding(Encoding::UTF_8) assert_equal(str, cmp) assert_equal(num_written, raw_size) ssl.close } start_server(OpenSSL::SSL::VERIFY_NONE, true, :server_proc => server_proc){|server, port| server_connect(port) { |ssl| str = auml * i num_written = ssl.write(str) } } } end def test_unset_OP_ALL ctx_proc = Proc.new { |ctx| # If OP_DONT_INSERT_EMPTY_FRAGMENTS is not defined, this test is # redundant because the default options already are equal to OP_ALL. # But it also degrades gracefully, so keep it ctx.options = OpenSSL::SSL::OP_ALL } start_server(OpenSSL::SSL::VERIFY_NONE, true, :ctx_proc => ctx_proc){|server, port| server_connect(port) { |ssl| ssl.puts('hello') assert_equal("hello\n", ssl.gets) } } end # different OpenSSL versions react differently when facing a SSL/TLS version # that has been marked as forbidden, therefore either of these may be raised HANDSHAKE_ERRORS = [OpenSSL::SSL::SSLError, Errno::ECONNRESET] if OpenSSL::SSL::SSLContext::METHODS.include?(:TLSv1) && OpenSSL::SSL::SSLContext::METHODS.include?(:SSLv3) def test_forbid_ssl_v3_for_client ctx_proc = Proc.new { |ctx| ctx.options = OpenSSL::SSL::OP_ALL | OpenSSL::SSL::OP_NO_SSLv3 } start_server_version(:SSLv23, ctx_proc) { |server, port| ctx = OpenSSL::SSL::SSLContext.new ctx.ssl_version = :SSLv3 assert_raise(*HANDSHAKE_ERRORS) { server_connect(port, ctx) } } end def test_forbid_ssl_v3_from_server start_server_version(:SSLv3) { |server, port| ctx = OpenSSL::SSL::SSLContext.new ctx.options = OpenSSL::SSL::OP_ALL | OpenSSL::SSL::OP_NO_SSLv3 assert_raise(*HANDSHAKE_ERRORS) { server_connect(port, ctx) } } end end if OpenSSL::SSL::SSLContext::METHODS.include? :TLSv1_1 def test_tls_v1_1 start_server_version(:TLSv1_1) { |server, port| server_connect(port) { |ssl| assert_equal("TLSv1.1", ssl.ssl_version) } } end def test_forbid_tls_v1_for_client ctx_proc = Proc.new { |ctx| ctx.options = OpenSSL::SSL::OP_ALL | OpenSSL::SSL::OP_NO_TLSv1 } start_server_version(:SSLv23, ctx_proc) { |server, port| ctx = OpenSSL::SSL::SSLContext.new ctx.ssl_version = :TLSv1 assert_raise(*HANDSHAKE_ERRORS) { server_connect(port, ctx) } } end def test_forbid_tls_v1_from_server start_server_version(:TLSv1) { |server, port| ctx = OpenSSL::SSL::SSLContext.new ctx.options = OpenSSL::SSL::OP_ALL | OpenSSL::SSL::OP_NO_TLSv1 assert_raise(*HANDSHAKE_ERRORS) { server_connect(port, ctx) } } end end if OpenSSL::SSL::SSLContext::METHODS.include? :TLSv1_2 def test_tls_v1_2 start_server_version(:TLSv1_2) { |server, port| ctx = OpenSSL::SSL::SSLContext.new ctx.ssl_version = :TLSv1_2_client server_connect(port, ctx) { |ssl| assert_equal("TLSv1.2", ssl.ssl_version) } } end if OpenSSL::OPENSSL_VERSION_NUMBER > 0x10001000 def test_forbid_tls_v1_1_for_client ctx_proc = Proc.new { |ctx| ctx.options = OpenSSL::SSL::OP_ALL | OpenSSL::SSL::OP_NO_TLSv1_1 } start_server_version(:SSLv23, ctx_proc) { |server, port| ctx = OpenSSL::SSL::SSLContext.new ctx.ssl_version = :TLSv1_1 assert_raise(*HANDSHAKE_ERRORS) { server_connect(port, ctx) } } end if defined?(OpenSSL::SSL::OP_NO_TLSv1_1) def test_forbid_tls_v1_1_from_server start_server_version(:TLSv1_1) { |server, port| ctx = OpenSSL::SSL::SSLContext.new ctx.options = OpenSSL::SSL::OP_ALL | OpenSSL::SSL::OP_NO_TLSv1_1 assert_raise(*HANDSHAKE_ERRORS) { server_connect(port, ctx) } } end if defined?(OpenSSL::SSL::OP_NO_TLSv1_1) def test_forbid_tls_v1_2_for_client ctx_proc = Proc.new { |ctx| ctx.options = OpenSSL::SSL::OP_ALL | OpenSSL::SSL::OP_NO_TLSv1_2 } start_server_version(:SSLv23, ctx_proc) { |server, port| ctx = OpenSSL::SSL::SSLContext.new ctx.ssl_version = :TLSv1_2 assert_raise(*HANDSHAKE_ERRORS) { server_connect(port, ctx) } } end if defined?(OpenSSL::SSL::OP_NO_TLSv1_2) def test_forbid_tls_v1_2_from_server start_server_version(:TLSv1_2) { |server, port| ctx = OpenSSL::SSL::SSLContext.new ctx.options = OpenSSL::SSL::OP_ALL | OpenSSL::SSL::OP_NO_TLSv1_2 assert_raise(*HANDSHAKE_ERRORS) { server_connect(port, ctx) } } end if defined?(OpenSSL::SSL::OP_NO_TLSv1_2) end def test_renegotiation_cb num_handshakes = 0 renegotiation_cb = Proc.new { |ssl| num_handshakes += 1 } ctx_proc = Proc.new { |ctx| ctx.renegotiation_cb = renegotiation_cb } start_server_version(:SSLv23, ctx_proc) { |server, port| server_connect(port) { |ssl| assert_equal(1, num_handshakes) } } end if OpenSSL::OPENSSL_VERSION_NUMBER >= 0x10002000 def test_alpn_protocol_selection_ary advertised = ["http/1.1", "spdy/2"] ctx_proc = Proc.new { |ctx| ctx.alpn_select_cb = -> (protocols) { protocols.first } ctx.alpn_protocols = advertised } start_server_version(:SSLv23, ctx_proc) { |server, port| ctx = OpenSSL::SSL::SSLContext.new ctx.alpn_protocols = advertised server_connect(port, ctx) { |ssl| assert_equal(advertised.first, ssl.alpn_protocol) } } end def test_alpn_protocol_selection_cancel ctx_proc = Proc.new { |ctx| ctx.alpn_select_cb = -> (protocols) { nil } } assert_raise(MiniTest::Assertion) do # minitest/assertion comes from `assert_join_threads` start_server_version(:SSLv23, ctx_proc) { |server, port| ctx = OpenSSL::SSL::SSLContext.new ctx.alpn_protocols = ["http/1.1"] assert_raise(OpenSSL::SSL::SSLError) { server_connect(port, ctx) } } end end end if OpenSSL::OPENSSL_VERSION_NUMBER > 0x10001000 def test_npn_protocol_selection_ary advertised = ["http/1.1", "spdy/2"] ctx_proc = Proc.new { |ctx| ctx.npn_protocols = advertised } start_server_version(:SSLv23, ctx_proc) { |server, port| selector = lambda { |which| ctx = OpenSSL::SSL::SSLContext.new ctx.npn_select_cb = -> (protocols) { protocols.send(which) } server_connect(port, ctx) { |ssl| assert_equal(advertised.send(which), ssl.npn_protocol) } } selector.call(:first) selector.call(:last) } end def test_npn_protocol_selection_enum advertised = Object.new def advertised.each yield "http/1.1" yield "spdy/2" end ctx_proc = Proc.new { |ctx| ctx.npn_protocols = advertised } start_server_version(:SSLv23, ctx_proc) { |server, port| selector = lambda { |selected, which| ctx = OpenSSL::SSL::SSLContext.new ctx.npn_select_cb = -> (protocols) { protocols.to_a.send(which) } server_connect(port, ctx) { |ssl| assert_equal(selected, ssl.npn_protocol) } } selector.call("http/1.1", :first) selector.call("spdy/2", :last) } end def test_npn_protocol_selection_cancel ctx_proc = Proc.new { |ctx| ctx.npn_protocols = ["http/1.1"] } start_server_version(:SSLv23, ctx_proc) { |server, port| ctx = OpenSSL::SSL::SSLContext.new ctx.npn_select_cb = -> (protocols) { raise RuntimeError.new } assert_raise(RuntimeError) { server_connect(port, ctx) } } end def test_npn_advertised_protocol_too_long ctx_proc = Proc.new { |ctx| ctx.npn_protocols = ["a" * 256] } start_server_version(:SSLv23, ctx_proc) { |server, port| ctx = OpenSSL::SSL::SSLContext.new ctx.npn_select_cb = -> (protocols) { protocols.first } assert_raise(*HANDSHAKE_ERRORS) { server_connect(port, ctx) } } end def test_npn_selected_protocol_too_long ctx_proc = Proc.new { |ctx| ctx.npn_protocols = ["http/1.1"] } start_server_version(:SSLv23, ctx_proc) { |server, port| ctx = OpenSSL::SSL::SSLContext.new ctx.npn_select_cb = -> (protocols) { "a" * 256 } assert_raise(*HANDSHAKE_ERRORS) { server_connect(port, ctx) } } end end def test_invalid_shutdown_by_gc assert_nothing_raised { start_server(OpenSSL::SSL::VERIFY_NONE, true){|server, port| 10.times { sock = TCPSocket.new("127.0.0.1", port) ssl = OpenSSL::SSL::SSLSocket.new(sock) GC.start ssl.connect sock.close } } } end def test_close_after_socket_close start_server(OpenSSL::SSL::VERIFY_NONE, true){|server, port| sock = TCPSocket.new("127.0.0.1", port) ssl = OpenSSL::SSL::SSLSocket.new(sock) ssl.sync_close = true ssl.connect sock.close assert_nothing_raised do ssl.close end } end def test_sync_close_without_connect Socket.open(:INET, :STREAM) {|s| ssl = OpenSSL::SSL::SSLSocket.new(s) ssl.sync_close = true ssl.close assert(s.closed?) } end private def start_server_version(version, ctx_proc=nil, server_proc=nil, &blk) ctx_wrap = Proc.new { |ctx| ctx.ssl_version = version ctx_proc.call(ctx) if ctx_proc } start_server( OpenSSL::SSL::VERIFY_NONE, true, :ctx_proc => ctx_wrap, :server_proc => server_proc, :ignore_listener_error => true, &blk ) end def server_connect(port, ctx=nil) sock = TCPSocket.new("127.0.0.1", port) ssl = ctx ? OpenSSL::SSL::SSLSocket.new(sock, ctx) : OpenSSL::SSL::SSLSocket.new(sock) ssl.sync_close = true ssl.connect yield ssl if block_given? ensure if ssl ssl.close elsif sock sock.close end end end end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/tk/sample/tkextlib/iwidgets/sample/dialog.rb
<reponame>arnab0073/idea #!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' Thread.new{Tk.mainloop} d = Tk::Iwidgets::Dialog.new(:modality=>:application) d.buttonconfigure('OK', :command=>proc{puts 'OK'; d.deactivate true}) d.buttonconfigure('Apply', :command=>proc{puts 'Apply'}) d.buttonconfigure('Cancel', :command=>proc{puts 'Cancel'; d.deactivate false}) d.buttonconfigure('Help', :command=>proc{puts 'Help'}) TkListbox.new(d.child_site, :relief=>:sunken).pack(:expand=>true, :fill=>:both) if TkComm.bool(d.activate) puts "Exit via OK button" else puts "Exit via Cancel button" end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/fog-1.29.0/lib/fog/openstack/models/planning/plans.rb
require 'fog/core/collection' require 'fog/openstack/models/planning/plan' module Fog module Openstack class Planning class Plans < Fog::Collection model Fog::Openstack::Planning::Plan def all load(service.list_plans.body) end def find_by_uuid(plan_uuid) new(service.get_plan(plan_uuid).body) end alias_method :get, :find_by_uuid def method_missing(method_sym, *arguments, &block) if method_sym.to_s =~ /^find_by_(.*)$/ self.all.find do |plan| plan.send($1) == arguments.first end else super end end end end end end
arnab0073/idea
.rvm/src/ruby-2.3.0/test/rubygems/test_gem_package.rb
<reponame>arnab0073/idea # coding: UTF-8 # frozen_string_literal: false require 'rubygems/package/tar_test_case' require 'rubygems/simple_gem' class TestGemPackage < Gem::Package::TarTestCase def setup super @spec = quick_gem 'a' do |s| s.description = 'π' s.files = %w[lib/code.rb] end util_build_gem @spec @gem = @spec.cache_file @destination = File.join @tempdir, 'extract' FileUtils.mkdir_p @destination end def test_class_new_old_format open 'old_format.gem', 'wb' do |io| io.write SIMPLE_GEM end package = Gem::Package.new 'old_format.gem' assert package.spec end def test_add_checksums gem_io = StringIO.new spec = Gem::Specification.new 'build', '1' spec.summary = 'build' spec.authors = 'build' spec.files = ['lib/code.rb'] spec.date = Time.at 0 spec.rubygems_version = Gem::Version.new '0' FileUtils.mkdir 'lib' open 'lib/code.rb', 'w' do |io| io.write '# lib/code.rb' end package = Gem::Package.new spec.file_name package.spec = spec package.build_time = 1 # 0 uses current time package.setup_signer Gem::Package::TarWriter.new gem_io do |gem| package.add_metadata gem package.add_contents gem package.add_checksums gem end gem_io.rewind reader = Gem::Package::TarReader.new gem_io checksums = nil tar = nil reader.each_entry do |entry| case entry.full_name when 'checksums.yaml.gz' then Zlib::GzipReader.wrap entry do |io| checksums = io.read end when 'data.tar.gz' then tar = entry.read end end s = StringIO.new package.gzip_to s do |io| io.write spec.to_yaml end metadata_sha1 = Digest::SHA1.hexdigest s.string metadata_sha512 = Digest::SHA512.hexdigest s.string expected = { 'SHA512' => { 'metadata.gz' => metadata_sha512, 'data.tar.gz' => Digest::SHA512.hexdigest(tar), } } if defined?(OpenSSL::Digest) then expected['SHA1'] = { 'metadata.gz' => metadata_sha1, 'data.tar.gz' => Digest::SHA1.hexdigest(tar), } end assert_equal expected, YAML.load(checksums) end def test_add_files spec = Gem::Specification.new spec.files = %w[lib/code.rb lib/empty] FileUtils.mkdir_p 'lib/empty' open 'lib/code.rb', 'w' do |io| io.write '# lib/code.rb' end open 'lib/extra.rb', 'w' do |io| io.write '# lib/extra.rb' end package = Gem::Package.new 'bogus.gem' package.spec = spec tar = util_tar do |tar_io| package.add_files tar_io end tar.rewind files = [] Gem::Package::TarReader.new tar do |tar_io| tar_io.each_entry do |entry| files << entry.full_name end end assert_equal %w[lib/code.rb], files end def test_add_files_symlink skip 'symlink not supported' if Gem.win_platform? spec = Gem::Specification.new spec.files = %w[lib/code.rb lib/code_sym.rb] FileUtils.mkdir_p 'lib' open 'lib/code.rb', 'w' do |io| io.write '# lib/code.rb' end File.symlink('lib/code.rb', 'lib/code_sym.rb') package = Gem::Package.new 'bogus.gem' package.spec = spec tar = util_tar do |tar_io| package.add_files tar_io end tar.rewind files, symlinks = [], [] Gem::Package::TarReader.new tar do |tar_io| tar_io.each_entry do |entry| (entry.symlink? ? symlinks : files) << entry.full_name end end assert_equal %w[lib/code.rb], files assert_equal %w[lib/code_sym.rb], symlinks end def test_build spec = Gem::Specification.new 'build', '1' spec.summary = 'build' spec.authors = 'build' spec.files = ['lib/code.rb'] spec.rubygems_version = :junk FileUtils.mkdir 'lib' open 'lib/code.rb', 'w' do |io| io.write '# lib/code.rb' end package = Gem::Package.new spec.file_name package.spec = spec package.build assert_equal Gem::VERSION, spec.rubygems_version assert_path_exists spec.file_name reader = Gem::Package.new spec.file_name assert_equal spec, reader.spec assert_equal %w[metadata.gz data.tar.gz checksums.yaml.gz], reader.files assert_equal %w[lib/code.rb], reader.contents end def test_build_auto_signed skip 'openssl is missing' unless defined?(OpenSSL::SSL) FileUtils.mkdir_p File.join(Gem.user_home, '.gem') private_key_path = File.join Gem.user_home, '.gem', 'gem-private_key.pem' Gem::Security.write PRIVATE_KEY, private_key_path public_cert_path = File.join Gem.user_home, '.gem', 'gem-public_cert.pem' FileUtils.cp PUBLIC_CERT_PATH, public_cert_path spec = Gem::Specification.new 'build', '1' spec.summary = 'build' spec.authors = 'build' spec.files = ['lib/code.rb'] FileUtils.mkdir 'lib' open 'lib/code.rb', 'w' do |io| io.write '# lib/code.rb' end package = Gem::Package.new spec.file_name package.spec = spec package.build assert_equal Gem::VERSION, spec.rubygems_version assert_path_exists spec.file_name reader = Gem::Package.new spec.file_name assert reader.verify assert_equal [PUBLIC_CERT.to_pem], reader.spec.cert_chain assert_equal %w[metadata.gz metadata.gz.sig data.tar.gz data.tar.gz.sig checksums.yaml.gz checksums.yaml.gz.sig], reader.files assert_equal %w[lib/code.rb], reader.contents end def test_build_auto_signed_encrypted_key skip 'openssl is missing' unless defined?(OpenSSL::SSL) FileUtils.mkdir_p File.join(Gem.user_home, '.gem') private_key_path = File.join Gem.user_home, '.gem', 'gem-private_key.pem' FileUtils.cp ENCRYPTED_PRIVATE_KEY_PATH, private_key_path public_cert_path = File.join Gem.user_home, '.gem', 'gem-public_cert.pem' Gem::Security.write PUBLIC_CERT, public_cert_path spec = Gem::Specification.new 'build', '1' spec.summary = 'build' spec.authors = 'build' spec.files = ['lib/code.rb'] FileUtils.mkdir 'lib' open 'lib/code.rb', 'w' do |io| io.write '# lib/code.rb' end package = Gem::Package.new spec.file_name package.spec = spec package.build assert_equal Gem::VERSION, spec.rubygems_version assert_path_exists spec.file_name reader = Gem::Package.new spec.file_name assert reader.verify assert_equal [PUBLIC_CERT.to_pem], reader.spec.cert_chain assert_equal %w[metadata.gz metadata.gz.sig data.tar.gz data.tar.gz.sig checksums.yaml.gz checksums.yaml.gz.sig], reader.files assert_equal %w[lib/code.rb], reader.contents end def test_build_invalid spec = Gem::Specification.new 'build', '1' package = Gem::Package.new spec.file_name package.spec = spec e = assert_raises Gem::InvalidSpecificationException do package.build end assert_equal 'missing value for attribute summary', e.message end def test_build_signed skip 'openssl is missing' unless defined?(OpenSSL::SSL) spec = Gem::Specification.new 'build', '1' spec.summary = 'build' spec.authors = 'build' spec.files = ['lib/code.rb'] spec.cert_chain = [PUBLIC_CERT.to_pem] spec.signing_key = PRIVATE_KEY FileUtils.mkdir 'lib' open 'lib/code.rb', 'w' do |io| io.write '# lib/code.rb' end package = Gem::Package.new spec.file_name package.spec = spec package.build assert_equal Gem::VERSION, spec.rubygems_version assert_path_exists spec.file_name reader = Gem::Package.new spec.file_name assert reader.verify assert_equal spec, reader.spec assert_equal %w[metadata.gz metadata.gz.sig data.tar.gz data.tar.gz.sig checksums.yaml.gz checksums.yaml.gz.sig], reader.files assert_equal %w[lib/code.rb], reader.contents end def test_build_signed_encrypted_key skip 'openssl is missing' unless defined?(OpenSSL::SSL) spec = Gem::Specification.new 'build', '1' spec.summary = 'build' spec.authors = 'build' spec.files = ['lib/code.rb'] spec.cert_chain = [PUBLIC_CERT.to_pem] spec.signing_key = ENCRYPTED_PRIVATE_KEY FileUtils.mkdir 'lib' open 'lib/code.rb', 'w' do |io| io.write '# lib/code.rb' end package = Gem::Package.new spec.file_name package.spec = spec package.build assert_equal Gem::VERSION, spec.rubygems_version assert_path_exists spec.file_name reader = Gem::Package.new spec.file_name assert reader.verify assert_equal spec, reader.spec assert_equal %w[metadata.gz metadata.gz.sig data.tar.gz data.tar.gz.sig checksums.yaml.gz checksums.yaml.gz.sig], reader.files assert_equal %w[lib/code.rb], reader.contents end def test_contents package = Gem::Package.new @gem assert_equal %w[lib/code.rb], package.contents end def test_extract_files package = Gem::Package.new @gem package.extract_files @destination extracted = File.join @destination, 'lib/code.rb' assert_path_exists extracted mask = 0100666 & (~File.umask) assert_equal mask.to_s(8), File.stat(extracted).mode.to_s(8) unless win_platform? end def test_extract_files_empty data_tgz = util_tar_gz do end gem = util_tar do |tar| tar.add_file 'data.tar.gz', 0644 do |io| io.write data_tgz.string end tar.add_file 'metadata.gz', 0644 do |io| Zlib::GzipWriter.wrap io do |gzio| gzio.write @spec.to_yaml end end end open 'empty.gem', 'wb' do |io| io.write gem.string end package = Gem::Package.new 'empty.gem' package.extract_files @destination assert_path_exists @destination end def test_extract_tar_gz_absolute package = Gem::Package.new @gem tgz_io = util_tar_gz do |tar| tar.add_file '/absolute.rb', 0644 do |io| io.write 'hi' end end e = assert_raises Gem::Package::PathError do package.extract_tar_gz tgz_io, @destination end assert_equal("installing into parent path /absolute.rb of " + "#{@destination} is not allowed", e.message) end def test_extract_tar_gz_symlink_absolute package = Gem::Package.new @gem tgz_io = util_tar_gz do |tar| tar.add_symlink 'code.rb', '/absolute.rb', 0644 end e = assert_raises Gem::Package::PathError do package.extract_tar_gz tgz_io, @destination end assert_equal("installing into parent path /absolute.rb of " + "#{@destination} is not allowed", e.message) end def test_extract_tar_gz_directory package = Gem::Package.new @gem tgz_io = util_tar_gz do |tar| tar.mkdir 'lib', 0755 tar.add_file 'lib/foo.rb', 0644 do |io| io.write 'hi' end tar.mkdir 'lib/foo', 0755 end package.extract_tar_gz tgz_io, @destination extracted = File.join @destination, 'lib/foo.rb' assert_path_exists extracted extracted = File.join @destination, 'lib/foo' assert_path_exists extracted end def test_extract_tar_gz_dot_slash package = Gem::Package.new @gem tgz_io = util_tar_gz do |tar| tar.add_file './dot_slash.rb', 0644 do |io| io.write 'hi' end end package.extract_tar_gz tgz_io, @destination extracted = File.join @destination, 'dot_slash.rb' assert_path_exists extracted end def test_extract_tar_gz_dot_file package = Gem::Package.new @gem tgz_io = util_tar_gz do |tar| tar.add_file '.dot_file.rb', 0644 do |io| io.write 'hi' end end package.extract_tar_gz tgz_io, @destination extracted = File.join @destination, '.dot_file.rb' assert_path_exists extracted end def test_install_location package = Gem::Package.new @gem file = 'file.rb' file.taint destination = package.install_location file, @destination assert_equal File.join(@destination, 'file.rb'), destination refute destination.tainted? end def test_install_location_absolute package = Gem::Package.new @gem e = assert_raises Gem::Package::PathError do package.install_location '/absolute.rb', @destination end assert_equal("installing into parent path /absolute.rb of " + "#{@destination} is not allowed", e.message) end def test_install_location_dots package = Gem::Package.new @gem file = 'file.rb' destination = File.join @destination, 'foo', '..', 'bar' FileUtils.mkdir_p File.join @destination, 'foo' FileUtils.mkdir_p File.expand_path destination destination = package.install_location file, destination # this test only fails on ruby missing File.realpath assert_equal File.join(@destination, 'bar', 'file.rb'), destination end def test_install_location_extra_slash skip 'no File.realpath on 1.8' if RUBY_VERSION < '1.9' package = Gem::Package.new @gem file = 'foo//file.rb' file.taint destination = @destination.sub '/', '//' destination = package.install_location file, destination assert_equal File.join(@destination, 'foo', 'file.rb'), destination refute destination.tainted? end def test_install_location_relative package = Gem::Package.new @gem e = assert_raises Gem::Package::PathError do package.install_location '../relative.rb', @destination end parent = File.expand_path File.join @destination, "../relative.rb" assert_equal("installing into parent path #{parent} of " + "#{@destination} is not allowed", e.message) end def test_load_spec entry = StringIO.new Gem.gzip @spec.to_yaml def entry.full_name() 'metadata.gz' end package = Gem::Package.new 'nonexistent.gem' spec = package.load_spec entry assert_equal @spec, spec end def test_verify package = Gem::Package.new @gem package.verify assert_equal @spec, package.spec assert_equal %w[checksums.yaml.gz data.tar.gz metadata.gz], package.files.sort end def test_verify_checksum_bad data_tgz = util_tar_gz do |tar| tar.add_file 'lib/code.rb', 0444 do |io| io.write '# lib/code.rb' end end data_tgz = data_tgz.string gem = util_tar do |tar| metadata_gz = Gem.gzip @spec.to_yaml tar.add_file 'metadata.gz', 0444 do |io| io.write metadata_gz end tar.add_file 'data.tar.gz', 0444 do |io| io.write data_tgz end bogus_checksums = { 'SHA1' => { 'data.tar.gz' => 'bogus', 'metadata.gz' => 'bogus', }, } tar.add_file 'checksums.yaml.gz', 0444 do |io| Zlib::GzipWriter.wrap io do |gz_io| gz_io.write YAML.dump bogus_checksums end end end open 'mismatch.gem', 'wb' do |io| io.write gem.string end package = Gem::Package.new 'mismatch.gem' e = assert_raises Gem::Package::FormatError do package.verify end assert_equal 'SHA1 checksum mismatch for data.tar.gz in mismatch.gem', e.message end def test_verify_checksum_missing data_tgz = util_tar_gz do |tar| tar.add_file 'lib/code.rb', 0444 do |io| io.write '# lib/code.rb' end end data_tgz = data_tgz.string gem = util_tar do |tar| metadata_gz = Gem.gzip @spec.to_yaml tar.add_file 'metadata.gz', 0444 do |io| io.write metadata_gz end digest = Digest::SHA1.new digest << metadata_gz checksums = { 'SHA1' => { 'metadata.gz' => digest.hexdigest, }, } tar.add_file 'checksums.yaml.gz', 0444 do |io| Zlib::GzipWriter.wrap io do |gz_io| gz_io.write YAML.dump checksums end end tar.add_file 'data.tar.gz', 0444 do |io| io.write data_tgz end end open 'data_checksum_missing.gem', 'wb' do |io| io.write gem.string end package = Gem::Package.new 'data_checksum_missing.gem' assert package.verify end def test_verify_corrupt tf = Tempfile.open 'corrupt' do |io| data = Gem.gzip 'a' * 10 io.write \ tar_file_header('metadata.gz', "\000x", 0644, data.length, Time.now) io.write data io.rewind package = Gem::Package.new io.path e = assert_raises Gem::Package::FormatError do package.verify end assert_equal "tar is corrupt, name contains null byte in #{io.path}", e.message io end tf.close! if tf.respond_to? :close! end def test_verify_empty FileUtils.touch 'empty.gem' package = Gem::Package.new 'empty.gem' e = assert_raises Gem::Package::FormatError do package.verify end assert_equal 'package metadata is missing in empty.gem', e.message end def test_verify_nonexistent package = Gem::Package.new 'nonexistent.gem' e = assert_raises Gem::Package::FormatError do package.verify end assert_match %r%^No such file or directory%, e.message assert_match %r%nonexistent.gem$%, e.message end def test_verify_security_policy skip 'openssl is missing' unless defined?(OpenSSL::SSL) package = Gem::Package.new @gem package.security_policy = Gem::Security::HighSecurity e = assert_raises Gem::Security::Exception do package.verify end assert_equal 'unsigned gems are not allowed by the High Security policy', e.message refute package.instance_variable_get(:@spec), '@spec must not be loaded' assert_empty package.instance_variable_get(:@files), '@files must empty' end def test_verify_security_policy_low_security skip 'openssl is missing' unless defined?(OpenSSL::SSL) @spec.cert_chain = [PUBLIC_CERT.to_pem] @spec.signing_key = PRIVATE_KEY FileUtils.mkdir_p 'lib' FileUtils.touch 'lib/code.rb' build = Gem::Package.new @gem build.spec = @spec build.build package = Gem::Package.new @gem package.security_policy = Gem::Security::LowSecurity assert package.verify end def test_verify_security_policy_checksum_missing skip 'openssl is missing' unless defined?(OpenSSL::SSL) @spec.cert_chain = [PUBLIC_CERT.to_pem] @spec.signing_key = PRIVATE_KEY build = Gem::Package.new @gem build.spec = @spec build.setup_signer FileUtils.mkdir 'lib' FileUtils.touch 'lib/code.rb' open @gem, 'wb' do |gem_io| Gem::Package::TarWriter.new gem_io do |gem| build.add_metadata gem build.add_contents gem # write bogus data.tar.gz to foil signature bogus_data = Gem.gzip 'hello' gem.add_file_simple 'data.tar.gz', 0444, bogus_data.length do |io| io.write bogus_data end # pre rubygems 2.0 gems do not add checksums end end Gem::Security.trust_dir.trust_cert PUBLIC_CERT package = Gem::Package.new @gem package.security_policy = Gem::Security::HighSecurity e = assert_raises Gem::Security::Exception do package.verify end assert_equal 'invalid signature', e.message refute package.instance_variable_get(:@spec), '@spec must not be loaded' assert_empty package.instance_variable_get(:@files), '@files must empty' end def test_verify_truncate open 'bad.gem', 'wb' do |io| io.write File.read(@gem, 1024) # don't care about newlines end package = Gem::Package.new 'bad.gem' e = assert_raises Gem::Package::FormatError do package.verify end assert_equal 'package content (data.tar.gz) is missing in bad.gem', e.message end # end #verify tests def test_verify_entry entry = Object.new def entry.full_name() raise ArgumentError, 'whatever' end package = Gem::Package.new @gem e = assert_raises Gem::Package::FormatError do package.verify_entry entry end assert_equal "package is corrupt, exception while verifying: whatever (ArgumentError) in #{@gem}", e.message end def test_spec package = Gem::Package.new @gem assert_equal @spec, package.spec end def test_spec_from_io # This functionality is used by rubygems.org to extract spec data from an # uploaded gem before it is written to storage. io = StringIO.new Gem.read_binary @gem package = Gem::Package.new io assert_equal @spec, package.spec end def test_spec_from_io_raises_gem_error_for_io_not_at_start io = StringIO.new Gem.read_binary @gem io.read(1) assert_raises(Gem::Package::Error) do Gem::Package.new io end end def util_tar tar_io = StringIO.new Gem::Package::TarWriter.new tar_io do |tar| yield tar end tar_io.rewind tar_io end def util_tar_gz(&block) tar_io = util_tar(&block) tgz_io = StringIO.new # can't wrap TarWriter because it seeks Zlib::GzipWriter.wrap tgz_io do |io| io.write tar_io.string end StringIO.new tgz_io.string end end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/net-ssh-2.6.8/lib/net/ssh/proxy/command.rb
<filename>.rvm/gems/ruby-2.3.0/gems/net-ssh-2.6.8/lib/net/ssh/proxy/command.rb require 'socket' require 'net/ssh/proxy/errors' require 'net/ssh/ruby_compat' module Net; module SSH; module Proxy # An implementation of a command proxy. To use it, instantiate it, # then pass the instantiated object via the :proxy key to # Net::SSH.start: # # require 'net/ssh/proxy/command' # # proxy = Net::SSH::Proxy::Command.new('ssh relay nc %h %p') # Net::SSH.start('host', 'user', :proxy => proxy) do |ssh| # ... # end class Command # The command line template attr_reader :command_line_template # The command line for the session attr_reader :command_line # Create a new socket factory that tunnels via a command executed # with the user's shell, which is composed from the given command # template. In the command template, `%h' will be substituted by # the host name to connect and `%p' by the port. def initialize(command_line_template) @command_line_template = command_line_template @command_line = nil end # Return a new socket connected to the given host and port via the # proxy that was requested when the socket factory was instantiated. def open(host, port) command_line = @command_line_template.gsub(/%(.)/) { case $1 when 'h' host when 'p' port.to_s when '%' '%' else raise ArgumentError, "unknown key: #{$1}" end } begin io = IO.popen(command_line, "r+") if result = Net::SSH::Compat.io_select([io], nil, [io], 60) if result.last.any? raise "command failed" end else raise "command timed out" end rescue => e raise ConnectError, "#{e}: #{command_line}" end @command_line = command_line class << io def send(data, flag) write_nonblock(data) end def recv(size) read_nonblock(size) end end io end end end; end; end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/rubyntlm-0.6.0/lib/net/ntlm/security_buffer.rb
module Net module NTLM class SecurityBuffer < FieldSet int16LE :length, {:value => 0} int16LE :allocated, {:value => 0} int32LE :offset, {:value => 0} attr_accessor :active def initialize(opts={}) super() @value = opts[:value] @active = opts[:active].nil? ? true : opts[:active] @size = 8 end def parse(str, offset=0) if @active and str.size >= offset + @size super(str, offset) @value = str[self.offset, self.length] @size else 0 end end def serialize super if @active end def value @value end def value=(val) @value = val self.length = self.allocated = val.size end def data_size @active ? @value.size : 0 end end end end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/ohai-6.18.0/lib/ohai/plugins/lua.rb
<gh_stars>1-10 # # Author:: <NAME> <<EMAIL>> # Copyright:: Copyright (c) 2009 VMware, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # provides "languages/lua" require_plugin "languages" output = nil lua = Mash.new status, stdout, stderr = run_command(:no_status_check => true, :command => "lua -v") if status == 0 output = stderr.split if output.length >= 1 lua[:version] = output[1] end languages[:lua] = lua if lua[:version] end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/tk/sample/tcltklib/lines1.rb
<reponame>arnab0073/idea #! /usr/local/bin/ruby require "tcltk" def drawlines() print Time.now, "\n" for j in 0 .. 99 print "*" $stdout.flush if (j & 1) != 0 col = "blue" else col = "red" end for i in 0 .. 99 # $a.e("create line", i, 0, 0, 500 - i, "-fill", col) end end print Time.now, "\n" for j in 0 .. 99 print "*" $stdout.flush if (j & 1) != 0 col = "blue" else col = "red" end for i in 0 .. 99 $a.e("create line", i, 0, 0, 500 - i, "-fill", col) end end print Time.now, "\n" # $ip.commands()["destroy"].e($root) end $ip = TclTkInterpreter.new() $root = $ip.rootwidget() $a = TclTkWidget.new($ip, $root, "canvas", "-height 500 -width 500") $c = TclTkCallback.new($ip, proc{drawlines()}) $b = TclTkWidget.new($ip, $root, "button", "-text draw -command", $c) $ip.commands()["pack"].e($a, $b, "-side left") TclTk.mainloop # eof
arnab0073/idea
.rvm/src/ruby-2.3.0/ext/-test-/bug_reporter/extconf.rb
# frozen_string_literal: false create_makefile("-test-/bug_reporter/bug_reporter")
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/fog-aws-0.9.2/lib/fog/aws/version.rb
<gh_stars>0 module Fog module AWS VERSION = "0.9.2" end end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/winrm-1.8.1/spec/command_executor_spec.rb
# -*- encoding: utf-8 -*- # # Author:: Fletcher (<<EMAIL>>) # # Copyright (C) 2015, <NAME> # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an 'AS IS' BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. require 'winrm/command_executor' require 'base64' require 'securerandom' describe WinRM::CommandExecutor, unit: true do let(:logged_output) { StringIO.new } let(:shell_id) { 'shell-123' } let(:executor_args) { [service, logger] } let(:executor) { WinRM::CommandExecutor.new(service) } let(:service) do double( 'winrm_service', logger: Logging.logger['test'], retry_limit: 1, retry_delay: 1 ) end let(:version_output) { { xml_fragment: [{ version: '6.3.9600' }] } } before do allow(service).to receive(:open_shell).and_return(shell_id) allow(service).to receive(:run_wql).and_return(version_output) end describe '#close' do it 'calls service#close_shell' do executor.open expect(service).to receive(:close_shell).with(shell_id) executor.close end it 'only calls service#close_shell once for multiple calls' do executor.open expect(service).to receive(:close_shell).with(shell_id).once executor.close executor.close executor.close end it 'undefines finalizer' do allow(service).to receive(:close_shell) allow(ObjectSpace).to receive(:define_finalizer) { |e, _| e == executor } expect(ObjectSpace).to receive(:undefine_finalizer).with(executor) executor.open executor.close end end describe '#open' do it 'calls service#open_shell' do expect(service).to receive(:open_shell).and_return(shell_id) executor.open end it 'defines a finalizer' do expect(ObjectSpace).to receive(:define_finalizer) do |e, _| expect(e).to eq(executor) end executor.open end it 'returns a shell id as a string' do expect(executor.open).to eq shell_id end describe 'failed connection attempts' do let(:error) { HTTPClient::ConnectTimeoutError } let(:limit) { 3 } let(:delay) { 0.1 } before do allow(service).to receive(:open_shell).and_raise(error) allow(service).to receive(:retry_delay).and_return(delay) allow(service).to receive(:retry_limit).and_return(limit) end it 'attempts to connect :retry_limit times' do begin allow(service).to receive(:open_shell).exactly.times(limit) executor.open rescue # rubocop:disable Lint/HandleExceptions # the raise is not what is being tested here, rather its side-effect end end it 'raises the inner error after retries' do expect { executor.open }.to raise_error(error) end end describe 'for modern windows distributions' do let(:version_output) { { xml_fragment: [{ version: '10.0.10586.63' }] } } it 'sets #max_commands to 1500 - 2' do expect(executor.max_commands).to eq(1500 - 2) end it 'sets code_page to UTF-8' do expect(executor.code_page).to eq 65_001 end end describe 'for older/legacy windows distributions' do let(:version_output) { { xml_fragment: [{ version: '6.1.8500' }] } } it 'sets #max_commands to 15 - 2' do expect(executor.max_commands).to eq(15 - 2) end it 'sets code_page to UTF-8' do expect(executor.code_page).to eq 65_001 end end describe 'for super duper older/legacy windows distributions' do let(:version_output) { { xml_fragment: [{ version: '6.0.8500' }] } } it 'sets #max_commands to 15 - 2' do expect(executor.max_commands).to eq(15 - 2) end it 'sets code_page to MS-DOS' do expect(executor.code_page).to eq 437 end end describe 'when unable to find os version' do let(:version_output) { { xml_fragment: [{ funny_clowns: 'haha' }] } } it 'raises WinRMError' do expect { executor.code_page }.to raise_error( ::WinRM::WinRMError, 'Unable to determine endpoint os version' ) end end end describe '#run_cmd' do describe 'when #open has not been previously called' do it 'raises a WinRMError error' do expect { executor.run_cmd('nope') }.to raise_error( ::WinRM::WinRMError, "#{executor.class}#open must be called before any run methods are invoked" ) end end describe 'when #open has been previously called' do let(:command_id) { 'command-123' } let(:echo_output) do o = ::WinRM::Output.new o[:exitcode] = 0 o[:data].concat([ { stdout: 'Hello\r\n' }, { stderr: 'Psst\r\n' } ]) o end before do stub_cmd(shell_id, 'echo', ['Hello'], echo_output, command_id) executor.open end it 'calls service#run_command' do expect(service).to receive(:run_command).with(shell_id, 'echo', ['Hello']) executor.run_cmd('echo', ['Hello']) end it 'calls service#get_command_output to get results' do expect(service).to receive(:get_command_output).with(shell_id, command_id) executor.run_cmd('echo', ['Hello']) end it 'calls service#get_command_output with a block to get results' do blk = proc { |_, _| 'something' } expect(service).to receive(:get_command_output).with(shell_id, command_id, &blk) executor.run_cmd('echo', ['Hello'], &blk) end it 'returns an Output object hash' do expect(executor.run_cmd('echo', ['Hello'])).to eq echo_output end it 'runs the block in #get_command_output when given' do io_out = StringIO.new io_err = StringIO.new stub_cmd( shell_id, 'echo', ['Hello'], echo_output, command_id ).and_yield(echo_output.stdout, echo_output.stderr) output = executor.run_cmd('echo', ['Hello']) do |stdout, stderr| io_out << stdout if stdout io_err << stderr if stderr end expect(io_out.string).to eq 'Hello\r\n' expect(io_err.string).to eq 'Psst\r\n' expect(output).to eq echo_output end shared_examples 'retry shell command' do it 'does not close the current shell' do expect(service).not_to receive(:close_shell) executor.run_cmd('echo', ['Hello']) end it 'opens a new shell once' do expect(service).to receive(:open_shell).once executor.run_cmd('echo', ['Hello']) end it 'retries the command once' do expect(service).to receive(:run_command).exactly(2).times executor.run_cmd('echo', ['Hello']) end end describe 'when shell is closed on server' do before do @times_called = 0 allow(service).to receive(:run_command) do @times_called += 1 fail WinRM::WinRMWSManFault.new('oops', '2150858843') if @times_called == 1 end end include_examples 'retry shell command' end describe 'when shell accesses a deleted registry key' do before do @times_called = 0 allow(service).to receive(:run_command) do @times_called += 1 fail WinRM::WinRMWSManFault.new('oops', '2147943418') if @times_called == 1 end end include_examples 'retry shell command' end end describe 'when called many times over time' do # use a 'old' version of windows with lower max_commands threshold # to trigger quicker shell recyles let(:version_output) { { xml_fragment: [{ version: '6.1.8500' }] } } let(:echo_output) do o = ::WinRM::Output.new o[:exitcode] = 0 o[:data].concat([{ stdout: 'Hello\r\n' }]) o end before do allow(service).to receive(:open_shell).and_return('s1', 's2') allow(service).to receive(:close_shell) allow(service).to receive(:run_command).and_yield('command-xxx') allow(service).to receive(:get_command_output).and_return(echo_output) allow(service).to receive(:run_wql).with('select version from Win32_OperatingSystem') .and_return(version_output) end it 'resets the shell when #max_commands threshold is tripped' do iterations = 35 reset_times = iterations / (15 - 2) expect(service).to receive(:close_shell).exactly(reset_times).times executor.open iterations.times { executor.run_cmd('echo', ['Hello']) } end end end describe '#run_powershell_script' do describe 'when #open has not been previously called' do it 'raises a WinRMError error' do expect { executor.run_powershell_script('nope') }.to raise_error( ::WinRM::WinRMError, "#{executor.class}#open must be called before any run methods are invoked" ) end end describe 'when #open has been previously called' do let(:command_id) { 'command-123' } let(:echo_output) do o = ::WinRM::Output.new o[:exitcode] = 0 o[:data].concat([ { stdout: 'Hello\r\n' }, { stderr: 'Psst\r\n' } ]) o end before do stub_powershell_script( shell_id, 'echo Hello', echo_output, command_id ) executor.open end it 'calls service#run_command' do expect(service).to receive(:run_command).with( shell_id, 'powershell', [ '-encodedCommand', ::WinRM::PowershellScript.new('echo Hello') .encoded ] ) executor.run_powershell_script('echo Hello') end it 'calls service#get_command_output to get results' do expect(service).to receive(:get_command_output).with(shell_id, command_id) executor.run_powershell_script('echo Hello') end it 'calls service#get_command_output with a block to get results' do blk = proc { |_, _| 'something' } expect(service).to receive(:get_command_output).with(shell_id, command_id, &blk) executor.run_powershell_script('echo Hello', &blk) end it 'returns an Output object hash' do expect(executor.run_powershell_script('echo Hello')).to eq echo_output end it 'runs the block in #get_command_output when given' do io_out = StringIO.new io_err = StringIO.new stub_cmd(shell_id, 'echo', ['Hello'], echo_output, command_id) .and_yield(echo_output.stdout, echo_output.stderr) output = executor.run_powershell_script('echo Hello') do |stdout, stderr| io_out << stdout if stdout io_err << stderr if stderr end expect(io_out.string).to eq 'Hello\r\n' expect(io_err.string).to eq 'Psst\r\n' expect(output).to eq echo_output end end describe 'when called many times over time' do # use a 'old' version of windows with lower max_commands threshold # to trigger quicker shell recyles let(:version_output) { { xml_fragment: [{ version: '6.1.8500' }] } } let(:echo_output) do o = ::WinRM::Output.new o[:exitcode] = 0 o[:data].concat([{ stdout: 'Hello\r\n' }]) o end before do allow(service).to receive(:open_shell).and_return('s1', 's2') allow(service).to receive(:close_shell) allow(service).to receive(:run_command).and_yield('command-xxx') allow(service).to receive(:get_command_output).and_return(echo_output) allow(service).to receive(:wsman_identify).with('select version from Win32_OperatingSystem') .and_return(version_output) end it 'resets the shell when #max_commands threshold is tripped' do iterations = 35 reset_times = iterations / (15 - 2) expect(service).to receive(:close_shell).exactly(reset_times).times executor.open iterations.times { executor.run_powershell_script('echo Hello') } end end end describe '#shell' do it 'is initially nil' do expect(executor.shell).to eq nil end it 'is set after #open is called' do executor.open expect(executor.shell).to eq shell_id end end def decode(powershell) Base64.strict_decode64(powershell).encode('UTF-8', 'UTF-16LE') end def debug_line_with(msg) /^D, .* : #{Regexp.escape(msg)}/ end def regexify(string) Regexp.new(Regexp.escape(string)) end def regexify_line(string) Regexp.new("^#{Regexp.escape(string)}$") end # rubocop:disable Metrics/ParameterLists def stub_cmd(shell_id, cmd, args, output, command_id = nil, &block) command_id ||= SecureRandom.uuid allow(service).to receive(:run_command).with(shell_id, cmd, args).and_yield(command_id) allow(service).to receive(:get_command_output).with(shell_id, command_id, &block) .and_return(output) end def stub_powershell_script(shell_id, script, output, command_id = nil) stub_cmd( shell_id, 'powershell', ['-encodedCommand', ::WinRM::PowershellScript.new(script).encoded], output, command_id ) end # rubocop:enable Metrics/ParameterLists end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/rubyntlm-0.6.0/lib/net/ntlm/int64_le.rb
<filename>.rvm/gems/ruby-2.3.0/gems/rubyntlm-0.6.0/lib/net/ntlm/int64_le.rb module Net module NTLM class Int64LE < Field def initialize(opt) super(opt) @size = 8 end def parse(str, offset=0) if @active and str.size >= offset + @size d, u = str.slice(offset, @size).unpack("V2") @value = (u * 0x100000000 + d) @size else 0 end end def serialize [@value & 0x00000000ffffffff, @value >> 32].pack("V2") if @active end end end end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/ohai-6.18.0/spec/unit/plugins/azure_spec.rb
<filename>.rvm/gems/ruby-2.3.0/gems/ohai-6.18.0/spec/unit/plugins/azure_spec.rb # # Author:: <NAME> (<<EMAIL>>) # Copyright:: Copyright (c) 2011-2013 Opscode, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') require 'open-uri' describe Ohai::System, "plugin azure" do before(:each) do @ohai = Ohai::System.new @ohai.stub!(:require_plugin).and_return(true) end describe "with azure cloud file" do before(:each) do File.stub!(:exist?).with('/etc/chef/ohai/hints/azure.json').and_return(true) File.stub!(:read).with('/etc/chef/ohai/hints/azure.json').and_return('{"public_ip":"172.16.31.10","vm_name":"test-vm","public_fqdn":"service.cloudapp.net","public_ssh_port":"22", "public_winrm_port":"5985"}') File.stub!(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(true) File.stub!(:read).with('C:\chef\ohai\hints/azure.json').and_return('{"public_ip":"172.16.31.10","vm_name":"test-vm","public_fqdn":"service.cloudapp.net","public_ssh_port":"22", "public_winrm_port":"5985"}') @ohai._require_plugin("azure") end it 'should set the azure cloud attributes' do @ohai[:azure].should_not be_nil @ohai[:azure]['public_ip'].should == "172.16.31.10" @ohai[:azure]['vm_name'].should == "test-vm" @ohai[:azure]['public_fqdn'].should == "service.cloudapp.net" @ohai[:azure]['public_ssh_port'].should == "22" @ohai[:azure]['public_winrm_port'].should == "5985" end end describe "without azure cloud file" do before(:each) do File.stub!(:exist?).with('/etc/chef/ohai/hints/azure.json').and_return(false) File.stub!(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(false) end it 'should not behave like azure' do @ohai[:azure].should be_nil end end describe "with rackspace cloud file" do before(:each) do File.stub!(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true) File.stub!(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('') File.stub!(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true) File.stub!(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('') end it 'should not behave like azure' do @ohai[:azure].should be_nil end end end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/logging-2.1.0/test/test_root_logger.rb
require File.expand_path('setup', File.dirname(__FILE__)) module TestLogging class TestRootLogger < Test::Unit::TestCase include LoggingTestCase def setup super @root = ::Logging::Logger.root end def test_additive assert_raise(NoMethodError) {@root.additive} end def test_additive_eq assert_raise(NoMethodError) {@root.additive = true} end def test_level_eq assert_equal 0, @root.level assert_raise(ArgumentError) {@root.level = -1} assert_raise(ArgumentError) {@root.level = 6} assert_raise(ArgumentError) {@root.level = Object} assert_raise(ArgumentError) {@root.level = 'bob'} assert_raise(ArgumentError) {@root.level = :wtf} @root.level = 'INFO' assert_equal 1, @root.level @root.level = :warn assert_equal 2, @root.level @root.level = 'error' assert_equal 3, @root.level @root.level = 4 assert_equal 4, @root.level @root.level = :all assert_equal 0, @root.level @root.level = 'OFF' assert_equal 5, @root.level @root.level = nil assert_equal 0, @root.level end def test_name assert_equal 'root', @root.name end def test_parent assert_raise(NoMethodError) {@root.parent} end def test_parent_eq assert_raise(NoMethodError) {@root.parent = nil} end def test_spaceship logs = %w( A A::B A::B::C A::B::C::D A::B::C::E A::B::C::E::G A::B::C::F ).map {|x| ::Logging::Logger[x]} logs.each do |log| assert_equal(-1, @root <=> log, "'root' <=> '#{log.name}'") end assert_equal 0, @root <=> @root assert_raise(ArgumentError) {@root <=> 'string'} end end # class TestRootLogger end # module TestLogging
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/rubyntlm-0.6.0/rubyntlm.gemspec
require File.join(File.dirname(__FILE__), 'lib', 'net', 'ntlm', 'version') Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = 'rubyntlm' s.version = Net::NTLM::VERSION::STRING s.summary = 'Ruby/NTLM library.' s.description = 'Ruby/NTLM provides message creator and parser for the NTLM authentication.' s.authors = ['<NAME>','<NAME>'] s.email = ['<EMAIL>','<EMAIL>'] s.homepage = 'https://github.com/winrb/rubyntlm' s.files = `git ls-files`.split($/) s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) } s.test_files = s.files.grep(%r{^(test|spec|features)/}) s.require_paths = ["lib"] s.required_ruby_version = '>= 1.8.7' s.license = 'MIT' s.add_development_dependency "pry" s.add_development_dependency "rake" s.add_development_dependency "rspec", ">= 2.11" s.add_development_dependency "simplecov" end
arnab0073/idea
.rvm/src/ruby-2.3.0/gems/did_you_mean-1.0.0/evaluation/calculator.rb
# -*- frozen-string-literal: true -*- require 'benchmark' def report(message, &block) time = 1000 * Benchmark.realtime(&block) if (time / 1000 / 60) >= 1 minutes = (time / 1000 / 60).floor seconds = (time % (60 * 1000)) / 1000 puts " \e[36m%2dm%.3fs:\e[0m %s" % [minutes, seconds, message] elsif (time / 1000) >= 1 seconds = (time % (60 * 1000)) / 1000 puts " \e[36m%9.3fs:\e[0m %s" % [seconds, message] else puts " \e[36m%8.1fms:\e[0m %s" % [time, message] end time end puts "\n" report "loading program" do require 'yaml' require 'set' require 'did_you_mean' begin require 'jaro_winkler' DidYouMean::JaroWinkler.module_eval do module_function def distance(str1, str2) ::JaroWinkler.distance(str1, str2) end if RUBY_ENGINE != 'jruby' end rescue LoadError, NameError end class DidYouMean::WordCollection include DidYouMean::SpellCheckable def initialize(words) @words = words end def similar_to(input, filter = '') @corrections, @input = nil, input corrections end def candidates { @input => @words } end private def normalize(str); str; end end if !defined?(DidYouMean::WordCollection) end report "loading dictionary" do yaml = open("evaluation/dictionary.yml").read yaml = YAML.load(yaml).map{|word| word.downcase.tr(" ", "_") } DICTIONARY = Set.new(yaml) end report "loading corrent/incorrect words" do COLLECTION = DidYouMean::WordCollection.new(DICTIONARY) INCORRECT_WORDS = YAML.load(open("evaluation/incorrect_words.yaml").read) end total_count = 0 correct_count = 0 words_not_corrected = [] filename = "log/words_not_corrected_#{Time.now.to_i}.yml" puts " Total number of test data: #{INCORRECT_WORDS.size} did_you_mean version: #{DidYouMean::VERSION} " report "calculating accuracy" do index = 0 INCORRECT_WORDS.each do |correct, incorrect| if DICTIONARY.include?(correct) total_count += 1 corrections = COLLECTION.similar_to(incorrect) if corrections.first == correct correct_count += 1 else words_not_corrected << { correct => incorrect, 'result' => corrections } end end index += 1 puts "processed #{index} items" if index % 100 == 0 end puts "\n" end puts " Evaulation result Total count : #{total_count} Correct count: #{correct_count} Accuracy : #{correct_count.to_f / total_count} " Dir.mkdir('log') unless File.exist?('log') File.open(filename, 'w') do |file| file.write(words_not_corrected.to_yaml) end puts "Incorrect corrections were logged to #{filename}."
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/benchmark/bm_vm1_not.rb
i = 0 obj = Object.new while i<30_000_000 # while loop 1 i+= 1 !obj end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/tk/lib/tkextlib/tcllib/panelframe.rb
<filename>.rvm/src/ruby-1.9.3-p551/ext/tk/lib/tkextlib/tcllib/panelframe.rb # # tkextlib/tcllib/panelframe.rb # by <NAME> (<EMAIL>) # # * Part of tcllib extension # * Create PanelFrame widgets. # require 'tk' require 'tkextlib/tcllib.rb' # TkPackage.require('widget::panelframe', '1.0') TkPackage.require('widget::panelframe') module Tk::Tcllib module Widget class PanelFrame < TkWindow PACKAGE_NAME = 'widget::panelframe'.freeze def self.package_name PACKAGE_NAME end def self.package_version begin TkPackage.require('widget::panelframe') rescue '' end end end Panelframe = PanelFrame end end class Tk::Tcllib::Widget::PanelFrame TkCommandNames = ['::widget::panelframe'.freeze].freeze def create_self(keys) if keys and keys != None tk_call_without_enc(self.class::TkCommandNames[0], @path, *hash_kv(keys, true)) else tk_call_without_enc(self.class::TkCommandNames[0], @path) end end private :create_self def add(what, *args) window(tk_send('add', *args)) end #def get_frame # window(tk_send('getframe')) #end def set_widget(widget) tk_send('setwidget', widget) self end def remove(*wins) tk_send('remove', *wins) self end def remove_destroy(*wins) tk_send('remove', '-destroy', *wins) self end def delete(*wins) tk_send('delete', *wins) self end def items simplelist(tk_send('items')).collect!{|w| window(w)} end end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/fog-1.29.0/lib/fog/xenserver/requests/compute/create_vlan.rb
module Fog module Compute class XenServer class Real # # Create a VLAN # # @see http://docs.vmd.citrix.com/XenServer/6.0.0/1.0/en_gb/api/?c=VLAN # def create_vlan( pif_ref, vlan_id, network_ref = '' ) if pif_ref.is_a?(Hash) config = pif_ref extra_config = vlan_id pif_ref = extra_config[:pif_ref] tag = config[:tag].to_s network_ref = extra_config[:network_ref] else Fog::Logger.deprecation( 'This api is deprecated. The only expected params are two hash of attributes.' ) tag = vlan_id.to_s end @connection.request( { :parser => Fog::Parsers::XenServer::Base.new, :method => 'VLAN.create' }, pif_ref, tag, network_ref ) end end class Mock def create_vlan( pif_ref, vlan_id, network_ref ) Fog::Mock.not_implemented end end end end end
arnab0073/idea
.rvm/src/ruby-2.3.0/lib/rdoc/markdown/entities.rb
<filename>.rvm/src/ruby-2.3.0/lib/rdoc/markdown/entities.rb # frozen_string_literal: false ## # HTML entity name map for RDoc::Markdown RDoc::Markdown::HTML_ENTITIES = { "AElig" => [0x000C6], "AMP" => [0x00026], "Aacute" => [0x000C1], "Abreve" => [0x00102], "Acirc" => [0x000C2], "Acy" => [0x00410], "Afr" => [0x1D504], "Agrave" => [0x000C0], "Alpha" => [0x00391], "Amacr" => [0x00100], "And" => [0x02A53], "Aogon" => [0x00104], "Aopf" => [0x1D538], "ApplyFunction" => [0x02061], "Aring" => [0x000C5], "Ascr" => [0x1D49C], "Assign" => [0x02254], "Atilde" => [0x000C3], "Auml" => [0x000C4], "Backslash" => [0x02216], "Barv" => [0x02AE7], "Barwed" => [0x02306], "Bcy" => [0x00411], "Because" => [0x02235], "Bernoullis" => [0x0212C], "Beta" => [0x00392], "Bfr" => [0x1D505], "Bopf" => [0x1D539], "Breve" => [0x002D8], "Bscr" => [0x0212C], "Bumpeq" => [0x0224E], "CHcy" => [0x00427], "COPY" => [0x000A9], "Cacute" => [0x00106], "Cap" => [0x022D2], "CapitalDifferentialD" => [0x02145], "Cayleys" => [0x0212D], "Ccaron" => [0x0010C], "Ccedil" => [0x000C7], "Ccirc" => [0x00108], "Cconint" => [0x02230], "Cdot" => [0x0010A], "Cedilla" => [0x000B8], "CenterDot" => [0x000B7], "Cfr" => [0x0212D], "Chi" => [0x003A7], "CircleDot" => [0x02299], "CircleMinus" => [0x02296], "CirclePlus" => [0x02295], "CircleTimes" => [0x02297], "ClockwiseContourIntegral" => [0x02232], "CloseCurlyDoubleQuote" => [0x0201D], "CloseCurlyQuote" => [0x02019], "Colon" => [0x02237], "Colone" => [0x02A74], "Congruent" => [0x02261], "Conint" => [0x0222F], "ContourIntegral" => [0x0222E], "Copf" => [0x02102], "Coproduct" => [0x02210], "CounterClockwiseContourIntegral" => [0x02233], "Cross" => [0x02A2F], "Cscr" => [0x1D49E], "Cup" => [0x022D3], "CupCap" => [0x0224D], "DD" => [0x02145], "DDotrahd" => [0x02911], "DJcy" => [0x00402], "DScy" => [0x00405], "DZcy" => [0x0040F], "Dagger" => [0x02021], "Darr" => [0x021A1], "Dashv" => [0x02AE4], "Dcaron" => [0x0010E], "Dcy" => [0x00414], "Del" => [0x02207], "Delta" => [0x00394], "Dfr" => [0x1D507], "DiacriticalAcute" => [0x000B4], "DiacriticalDot" => [0x002D9], "DiacriticalDoubleAcute" => [0x002DD], "DiacriticalGrave" => [0x00060], "DiacriticalTilde" => [0x002DC], "Diamond" => [0x022C4], "DifferentialD" => [0x02146], "Dopf" => [0x1D53B], "Dot" => [0x000A8], "DotDot" => [0x020DC], "DotEqual" => [0x02250], "DoubleContourIntegral" => [0x0222F], "DoubleDot" => [0x000A8], "DoubleDownArrow" => [0x021D3], "DoubleLeftArrow" => [0x021D0], "DoubleLeftRightArrow" => [0x021D4], "DoubleLeftTee" => [0x02AE4], "DoubleLongLeftArrow" => [0x027F8], "DoubleLongLeftRightArrow" => [0x027FA], "DoubleLongRightArrow" => [0x027F9], "DoubleRightArrow" => [0x021D2], "DoubleRightTee" => [0x022A8], "DoubleUpArrow" => [0x021D1], "DoubleUpDownArrow" => [0x021D5], "DoubleVerticalBar" => [0x02225], "DownArrow" => [0x02193], "DownArrowBar" => [0x02913], "DownArrowUpArrow" => [0x021F5], "DownBreve" => [0x00311], "DownLeftRightVector" => [0x02950], "DownLeftTeeVector" => [0x0295E], "DownLeftVector" => [0x021BD], "DownLeftVectorBar" => [0x02956], "DownRightTeeVector" => [0x0295F], "DownRightVector" => [0x021C1], "DownRightVectorBar" => [0x02957], "DownTee" => [0x022A4], "DownTeeArrow" => [0x021A7], "Downarrow" => [0x021D3], "Dscr" => [0x1D49F], "Dstrok" => [0x00110], "ENG" => [0x0014A], "ETH" => [0x000D0], "Eacute" => [0x000C9], "Ecaron" => [0x0011A], "Ecirc" => [0x000CA], "Ecy" => [0x0042D], "Edot" => [0x00116], "Efr" => [0x1D508], "Egrave" => [0x000C8], "Element" => [0x02208], "Emacr" => [0x00112], "EmptySmallSquare" => [0x025FB], "EmptyVerySmallSquare" => [0x025AB], "Eogon" => [0x00118], "Eopf" => [0x1D53C], "Epsilon" => [0x00395], "Equal" => [0x02A75], "EqualTilde" => [0x02242], "Equilibrium" => [0x021CC], "Escr" => [0x02130], "Esim" => [0x02A73], "Eta" => [0x00397], "Euml" => [0x000CB], "Exists" => [0x02203], "ExponentialE" => [0x02147], "Fcy" => [0x00424], "Ffr" => [0x1D509], "FilledSmallSquare" => [0x025FC], "FilledVerySmallSquare" => [0x025AA], "Fopf" => [0x1D53D], "ForAll" => [0x02200], "Fouriertrf" => [0x02131], "Fscr" => [0x02131], "GJcy" => [0x00403], "GT" => [0x0003E], "Gamma" => [0x00393], "Gammad" => [0x003DC], "Gbreve" => [0x0011E], "Gcedil" => [0x00122], "Gcirc" => [0x0011C], "Gcy" => [0x00413], "Gdot" => [0x00120], "Gfr" => [0x1D50A], "Gg" => [0x022D9], "Gopf" => [0x1D53E], "GreaterEqual" => [0x02265], "GreaterEqualLess" => [0x022DB], "GreaterFullEqual" => [0x02267], "GreaterGreater" => [0x02AA2], "GreaterLess" => [0x02277], "GreaterSlantEqual" => [0x02A7E], "GreaterTilde" => [0x02273], "Gscr" => [0x1D4A2], "Gt" => [0x0226B], "HARDcy" => [0x0042A], "Hacek" => [0x002C7], "Hat" => [0x0005E], "Hcirc" => [0x00124], "Hfr" => [0x0210C], "HilbertSpace" => [0x0210B], "Hopf" => [0x0210D], "HorizontalLine" => [0x02500], "Hscr" => [0x0210B], "Hstrok" => [0x00126], "HumpDownHump" => [0x0224E], "HumpEqual" => [0x0224F], "IEcy" => [0x00415], "IJlig" => [0x00132], "IOcy" => [0x00401], "Iacute" => [0x000CD], "Icirc" => [0x000CE], "Icy" => [0x00418], "Idot" => [0x00130], "Ifr" => [0x02111], "Igrave" => [0x000CC], "Im" => [0x02111], "Imacr" => [0x0012A], "ImaginaryI" => [0x02148], "Implies" => [0x021D2], "Int" => [0x0222C], "Integral" => [0x0222B], "Intersection" => [0x022C2], "InvisibleComma" => [0x02063], "InvisibleTimes" => [0x02062], "Iogon" => [0x0012E], "Iopf" => [0x1D540], "Iota" => [0x00399], "Iscr" => [0x02110], "Itilde" => [0x00128], "Iukcy" => [0x00406], "Iuml" => [0x000CF], "Jcirc" => [0x00134], "Jcy" => [0x00419], "Jfr" => [0x1D50D], "Jopf" => [0x1D541], "Jscr" => [0x1D4A5], "Jsercy" => [0x00408], "Jukcy" => [0x00404], "KHcy" => [0x00425], "KJcy" => [0x0040C], "Kappa" => [0x0039A], "Kcedil" => [0x00136], "Kcy" => [0x0041A], "Kfr" => [0x1D50E], "Kopf" => [0x1D542], "Kscr" => [0x1D4A6], "LJcy" => [0x00409], "LT" => [0x0003C], "Lacute" => [0x00139], "Lambda" => [0x0039B], "Lang" => [0x027EA], "Laplacetrf" => [0x02112], "Larr" => [0x0219E], "Lcaron" => [0x0013D], "Lcedil" => [0x0013B], "Lcy" => [0x0041B], "LeftAngleBracket" => [0x027E8], "LeftArrow" => [0x02190], "LeftArrowBar" => [0x021E4], "LeftArrowRightArrow" => [0x021C6], "LeftCeiling" => [0x02308], "LeftDoubleBracket" => [0x027E6], "LeftDownTeeVector" => [0x02961], "LeftDownVector" => [0x021C3], "LeftDownVectorBar" => [0x02959], "LeftFloor" => [0x0230A], "LeftRightArrow" => [0x02194], "LeftRightVector" => [0x0294E], "LeftTee" => [0x022A3], "LeftTeeArrow" => [0x021A4], "LeftTeeVector" => [0x0295A], "LeftTriangle" => [0x022B2], "LeftTriangleBar" => [0x029CF], "LeftTriangleEqual" => [0x022B4], "LeftUpDownVector" => [0x02951], "LeftUpTeeVector" => [0x02960], "LeftUpVector" => [0x021BF], "LeftUpVectorBar" => [0x02958], "LeftVector" => [0x021BC], "LeftVectorBar" => [0x02952], "Leftarrow" => [0x021D0], "Leftrightarrow" => [0x021D4], "LessEqualGreater" => [0x022DA], "LessFullEqual" => [0x02266], "LessGreater" => [0x02276], "LessLess" => [0x02AA1], "LessSlantEqual" => [0x02A7D], "LessTilde" => [0x02272], "Lfr" => [0x1D50F], "Ll" => [0x022D8], "Lleftarrow" => [0x021DA], "Lmidot" => [0x0013F], "LongLeftArrow" => [0x027F5], "LongLeftRightArrow" => [0x027F7], "LongRightArrow" => [0x027F6], "Longleftarrow" => [0x027F8], "Longleftrightarrow" => [0x027FA], "Longrightarrow" => [0x027F9], "Lopf" => [0x1D543], "LowerLeftArrow" => [0x02199], "LowerRightArrow" => [0x02198], "Lscr" => [0x02112], "Lsh" => [0x021B0], "Lstrok" => [0x00141], "Lt" => [0x0226A], "Map" => [0x02905], "Mcy" => [0x0041C], "MediumSpace" => [0x0205F], "Mellintrf" => [0x02133], "Mfr" => [0x1D510], "MinusPlus" => [0x02213], "Mopf" => [0x1D544], "Mscr" => [0x02133], "Mu" => [0x0039C], "NJcy" => [0x0040A], "Nacute" => [0x00143], "Ncaron" => [0x00147], "Ncedil" => [0x00145], "Ncy" => [0x0041D], "NegativeMediumSpace" => [0x0200B], "NegativeThickSpace" => [0x0200B], "NegativeThinSpace" => [0x0200B], "NegativeVeryThinSpace" => [0x0200B], "NestedGreaterGreater" => [0x0226B], "NestedLessLess" => [0x0226A], "NewLine" => [0x0000A], "Nfr" => [0x1D511], "NoBreak" => [0x02060], "NonBreakingSpace" => [0x000A0], "Nopf" => [0x02115], "Not" => [0x02AEC], "NotCongruent" => [0x02262], "NotCupCap" => [0x0226D], "NotDoubleVerticalBar" => [0x02226], "NotElement" => [0x02209], "NotEqual" => [0x02260], "NotEqualTilde" => [0x02242, 0x00338], "NotExists" => [0x02204], "NotGreater" => [0x0226F], "NotGreaterEqual" => [0x02271], "NotGreaterFullEqual" => [0x02267, 0x00338], "NotGreaterGreater" => [0x0226B, 0x00338], "NotGreaterLess" => [0x02279], "NotGreaterSlantEqual" => [0x02A7E, 0x00338], "NotGreaterTilde" => [0x02275], "NotHumpDownHump" => [0x0224E, 0x00338], "NotHumpEqual" => [0x0224F, 0x00338], "NotLeftTriangle" => [0x022EA], "NotLeftTriangleBar" => [0x029CF, 0x00338], "NotLeftTriangleEqual" => [0x022EC], "NotLess" => [0x0226E], "NotLessEqual" => [0x02270], "NotLessGreater" => [0x02278], "NotLessLess" => [0x0226A, 0x00338], "NotLessSlantEqual" => [0x02A7D, 0x00338], "NotLessTilde" => [0x02274], "NotNestedGreaterGreater" => [0x02AA2, 0x00338], "NotNestedLessLess" => [0x02AA1, 0x00338], "NotPrecedes" => [0x02280], "NotPrecedesEqual" => [0x02AAF, 0x00338], "NotPrecedesSlantEqual" => [0x022E0], "NotReverseElement" => [0x0220C], "NotRightTriangle" => [0x022EB], "NotRightTriangleBar" => [0x029D0, 0x00338], "NotRightTriangleEqual" => [0x022ED], "NotSquareSubset" => [0x0228F, 0x00338], "NotSquareSubsetEqual" => [0x022E2], "NotSquareSuperset" => [0x02290, 0x00338], "NotSquareSupersetEqual" => [0x022E3], "NotSubset" => [0x02282, 0x020D2], "NotSubsetEqual" => [0x02288], "NotSucceeds" => [0x02281], "NotSucceedsEqual" => [0x02AB0, 0x00338], "NotSucceedsSlantEqual" => [0x022E1], "NotSucceedsTilde" => [0x0227F, 0x00338], "NotSuperset" => [0x02283, 0x020D2], "NotSupersetEqual" => [0x02289], "NotTilde" => [0x02241], "NotTildeEqual" => [0x02244], "NotTildeFullEqual" => [0x02247], "NotTildeTilde" => [0x02249], "NotVerticalBar" => [0x02224], "Nscr" => [0x1D4A9], "Ntilde" => [0x000D1], "Nu" => [0x0039D], "OElig" => [0x00152], "Oacute" => [0x000D3], "Ocirc" => [0x000D4], "Ocy" => [0x0041E], "Odblac" => [0x00150], "Ofr" => [0x1D512], "Ograve" => [0x000D2], "Omacr" => [0x0014C], "Omega" => [0x003A9], "Omicron" => [0x0039F], "Oopf" => [0x1D546], "OpenCurlyDoubleQuote" => [0x0201C], "OpenCurlyQuote" => [0x02018], "Or" => [0x02A54], "Oscr" => [0x1D4AA], "Oslash" => [0x000D8], "Otilde" => [0x000D5], "Otimes" => [0x02A37], "Ouml" => [0x000D6], "OverBar" => [0x0203E], "OverBrace" => [0x023DE], "OverBracket" => [0x023B4], "OverParenthesis" => [0x023DC], "PartialD" => [0x02202], "Pcy" => [0x0041F], "Pfr" => [0x1D513], "Phi" => [0x003A6], "Pi" => [0x003A0], "PlusMinus" => [0x000B1], "Poincareplane" => [0x0210C], "Popf" => [0x02119], "Pr" => [0x02ABB], "Precedes" => [0x0227A], "PrecedesEqual" => [0x02AAF], "PrecedesSlantEqual" => [0x0227C], "PrecedesTilde" => [0x0227E], "Prime" => [0x02033], "Product" => [0x0220F], "Proportion" => [0x02237], "Proportional" => [0x0221D], "Pscr" => [0x1D4AB], "Psi" => [0x003A8], "QUOT" => [0x00022], "Qfr" => [0x1D514], "Qopf" => [0x0211A], "Qscr" => [0x1D4AC], "RBarr" => [0x02910], "REG" => [0x000AE], "Racute" => [0x00154], "Rang" => [0x027EB], "Rarr" => [0x021A0], "Rarrtl" => [0x02916], "Rcaron" => [0x00158], "Rcedil" => [0x00156], "Rcy" => [0x00420], "Re" => [0x0211C], "ReverseElement" => [0x0220B], "ReverseEquilibrium" => [0x021CB], "ReverseUpEquilibrium" => [0x0296F], "Rfr" => [0x0211C], "Rho" => [0x003A1], "RightAngleBracket" => [0x027E9], "RightArrow" => [0x02192], "RightArrowBar" => [0x021E5], "RightArrowLeftArrow" => [0x021C4], "RightCeiling" => [0x02309], "RightDoubleBracket" => [0x027E7], "RightDownTeeVector" => [0x0295D], "RightDownVector" => [0x021C2], "RightDownVectorBar" => [0x02955], "RightFloor" => [0x0230B], "RightTee" => [0x022A2], "RightTeeArrow" => [0x021A6], "RightTeeVector" => [0x0295B], "RightTriangle" => [0x022B3], "RightTriangleBar" => [0x029D0], "RightTriangleEqual" => [0x022B5], "RightUpDownVector" => [0x0294F], "RightUpTeeVector" => [0x0295C], "RightUpVector" => [0x021BE], "RightUpVectorBar" => [0x02954], "RightVector" => [0x021C0], "RightVectorBar" => [0x02953], "Rightarrow" => [0x021D2], "Ropf" => [0x0211D], "RoundImplies" => [0x02970], "Rrightarrow" => [0x021DB], "Rscr" => [0x0211B], "Rsh" => [0x021B1], "RuleDelayed" => [0x029F4], "SHCHcy" => [0x00429], "SHcy" => [0x00428], "SOFTcy" => [0x0042C], "Sacute" => [0x0015A], "Sc" => [0x02ABC], "Scaron" => [0x00160], "Scedil" => [0x0015E], "Scirc" => [0x0015C], "Scy" => [0x00421], "Sfr" => [0x1D516], "ShortDownArrow" => [0x02193], "ShortLeftArrow" => [0x02190], "ShortRightArrow" => [0x02192], "ShortUpArrow" => [0x02191], "Sigma" => [0x003A3], "SmallCircle" => [0x02218], "Sopf" => [0x1D54A], "Sqrt" => [0x0221A], "Square" => [0x025A1], "SquareIntersection" => [0x02293], "SquareSubset" => [0x0228F], "SquareSubsetEqual" => [0x02291], "SquareSuperset" => [0x02290], "SquareSupersetEqual" => [0x02292], "SquareUnion" => [0x02294], "Sscr" => [0x1D4AE], "Star" => [0x022C6], "Sub" => [0x022D0], "Subset" => [0x022D0], "SubsetEqual" => [0x02286], "Succeeds" => [0x0227B], "SucceedsEqual" => [0x02AB0], "SucceedsSlantEqual" => [0x0227D], "SucceedsTilde" => [0x0227F], "SuchThat" => [0x0220B], "Sum" => [0x02211], "Sup" => [0x022D1], "Superset" => [0x02283], "SupersetEqual" => [0x02287], "Supset" => [0x022D1], "THORN" => [0x000DE], "TRADE" => [0x02122], "TSHcy" => [0x0040B], "TScy" => [0x00426], "Tab" => [0x00009], "Tau" => [0x003A4], "Tcaron" => [0x00164], "Tcedil" => [0x00162], "Tcy" => [0x00422], "Tfr" => [0x1D517], "Therefore" => [0x02234], "Theta" => [0x00398], "ThickSpace" => [0x0205F, 0x0200A], "ThinSpace" => [0x02009], "Tilde" => [0x0223C], "TildeEqual" => [0x02243], "TildeFullEqual" => [0x02245], "TildeTilde" => [0x02248], "Topf" => [0x1D54B], "TripleDot" => [0x020DB], "Tscr" => [0x1D4AF], "Tstrok" => [0x00166], "Uacute" => [0x000DA], "Uarr" => [0x0219F], "Uarrocir" => [0x02949], "Ubrcy" => [0x0040E], "Ubreve" => [0x0016C], "Ucirc" => [0x000DB], "Ucy" => [0x00423], "Udblac" => [0x00170], "Ufr" => [0x1D518], "Ugrave" => [0x000D9], "Umacr" => [0x0016A], "UnderBar" => [0x0005F], "UnderBrace" => [0x023DF], "UnderBracket" => [0x023B5], "UnderParenthesis" => [0x023DD], "Union" => [0x022C3], "UnionPlus" => [0x0228E], "Uogon" => [0x00172], "Uopf" => [0x1D54C], "UpArrow" => [0x02191], "UpArrowBar" => [0x02912], "UpArrowDownArrow" => [0x021C5], "UpDownArrow" => [0x02195], "UpEquilibrium" => [0x0296E], "UpTee" => [0x022A5], "UpTeeArrow" => [0x021A5], "Uparrow" => [0x021D1], "Updownarrow" => [0x021D5], "UpperLeftArrow" => [0x02196], "UpperRightArrow" => [0x02197], "Upsi" => [0x003D2], "Upsilon" => [0x003A5], "Uring" => [0x0016E], "Uscr" => [0x1D4B0], "Utilde" => [0x00168], "Uuml" => [0x000DC], "VDash" => [0x022AB], "Vbar" => [0x02AEB], "Vcy" => [0x00412], "Vdash" => [0x022A9], "Vdashl" => [0x02AE6], "Vee" => [0x022C1], "Verbar" => [0x02016], "Vert" => [0x02016], "VerticalBar" => [0x02223], "VerticalLine" => [0x0007C], "VerticalSeparator" => [0x02758], "VerticalTilde" => [0x02240], "VeryThinSpace" => [0x0200A], "Vfr" => [0x1D519], "Vopf" => [0x1D54D], "Vscr" => [0x1D4B1], "Vvdash" => [0x022AA], "Wcirc" => [0x00174], "Wedge" => [0x022C0], "Wfr" => [0x1D51A], "Wopf" => [0x1D54E], "Wscr" => [0x1D4B2], "Xfr" => [0x1D51B], "Xi" => [0x0039E], "Xopf" => [0x1D54F], "Xscr" => [0x1D4B3], "YAcy" => [0x0042F], "YIcy" => [0x00407], "YUcy" => [0x0042E], "Yacute" => [0x000DD], "Ycirc" => [0x00176], "Ycy" => [0x0042B], "Yfr" => [0x1D51C], "Yopf" => [0x1D550], "Yscr" => [0x1D4B4], "Yuml" => [0x00178], "ZHcy" => [0x00416], "Zacute" => [0x00179], "Zcaron" => [0x0017D], "Zcy" => [0x00417], "Zdot" => [0x0017B], "ZeroWidthSpace" => [0x0200B], "Zeta" => [0x00396], "Zfr" => [0x02128], "Zopf" => [0x02124], "Zscr" => [0x1D4B5], "aacute" => [0x000E1], "abreve" => [0x00103], "ac" => [0x0223E], "acE" => [0x0223E, 0x00333], "acd" => [0x0223F], "acirc" => [0x000E2], "acute" => [0x000B4], "acy" => [0x00430], "aelig" => [0x000E6], "af" => [0x02061], "afr" => [0x1D51E], "agrave" => [0x000E0], "alefsym" => [0x02135], "aleph" => [0x02135], "alpha" => [0x003B1], "amacr" => [0x00101], "amalg" => [0x02A3F], "amp" => [0x00026], "and" => [0x02227], "andand" => [0x02A55], "andd" => [0x02A5C], "andslope" => [0x02A58], "andv" => [0x02A5A], "ang" => [0x02220], "ange" => [0x029A4], "angle" => [0x02220], "angmsd" => [0x02221], "angmsdaa" => [0x029A8], "angmsdab" => [0x029A9], "angmsdac" => [0x029AA], "angmsdad" => [0x029AB], "angmsdae" => [0x029AC], "angmsdaf" => [0x029AD], "angmsdag" => [0x029AE], "angmsdah" => [0x029AF], "angrt" => [0x0221F], "angrtvb" => [0x022BE], "angrtvbd" => [0x0299D], "angsph" => [0x02222], "angst" => [0x000C5], "angzarr" => [0x0237C], "aogon" => [0x00105], "aopf" => [0x1D552], "ap" => [0x02248], "apE" => [0x02A70], "apacir" => [0x02A6F], "ape" => [0x0224A], "apid" => [0x0224B], "apos" => [0x00027], "approx" => [0x02248], "approxeq" => [0x0224A], "aring" => [0x000E5], "ascr" => [0x1D4B6], "ast" => [0x0002A], "asymp" => [0x02248], "asympeq" => [0x0224D], "atilde" => [0x000E3], "auml" => [0x000E4], "awconint" => [0x02233], "awint" => [0x02A11], "bNot" => [0x02AED], "backcong" => [0x0224C], "backepsilon" => [0x003F6], "backprime" => [0x02035], "backsim" => [0x0223D], "backsimeq" => [0x022CD], "barvee" => [0x022BD], "barwed" => [0x02305], "barwedge" => [0x02305], "bbrk" => [0x023B5], "bbrktbrk" => [0x023B6], "bcong" => [0x0224C], "bcy" => [0x00431], "bdquo" => [0x0201E], "becaus" => [0x02235], "because" => [0x02235], "bemptyv" => [0x029B0], "bepsi" => [0x003F6], "bernou" => [0x0212C], "beta" => [0x003B2], "beth" => [0x02136], "between" => [0x0226C], "bfr" => [0x1D51F], "bigcap" => [0x022C2], "bigcirc" => [0x025EF], "bigcup" => [0x022C3], "bigodot" => [0x02A00], "bigoplus" => [0x02A01], "bigotimes" => [0x02A02], "bigsqcup" => [0x02A06], "bigstar" => [0x02605], "bigtriangledown" => [0x025BD], "bigtriangleup" => [0x025B3], "biguplus" => [0x02A04], "bigvee" => [0x022C1], "bigwedge" => [0x022C0], "bkarow" => [0x0290D], "blacklozenge" => [0x029EB], "blacksquare" => [0x025AA], "blacktriangle" => [0x025B4], "blacktriangledown" => [0x025BE], "blacktriangleleft" => [0x025C2], "blacktriangleright" => [0x025B8], "blank" => [0x02423], "blk12" => [0x02592], "blk14" => [0x02591], "blk34" => [0x02593], "block" => [0x02588], "bne" => [0x0003D, 0x020E5], "bnequiv" => [0x02261, 0x020E5], "bnot" => [0x02310], "bopf" => [0x1D553], "bot" => [0x022A5], "bottom" => [0x022A5], "bowtie" => [0x022C8], "boxDL" => [0x02557], "boxDR" => [0x02554], "boxDl" => [0x02556], "boxDr" => [0x02553], "boxH" => [0x02550], "boxHD" => [0x02566], "boxHU" => [0x02569], "boxHd" => [0x02564], "boxHu" => [0x02567], "boxUL" => [0x0255D], "boxUR" => [0x0255A], "boxUl" => [0x0255C], "boxUr" => [0x02559], "boxV" => [0x02551], "boxVH" => [0x0256C], "boxVL" => [0x02563], "boxVR" => [0x02560], "boxVh" => [0x0256B], "boxVl" => [0x02562], "boxVr" => [0x0255F], "boxbox" => [0x029C9], "boxdL" => [0x02555], "boxdR" => [0x02552], "boxdl" => [0x02510], "boxdr" => [0x0250C], "boxh" => [0x02500], "boxhD" => [0x02565], "boxhU" => [0x02568], "boxhd" => [0x0252C], "boxhu" => [0x02534], "boxminus" => [0x0229F], "boxplus" => [0x0229E], "boxtimes" => [0x022A0], "boxuL" => [0x0255B], "boxuR" => [0x02558], "boxul" => [0x02518], "boxur" => [0x02514], "boxv" => [0x02502], "boxvH" => [0x0256A], "boxvL" => [0x02561], "boxvR" => [0x0255E], "boxvh" => [0x0253C], "boxvl" => [0x02524], "boxvr" => [0x0251C], "bprime" => [0x02035], "breve" => [0x002D8], "brvbar" => [0x000A6], "bscr" => [0x1D4B7], "bsemi" => [0x0204F], "bsim" => [0x0223D], "bsime" => [0x022CD], "bsol" => [0x0005C], "bsolb" => [0x029C5], "bsolhsub" => [0x027C8], "bull" => [0x02022], "bullet" => [0x02022], "bump" => [0x0224E], "bumpE" => [0x02AAE], "bumpe" => [0x0224F], "bumpeq" => [0x0224F], "cacute" => [0x00107], "cap" => [0x02229], "capand" => [0x02A44], "capbrcup" => [0x02A49], "capcap" => [0x02A4B], "capcup" => [0x02A47], "capdot" => [0x02A40], "caps" => [0x02229, 0x0FE00], "caret" => [0x02041], "caron" => [0x002C7], "ccaps" => [0x02A4D], "ccaron" => [0x0010D], "ccedil" => [0x000E7], "ccirc" => [0x00109], "ccups" => [0x02A4C], "ccupssm" => [0x02A50], "cdot" => [0x0010B], "cedil" => [0x000B8], "cemptyv" => [0x029B2], "cent" => [0x000A2], "centerdot" => [0x000B7], "cfr" => [0x1D520], "chcy" => [0x00447], "check" => [0x02713], "checkmark" => [0x02713], "chi" => [0x003C7], "cir" => [0x025CB], "cirE" => [0x029C3], "circ" => [0x002C6], "circeq" => [0x02257], "circlearrowleft" => [0x021BA], "circlearrowright" => [0x021BB], "circledR" => [0x000AE], "circledS" => [0x024C8], "circledast" => [0x0229B], "circledcirc" => [0x0229A], "circleddash" => [0x0229D], "cire" => [0x02257], "cirfnint" => [0x02A10], "cirmid" => [0x02AEF], "cirscir" => [0x029C2], "clubs" => [0x02663], "clubsuit" => [0x02663], "colon" => [0x0003A], "colone" => [0x02254], "coloneq" => [0x02254], "comma" => [0x0002C], "commat" => [0x00040], "comp" => [0x02201], "compfn" => [0x02218], "complement" => [0x02201], "complexes" => [0x02102], "cong" => [0x02245], "congdot" => [0x02A6D], "conint" => [0x0222E], "copf" => [0x1D554], "coprod" => [0x02210], "copy" => [0x000A9], "copysr" => [0x02117], "crarr" => [0x021B5], "cross" => [0x02717], "cscr" => [0x1D4B8], "csub" => [0x02ACF], "csube" => [0x02AD1], "csup" => [0x02AD0], "csupe" => [0x02AD2], "ctdot" => [0x022EF], "cudarrl" => [0x02938], "cudarrr" => [0x02935], "cuepr" => [0x022DE], "cuesc" => [0x022DF], "cularr" => [0x021B6], "cularrp" => [0x0293D], "cup" => [0x0222A], "cupbrcap" => [0x02A48], "cupcap" => [0x02A46], "cupcup" => [0x02A4A], "cupdot" => [0x0228D], "cupor" => [0x02A45], "cups" => [0x0222A, 0x0FE00], "curarr" => [0x021B7], "curarrm" => [0x0293C], "curlyeqprec" => [0x022DE], "curlyeqsucc" => [0x022DF], "curlyvee" => [0x022CE], "curlywedge" => [0x022CF], "curren" => [0x000A4], "curvearrowleft" => [0x021B6], "curvearrowright" => [0x021B7], "cuvee" => [0x022CE], "cuwed" => [0x022CF], "cwconint" => [0x02232], "cwint" => [0x02231], "cylcty" => [0x0232D], "dArr" => [0x021D3], "dHar" => [0x02965], "dagger" => [0x02020], "daleth" => [0x02138], "darr" => [0x02193], "dash" => [0x02010], "dashv" => [0x022A3], "dbkarow" => [0x0290F], "dblac" => [0x002DD], "dcaron" => [0x0010F], "dcy" => [0x00434], "dd" => [0x02146], "ddagger" => [0x02021], "ddarr" => [0x021CA], "ddotseq" => [0x02A77], "deg" => [0x000B0], "delta" => [0x003B4], "demptyv" => [0x029B1], "dfisht" => [0x0297F], "dfr" => [0x1D521], "dharl" => [0x021C3], "dharr" => [0x021C2], "diam" => [0x022C4], "diamond" => [0x022C4], "diamondsuit" => [0x02666], "diams" => [0x02666], "die" => [0x000A8], "digamma" => [0x003DD], "disin" => [0x022F2], "div" => [0x000F7], "divide" => [0x000F7], "divideontimes" => [0x022C7], "divonx" => [0x022C7], "djcy" => [0x00452], "dlcorn" => [0x0231E], "dlcrop" => [0x0230D], "dollar" => [0x00024], "dopf" => [0x1D555], "dot" => [0x002D9], "doteq" => [0x02250], "doteqdot" => [0x02251], "dotminus" => [0x02238], "dotplus" => [0x02214], "dotsquare" => [0x022A1], "doublebarwedge" => [0x02306], "downarrow" => [0x02193], "downdownarrows" => [0x021CA], "downharpoonleft" => [0x021C3], "downharpoonright" => [0x021C2], "drbkarow" => [0x02910], "drcorn" => [0x0231F], "drcrop" => [0x0230C], "dscr" => [0x1D4B9], "dscy" => [0x00455], "dsol" => [0x029F6], "dstrok" => [0x00111], "dtdot" => [0x022F1], "dtri" => [0x025BF], "dtrif" => [0x025BE], "duarr" => [0x021F5], "duhar" => [0x0296F], "dwangle" => [0x029A6], "dzcy" => [0x0045F], "dzigrarr" => [0x027FF], "eDDot" => [0x02A77], "eDot" => [0x02251], "eacute" => [0x000E9], "easter" => [0x02A6E], "ecaron" => [0x0011B], "ecir" => [0x02256], "ecirc" => [0x000EA], "ecolon" => [0x02255], "ecy" => [0x0044D], "edot" => [0x00117], "ee" => [0x02147], "efDot" => [0x02252], "efr" => [0x1D522], "eg" => [0x02A9A], "egrave" => [0x000E8], "egs" => [0x02A96], "egsdot" => [0x02A98], "el" => [0x02A99], "elinters" => [0x023E7], "ell" => [0x02113], "els" => [0x02A95], "elsdot" => [0x02A97], "emacr" => [0x00113], "empty" => [0x02205], "emptyset" => [0x02205], "emptyv" => [0x02205], "emsp" => [0x02003], "emsp13" => [0x02004], "emsp14" => [0x02005], "eng" => [0x0014B], "ensp" => [0x02002], "eogon" => [0x00119], "eopf" => [0x1D556], "epar" => [0x022D5], "eparsl" => [0x029E3], "eplus" => [0x02A71], "epsi" => [0x003B5], "epsilon" => [0x003B5], "epsiv" => [0x003F5], "eqcirc" => [0x02256], "eqcolon" => [0x02255], "eqsim" => [0x02242], "eqslantgtr" => [0x02A96], "eqslantless" => [0x02A95], "equals" => [0x0003D], "equest" => [0x0225F], "equiv" => [0x02261], "equivDD" => [0x02A78], "eqvparsl" => [0x029E5], "erDot" => [0x02253], "erarr" => [0x02971], "escr" => [0x0212F], "esdot" => [0x02250], "esim" => [0x02242], "eta" => [0x003B7], "eth" => [0x000F0], "euml" => [0x000EB], "euro" => [0x020AC], "excl" => [0x00021], "exist" => [0x02203], "expectation" => [0x02130], "exponentiale" => [0x02147], "fallingdotseq" => [0x02252], "fcy" => [0x00444], "female" => [0x02640], "ffilig" => [0x0FB03], "fflig" => [0x0FB00], "ffllig" => [0x0FB04], "ffr" => [0x1D523], "filig" => [0x0FB01], "fjlig" => [0x00066, 0x0006A], "flat" => [0x0266D], "fllig" => [0x0FB02], "fltns" => [0x025B1], "fnof" => [0x00192], "fopf" => [0x1D557], "forall" => [0x02200], "fork" => [0x022D4], "forkv" => [0x02AD9], "fpartint" => [0x02A0D], "frac12" => [0x000BD], "frac13" => [0x02153], "frac14" => [0x000BC], "frac15" => [0x02155], "frac16" => [0x02159], "frac18" => [0x0215B], "frac23" => [0x02154], "frac25" => [0x02156], "frac34" => [0x000BE], "frac35" => [0x02157], "frac38" => [0x0215C], "frac45" => [0x02158], "frac56" => [0x0215A], "frac58" => [0x0215D], "frac78" => [0x0215E], "frasl" => [0x02044], "frown" => [0x02322], "fscr" => [0x1D4BB], "gE" => [0x02267], "gEl" => [0x02A8C], "gacute" => [0x001F5], "gamma" => [0x003B3], "gammad" => [0x003DD], "gap" => [0x02A86], "gbreve" => [0x0011F], "gcirc" => [0x0011D], "gcy" => [0x00433], "gdot" => [0x00121], "ge" => [0x02265], "gel" => [0x022DB], "geq" => [0x02265], "geqq" => [0x02267], "geqslant" => [0x02A7E], "ges" => [0x02A7E], "gescc" => [0x02AA9], "gesdot" => [0x02A80], "gesdoto" => [0x02A82], "gesdotol" => [0x02A84], "gesl" => [0x022DB, 0x0FE00], "gesles" => [0x02A94], "gfr" => [0x1D524], "gg" => [0x0226B], "ggg" => [0x022D9], "gimel" => [0x02137], "gjcy" => [0x00453], "gl" => [0x02277], "glE" => [0x02A92], "gla" => [0x02AA5], "glj" => [0x02AA4], "gnE" => [0x02269], "gnap" => [0x02A8A], "gnapprox" => [0x02A8A], "gne" => [0x02A88], "gneq" => [0x02A88], "gneqq" => [0x02269], "gnsim" => [0x022E7], "gopf" => [0x1D558], "grave" => [0x00060], "gscr" => [0x0210A], "gsim" => [0x02273], "gsime" => [0x02A8E], "gsiml" => [0x02A90], "gt" => [0x0003E], "gtcc" => [0x02AA7], "gtcir" => [0x02A7A], "gtdot" => [0x022D7], "gtlPar" => [0x02995], "gtquest" => [0x02A7C], "gtrapprox" => [0x02A86], "gtrarr" => [0x02978], "gtrdot" => [0x022D7], "gtreqless" => [0x022DB], "gtreqqless" => [0x02A8C], "gtrless" => [0x02277], "gtrsim" => [0x02273], "gvertneqq" => [0x02269, 0x0FE00], "gvnE" => [0x02269, 0x0FE00], "hArr" => [0x021D4], "hairsp" => [0x0200A], "half" => [0x000BD], "hamilt" => [0x0210B], "hardcy" => [0x0044A], "harr" => [0x02194], "harrcir" => [0x02948], "harrw" => [0x021AD], "hbar" => [0x0210F], "hcirc" => [0x00125], "hearts" => [0x02665], "heartsuit" => [0x02665], "hellip" => [0x02026], "hercon" => [0x022B9], "hfr" => [0x1D525], "hksearow" => [0x02925], "hkswarow" => [0x02926], "hoarr" => [0x021FF], "homtht" => [0x0223B], "hookleftarrow" => [0x021A9], "hookrightarrow" => [0x021AA], "hopf" => [0x1D559], "horbar" => [0x02015], "hscr" => [0x1D4BD], "hslash" => [0x0210F], "hstrok" => [0x00127], "hybull" => [0x02043], "hyphen" => [0x02010], "iacute" => [0x000ED], "ic" => [0x02063], "icirc" => [0x000EE], "icy" => [0x00438], "iecy" => [0x00435], "iexcl" => [0x000A1], "iff" => [0x021D4], "ifr" => [0x1D526], "igrave" => [0x000EC], "ii" => [0x02148], "iiiint" => [0x02A0C], "iiint" => [0x0222D], "iinfin" => [0x029DC], "iiota" => [0x02129], "ijlig" => [0x00133], "imacr" => [0x0012B], "image" => [0x02111], "imagline" => [0x02110], "imagpart" => [0x02111], "imath" => [0x00131], "imof" => [0x022B7], "imped" => [0x001B5], "in" => [0x02208], "incare" => [0x02105], "infin" => [0x0221E], "infintie" => [0x029DD], "inodot" => [0x00131], "int" => [0x0222B], "intcal" => [0x022BA], "integers" => [0x02124], "intercal" => [0x022BA], "intlarhk" => [0x02A17], "intprod" => [0x02A3C], "iocy" => [0x00451], "iogon" => [0x0012F], "iopf" => [0x1D55A], "iota" => [0x003B9], "iprod" => [0x02A3C], "iquest" => [0x000BF], "iscr" => [0x1D4BE], "isin" => [0x02208], "isinE" => [0x022F9], "isindot" => [0x022F5], "isins" => [0x022F4], "isinsv" => [0x022F3], "isinv" => [0x02208], "it" => [0x02062], "itilde" => [0x00129], "iukcy" => [0x00456], "iuml" => [0x000EF], "jcirc" => [0x00135], "jcy" => [0x00439], "jfr" => [0x1D527], "jmath" => [0x00237], "jopf" => [0x1D55B], "jscr" => [0x1D4BF], "jsercy" => [0x00458], "jukcy" => [0x00454], "kappa" => [0x003BA], "kappav" => [0x003F0], "kcedil" => [0x00137], "kcy" => [0x0043A], "kfr" => [0x1D528], "kgreen" => [0x00138], "khcy" => [0x00445], "kjcy" => [0x0045C], "kopf" => [0x1D55C], "kscr" => [0x1D4C0], "lAarr" => [0x021DA], "lArr" => [0x021D0], "lAtail" => [0x0291B], "lBarr" => [0x0290E], "lE" => [0x02266], "lEg" => [0x02A8B], "lHar" => [0x02962], "lacute" => [0x0013A], "laemptyv" => [0x029B4], "lagran" => [0x02112], "lambda" => [0x003BB], "lang" => [0x027E8], "langd" => [0x02991], "langle" => [0x027E8], "lap" => [0x02A85], "laquo" => [0x000AB], "larr" => [0x02190], "larrb" => [0x021E4], "larrbfs" => [0x0291F], "larrfs" => [0x0291D], "larrhk" => [0x021A9], "larrlp" => [0x021AB], "larrpl" => [0x02939], "larrsim" => [0x02973], "larrtl" => [0x021A2], "lat" => [0x02AAB], "latail" => [0x02919], "late" => [0x02AAD], "lates" => [0x02AAD, 0x0FE00], "lbarr" => [0x0290C], "lbbrk" => [0x02772], "lbrace" => [0x0007B], "lbrack" => [0x0005B], "lbrke" => [0x0298B], "lbrksld" => [0x0298F], "lbrkslu" => [0x0298D], "lcaron" => [0x0013E], "lcedil" => [0x0013C], "lceil" => [0x02308], "lcub" => [0x0007B], "lcy" => [0x0043B], "ldca" => [0x02936], "ldquo" => [0x0201C], "ldquor" => [0x0201E], "ldrdhar" => [0x02967], "ldrushar" => [0x0294B], "ldsh" => [0x021B2], "le" => [0x02264], "leftarrow" => [0x02190], "leftarrowtail" => [0x021A2], "leftharpoondown" => [0x021BD], "leftharpoonup" => [0x021BC], "leftleftarrows" => [0x021C7], "leftrightarrow" => [0x02194], "leftrightarrows" => [0x021C6], "leftrightharpoons" => [0x021CB], "leftrightsquigarrow" => [0x021AD], "leftthreetimes" => [0x022CB], "leg" => [0x022DA], "leq" => [0x02264], "leqq" => [0x02266], "leqslant" => [0x02A7D], "les" => [0x02A7D], "lescc" => [0x02AA8], "lesdot" => [0x02A7F], "lesdoto" => [0x02A81], "lesdotor" => [0x02A83], "lesg" => [0x022DA, 0x0FE00], "lesges" => [0x02A93], "lessapprox" => [0x02A85], "lessdot" => [0x022D6], "lesseqgtr" => [0x022DA], "lesseqqgtr" => [0x02A8B], "lessgtr" => [0x02276], "lesssim" => [0x02272], "lfisht" => [0x0297C], "lfloor" => [0x0230A], "lfr" => [0x1D529], "lg" => [0x02276], "lgE" => [0x02A91], "lhard" => [0x021BD], "lharu" => [0x021BC], "lharul" => [0x0296A], "lhblk" => [0x02584], "ljcy" => [0x00459], "ll" => [0x0226A], "llarr" => [0x021C7], "llcorner" => [0x0231E], "llhard" => [0x0296B], "lltri" => [0x025FA], "lmidot" => [0x00140], "lmoust" => [0x023B0], "lmoustache" => [0x023B0], "lnE" => [0x02268], "lnap" => [0x02A89], "lnapprox" => [0x02A89], "lne" => [0x02A87], "lneq" => [0x02A87], "lneqq" => [0x02268], "lnsim" => [0x022E6], "loang" => [0x027EC], "loarr" => [0x021FD], "lobrk" => [0x027E6], "longleftarrow" => [0x027F5], "longleftrightarrow" => [0x027F7], "longmapsto" => [0x027FC], "longrightarrow" => [0x027F6], "looparrowleft" => [0x021AB], "looparrowright" => [0x021AC], "lopar" => [0x02985], "lopf" => [0x1D55D], "loplus" => [0x02A2D], "lotimes" => [0x02A34], "lowast" => [0x02217], "lowbar" => [0x0005F], "loz" => [0x025CA], "lozenge" => [0x025CA], "lozf" => [0x029EB], "lpar" => [0x00028], "lparlt" => [0x02993], "lrarr" => [0x021C6], "lrcorner" => [0x0231F], "lrhar" => [0x021CB], "lrhard" => [0x0296D], "lrm" => [0x0200E], "lrtri" => [0x022BF], "lsaquo" => [0x02039], "lscr" => [0x1D4C1], "lsh" => [0x021B0], "lsim" => [0x02272], "lsime" => [0x02A8D], "lsimg" => [0x02A8F], "lsqb" => [0x0005B], "lsquo" => [0x02018], "lsquor" => [0x0201A], "lstrok" => [0x00142], "lt" => [0x0003C], "ltcc" => [0x02AA6], "ltcir" => [0x02A79], "ltdot" => [0x022D6], "lthree" => [0x022CB], "ltimes" => [0x022C9], "ltlarr" => [0x02976], "ltquest" => [0x02A7B], "ltrPar" => [0x02996], "ltri" => [0x025C3], "ltrie" => [0x022B4], "ltrif" => [0x025C2], "lurdshar" => [0x0294A], "luruhar" => [0x02966], "lvertneqq" => [0x02268, 0x0FE00], "lvnE" => [0x02268, 0x0FE00], "mDDot" => [0x0223A], "macr" => [0x000AF], "male" => [0x02642], "malt" => [0x02720], "maltese" => [0x02720], "map" => [0x021A6], "mapsto" => [0x021A6], "mapstodown" => [0x021A7], "mapstoleft" => [0x021A4], "mapstoup" => [0x021A5], "marker" => [0x025AE], "mcomma" => [0x02A29], "mcy" => [0x0043C], "mdash" => [0x02014], "measuredangle" => [0x02221], "mfr" => [0x1D52A], "mho" => [0x02127], "micro" => [0x000B5], "mid" => [0x02223], "midast" => [0x0002A], "midcir" => [0x02AF0], "middot" => [0x000B7], "minus" => [0x02212], "minusb" => [0x0229F], "minusd" => [0x02238], "minusdu" => [0x02A2A], "mlcp" => [0x02ADB], "mldr" => [0x02026], "mnplus" => [0x02213], "models" => [0x022A7], "mopf" => [0x1D55E], "mp" => [0x02213], "mscr" => [0x1D4C2], "mstpos" => [0x0223E], "mu" => [0x003BC], "multimap" => [0x022B8], "mumap" => [0x022B8], "nGg" => [0x022D9, 0x00338], "nGt" => [0x0226B, 0x020D2], "nGtv" => [0x0226B, 0x00338], "nLeftarrow" => [0x021CD], "nLeftrightarrow" => [0x021CE], "nLl" => [0x022D8, 0x00338], "nLt" => [0x0226A, 0x020D2], "nLtv" => [0x0226A, 0x00338], "nRightarrow" => [0x021CF], "nVDash" => [0x022AF], "nVdash" => [0x022AE], "nabla" => [0x02207], "nacute" => [0x00144], "nang" => [0x02220, 0x020D2], "nap" => [0x02249], "napE" => [0x02A70, 0x00338], "napid" => [0x0224B, 0x00338], "napos" => [0x00149], "napprox" => [0x02249], "natur" => [0x0266E], "natural" => [0x0266E], "naturals" => [0x02115], "nbsp" => [0x000A0], "nbump" => [0x0224E, 0x00338], "nbumpe" => [0x0224F, 0x00338], "ncap" => [0x02A43], "ncaron" => [0x00148], "ncedil" => [0x00146], "ncong" => [0x02247], "ncongdot" => [0x02A6D, 0x00338], "ncup" => [0x02A42], "ncy" => [0x0043D], "ndash" => [0x02013], "ne" => [0x02260], "neArr" => [0x021D7], "nearhk" => [0x02924], "nearr" => [0x02197], "nearrow" => [0x02197], "nedot" => [0x02250, 0x00338], "nequiv" => [0x02262], "nesear" => [0x02928], "nesim" => [0x02242, 0x00338], "nexist" => [0x02204], "nexists" => [0x02204], "nfr" => [0x1D52B], "ngE" => [0x02267, 0x00338], "nge" => [0x02271], "ngeq" => [0x02271], "ngeqq" => [0x02267, 0x00338], "ngeqslant" => [0x02A7E, 0x00338], "nges" => [0x02A7E, 0x00338], "ngsim" => [0x02275], "ngt" => [0x0226F], "ngtr" => [0x0226F], "nhArr" => [0x021CE], "nharr" => [0x021AE], "nhpar" => [0x02AF2], "ni" => [0x0220B], "nis" => [0x022FC], "nisd" => [0x022FA], "niv" => [0x0220B], "njcy" => [0x0045A], "nlArr" => [0x021CD], "nlE" => [0x02266, 0x00338], "nlarr" => [0x0219A], "nldr" => [0x02025], "nle" => [0x02270], "nleftarrow" => [0x0219A], "nleftrightarrow" => [0x021AE], "nleq" => [0x02270], "nleqq" => [0x02266, 0x00338], "nleqslant" => [0x02A7D, 0x00338], "nles" => [0x02A7D, 0x00338], "nless" => [0x0226E], "nlsim" => [0x02274], "nlt" => [0x0226E], "nltri" => [0x022EA], "nltrie" => [0x022EC], "nmid" => [0x02224], "nopf" => [0x1D55F], "not" => [0x000AC], "notin" => [0x02209], "notinE" => [0x022F9, 0x00338], "notindot" => [0x022F5, 0x00338], "notinva" => [0x02209], "notinvb" => [0x022F7], "notinvc" => [0x022F6], "notni" => [0x0220C], "notniva" => [0x0220C], "notnivb" => [0x022FE], "notnivc" => [0x022FD], "npar" => [0x02226], "nparallel" => [0x02226], "nparsl" => [0x02AFD, 0x020E5], "npart" => [0x02202, 0x00338], "npolint" => [0x02A14], "npr" => [0x02280], "nprcue" => [0x022E0], "npre" => [0x02AAF, 0x00338], "nprec" => [0x02280], "npreceq" => [0x02AAF, 0x00338], "nrArr" => [0x021CF], "nrarr" => [0x0219B], "nrarrc" => [0x02933, 0x00338], "nrarrw" => [0x0219D, 0x00338], "nrightarrow" => [0x0219B], "nrtri" => [0x022EB], "nrtrie" => [0x022ED], "nsc" => [0x02281], "nsccue" => [0x022E1], "nsce" => [0x02AB0, 0x00338], "nscr" => [0x1D4C3], "nshortmid" => [0x02224], "nshortparallel" => [0x02226], "nsim" => [0x02241], "nsime" => [0x02244], "nsimeq" => [0x02244], "nsmid" => [0x02224], "nspar" => [0x02226], "nsqsube" => [0x022E2], "nsqsupe" => [0x022E3], "nsub" => [0x02284], "nsubE" => [0x02AC5, 0x00338], "nsube" => [0x02288], "nsubset" => [0x02282, 0x020D2], "nsubseteq" => [0x02288], "nsubseteqq" => [0x02AC5, 0x00338], "nsucc" => [0x02281], "nsucceq" => [0x02AB0, 0x00338], "nsup" => [0x02285], "nsupE" => [0x02AC6, 0x00338], "nsupe" => [0x02289], "nsupset" => [0x02283, 0x020D2], "nsupseteq" => [0x02289], "nsupseteqq" => [0x02AC6, 0x00338], "ntgl" => [0x02279], "ntilde" => [0x000F1], "ntlg" => [0x02278], "ntriangleleft" => [0x022EA], "ntrianglelefteq" => [0x022EC], "ntriangleright" => [0x022EB], "ntrianglerighteq" => [0x022ED], "nu" => [0x003BD], "num" => [0x00023], "numero" => [0x02116], "numsp" => [0x02007], "nvDash" => [0x022AD], "nvHarr" => [0x02904], "nvap" => [0x0224D, 0x020D2], "nvdash" => [0x022AC], "nvge" => [0x02265, 0x020D2], "nvgt" => [0x0003E, 0x020D2], "nvinfin" => [0x029DE], "nvlArr" => [0x02902], "nvle" => [0x02264, 0x020D2], "nvlt" => [0x0003C, 0x020D2], "nvltrie" => [0x022B4, 0x020D2], "nvrArr" => [0x02903], "nvrtrie" => [0x022B5, 0x020D2], "nvsim" => [0x0223C, 0x020D2], "nwArr" => [0x021D6], "nwarhk" => [0x02923], "nwarr" => [0x02196], "nwarrow" => [0x02196], "nwnear" => [0x02927], "oS" => [0x024C8], "oacute" => [0x000F3], "oast" => [0x0229B], "ocir" => [0x0229A], "ocirc" => [0x000F4], "ocy" => [0x0043E], "odash" => [0x0229D], "odblac" => [0x00151], "odiv" => [0x02A38], "odot" => [0x02299], "odsold" => [0x029BC], "oelig" => [0x00153], "ofcir" => [0x029BF], "ofr" => [0x1D52C], "ogon" => [0x002DB], "ograve" => [0x000F2], "ogt" => [0x029C1], "ohbar" => [0x029B5], "ohm" => [0x003A9], "oint" => [0x0222E], "olarr" => [0x021BA], "olcir" => [0x029BE], "olcross" => [0x029BB], "oline" => [0x0203E], "olt" => [0x029C0], "omacr" => [0x0014D], "omega" => [0x003C9], "omicron" => [0x003BF], "omid" => [0x029B6], "ominus" => [0x02296], "oopf" => [0x1D560], "opar" => [0x029B7], "operp" => [0x029B9], "oplus" => [0x02295], "or" => [0x02228], "orarr" => [0x021BB], "ord" => [0x02A5D], "order" => [0x02134], "orderof" => [0x02134], "ordf" => [0x000AA], "ordm" => [0x000BA], "origof" => [0x022B6], "oror" => [0x02A56], "orslope" => [0x02A57], "orv" => [0x02A5B], "oscr" => [0x02134], "oslash" => [0x000F8], "osol" => [0x02298], "otilde" => [0x000F5], "otimes" => [0x02297], "otimesas" => [0x02A36], "ouml" => [0x000F6], "ovbar" => [0x0233D], "par" => [0x02225], "para" => [0x000B6], "parallel" => [0x02225], "parsim" => [0x02AF3], "parsl" => [0x02AFD], "part" => [0x02202], "pcy" => [0x0043F], "percnt" => [0x00025], "period" => [0x0002E], "permil" => [0x02030], "perp" => [0x022A5], "pertenk" => [0x02031], "pfr" => [0x1D52D], "phi" => [0x003C6], "phiv" => [0x003D5], "phmmat" => [0x02133], "phone" => [0x0260E], "pi" => [0x003C0], "pitchfork" => [0x022D4], "piv" => [0x003D6], "planck" => [0x0210F], "planckh" => [0x0210E], "plankv" => [0x0210F], "plus" => [0x0002B], "plusacir" => [0x02A23], "plusb" => [0x0229E], "pluscir" => [0x02A22], "plusdo" => [0x02214], "plusdu" => [0x02A25], "pluse" => [0x02A72], "plusmn" => [0x000B1], "plussim" => [0x02A26], "plustwo" => [0x02A27], "pm" => [0x000B1], "pointint" => [0x02A15], "popf" => [0x1D561], "pound" => [0x000A3], "pr" => [0x0227A], "prE" => [0x02AB3], "prap" => [0x02AB7], "prcue" => [0x0227C], "pre" => [0x02AAF], "prec" => [0x0227A], "precapprox" => [0x02AB7], "preccurlyeq" => [0x0227C], "preceq" => [0x02AAF], "precnapprox" => [0x02AB9], "precneqq" => [0x02AB5], "precnsim" => [0x022E8], "precsim" => [0x0227E], "prime" => [0x02032], "primes" => [0x02119], "prnE" => [0x02AB5], "prnap" => [0x02AB9], "prnsim" => [0x022E8], "prod" => [0x0220F], "profalar" => [0x0232E], "profline" => [0x02312], "profsurf" => [0x02313], "prop" => [0x0221D], "propto" => [0x0221D], "prsim" => [0x0227E], "prurel" => [0x022B0], "pscr" => [0x1D4C5], "psi" => [0x003C8], "puncsp" => [0x02008], "qfr" => [0x1D52E], "qint" => [0x02A0C], "qopf" => [0x1D562], "qprime" => [0x02057], "qscr" => [0x1D4C6], "quaternions" => [0x0210D], "quatint" => [0x02A16], "quest" => [0x0003F], "questeq" => [0x0225F], "quot" => [0x00022], "rAarr" => [0x021DB], "rArr" => [0x021D2], "rAtail" => [0x0291C], "rBarr" => [0x0290F], "rHar" => [0x02964], "race" => [0x0223D, 0x00331], "racute" => [0x00155], "radic" => [0x0221A], "raemptyv" => [0x029B3], "rang" => [0x027E9], "rangd" => [0x02992], "range" => [0x029A5], "rangle" => [0x027E9], "raquo" => [0x000BB], "rarr" => [0x02192], "rarrap" => [0x02975], "rarrb" => [0x021E5], "rarrbfs" => [0x02920], "rarrc" => [0x02933], "rarrfs" => [0x0291E], "rarrhk" => [0x021AA], "rarrlp" => [0x021AC], "rarrpl" => [0x02945], "rarrsim" => [0x02974], "rarrtl" => [0x021A3], "rarrw" => [0x0219D], "ratail" => [0x0291A], "ratio" => [0x02236], "rationals" => [0x0211A], "rbarr" => [0x0290D], "rbbrk" => [0x02773], "rbrace" => [0x0007D], "rbrack" => [0x0005D], "rbrke" => [0x0298C], "rbrksld" => [0x0298E], "rbrkslu" => [0x02990], "rcaron" => [0x00159], "rcedil" => [0x00157], "rceil" => [0x02309], "rcub" => [0x0007D], "rcy" => [0x00440], "rdca" => [0x02937], "rdldhar" => [0x02969], "rdquo" => [0x0201D], "rdquor" => [0x0201D], "rdsh" => [0x021B3], "real" => [0x0211C], "realine" => [0x0211B], "realpart" => [0x0211C], "reals" => [0x0211D], "rect" => [0x025AD], "reg" => [0x000AE], "rfisht" => [0x0297D], "rfloor" => [0x0230B], "rfr" => [0x1D52F], "rhard" => [0x021C1], "rharu" => [0x021C0], "rharul" => [0x0296C], "rho" => [0x003C1], "rhov" => [0x003F1], "rightarrow" => [0x02192], "rightarrowtail" => [0x021A3], "rightharpoondown" => [0x021C1], "rightharpoonup" => [0x021C0], "rightleftarrows" => [0x021C4], "rightleftharpoons" => [0x021CC], "rightrightarrows" => [0x021C9], "rightsquigarrow" => [0x0219D], "rightthreetimes" => [0x022CC], "ring" => [0x002DA], "risingdotseq" => [0x02253], "rlarr" => [0x021C4], "rlhar" => [0x021CC], "rlm" => [0x0200F], "rmoust" => [0x023B1], "rmoustache" => [0x023B1], "rnmid" => [0x02AEE], "roang" => [0x027ED], "roarr" => [0x021FE], "robrk" => [0x027E7], "ropar" => [0x02986], "ropf" => [0x1D563], "roplus" => [0x02A2E], "rotimes" => [0x02A35], "rpar" => [0x00029], "rpargt" => [0x02994], "rppolint" => [0x02A12], "rrarr" => [0x021C9], "rsaquo" => [0x0203A], "rscr" => [0x1D4C7], "rsh" => [0x021B1], "rsqb" => [0x0005D], "rsquo" => [0x02019], "rsquor" => [0x02019], "rthree" => [0x022CC], "rtimes" => [0x022CA], "rtri" => [0x025B9], "rtrie" => [0x022B5], "rtrif" => [0x025B8], "rtriltri" => [0x029CE], "ruluhar" => [0x02968], "rx" => [0x0211E], "sacute" => [0x0015B], "sbquo" => [0x0201A], "sc" => [0x0227B], "scE" => [0x02AB4], "scap" => [0x02AB8], "scaron" => [0x00161], "sccue" => [0x0227D], "sce" => [0x02AB0], "scedil" => [0x0015F], "scirc" => [0x0015D], "scnE" => [0x02AB6], "scnap" => [0x02ABA], "scnsim" => [0x022E9], "scpolint" => [0x02A13], "scsim" => [0x0227F], "scy" => [0x00441], "sdot" => [0x022C5], "sdotb" => [0x022A1], "sdote" => [0x02A66], "seArr" => [0x021D8], "searhk" => [0x02925], "searr" => [0x02198], "searrow" => [0x02198], "sect" => [0x000A7], "semi" => [0x0003B], "seswar" => [0x02929], "setminus" => [0x02216], "setmn" => [0x02216], "sext" => [0x02736], "sfr" => [0x1D530], "sfrown" => [0x02322], "sharp" => [0x0266F], "shchcy" => [0x00449], "shcy" => [0x00448], "shortmid" => [0x02223], "shortparallel" => [0x02225], "shy" => [0x000AD], "sigma" => [0x003C3], "sigmaf" => [0x003C2], "sigmav" => [0x003C2], "sim" => [0x0223C], "simdot" => [0x02A6A], "sime" => [0x02243], "simeq" => [0x02243], "simg" => [0x02A9E], "simgE" => [0x02AA0], "siml" => [0x02A9D], "simlE" => [0x02A9F], "simne" => [0x02246], "simplus" => [0x02A24], "simrarr" => [0x02972], "slarr" => [0x02190], "smallsetminus" => [0x02216], "smashp" => [0x02A33], "smeparsl" => [0x029E4], "smid" => [0x02223], "smile" => [0x02323], "smt" => [0x02AAA], "smte" => [0x02AAC], "smtes" => [0x02AAC, 0x0FE00], "softcy" => [0x0044C], "sol" => [0x0002F], "solb" => [0x029C4], "solbar" => [0x0233F], "sopf" => [0x1D564], "spades" => [0x02660], "spadesuit" => [0x02660], "spar" => [0x02225], "sqcap" => [0x02293], "sqcaps" => [0x02293, 0x0FE00], "sqcup" => [0x02294], "sqcups" => [0x02294, 0x0FE00], "sqsub" => [0x0228F], "sqsube" => [0x02291], "sqsubset" => [0x0228F], "sqsubseteq" => [0x02291], "sqsup" => [0x02290], "sqsupe" => [0x02292], "sqsupset" => [0x02290], "sqsupseteq" => [0x02292], "squ" => [0x025A1], "square" => [0x025A1], "squarf" => [0x025AA], "squf" => [0x025AA], "srarr" => [0x02192], "sscr" => [0x1D4C8], "ssetmn" => [0x02216], "ssmile" => [0x02323], "sstarf" => [0x022C6], "star" => [0x02606], "starf" => [0x02605], "straightepsilon" => [0x003F5], "straightphi" => [0x003D5], "strns" => [0x000AF], "sub" => [0x02282], "subE" => [0x02AC5], "subdot" => [0x02ABD], "sube" => [0x02286], "subedot" => [0x02AC3], "submult" => [0x02AC1], "subnE" => [0x02ACB], "subne" => [0x0228A], "subplus" => [0x02ABF], "subrarr" => [0x02979], "subset" => [0x02282], "subseteq" => [0x02286], "subseteqq" => [0x02AC5], "subsetneq" => [0x0228A], "subsetneqq" => [0x02ACB], "subsim" => [0x02AC7], "subsub" => [0x02AD5], "subsup" => [0x02AD3], "succ" => [0x0227B], "succapprox" => [0x02AB8], "succcurlyeq" => [0x0227D], "succeq" => [0x02AB0], "succnapprox" => [0x02ABA], "succneqq" => [0x02AB6], "succnsim" => [0x022E9], "succsim" => [0x0227F], "sum" => [0x02211], "sung" => [0x0266A], "sup" => [0x02283], "sup1" => [0x000B9], "sup2" => [0x000B2], "sup3" => [0x000B3], "supE" => [0x02AC6], "supdot" => [0x02ABE], "supdsub" => [0x02AD8], "supe" => [0x02287], "supedot" => [0x02AC4], "suphsol" => [0x027C9], "suphsub" => [0x02AD7], "suplarr" => [0x0297B], "supmult" => [0x02AC2], "supnE" => [0x02ACC], "supne" => [0x0228B], "supplus" => [0x02AC0], "supset" => [0x02283], "supseteq" => [0x02287], "supseteqq" => [0x02AC6], "supsetneq" => [0x0228B], "supsetneqq" => [0x02ACC], "supsim" => [0x02AC8], "supsub" => [0x02AD4], "supsup" => [0x02AD6], "swArr" => [0x021D9], "swarhk" => [0x02926], "swarr" => [0x02199], "swarrow" => [0x02199], "swnwar" => [0x0292A], "szlig" => [0x000DF], "target" => [0x02316], "tau" => [0x003C4], "tbrk" => [0x023B4], "tcaron" => [0x00165], "tcedil" => [0x00163], "tcy" => [0x00442], "tdot" => [0x020DB], "telrec" => [0x02315], "tfr" => [0x1D531], "there4" => [0x02234], "therefore" => [0x02234], "theta" => [0x003B8], "thetasym" => [0x003D1], "thetav" => [0x003D1], "thickapprox" => [0x02248], "thicksim" => [0x0223C], "thinsp" => [0x02009], "thkap" => [0x02248], "thksim" => [0x0223C], "thorn" => [0x000FE], "tilde" => [0x002DC], "times" => [0x000D7], "timesb" => [0x022A0], "timesbar" => [0x02A31], "timesd" => [0x02A30], "tint" => [0x0222D], "toea" => [0x02928], "top" => [0x022A4], "topbot" => [0x02336], "topcir" => [0x02AF1], "topf" => [0x1D565], "topfork" => [0x02ADA], "tosa" => [0x02929], "tprime" => [0x02034], "trade" => [0x02122], "triangle" => [0x025B5], "triangledown" => [0x025BF], "triangleleft" => [0x025C3], "trianglelefteq" => [0x022B4], "triangleq" => [0x0225C], "triangleright" => [0x025B9], "trianglerighteq" => [0x022B5], "tridot" => [0x025EC], "trie" => [0x0225C], "triminus" => [0x02A3A], "triplus" => [0x02A39], "trisb" => [0x029CD], "tritime" => [0x02A3B], "trpezium" => [0x023E2], "tscr" => [0x1D4C9], "tscy" => [0x00446], "tshcy" => [0x0045B], "tstrok" => [0x00167], "twixt" => [0x0226C], "twoheadleftarrow" => [0x0219E], "twoheadrightarrow" => [0x021A0], "uArr" => [0x021D1], "uHar" => [0x02963], "uacute" => [0x000FA], "uarr" => [0x02191], "ubrcy" => [0x0045E], "ubreve" => [0x0016D], "ucirc" => [0x000FB], "ucy" => [0x00443], "udarr" => [0x021C5], "udblac" => [0x00171], "udhar" => [0x0296E], "ufisht" => [0x0297E], "ufr" => [0x1D532], "ugrave" => [0x000F9], "uharl" => [0x021BF], "uharr" => [0x021BE], "uhblk" => [0x02580], "ulcorn" => [0x0231C], "ulcorner" => [0x0231C], "ulcrop" => [0x0230F], "ultri" => [0x025F8], "umacr" => [0x0016B], "uml" => [0x000A8], "uogon" => [0x00173], "uopf" => [0x1D566], "uparrow" => [0x02191], "updownarrow" => [0x02195], "upharpoonleft" => [0x021BF], "upharpoonright" => [0x021BE], "uplus" => [0x0228E], "upsi" => [0x003C5], "upsih" => [0x003D2], "upsilon" => [0x003C5], "upuparrows" => [0x021C8], "urcorn" => [0x0231D], "urcorner" => [0x0231D], "urcrop" => [0x0230E], "uring" => [0x0016F], "urtri" => [0x025F9], "uscr" => [0x1D4CA], "utdot" => [0x022F0], "utilde" => [0x00169], "utri" => [0x025B5], "utrif" => [0x025B4], "uuarr" => [0x021C8], "uuml" => [0x000FC], "uwangle" => [0x029A7], "vArr" => [0x021D5], "vBar" => [0x02AE8], "vBarv" => [0x02AE9], "vDash" => [0x022A8], "vangrt" => [0x0299C], "varepsilon" => [0x003F5], "varkappa" => [0x003F0], "varnothing" => [0x02205], "varphi" => [0x003D5], "varpi" => [0x003D6], "varpropto" => [0x0221D], "varr" => [0x02195], "varrho" => [0x003F1], "varsigma" => [0x003C2], "varsubsetneq" => [0x0228A, 0x0FE00], "varsubsetneqq" => [0x02ACB, 0x0FE00], "varsupsetneq" => [0x0228B, 0x0FE00], "varsupsetneqq" => [0x02ACC, 0x0FE00], "vartheta" => [0x003D1], "vartriangleleft" => [0x022B2], "vartriangleright" => [0x022B3], "vcy" => [0x00432], "vdash" => [0x022A2], "vee" => [0x02228], "veebar" => [0x022BB], "veeeq" => [0x0225A], "vellip" => [0x022EE], "verbar" => [0x0007C], "vert" => [0x0007C], "vfr" => [0x1D533], "vltri" => [0x022B2], "vnsub" => [0x02282, 0x020D2], "vnsup" => [0x02283, 0x020D2], "vopf" => [0x1D567], "vprop" => [0x0221D], "vrtri" => [0x022B3], "vscr" => [0x1D4CB], "vsubnE" => [0x02ACB, 0x0FE00], "vsubne" => [0x0228A, 0x0FE00], "vsupnE" => [0x02ACC, 0x0FE00], "vsupne" => [0x0228B, 0x0FE00], "vzigzag" => [0x0299A], "wcirc" => [0x00175], "wedbar" => [0x02A5F], "wedge" => [0x02227], "wedgeq" => [0x02259], "weierp" => [0x02118], "wfr" => [0x1D534], "wopf" => [0x1D568], "wp" => [0x02118], "wr" => [0x02240], "wreath" => [0x02240], "wscr" => [0x1D4CC], "xcap" => [0x022C2], "xcirc" => [0x025EF], "xcup" => [0x022C3], "xdtri" => [0x025BD], "xfr" => [0x1D535], "xhArr" => [0x027FA], "xharr" => [0x027F7], "xi" => [0x003BE], "xlArr" => [0x027F8], "xlarr" => [0x027F5], "xmap" => [0x027FC], "xnis" => [0x022FB], "xodot" => [0x02A00], "xopf" => [0x1D569], "xoplus" => [0x02A01], "xotime" => [0x02A02], "xrArr" => [0x027F9], "xrarr" => [0x027F6], "xscr" => [0x1D4CD], "xsqcup" => [0x02A06], "xuplus" => [0x02A04], "xutri" => [0x025B3], "xvee" => [0x022C1], "xwedge" => [0x022C0], "yacute" => [0x000FD], "yacy" => [0x0044F], "ycirc" => [0x00177], "ycy" => [0x0044B], "yen" => [0x000A5], "yfr" => [0x1D536], "yicy" => [0x00457], "yopf" => [0x1D56A], "yscr" => [0x1D4CE], "yucy" => [0x0044E], "yuml" => [0x000FF], "zacute" => [0x0017A], "zcaron" => [0x0017E], "zcy" => [0x00437], "zdot" => [0x0017C], "zeetrf" => [0x02128], "zeta" => [0x003B6], "zfr" => [0x1D537], "zhcy" => [0x00436], "zigrarr" => [0x021DD], "zopf" => [0x1D56B], "zscr" => [0x1D4CF], "zwj" => [0x0200D], "zwnj" => [0x0200C], }
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/knife-windows-1.4.1/spec/unit/knife/core/windows_bootstrap_context_spec.rb
<reponame>arnab0073/idea # # Author:: <NAME> <<EMAIL>> # Copyright:: Copyright (c) 2014-2016 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # require 'spec_helper' describe Chef::Knife::Core::WindowsBootstrapContext do let(:mock_bootstrap_context) { Chef::Knife::Core::WindowsBootstrapContext.new({ }, nil, { :knife => {} }) } before do allow(Chef::Knife::Core::WindowsBootstrapContext).to receive(:new).and_return(mock_bootstrap_context) end describe "fips" do before do Chef::Config[:fips] = fips_mode end after do Chef::Config.reset! end context "when fips is set" do let(:fips_mode) { true } it "sets fips mode in the client.rb" do expect(mock_bootstrap_context.config_content).to match(/fips true/) end end context "when fips is not set" do let(:fips_mode) { false } it "sets fips mode in the client.rb" do expect(mock_bootstrap_context.config_content).not_to match(/fips true/) end end end describe "validation_key", :chef_gte_12_only do before do mock_bootstrap_context.instance_variable_set(:@config, Mash.new(:validation_key => "C:\\chef\\key.pem")) end it "should return false if validation_key does not exist" do allow(::File).to receive(:expand_path) allow(::File).to receive(:exist?).and_return(false) expect(mock_bootstrap_context.validation_key).to eq(false) end end describe "latest_current_windows_chef_version_query" do it "returns the major version of the current version of Chef" do stub_const("Chef::VERSION", '11.1.2') expect(mock_bootstrap_context.latest_current_windows_chef_version_query).to eq("&v=11") end it "does not add prerelease if the version of Chef installed is a prerelease" do stub_const("Chef::VERSION", '42.0.1.alpha.1') expect(mock_bootstrap_context.latest_current_windows_chef_version_query).not_to match(/&prerelease=true/) end it "does add prerelease if the version specified to be installed is a prerelease" do allow(mock_bootstrap_context).to receive(:knife_config).and_return(Mash.new(:bootstrap_version => "12.0.0.alpha.1")) expect(mock_bootstrap_context.latest_current_windows_chef_version_query).to eq("&v=12.0.0.alpha.1&prerelease=true") end context "when the prerelease config option is set" do before do mock_bootstrap_context.instance_variable_set(:@config, Mash.new(:prerelease => true)) end it "sets prerelease to true in the returned string" do expect(mock_bootstrap_context.latest_current_windows_chef_version_query).to eq("&prerelease=true") end end end describe "msi_url" do context "when config option is not set" do before do expect(mock_bootstrap_context).to receive(:latest_current_windows_chef_version_query).and_return("&v=something") end it "returns a chef.io msi url with minimal url parameters" do reference_url = "https://www.chef.io/chef/download?p=windows&v=something" expect(mock_bootstrap_context.msi_url).to eq(reference_url) end it "returns a chef.io msi url with provided url parameters substituted" do reference_url = "https://www.chef.io/chef/download?p=windows&pv=machine&m=arch&DownloadContext=ctx&v=something" expect(mock_bootstrap_context.msi_url('machine', 'arch', 'ctx')).to eq(reference_url) end end context "when msi_url config option is set" do let(:custom_url) { "file://something" } before do mock_bootstrap_context.instance_variable_set(:@config, Mash.new(:msi_url => custom_url)) end it "returns the overriden url" do expect(mock_bootstrap_context.msi_url).to eq(custom_url) end it "doesn't introduce any unnecessary query parameters if provided by the template" do expect(mock_bootstrap_context.msi_url('machine', 'arch', 'ctx')).to eq(custom_url) end end end describe "bootstrap_install_command for bootstrap through WinRM" do context "when bootstrap_install_command option is passed on CLI" do let(:bootstrap) { Chef::Knife::BootstrapWindowsWinrm.new(['--bootstrap-install-command', 'chef-client']) } before do bootstrap.config[:bootstrap_install_command] = "chef-client" end it "sets the bootstrap_install_command option under Chef::Config::Knife object" do expect(Chef::Config[:knife][:bootstrap_install_command]).to eq("chef-client") end after do bootstrap.config.delete(:bootstrap_install_command) Chef::Config[:knife].delete(:bootstrap_install_command) end end context "when bootstrap_install_command option is not passed on CLI" do let(:bootstrap) { Chef::Knife::BootstrapWindowsWinrm.new([]) } it "does not set the bootstrap_install_command option under Chef::Config::Knife object" do expect(Chef::Config[:knife][:bootstrap_install_command]). to eq(nil) end end end describe "bootstrap_install_command for bootstrap through SSH" do context "when bootstrap_install_command option is passed on CLI" do let(:bootstrap) { Chef::Knife::BootstrapWindowsSsh.new(['--bootstrap-install-command', 'chef-client']) } before do bootstrap.config[:bootstrap_install_command] = "chef-client" end it "sets the bootstrap_install_command option under Chef::Config::Knife object" do expect(Chef::Config[:knife][:bootstrap_install_command]).to eq("chef-client") end after do bootstrap.config.delete(:bootstrap_install_command) Chef::Config[:knife].delete(:bootstrap_install_command) end end context "when bootstrap_install_command option is not passed on CLI" do let(:bootstrap) { Chef::Knife::BootstrapWindowsSsh.new([]) } it "does not set the bootstrap_install_command option under Chef::Config::Knife object" do expect(Chef::Config[:knife][:bootstrap_install_command]). to eq(nil) end end end end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/tk/lib/tkextlib/treectrl.rb
# # TkTreeCtrl support # by <NAME> (<EMAIL>) # # call setup script for general 'tkextlib' libraries require 'tkextlib/setup.rb' # call setup script require 'tkextlib/treectrl/setup.rb' # load library require 'tkextlib/treectrl/tktreectrl'
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/-test-/win32/fd_setsize/extconf.rb
<reponame>arnab0073/idea if $mingw or $mswin create_makefile("-test-/win32/fd_setsize") end
arnab0073/idea
.rvm/src/ruby-2.3.0/tool/node_name.rb
#! ./miniruby while gets if ~/enum node_type \{/..~/^\};/ ~/(NODE_.+),/ and puts(" case #{$1}:\n\treturn \"#{$1}\";") end end
arnab0073/idea
.rvm/src/ruby-2.3.0/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb
<reponame>arnab0073/idea # frozen_string_literal: false module Gem::Resolver::Molinillo # An error that occurred during the resolution process class ResolverError < StandardError; end # An error caused by searching for a dependency that is completely unknown, # i.e. has no versions available whatsoever. class NoSuchDependencyError < ResolverError # @return [Object] the dependency that could not be found attr_accessor :dependency # @return [Array<Object>] the specifications that depended upon {#dependency} attr_accessor :required_by # @param [Object] dependency @see {#dependency} # @param [Array<Object>] required_by @see {#required_by} def initialize(dependency, required_by = []) @dependency = dependency @required_by = required_by super() end def message sources = required_by.map { |r| "`#{r}`" }.join(' and ') message = "Unable to find a specification for `#{dependency}`" message << " depended upon by #{sources}" unless sources.empty? message end end # An error caused by attempting to fulfil a dependency that was circular # # @note This exception will be thrown iff a {Vertex} is added to a # {DependencyGraph} that has a {DependencyGraph::Vertex#path_to?} an # existing {DependencyGraph::Vertex} class CircularDependencyError < ResolverError # [Set<Object>] the dependencies responsible for causing the error attr_reader :dependencies # @param [Array<DependencyGraph::Vertex>] nodes the nodes in the dependency # that caused the error def initialize(nodes) super "There is a circular dependency between #{nodes.map(&:name).join(' and ')}" @dependencies = nodes.map(&:payload).to_set end end # An error caused by conflicts in version class VersionConflict < ResolverError # @return [{String => Resolution::Conflict}] the conflicts that caused # resolution to fail attr_reader :conflicts # @param [{String => Resolution::Conflict}] conflicts see {#conflicts} def initialize(conflicts) pairs = [] conflicts.values.flatten.map(&:requirements).flatten.each do |conflicting| conflicting.each do |source, conflict_requirements| conflict_requirements.each do |c| pairs << [c, source] end end end super "Unable to satisfy the following requirements:\n\n" \ "#{pairs.map { |r, d| "- `#{r}` required by `#{d}`" }.join("\n")}" @conflicts = conflicts end end end
arnab0073/idea
.rvm/src/ruby-2.3.0/ext/tk/lib/tkextlib/pkg_checker.rb
#!/usr/bin/env ruby # frozen_string_literal: false # # Ruby/Tk extension library checker # # by <NAME> (<EMAIL>) # require 'tk' TkRoot.new.withdraw # hide root window name = File.basename(__FILE__) add_path = false verbose = false def help_msg print "Usage: #{$0} [-l] [-v] [-h] [--] [dir]\n" print "\tIf dir is omitted, check the directory that this command exists.\n" print "\tAvailable options are \n" print "\t -l : Add dir to $LOAD_PATH\n" print "\t (If dir == '<parent>/tkextlib', add <parent> also.)\n" print "\t -v : Verbose mode (show reason of fail)\n" print "\t -h : Show this message\n" print "\t -- : End of options\n" end while(ARGV[0] && ARGV[0][0] == ?-) case ARGV[0] when '--' ARGV.shift break; when '-l' ARGV.shift add_path = true when '-v' ARGV.shift verbose = true when '-h' help_msg exit(0) else print "Argument Error!! : unknown option '#{ARGV[0]}'\n" help_msg exit(1) end end if ARGV[0] dir = File.expand_path(ARGV[0]) else dir = File.dirname(File.expand_path(__FILE__)) end if add_path $LOAD_PATH.unshift(dir) if File.basename(dir) == 'tkextlib' $LOAD_PATH.unshift(File.dirname(dir)) end end print "\nRuby/Tk extension library checker\n" print "( Note:: This check is very simple one. Shown status may be wrong. )\n" print "\n check directory :: #{dir}" print "\n $LOAD_PATH :: #{$LOAD_PATH.inspect}\n" def get_pkg_list(file) pkg_list = [] File.foreach(file){|l| if l =~ /^(?:[^#]+\s|\s*)(?:|;\s*)TkPackage\s*\.\s*require\s*\(?\s*(["'])((\w|:)+)\1/ pkg = [$2, :package] pkg_list << pkg unless pkg_list.member?(pkg) end if l =~ /^(?:[^#]+\s|\s*)(?:|;\s*)Tk\s*\.\s*load_tcllibrary\s*\(?\s*(["'])((\w|:)+)\1/ pkg = [$2, :library] pkg_list << pkg unless pkg_list.member?(pkg) end if l =~ /^(?:[^#]+\s|\s*)(?:|;\s*)Tk\s*\.\s*load_tclscript\s*\(?\s*(["'])((\w|:)+)\1/ pkg = [$2, :script] pkg_list << pkg unless pkg_list.member?(pkg) end if l =~ /^(?:[^#]+\s|\s*)(?:|;\s*)require\s*\(?\s*(["'])((\w|\/|:)+)\1/ pkg = [$2, :require_ruby_lib] pkg_list << pkg unless pkg_list.member?(pkg) end } pkg_list end def check_pkg(file, verbose=false) pkg_list = get_pkg_list(file) error_list = [] success_list = {} pkg_list.each{|name, type| next if success_list[name] begin case type when :package ver = TkPackage.require(name) success_list[name] = ver error_list.delete_if{|n, t| n == name} when :library Tk.load_tcllibrary(name) success_list[name] = :library error_list.delete_if{|n, t| n == name} when :script Tk.load_tclscript(name) success_list[name] = :script error_list.delete_if{|n, t| n == name} when :require_ruby_lib require name end rescue => e if verbose error_list << [name, type, e.message] else error_list << [name, type] end end } success_list.dup.each{|name, ver| unless ver.kind_of?(String) begin ver = TkPackage.require(name) sccess_list[name] = ver rescue end end } [success_list, error_list] end def subdir_check(dir, verbose=false) Dir.foreach(dir){|f| next if f == '.' || f == '..' if File.directory?(f) subdir_check(File.join(dir, f)) elsif File.extname(f) == '.rb' path = File.join(dir, f) suc, err = check_pkg(path, verbose) if err.empty? print 'Ready : ', path, ' : require->', suc.inspect, "\n" else print '*LACK : ', path, ' : require->', suc.inspect, ' FAIL->', err.inspect, "\n" end end } end Dir.chdir(dir) (Dir['*.rb'] - ['setup.rb', name]).each{|f| subdir = File.basename(f, '.*') =begin begin # read 'setup.rb' as if the library has standard structure require File.join(subdir, 'setup.rb') rescue LoadError # ignore error end =end print "\n" suc, err = check_pkg(f, verbose) if err.empty? print 'Ready : ', f, ' : require->', suc.inspect, "\n" else print '*LACK : ', f, ' : require->', suc.inspect, ' FAIL->', err.inspect, "\n" end subdir_check(subdir, verbose) if File.directory?(subdir) }
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/gssapi-1.2.0/lib/gssapi/lib_gssapi_loader.rb
<reponame>arnab0073/idea<filename>.rvm/gems/ruby-2.3.0/gems/gssapi-1.2.0/lib/gssapi/lib_gssapi_loader.rb =begin Copyright © 2010 <NAME> <<EMAIL>> Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php =end module GSSAPI module LibGSSAPI class GssOID < FFI::Struct layout :length, :OM_uint32, :elements, :pointer # pointer of :void def self.gss_c_no_oid self.new(GSSAPI::LibGSSAPI::GSS_C_NO_OID) end end def self.load_mit host_os = RbConfig::CONFIG['host_os'] case host_os when /linux/ gssapi_lib = 'libgssapi_krb5.so.2' ffi_lib gssapi_lib, FFI::Library::LIBC when /darwin/ gssapi_lib = '/usr/lib/libgssapi_krb5.dylib' ffi_lib gssapi_lib, FFI::Library::LIBC when /mswin|mingw32|windows/ # Pull the gssapi32 path from the environment if it exist, otherwise use the default in Program Files gssapi32_path = ENV['gssapi32'] ? ENV['gssapi32'] : 'C:\Program Files (x86)\MIT\Kerberos\bin\gssapi32.dll' ffi_lib gssapi32_path, FFI::Library::LIBC # Required the MIT Kerberos libraries to be installed ffi_convention :stdcall else raise LoadError, "This host OS (#{host_os}) is not supported by ruby gssapi and the MIT libraries." end # -------------------- MIT Specifics -------------------- attach_variable :__GSS_C_NT_HOSTBASED_SERVICE, :GSS_C_NT_HOSTBASED_SERVICE, :pointer # type gss_OID attach_variable :__GSS_C_NT_EXPORT_NAME, :GSS_C_NT_EXPORT_NAME, :pointer # type gss_OID LibGSSAPI.const_set("GSS_C_NT_HOSTBASED_SERVICE", __GSS_C_NT_HOSTBASED_SERVICE) LibGSSAPI.const_set("GSS_C_NT_EXPORT_NAME", __GSS_C_NT_EXPORT_NAME) end def self.load_heimdal host_os = RbConfig::CONFIG['host_os'] case host_os when /linux/ gssapi_lib = 'libgssapi.so.3' when /darwin/ # use Heimdal Kerberos since Mac MIT Kerberos is OLD. Do a "require 'gssapi/heimdal'" first gssapi_lib = '/usr/heimdal/lib/libgssapi.dylib' else raise LoadError, "This host OS (#{host_os}) is not supported by ruby gssapi and the Heimdal libraries." end ffi_lib gssapi_lib, FFI::Library::LIBC # ------------------ Heimdal Specifics ------------------ attach_variable :__gss_c_nt_hostbased_service_oid_desc, GssOID attach_variable :__gss_c_nt_export_name_oid_desc, GssOID LibGSSAPI.const_set("GSS_C_NT_HOSTBASED_SERVICE", FFI::Pointer.new(__gss_c_nt_hostbased_service_oid_desc.to_ptr)) LibGSSAPI.const_set("GSS_C_NT_EXPORT_NAME", FFI::Pointer.new(__gss_c_nt_export_name_oid_desc.to_ptr)) end # Heimdal supported the *_iov functions before MIT did so in some OS distributions if # you need IOV support and MIT does not provide it try the Heimdal libs and then # before doing a "require 'gssapi'" do a "require 'gssapi/heimdal'" and that will attempt # to load the Heimdal libs case GSSAPI_LIB_TYPE when :mit load_mit when :heimdal load_heimdal else raise LoadError, "Unexpected Lib type: #{GSSAPI_LIB_TYPE}" end end end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/tk/lib/tkextlib/blt/watch.rb
# # tkextlib/blt/watch.rb # by <NAME> (<EMAIL>) # require 'tk' require 'tkextlib/blt.rb' module Tk::BLT class Watch < TkObject extend TkCore TkCommandNames = ['::blt::watch'.freeze].freeze WATCH_ID_TBL = TkCore::INTERP.create_table (BLT_WATCH_ID = ['blt_watch_id'.freeze, TkUtil.untrust('00000')]).instance_eval{ @mutex = Mutex.new def mutex; @mutex; end freeze } TkCore::INTERP.init_ip_env{ WATCH_ID_TBL.mutex.synchronize{ WATCH_ID_TBL.clear } } def self.names(state = None) lst = tk_split_list(tk_call('::blt::watch', 'names', state)) WATCH_ID_TBL.mutex.synchronize{ lst.collect{|name| WATCH_ID_TBL[name] || name } } end def __numval_optkeys ['maxlevel'] end private :__numval_optkeys def __boolval_optkeys ['active'] end private :__boolval_optkeys def __config_cmd ['::blt::watch', 'configure', self.path] end private :__config_cmd def initialize(name = nil, keys = {}) if name.kind_of?(Hash) keys = name name = nil end if name @id = name.to_s else BLT_WATCH_ID.mutex.synchronize{ @id = BLT_WATCH_ID.join(TkCore::INTERP._ip_id_) BLT_WATCH_ID[1].succ! } end @path = @id WATCH_ID_TBL.mutex.synchronize{ WATCH_ID_TBL[@id] = self } tk_call('::blt::watch', 'create', @id, *hash_kv(keys)) end def activate tk_call('::blt::watch', 'activate', @id) self end def deactivate tk_call('::blt::watch', 'deactivate', @id) self end def delete tk_call('::blt::watch', 'delete', @id) self end def info ret = [] lst = tk_split_simplelist(tk_call('::blt::watch', 'info', @id)) until lst.empty? k, v, *lst = lst k = k[1..-1] case k when /^(#{__strval_optkeys.join('|')})$/ # do nothing when /^(#{__numval_optkeys.join('|')})$/ begin v = number(v) rescue v = nil end when /^(#{__numstrval_optkeys.join('|')})$/ v = num_or_str(v) when /^(#{__boolval_optkeys.join('|')})$/ begin v = bool(v) rescue v = nil end when /^(#{__listval_optkeys.join('|')})$/ v = simplelist(v) when /^(#{__numlistval_optkeys.join('|')})$/ v = list(v) else if v.index('{') v = tk_split_list(v) else v = tk_tcl2ruby(v) end end ret << [k, v] end ret end def configinfo(slot = nil) if slot slot = slot.to_s v = cget(slot) if TkComm::GET_CONFIGINFO_AS_ARRAY [slot, v] else {slot=>v} end else if TkComm::GET_CONFIGINFO_AS_ARRAY info else Hash[*(info.flatten)] end end end def cget_strict(key) key = key.to_s begin info.assoc(key)[1] rescue fail ArgumentError, "unknown option '#{key}'" end end def cget(key) unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__ cget_strict(key) else begin cget_strict(key) rescue => e if current_configinfo.has_key?(key.to_s) # error on known option fail e else # unknown option nil end end end end end end
arnab0073/idea
.rvm/src/ruby-2.3.0/test/fiddle/test_func.rb
<gh_stars>10-100 # frozen_string_literal: false begin require_relative 'helper' rescue LoadError end module Fiddle class TestFunc < TestCase def test_random f = Function.new(@libc['srand'], [-TYPE_LONG], TYPE_VOID) assert_nil f.call(10) end def test_syscall_with_tainted_string f = Function.new(@libc['system'], [TYPE_VOIDP], TYPE_INT) assert_raises(SecurityError) do Thread.new { $SAFE = 1 f.call("uname -rs".taint) }.join end end def test_sinf begin f = Function.new(@libm['sinf'], [TYPE_FLOAT], TYPE_FLOAT) rescue Fiddle::DLError skip "libm may not have sinf()" end assert_in_delta 1.0, f.call(90 * Math::PI / 180), 0.0001 end def test_sin f = Function.new(@libm['sin'], [TYPE_DOUBLE], TYPE_DOUBLE) assert_in_delta 1.0, f.call(90 * Math::PI / 180), 0.0001 end def test_string stress, GC.stress = GC.stress, true f = Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP) buff = "000" str = f.call(buff, "123") assert_equal("123", buff) assert_equal("123", str.to_s) ensure GC.stress = stress end def test_isdigit f = Function.new(@libc['isdigit'], [TYPE_INT], TYPE_INT) r1 = f.call(?1.ord) r2 = f.call(?2.ord) rr = f.call(?r.ord) assert_operator r1, :>, 0 assert_operator r2, :>, 0 assert_equal 0, rr end def test_atof f = Function.new(@libc['atof'], [TYPE_VOIDP], TYPE_DOUBLE) r = f.call("12.34") assert_includes(12.00..13.00, r) end def test_strtod f = Function.new(@libc['strtod'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_DOUBLE) buff1 = Pointer["12.34"] buff2 = buff1 + 4 r = f.call(buff1, - buff2) assert_in_delta(12.34, r, 0.001) end def test_qsort1 cb = Class.new(Closure) { def call(x, y) Pointer.new(x)[0] <=> Pointer.new(y)[0] end }.new(TYPE_INT, [TYPE_VOIDP, TYPE_VOIDP]) qsort = Function.new(@libc['qsort'], [TYPE_VOIDP, TYPE_SIZE_T, TYPE_SIZE_T, TYPE_VOIDP], TYPE_VOID) buff = "9341" qsort.call(buff, buff.size, 1, cb) assert_equal("1349", buff) bug4929 = '[ruby-core:37395]' buff = "9341" EnvUtil.under_gc_stress {qsort.call(buff, buff.size, 1, cb)} assert_equal("1349", buff, bug4929) end end end if defined?(Fiddle)
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/fog-1.29.0/tests/xenserver/xenserver_tests.rb
Shindo.tests('Fog::Compute[:xenserver]', ['xenserver']) do tests("Login") do raises(Fog::XenServer::InvalidLogin, 'raises error when invalid password') do conn = Fog::Compute.new({ :provider => 'XenServer', :xenserver_url => 'xenserver-test', :xenserver_username => 'root', :xenserver_password => '<PASSWORD>' }) end raises(Fog::XenServer::InvalidLogin, 'raises error when invalid user') do conn = Fog::Compute.new({ :provider => 'XenServer', :xenserver_url => 'xenserver-test', :xenserver_username => 'rootffff', :xenserver_password => '<PASSWORD>' }) end raises(SocketError, 'raises error when invalid host') do conn = Fog::Compute.new({ :provider => 'XenServer', :xenserver_url => 'xenserver-testlakjsdflkj', :xenserver_username => 'root', :xenserver_password => '<PASSWORD>' }) end end end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/objspace/extconf.rb
$INCFLAGS << " -I$(topdir) -I$(top_srcdir)" create_makefile('objspace')
arnab0073/idea
.rvm/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/rvm-1.11.3.9/lib/rvm/version.rb
<gh_stars>1-10 module RVM Version = "1.11.3.9" end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/knife-windows-1.4.1/lib/chef/knife/winrm.rb
# # Author:: <NAME> (<<EMAIL>>) # Copyright:: Copyright (c) 2011-2016 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # require 'chef/knife' require 'chef/knife/winrm_knife_base' require 'chef/knife/windows_cert_generate' require 'chef/knife/windows_cert_install' require 'chef/knife/windows_listener_create' require 'chef/knife/winrm_session' require 'chef/knife/knife_windows_base' class Chef class Knife class Winrm < Knife include Chef::Knife::WinrmCommandSharedFunctions include Chef::Knife::KnifeWindowsBase deps do require 'readline' require 'chef/search/query' end attr_writer :password banner "knife winrm QUERY COMMAND (options)" option :returns, :long => "--returns CODES", :description => "A comma delimited list of return codes which indicate success", :default => "0" def run STDOUT.sync = STDERR.sync = true configure_session execute_remote_command end def execute_remote_command case @name_args[1] when "interactive" interactive else run_command(@name_args[1..-1].join(" ")) end end private def interactive puts "WARN: Deprecated functionality. This will not be supported in future knife-windows releases." puts "Connected to #{ui.list(session.servers.collect { |s| ui.color(s.host, :cyan) }, :inline, " and ")}" puts puts "To run a command on a list of servers, do:" puts " on SERVER1 SERVER2 SERVER3; COMMAND" puts " Example: on latte foamy; echo foobar" puts puts "To exit interactive mode, use 'quit!'" puts while 1 command = read_line case command when 'quit!' puts 'Bye!' break when /^on (.+?); (.+)$/ raw_list = $1.split(" ") server_list = Array.new @winrm_sessions.each do |session_server| server_list << session_server if raw_list.include?(session_server.host) end command = $2 relay_winrm_command(command, server_list) else relay_winrm_command(command) end end end # Present the prompt and read a single line from the console. It also # detects ^D and returns "exit" in that case. Adds the input to the # history, unless the input is empty. Loops repeatedly until a non-empty # line is input. def read_line loop do command = reader.readline("#{ui.color('knife-winrm>', :bold)} ", true) if command.nil? command = "exit" puts(command) else command.strip! end unless command.empty? return command end end end def reader Readline end end end end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/winrm-1.8.1/spec/wql_spec.rb
<reponame>arnab0073/idea<filename>.rvm/gems/ruby-2.3.0/gems/winrm-1.8.1/spec/wql_spec.rb # encoding: UTF-8 describe 'winrm client wql', integration: true do before(:all) do @winrm = winrm_connection end it 'should query Win32_OperatingSystem' do output = @winrm.run_wql('select * from Win32_OperatingSystem') expect(output).to_not be_empty output_caption = output[:win32_operating_system][0][:caption] expect(output_caption).to include('Microsoft') expect(output_caption).to include('Windows') end end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/tk/sample/tkalignbox.rb
# # tkalignbox.rb : align widgets with same width/height # # by <NAME> # # The box size depends on 'reqheight' and 'reqwidth' of contained widgets. # If you want to give the box size when those requested sizes are 0, # please set box.propagate = false (See the test routine at the tail of # this file). require 'tk' module Tk module RbWidget class AlignBox < TkFrame end end end class Tk::RbWidget::AlignBox < TkFrame def initialize(*args) if self.class == Tk::RbWidget::AlignBox fail RuntimeError, "Tk::AlignBox is an abstract class" end @padx = 0 @pady = 0 if args[-1].kind_of? Hash keys = _symbolkey2str(args.pop) @padx = keys.delete('padx') || 0 @pady = keys.delete('pady') || 0 args.push(keys) end super(*args) @max_width = 0 @max_height = 0 @propagate = true @widgets = [] end def _set_framesize fail RuntimeError, "Tk::AlignBox is an abstract class" end private :_set_framesize def _place_config(widget, idx, cnt) fail RuntimeError, "Tk::AlignBox is an abstract class" end private :_place_config def align widgets = [] @widgets.each{|w| widgets << w if w.winfo_exist?} @widgets = widgets cnt = @widgets.size.to_f @widgets.each_with_index{|w, idx| _place_config(w, idx, cnt)} @widgets = widgets _set_framesize if @propagate self end def add(*widgets) widgets.each{|w| unless w.kind_of? TkWindow fail RuntimeError, "#{w.inspect} is not a widget instance." end @widgets.delete(w) @widgets << w sz = w.winfo_reqwidth @max_width = sz if @max_width < sz sz = w.winfo_reqheight @max_height = sz if @max_height < sz } align end def <<(widget) add(widget) end def insert(idx, widget) unless widget.kind_of? TkWindow fail RuntimeError, "#{widget.inspect} is not a widget instance." end @widgets.delete(widget) @widgets[idx,0] = widget sz = widget.winfo_reqwidth @max_width = sz if @max_width < sz sz = widget.winfo_reqheight @max_height = sz if @max_height < sz align end def delete(idx) ret = @widgets.delete_at(idx) @req_size = 0 @widget.each{|w| sz = w.winfo_reqwidth @max_width = sz if @max_width < sz sz = w.winfo_reqheight @max_height = sz if @max_height < sz } align ret end def padx(size = nil) if size @padx = size align else @padx end end def pady(size = nil) if size @pady = size align else @pady end end attr_accessor :propagate end class Tk::RbWidget::HBox < Tk::RbWidget::AlignBox def _set_framesize bd = self.borderwidth self.width((@max_width + 2*@padx) * @widgets.size + 2*bd) self.height(@max_height + 2*@pady + 2*bd) end private :_set_framesize def _place_config(widget, idx, cnt) widget.place_in(self, 'relx'=>idx/cnt, 'x'=>@padx, 'rely'=>0, 'y'=>@pady, 'relwidth'=>1.0/cnt, 'width'=>-2*@padx, 'relheight'=>1.0, 'height'=>-2*@pady) end private :_place_config end Tk::RbWidget::HLBox = Tk::RbWidget::HBox class Tk::RbWidget::HRBox < Tk::RbWidget::HBox def _place_config(widget, idx, cnt) widget.place_in(self, 'relx'=>(cnt - idx - 1)/cnt, 'x'=>@padx, 'rely'=>0, 'y'=>@pady, 'relwidth'=>1.0/cnt, 'width'=>-2*@padx, 'relheight'=>1.0, 'height'=>-2*@pady) end private :_place_config end class Tk::RbWidget::VBox < Tk::RbWidget::AlignBox def _set_framesize bd = self.borderwidth self.width(@max_width + 2*@padx + 2*bd) self.height((@max_height + 2*@pady) * @widgets.size + 2*bd) end private :_set_framesize def _place_config(widget, idx, cnt) widget.place_in(self, 'relx'=>0, 'x'=>@padx, 'rely'=>idx/cnt, 'y'=>@pady, 'relwidth'=>1.0, 'width'=>-2*@padx, 'relheight'=>1.0/cnt, 'height'=>-2*@pady) end private :_place_config end Tk::RbWidget::VTBox = Tk::RbWidget::VBox class Tk::RbWidget::VBBox < Tk::RbWidget::VBox def _place_config(widget, idx, cnt) widget.place_in(self, 'relx'=>0, 'x'=>@padx, 'rely'=>(cnt - idx - 1)/cnt, 'y'=>@pady, 'relwidth'=>1.0, 'width'=>-2*@padx, 'relheight'=>1.0/cnt, 'height'=>-2*@pady) end private :_place_config end ################################################ # test ################################################ if __FILE__ == $0 f = Tk::RbWidget::HBox.new(:borderwidth=>3, :relief=>'ridge').pack f.add(TkButton.new(f, :text=>'a'), TkButton.new(f, :text=>'aa', :font=>'Helvetica 16'), TkButton.new(f, :text=>'aaa'), TkButton.new(f, :text=>'aaaa')) f = Tk::RbWidget::HBox.new(:borderwidth=>3, :relief=>'ridge', :padx=>7, :pady=>3, :background=>'yellow').pack f.add(TkButton.new(f, :text=>'a'), TkButton.new(f, :text=>'aa', :font=>'Helvetica 16'), TkButton.new(f, :text=>'aaa'), TkButton.new(f, :text=>'aaaa')) f = Tk::RbWidget::VBox.new(:borderwidth=>5, :relief=>'groove').pack(:fill=>:y, :expand=>true) f.add(TkButton.new(f, :text=>'a'), TkButton.new(f, :text=>'aa', :font=>'Helvetica 30'), TkButton.new(f, :text=>'aaa'), TkButton.new(f, :text=>'aaaa')) f = Tk::RbWidget::HRBox.new(:borderwidth=>3, :relief=>'raised').pack(:fill=>:x) f.add(TkButton.new(f, :text=>'a'), TkButton.new(f, :text=>'aa'), TkButton.new(f, :text=>'aaa')) f = Tk::RbWidget::VBBox.new(:borderwidth=>3, :relief=>'ridge').pack(:fill=>:x) f.propagate = false f.height 100 f.add(TkFrame.new(f){|ff| TkButton.new(ff, :text=>'a').pack(:pady=>4, :padx=>6, :fill=>:both, :expand=>true) }, TkFrame.new(f){|ff| TkButton.new(ff, :text=>'aa').pack(:pady=>4, :padx=>6, :fill=>:both, :expand=>true) }, TkFrame.new(f){|ff| TkButton.new(ff, :text=>'aaaa').pack(:pady=>4, :padx=>6, :fill=>:both, :expand=>true) }) Tk.mainloop end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/ohai-6.18.0/lib/ohai/plugins/gce.rb
<gh_stars>0 # # Author:: <NAME> (<<EMAIL>>) # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. provides "gce" require 'ohai/mixin/gce_metadata' GOOGLE_SYSFS_DMI = '/sys/firmware/dmi/entries/1-0/raw' #https://developers.google.com/compute/docs/instances#dmi def has_google_dmi? ::File.read(GOOGLE_SYSFS_DMI).include?('Google') end def looks_like_gce? hint?('gce') || (has_google_dmi? && Ohai::Mixin::GCEMetadata.can_metadata_connect?(Ohai::Mixin::GCEMetadata::GCE_METADATA_ADDR,80)) end if looks_like_gce? Ohai::Log.debug("looks_like_gce? == true") gce Mash.new Ohai::Mixin::GCEMetadata.fetch_metadata.each {|k, v| gce[k] = v } else Ohai::Log.debug("looks_like_gce? == false") false end
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/tk/lib/tkextlib/tcllib/tooltip.rb
# # tkextlib/tcllib/tooltip.rb # by <NAME> (<EMAIL>) # # * Part of tcllib extension # * Provides tooltips, a small text message that is displayed when the # mouse hovers over a widget. # require 'tk' require 'tkextlib/tcllib.rb' # TkPackage.require('tooltip', '1.1') TkPackage.require('tooltip') module Tk::Tcllib module Tooltip PACKAGE_NAME = 'tooltip'.freeze def self.package_name PACKAGE_NAME end def self.package_version begin TkPackage.require('tooltip') rescue '' end end end end module Tk::Tcllib::Tooltip extend TkCore WidgetClassName = 'Tooltip'.freeze WidgetClassNames[WidgetClassName] ||= self def self.database_classname self::WidgetClassName end def self.database_class WidgetClassNames[self::WidgetClassName] end def self.clear(glob_path_pat = None) self.clear_glob(glob_path_pat) end def self.clear_glob(glob_path_pat) tk_call_without_enc('::tooltip::tooltip', 'clear', glob_path_pat) end def self.clear_widgets(*args) self.clear_glob("{#{args.collect{|w| _get_eval_string(w)}.join(',')}}") end def self.clear_children(*args) self.clear_glob("{#{args.collect{|w| s = _get_eval_string(w); "#{s},#{s}.*"}.join(',')}}") end def self.delay(millisecs=None) number(tk_call_without_enc('::tooltip::tooltip', 'delay', millisecs)) end def self.delay=(millisecs) self.delay(millisecs) end def self.fade? bool(tk_call_without_enc('::tooltip::tooltip', 'fade')) end def self.fade(mode) tk_call_without_enc('::tooltip::tooltip', 'fade', mode) end def self.disable tk_call_without_enc('::tooltip::tooltip', 'disable') false end def self.off self.disable end def self.enable tk_call_without_enc('::tooltip::tooltip', 'enable') true end def self.on self.enable end def self.register(widget, msg, keys=nil) if keys.kind_of?(Hash) args = hash_kv(keys) << msg else args = msg end tk_call('::tooltip::tooltip', widget.path, *args) end def self.erase(widget) tk_call_without_enc('::tooltip::tooltip', widget.path, '') end end
arnab0073/idea
.rvm/src/ruby-2.3.0/lib/net/http/response.rb
# frozen_string_literal: false # HTTP response class. # # This class wraps together the response header and the response body (the # entity requested). # # It mixes in the HTTPHeader module, which provides access to response # header values both via hash-like methods and via individual readers. # # Note that each possible HTTP response code defines its own # HTTPResponse subclass. These are listed below. # # All classes are defined under the Net module. Indentation indicates # inheritance. For a list of the classes see Net::HTTP. # # class Net::HTTPResponse class << self # true if the response has a body. def body_permitted? self::HAS_BODY end def exception_type # :nodoc: internal use only self::EXCEPTION_TYPE end def read_new(sock) #:nodoc: internal use only httpv, code, msg = read_status_line(sock) res = response_class(code).new(httpv, code, msg) each_response_header(sock) do |k,v| res.add_field k, v end res end private def read_status_line(sock) str = sock.readline m = /\AHTTP(?:\/(\d+\.\d+))?\s+(\d\d\d)(?:\s+(.*))?\z/in.match(str) or raise Net::HTTPBadResponse, "wrong status line: #{str.dump}" m.captures end def response_class(code) CODE_TO_OBJ[code] or CODE_CLASS_TO_OBJ[code[0,1]] or Net::HTTPUnknownResponse end def each_response_header(sock) key = value = nil while true line = sock.readuntil("\n", true).sub(/\s+\z/, '') break if line.empty? if line[0] == ?\s or line[0] == ?\t and value value << ' ' unless value.empty? value << line.strip else yield key, value if key key, value = line.strip.split(/\s*:\s*/, 2) raise Net::HTTPBadResponse, 'wrong header line format' if value.nil? end end yield key, value if key end end # next is to fix bug in RDoc, where the private inside class << self # spills out. public include Net::HTTPHeader def initialize(httpv, code, msg) #:nodoc: internal use only @http_version = httpv @code = code @message = msg initialize_http_header nil @body = nil @read = false @uri = nil @decode_content = false end # The HTTP version supported by the server. attr_reader :http_version # The HTTP result code string. For example, '302'. You can also # determine the response type by examining which response subclass # the response object is an instance of. attr_reader :code # The HTTP result message sent by the server. For example, 'Not Found'. attr_reader :message alias msg message # :nodoc: obsolete # The URI used to fetch this response. The response URI is only available # if a URI was used to create the request. attr_reader :uri # Set to true automatically when the request did not contain an # Accept-Encoding header from the user. attr_accessor :decode_content def inspect "#<#{self.class} #{@code} #{@message} readbody=#{@read}>" end # # response <-> exception relationship # def code_type #:nodoc: self.class end def error! #:nodoc: raise error_type().new(@code + ' ' + @message.dump, self) end def error_type #:nodoc: self.class::EXCEPTION_TYPE end # Raises an HTTP error if the response is not 2xx (success). def value error! unless self.kind_of?(Net::HTTPSuccess) end def uri= uri # :nodoc: @uri = uri.dup if uri end # # header (for backward compatibility only; DO NOT USE) # def response #:nodoc: warn "#{caller(1)[0]}: warning: Net::HTTPResponse#response is obsolete" if $VERBOSE self end def header #:nodoc: warn "#{caller(1)[0]}: warning: Net::HTTPResponse#header is obsolete" if $VERBOSE self end def read_header #:nodoc: warn "#{caller(1)[0]}: warning: Net::HTTPResponse#read_header is obsolete" if $VERBOSE self end # # body # def reading_body(sock, reqmethodallowbody) #:nodoc: internal use only @socket = sock @body_exist = reqmethodallowbody && self.class.body_permitted? begin yield self.body # ensure to read body ensure @socket = nil end end # Gets the entity body returned by the remote HTTP server. # # If a block is given, the body is passed to the block, and # the body is provided in fragments, as it is read in from the socket. # # Calling this method a second or subsequent time for the same # HTTPResponse object will return the value already read. # # http.request_get('/index.html') {|res| # puts res.read_body # } # # http.request_get('/index.html') {|res| # p res.read_body.object_id # 538149362 # p res.read_body.object_id # 538149362 # } # # # using iterator # http.request_get('/index.html') {|res| # res.read_body do |segment| # print segment # end # } # def read_body(dest = nil, &block) if @read raise IOError, "#{self.class}\#read_body called twice" if dest or block return @body end to = procdest(dest, block) stream_check if @body_exist read_body_0 to @body = to else @body = nil end @read = true @body end # Returns the full entity body. # # Calling this method a second or subsequent time will return the # string already read. # # http.request_get('/index.html') {|res| # puts res.body # } # # http.request_get('/index.html') {|res| # p res.body.object_id # 538149362 # p res.body.object_id # 538149362 # } # def body read_body() end # Because it may be necessary to modify the body, Eg, decompression # this method facilitates that. def body=(value) @body = value end alias entity body #:nodoc: obsolete private ## # Checks for a supported Content-Encoding header and yields an Inflate # wrapper for this response's socket when zlib is present. If the # Content-Encoding is unsupported or zlib is missing the plain socket is # yielded. # # If a Content-Range header is present a plain socket is yielded as the # bytes in the range may not be a complete deflate block. def inflater # :nodoc: return yield @socket unless Net::HTTP::HAVE_ZLIB return yield @socket unless @decode_content return yield @socket if self['content-range'] v = self['content-encoding'] case v&.downcase when 'deflate', 'gzip', 'x-gzip' then self.delete 'content-encoding' inflate_body_io = Inflater.new(@socket) begin yield inflate_body_io ensure orig_err = $! begin inflate_body_io.finish rescue => err raise orig_err || err end end when 'none', 'identity' then self.delete 'content-encoding' yield @socket else yield @socket end end def read_body_0(dest) inflater do |inflate_body_io| if chunked? read_chunked dest, inflate_body_io return end @socket = inflate_body_io clen = content_length() if clen @socket.read clen, dest, true # ignore EOF return end clen = range_length() if clen @socket.read clen, dest return end @socket.read_all dest end end ## # read_chunked reads from +@socket+ for chunk-size, chunk-extension, CRLF, # etc. and +chunk_data_io+ for chunk-data which may be deflate or gzip # encoded. # # See RFC 2616 section 3.6.1 for definitions def read_chunked(dest, chunk_data_io) # :nodoc: total = 0 while true line = @socket.readline hexlen = line.slice(/[0-9a-fA-F]+/) or raise Net::HTTPBadResponse, "wrong chunk size line: #{line}" len = hexlen.hex break if len == 0 begin chunk_data_io.read len, dest ensure total += len @socket.read 2 # \r\n end end until @socket.readline.empty? # none end end def stream_check raise IOError, 'attempt to read body out of block' if @socket.closed? end def procdest(dest, block) raise ArgumentError, 'both arg and block given for HTTP method' if dest and block if block Net::ReadAdapter.new(block) else dest || '' end end ## # Inflater is a wrapper around Net::BufferedIO that transparently inflates # zlib and gzip streams. class Inflater # :nodoc: ## # Creates a new Inflater wrapping +socket+ def initialize socket @socket = socket # zlib with automatic gzip detection @inflate = Zlib::Inflate.new(32 + Zlib::MAX_WBITS) end ## # Finishes the inflate stream. def finish return if @inflate.total_in == 0 @inflate.finish end ## # Returns a Net::ReadAdapter that inflates each read chunk into +dest+. # # This allows a large response body to be inflated without storing the # entire body in memory. def inflate_adapter(dest) if dest.respond_to?(:set_encoding) dest.set_encoding(Encoding::ASCII_8BIT) elsif dest.respond_to?(:force_encoding) dest.force_encoding(Encoding::ASCII_8BIT) end block = proc do |compressed_chunk| @inflate.inflate(compressed_chunk) do |chunk| dest << chunk end end Net::ReadAdapter.new(block) end ## # Reads +clen+ bytes from the socket, inflates them, then writes them to # +dest+. +ignore_eof+ is passed down to Net::BufferedIO#read # # Unlike Net::BufferedIO#read, this method returns more than +clen+ bytes. # At this time there is no way for a user of Net::HTTPResponse to read a # specific number of bytes from the HTTP response body, so this internal # API does not return the same number of bytes as were requested. # # See https://bugs.ruby-lang.org/issues/6492 for further discussion. def read clen, dest, ignore_eof = false temp_dest = inflate_adapter(dest) @socket.read clen, temp_dest, ignore_eof end ## # Reads the rest of the socket, inflates it, then writes it to +dest+. def read_all dest temp_dest = inflate_adapter(dest) @socket.read_all temp_dest end end end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/mixlib-cli-1.6.0/lib/mixlib/cli.rb
# # Author:: <NAME> (<<EMAIL>>) # Copyright:: Copyright (c) 2008 Opscode, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # require "optparse" module Mixlib # == Mixlib::CLI # Adds a DSL for defining command line options and methods for parsing those # options to the including class. # # Mixlib::CLI does some setup in #initialize, so the including class must # call `super()` if it defines a custom initializer. # # === DSL # When included, Mixlib::CLI also extends the including class with its # ClassMethods, which define the DSL. The primary methods of the DSL are # ClassMethods#option, which defines a command line option, and # ClassMethods#banner, which defines the "usage" banner. # # === Parsing # Command line options are parsed by calling the instance method # #parse_options. After calling this method, the attribute #config will # contain a hash of `:option_name => value` pairs. module CLI module InheritMethods def inherited(receiver) receiver.options = deep_dup(self.options) receiver.extend(Mixlib::CLI::InheritMethods) end # object:: Instance to clone # This method will return a "deep clone" of the provided # `object`. If the provided `object` is an enumerable type the # contents will be iterated and cloned as well. def deep_dup(object) cloned_object = object.respond_to?(:dup) ? object.dup : object if cloned_object.kind_of?(Enumerable) if cloned_object.kind_of?(Hash) new_hash = cloned_object.class.new cloned_object.each do |key, value| cloned_key = deep_dup(key) cloned_value = deep_dup(value) new_hash[cloned_key] = cloned_value end cloned_object.replace(new_hash) else cloned_object.map! do |shallow_instance| deep_dup(shallow_instance) end end end cloned_object rescue TypeError # Symbol will happily provide a `#dup` method even though # attempts to clone it will result in an exception (atoms!). # So if we run into an issue of TypeErrors, just return the # original object as we gave our "best effort" object end end module ClassMethods # When this setting is set to +true+, default values supplied to the # mixlib-cli DSL will be stored in a separate Hash def use_separate_default_options(true_or_false) @separate_default_options = true_or_false end def use_separate_defaults? @separate_default_options ||= false end # Add a command line option. # # === Parameters # name<Symbol>:: The name of the option to add # args<Hash>:: A hash of arguments for the option, specifying how it should be parsed. # === Returns # true:: Always returns true. def option(name, args) @options ||= {} raise(ArgumentError, "Option name must be a symbol") unless name.kind_of?(Symbol) @options[name.to_sym] = args end # Get the hash of current options. # # === Returns # @options<Hash>:: The current options hash. def options @options ||= {} @options end # Set the current options hash # # === Parameters # val<Hash>:: The hash to set the options to # # === Returns # @options<Hash>:: The current options hash. def options=(val) raise(ArgumentError, "Options must recieve a hash") unless val.kind_of?(Hash) @options = val end # Change the banner. Defaults to: # Usage: #{0} (options) # # === Parameters # bstring<String>:: The string to set the banner to # # === Returns # @banner<String>:: The current banner def banner(bstring = nil) if bstring @banner = bstring else @banner ||= "Usage: #{$0} (options)" @banner end end end # Gives the command line options definition as configured in the DSL. These # are used by #parse_options to generate the option parsing code. To get # the values supplied by the user, see #config. attr_accessor :options # A Hash containing the values supplied by command line options. # # The behavior and contents of this Hash vary depending on whether # ClassMethods#use_separate_default_options is enabled. # ==== use_separate_default_options *disabled* # After initialization, +config+ will contain any default values defined # via the mixlib-config DSL. When #parse_options is called, user-supplied # values (from ARGV) will be merged in. # ==== use_separate_default_options *enabled* # After initialization, this will be an empty hash. When #parse_options is # called, +config+ is populated *only* with user-supplied values. attr_accessor :config # If ClassMethods#use_separate_default_options is enabled, this will be a # Hash containing key value pairs of `:option_name => default_value` # (populated during object initialization). # # If use_separate_default_options is disabled, it will always be an empty # hash. attr_accessor :default_config # Any arguments which were not parsed and placed in "config"--the leftovers. attr_accessor :cli_arguments # Banner for the option parser. If the option parser is printed, e.g., by # `puts opt_parser`, this string will be used as the first line. attr_accessor :banner # Create a new Mixlib::CLI class. If you override this, make sure you call super! # # === Parameters # *args<Array>:: The array of arguments passed to the initializer # # === Returns # object<Mixlib::Config>:: Returns an instance of whatever you wanted :) def initialize(*args) @options = Hash.new @config = Hash.new @default_config = Hash.new @opt_parser = nil # Set the banner @banner = self.class.banner # Dupe the class options for this instance klass_options = self.class.options klass_options.keys.inject(@options) { |memo, key| memo[key] = klass_options[key].dup; memo } # If use_separate_defaults? is on, default values go in @default_config defaults_container = if self.class.use_separate_defaults? @default_config else @config end # Set the default configuration values for this instance @options.each do |config_key, config_opts| config_opts[:on] ||= :on config_opts[:boolean] ||= false config_opts[:required] ||= false config_opts[:proc] ||= nil config_opts[:show_options] ||= false config_opts[:exit] ||= nil config_opts[:in] ||= nil if config_opts.has_key?(:default) defaults_container[config_key] = config_opts[:default] end end super(*args) end # Parses an array, by default ARGV, for command line options (as configured at # the class level). # === Parameters # argv<Array>:: The array of arguments to parse; defaults to ARGV # # === Returns # argv<Array>:: Returns any un-parsed elements. def parse_options(argv = ARGV) argv = argv.dup opt_parser.parse!(argv) # Deal with any required values options.each do |opt_key, opt_value| if opt_value[:required] && !config.has_key?(opt_key) reqarg = opt_value[:short] || opt_value[:long] puts "You must supply #{reqarg}!" puts @opt_parser exit 2 end if opt_value[:in] unless opt_value[:in].kind_of?(Array) raise(ArgumentError, "Options config key :in must receive an Array") end if !opt_value[:in].include?(config[opt_key]) reqarg = opt_value[:short] || opt_value[:long] puts "#{reqarg}: #{config[opt_key]} is not included in the list ['#{opt_value[:in].join("', '")}'] " puts @opt_parser exit 2 end end end @cli_arguments = argv argv end # The option parser generated from the mixlib-cli DSL. +opt_parser+ can be # used to print a help message including the banner and any CLI options via # `puts opt_parser`. # === Returns # opt_parser<OptionParser>:: The option parser object. def opt_parser @opt_parser ||= OptionParser.new do |opts| # Set the banner opts.banner = banner # Create new options options.sort { |a, b| a[0].to_s <=> b[0].to_s }.each do |opt_key, opt_val| opt_args = build_option_arguments(opt_val) opt_method = case opt_val[:on] when :on :on when :tail :on_tail when :head :on_head else raise ArgumentError, "You must pass :on, :tail, or :head to :on" end parse_block = Proc.new() do |c| config[opt_key] = (opt_val[:proc] && opt_val[:proc].call(c)) || c puts opts if opt_val[:show_options] exit opt_val[:exit] if opt_val[:exit] end full_opt = [ opt_method ] opt_args.inject(full_opt) { |memo, arg| memo << arg; memo } full_opt << parse_block opts.send(*full_opt) end end end def build_option_arguments(opt_setting) arguments = Array.new arguments << opt_setting[:short] if opt_setting.has_key?(:short) arguments << opt_setting[:long] if opt_setting.has_key?(:long) if opt_setting.has_key?(:description) description = opt_setting[:description] description << " (required)" if opt_setting[:required] description << " (included in ['#{opt_setting[:in].join("', '")}'])" if opt_setting[:in] arguments << description end arguments end def self.included(receiver) receiver.extend(Mixlib::CLI::ClassMethods) receiver.extend(Mixlib::CLI::InheritMethods) end end end
arnab0073/idea
.rvm/src/ruby-2.3.0/ext/json/json.gemspec
<reponame>arnab0073/idea Gem::Specification.new do |s| s.name = "json" s.version = "1.8.3" s.summary = "This json is bundled with Ruby" s.executables = [] s.files = ["json.rb", "json/add/bigdecimal.rb", "json/add/complex.rb", "json/add/core.rb", "json/add/date.rb", "json/add/date_time.rb", "json/add/exception.rb", "json/add/ostruct.rb", "json/add/range.rb", "json/add/rational.rb", "json/add/regexp.rb", "json/add/struct.rb", "json/add/symbol.rb", "json/add/time.rb", "json/common.rb", "json/ext.rb", "json/ext/generator.bundle", "json/ext/parser.bundle", "json/generic_object.rb", "json/version.rb"] end
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/net-ssh-multi-1.2.0/test/common.rb
<filename>.rvm/gems/ruby-2.3.0/gems/net-ssh-multi-1.2.0/test/common.rb require 'test/unit' require 'mocha'
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/logging-2.1.0/test/test_color_scheme.rb
require File.expand_path('../setup', __FILE__) module TestLogging class TestColorScheme < Test::Unit::TestCase include LoggingTestCase def setup super ::Logging.init end def test_default_color_scheme scheme = Logging.color_scheme :default assert_instance_of ::Logging::ColorScheme, scheme assert_equal false, scheme.include?(:debug) assert scheme.include?(:info) assert scheme.include?(:warn) assert scheme.include?(:error) assert scheme.include?(:fatal) end def test_lines_levels_exclusivity assert_raise(ArgumentError) { Logging.color_scheme(:error, :lines => {}, :levels => {}) } end def test_colorization scheme = Logging.color_scheme :default assert_equal "no change", scheme.color('no change', :debug) assert_equal "\e[32minfo is green\e[0m", scheme.color('info is green', :info) assert_equal "\e[37m\e[41mfatal has multiple color codes\e[0m", scheme.color('fatal has multiple color codes', :fatal) end end # TestColorScheme end # TestLogging
arnab0073/idea
.rvm/src/ruby-1.9.3-p551/ext/readline/extconf.rb
require "mkmf" $readline_headers = ["stdio.h"] def have_readline_header(header) if have_header(header, &$readline_extra_check) $readline_headers.push(header) return true else return false end end def have_readline_var(var) return have_var(var, $readline_headers) end def have_readline_func(func) return have_func(func, $readline_headers) end def have_readline_macro(macro) return have_macro(macro, $readline_headers) end dir_config('curses') dir_config('ncurses') dir_config('termcap') dir_config("readline") enable_libedit = enable_config("libedit") have_library("user32", nil) if /cygwin/ === RUBY_PLATFORM have_library("ncurses", "tgetnum") || have_library("termcap", "tgetnum") || have_library("curses", "tgetnum") case enable_libedit when true # --enable-libedit unless (have_readline_header("editline/readline.h") || have_readline_header("readline/readline.h")) && have_library("edit", "readline") raise "libedit not found" end when false # --disable-libedit unless ((have_readline_header("readline/readline.h") && have_readline_header("readline/history.h")) && have_library("readline", "readline")) raise "readline not found" end else # does not specify unless ((have_readline_header("readline/readline.h") && have_readline_header("readline/history.h")) && (have_library("readline", "readline") || have_library("edit", "readline"))) || (have_readline_header("editline/readline.h") && have_library("edit", "readline")) raise "readline nor libedit not found" end end have_readline_func("rl_getc") have_readline_func("rl_getc_function") have_readline_func("rl_filename_completion_function") have_readline_func("rl_username_completion_function") have_readline_func("rl_completion_matches") have_readline_func("rl_refresh_line") have_readline_var("rl_deprep_term_function") have_readline_var("rl_completion_append_character") have_readline_var("rl_basic_word_break_characters") have_readline_var("rl_completer_word_break_characters") have_readline_var("rl_basic_quote_characters") have_readline_var("rl_completer_quote_characters") have_readline_var("rl_filename_quote_characters") have_readline_var("rl_attempted_completion_over") have_readline_var("rl_library_version") have_readline_var("rl_editing_mode") have_readline_var("rl_line_buffer") have_readline_var("rl_point") # workaround for native windows. /mswin|bccwin|mingw/ !~ RUBY_PLATFORM && have_readline_var("rl_event_hook") /mswin|bccwin|mingw/ !~ RUBY_PLATFORM && have_readline_var("rl_catch_sigwinch") /mswin|bccwin|mingw/ !~ RUBY_PLATFORM && have_readline_var("rl_catch_signals") have_readline_func("rl_cleanup_after_signal") have_readline_func("rl_free_line_state") have_readline_func("rl_clear_signals") have_readline_func("rl_set_screen_size") have_readline_func("rl_get_screen_size") have_readline_func("rl_vi_editing_mode") have_readline_func("rl_emacs_editing_mode") have_readline_func("replace_history_entry") have_readline_func("remove_history") have_readline_func("clear_history") have_readline_macro("RL_PROMPT_START_IGNORE") have_readline_macro("RL_PROMPT_END_IGNORE") create_makefile("readline")
arnab0073/idea
.rvm/gems/ruby-2.3.0/gems/fog-core-1.40.0/lib/fog/core/version.rb
module Fog module Core VERSION = "1.40.0" end end