Provides information about specifications and dependencies to the resolver, allowing the {Resolver} class to remain generic while still providing power and flexibility.
This module contains the methods that users of Gem::Resolver::Molinillo
must to implement, using knowledge of their own model classes.
A log for dependency graph actions
@!visibility private (see DependencyGraph#add_edge_no_circular
)
@!visibility private (see DependencyGraph#delete_edge
)
@!visibility private @see DependencyGraph#detach_vertex_named
A vertex in a {DependencyGraph} that encapsulates a {#name} and a {#payload}
Delegates
all {Gem::Resolver::Molinillo::SpecificationProvider} methods to a ‘#specification_provider` property.
Returns the short user name of the currently logged in user. Unfortunately, it is often rather easy to fool ::getlogin
.
Avoid ::getlogin
for security-related purposes.
If ::getlogin
fails, try ::getpwuid
.
See the unix manpage for getpwuid(3)
for more detail.
e.g.
Etc.getlogin -> 'guest'
Returns an Array containing header converters; used for parsing; see Header Converters:
CSV.new('').header_converters # => []
Notes that you need to call +Ractor.make_shareable(CSV::HeaderConverters
)+ on the main Ractor
to use this method.
Returns garbage collector generation for the given object
.
class B include ObjectSpace def foo trace_object_allocations do obj = Object.new p "Generation is #{allocation_generation(obj)}" end end end B.new.foo #=> "Generation is 3"
See ::trace_object_allocations
for more information and examples.
Since int
is already an Integer
, this always returns true
.
Returns a new Time
object representing time in local time (using the local time zone in effect for this process).
If utc_offset
is given, it is used instead of the local time. utc_offset
can be given as a human-readable string (eg. "+09:00"
) or as a number of seconds (eg. 32400
).
t = Time.utc(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC t.utc? #=> true l = t.getlocal #=> 2000-01-01 14:15:01 -0600 l.utc? #=> false t == l #=> true j = t.getlocal("+09:00") #=> 2000-01-02 05:15:01 +0900 j.utc? #=> false t == j #=> true k = t.getlocal(9*60*60) #=> 2000-01-02 05:15:01 +0900 k.utc? #=> false t == k #=> true
Merges the elements of the given enumerable object to the set and returns self.
Obtains the port number for service_name.
If protocol_name is not given, “tcp” is assumed.
Socket.getservbyname("smtp") #=> 25 Socket.getservbyname("shell") #=> 514 Socket.getservbyname("syslog", "udp") #=> 514
Obtains the port number for port.
If protocol_name is not given, “tcp” is assumed.
Socket.getservbyport(80) #=> "www" Socket.getservbyport(514, "tcp") #=> "shell" Socket.getservbyport(514, "udp") #=> "syslog"
Returns the remote address of the socket as a sockaddr string.
TCPServer.open("127.0.0.1", 1440) {|serv| c = TCPSocket.new("127.0.0.1", 1440) s = serv.accept p s.getpeername #=> "\x02\x00\x82u\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" }
If Addrinfo
object is preferred over the binary string, use BasicSocket#remote_address
.
Returns the user and group on the peer of the UNIX socket. The result is a two element array which contains the effective uid and the effective gid.
Socket.unix_server_loop("/tmp/sock") {|s| begin euid, egid = s.getpeereid # Check the connected client is myself or not. next if euid != Process.uid # do something about my resource. ensure s.close end }
Runs the early binding method to get property. The 1st argument specifies dispatch ID, the 2nd argument specifies the array of arguments, the 3rd argument specifies the array of the type of arguments.
excel = WIN32OLE.new('Excel.Application') puts excel._getproperty(558, [], []) # same effect as puts excel.visible
Merges each of other_hashes
into self
; returns self
.
Each argument in other_hashes
must be a Hash.
Method update
is an alias for #merge!.
With arguments and no block:
Returns self
, after the given hashes are merged into it.
The given hashes are merged left to right.
Each new entry is added at the end.
Each duplicate-key entry’s value overwrites the previous value.
Example:
h = {foo: 0, bar: 1, baz: 2} h1 = {bat: 3, bar: 4} h2 = {bam: 5, bat:6} h.merge!(h1, h2) # => {:foo=>0, :bar=>4, :baz=>2, :bat=>6, :bam=>5}
With arguments and a block:
Returns self
, after the given hashes are merged.
The given hashes are merged left to right.
Each new-key entry is added at the end.
For each duplicate key:
Calls the block with the key and the old and new values.
The block’s return value becomes the new value for the entry.
Example:
h = {foo: 0, bar: 1, baz: 2} h1 = {bat: 3, bar: 4} h2 = {bam: 5, bat:6} h3 = h.merge!(h1, h2) { |key, old_value, new_value| old_value + new_value } h3 # => {:foo=>0, :bar=>5, :baz=>2, :bat=>9, :bam=>5}
With no arguments:
Returns self
, unmodified.
The block, if given, is ignored.
Example:
h = {foo: 0, bar: 1, baz: 2} h.merge # => {:foo=>0, :bar=>1, :baz=>2} h1 = h.merge! { |key, old_value, new_value| raise 'Cannot happen' } h1 # => {:foo=>0, :bar=>1, :baz=>2}
Returns the new Hash formed by merging each of other_hashes
into a copy of self
.
Each argument in other_hashes
must be a Hash.
With arguments and no block:
Returns the new Hash object formed by merging each successive Hash in other_hashes
into self
.
Each new-key entry is added at the end.
Each duplicate-key entry’s value overwrites the previous value.
Example:
h = {foo: 0, bar: 1, baz: 2} h1 = {bat: 3, bar: 4} h2 = {bam: 5, bat:6} h.merge(h1, h2) # => {:foo=>0, :bar=>4, :baz=>2, :bat=>6, :bam=>5}
With arguments and a block:
Returns a new Hash object that is the merge of self
and each given hash.
The given hashes are merged left to right.
Each new-key entry is added at the end.
For each duplicate key:
Calls the block with the key and the old and new values.
The block’s return value becomes the new value for the entry.
Example:
h = {foo: 0, bar: 1, baz: 2} h1 = {bat: 3, bar: 4} h2 = {bam: 5, bat:6} h3 = h.merge(h1, h2) { |key, old_value, new_value| old_value + new_value } h3 # => {:foo=>0, :bar=>5, :baz=>2, :bat=>9, :bam=>5}
With no arguments:
Returns a copy of self
.
The block, if given, is ignored.
Example:
h = {foo: 0, bar: 1, baz: 2} h.merge # => {:foo=>0, :bar=>1, :baz=>2} h1 = h.merge { |key, old_value, new_value| raise 'Cannot happen' } h1 # => {:foo=>0, :bar=>1, :baz=>2}
ENV.update
is an alias for ENV.merge!
.
Adds to ENV
each key/value pair in the given hash
; returns ENV:
ENV.replace('foo' => '0', 'bar' => '1') ENV.merge!('baz' => '2', 'bat' => '3') # => {"bar"=>"1", "bat"=>"3", "baz"=>"2", "foo"=>"0"}
Deletes the ENV
entry for a hash value that is nil
:
ENV.merge!('baz' => nil, 'bat' => nil) # => {"bar"=>"1", "foo"=>"0"}
For an already-existing name, if no block given, overwrites the ENV
value:
ENV.merge!('foo' => '4') # => {"bar"=>"1", "foo"=>"4"}
For an already-existing name, if block given, yields the name, its ENV
value, and its hash value; the block’s return value becomes the new name:
ENV.merge!('foo' => '5') { |name, env_val, hash_val | env_val + hash_val } # => {"bar"=>"1", "foo"=>"45"}
Raises an exception if a name or value is invalid (see Invalid Names and Values);
ENV.replace('foo' => '0', 'bar' => '1') ENV.merge!('foo' => '6', :bar => '7', 'baz' => '9') # Raises TypeError (no implicit conversion of Symbol into String) ENV # => {"bar"=>"1", "foo"=>"6"} ENV.merge!('foo' => '7', 'bar' => 8, 'baz' => '9') # Raises TypeError (no implicit conversion of Integer into String) ENV # => {"bar"=>"1", "foo"=>"7"}
Raises an exception if the block returns an invalid name: (see Invalid Names and Values):
ENV.merge!('bat' => '8', 'foo' => '9') { |name, env_val, hash_val | 10 } # Raises TypeError (no implicit conversion of Integer into String) ENV # => {"bar"=>"1", "bat"=>"8", "foo"=>"7"}
Note that for the exceptions above, hash pairs preceding an invalid name or value are processed normally; those following are ignored.