code
stringlengths 26
124k
| docstring
stringlengths 23
125k
| func_name
stringlengths 1
98
| language
stringclasses 1
value | repo
stringlengths 5
53
| path
stringlengths 7
151
| url
stringlengths 50
211
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
def from_native(ptr, ctx)
struct_class.new(AutoPointer.new(ptr, @method))
end
|
@param [Pointer] ptr
@param [nil] ctx
@return [Struct]
|
from_native
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct.rb
|
Apache-2.0
|
def layout(*spec)
warn "[DEPRECATION] Struct layout is already defined for class #{self.inspect}. Redefinition as in #{caller[0]} will be disallowed in ffi-2.0." if defined?(@layout)
return @layout if spec.size == 0
builder = StructLayoutBuilder.new
builder.union = self < Union
builder.packed = @packed if defined?(@packed)
builder.alignment = @min_alignment if defined?(@min_alignment)
if spec[0].kind_of?(Hash)
hash_layout(builder, spec)
else
array_layout(builder, spec)
end
builder.size = @size if defined?(@size) && @size > builder.size
cspec = builder.build
@layout = cspec unless self == Struct
@size = cspec.size
return cspec
end
|
@return [StructLayout]
@overload layout
@return [StructLayout]
Get struct layout.
@overload layout(*spec)
@param [Array<Symbol, Integer>,Array(Hash)] spec
@return [StructLayout]
Create struct layout from +spec+.
@example Creating a layout from an array +spec+
class MyStruct < Struct
layout :field1, :int,
:field2, :pointer,
:field3, :string
end
@example Creating a layout from an array +spec+ with offset
class MyStructWithOffset < Struct
layout :field1, :int,
:field2, :pointer, 6, # set offset to 6 for this field
:field3, :string
end
@example Creating a layout from a hash +spec+
class MyStructFromHash < Struct
layout :field1 => :int,
:field2 => :pointer,
:field3 => :string
end
@example Creating a layout with pointers to functions
class MyFunctionTable < Struct
layout :function1, callback([:int, :int], :int),
:function2, callback([:pointer], :void),
:field3, :string
end
|
layout
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct.rb
|
Apache-2.0
|
def hash_layout(builder, spec)
spec[0].each do |name, type|
builder.add name, find_field_type(type), nil
end
end
|
@param [StructLayoutBuilder] builder
@param [Hash] spec
@return [builder]
Add hash +spec+ to +builder+.
|
hash_layout
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct.rb
|
Apache-2.0
|
def array_layout(builder, spec)
i = 0
while i < spec.size
name, type = spec[i, 2]
i += 2
# If the next param is a Integer, it specifies the offset
if spec[i].kind_of?(Integer)
offset = spec[i]
i += 1
else
offset = nil
end
builder.add name, find_field_type(type), offset
end
end
|
@param [StructLayoutBuilder] builder
@param [Array<Symbol, Integer>] spec
@return [builder]
Add array +spec+ to +builder+.
|
array_layout
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct.rb
|
Apache-2.0
|
def to_native(value, ctx)
return Pointer::NULL if value.nil?
unless @struct_class === value
raise TypeError, "wrong argument type #{value.class} (expected #{@struct_class})"
end
value.pointer
end
|
@param [nil, Struct] value
@param [nil] ctx
@return [AbstractMemory] Pointer on +value+.
|
to_native
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct_by_reference.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct_by_reference.rb
|
Apache-2.0
|
def offsets
members.map { |m| [ m, self[m].offset ] }
end
|
@return [Array<Array(Symbol, Numeric)>
Get an array of tuples (field name, offset of the field).
|
offsets
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct_layout.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct_layout.rb
|
Apache-2.0
|
def put(ptr, value)
ptr.put_int(offset, type.find(value))
end
|
@param [AbstractMemory] ptr pointer on a {Struct}
@param value
@return [nil]
Set +value+ into memory pointed by +ptr+.
|
put
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct_layout.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct_layout.rb
|
Apache-2.0
|
def add(name, type, offset = nil)
if offset.nil? || offset == -1
offset = @union ? 0 : align(@size, @packed ? [ @packed, type.alignment ].min : [ @min_alignment, type.alignment ].max)
end
#
# If a FFI::Type type was passed in as the field arg, try and convert to a StructLayout::Field instance
#
field = type.is_a?(StructLayout::Field) ? type : field_for_type(name, offset, type)
@fields << field
@alignment = [ @alignment, field.alignment ].max unless @packed
@size = [ @size, field.size + (@union ? 0 : field.offset) ].max
return self
end
|
@param [String, Symbol] name name of the field
@param [Array, DataConverter, Struct, StructLayout::Field, Symbol, Type] type type of the field
@param [Numeric, nil] offset
@return [self]
Add a field to the builder.
@note Setting +offset+ to +nil+ or +-1+ is equivalent to +0+.
|
add
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct_layout_builder.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct_layout_builder.rb
|
Apache-2.0
|
def add_field(name, type, offset = nil)
add(name, type, offset)
end
|
@param (see #add)
@return (see #add)
Same as {#add}.
@see #add
|
add_field
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct_layout_builder.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct_layout_builder.rb
|
Apache-2.0
|
def add_struct(name, type, offset = nil)
add(name, Type::Struct.new(type), offset)
end
|
@param (see #add)
@return (see #add)
Add a struct as a field to the builder.
|
add_struct
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct_layout_builder.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct_layout_builder.rb
|
Apache-2.0
|
def add_array(name, type, count, offset = nil)
add(name, Type::Array.new(type, count), offset)
end
|
@param name (see #add)
@param type (see #add)
@param [Numeric] count array length
@param offset (see #add)
@return (see #add)
Add an array as a field to the builder.
|
add_array
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct_layout_builder.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct_layout_builder.rb
|
Apache-2.0
|
def build
# Add tail padding if the struct is not packed
size = @packed ? @size : align(@size, @alignment)
layout = StructLayout.new(@fields, size, @alignment)
layout.__union! if @union
layout
end
|
@return [StructLayout]
Build and return the struct layout.
|
build
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct_layout_builder.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct_layout_builder.rb
|
Apache-2.0
|
def align(offset, align)
align + ((offset - 1) & ~(align - 1));
end
|
@param [Numeric] offset
@param [Numeric] align
@return [Numeric]
|
align
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct_layout_builder.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct_layout_builder.rb
|
Apache-2.0
|
def field_for_type(name, offset, type)
field_class = case
when type.is_a?(Type::Function)
StructLayout::Function
when type.is_a?(Type::Struct)
StructLayout::InnerStruct
when type.is_a?(Type::Array)
StructLayout::Array
when type.is_a?(FFI::Enum)
StructLayout::Enum
when NUMBER_TYPES.include?(type)
StructLayout::Number
when type == Type::POINTER
StructLayout::Pointer
when type == Type::STRING
StructLayout::String
when type.is_a?(Class) && type < StructLayout::Field
type
when type.is_a?(DataConverter)
return StructLayout::Mapped.new(name, offset, Type::Mapped.new(type), field_for_type(name, offset, type.native_type))
when type.is_a?(Type::Mapped)
return StructLayout::Mapped.new(name, offset, type, field_for_type(name, offset, type.native_type))
else
raise TypeError, "invalid struct field type #{type.inspect}"
end
field_class.new(name, offset, type)
end
|
@param (see #add)
@return [StructLayout::Field]
|
field_for_type
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct_layout_builder.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/struct_layout_builder.rb
|
Apache-2.0
|
def attach(mod, mname)
invoker = self
params = "*args"
call = "call"
mod.module_eval <<-code
@@#{mname} = invoker
def self.#{mname}(#{params})
@@#{mname}.#{call}(#{params})
end
def #{mname}(#{params})
@@#{mname}.#{call}(#{params})
end
code
invoker
end
|
Attach the invoker to module +mod+ as +mname+
|
attach
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/variadic.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/variadic.rb
|
Apache-2.0
|
def initialize(prefix = nil, options = {})
@includes = ['stdio.h', 'stddef.h']
@constants = {}
@prefix = prefix
@required = options[:required]
@options = options
if block_given? then
yield self
calculate self.class.options.merge(options)
end
end
|
Creates a new constant generator that uses +prefix+ as a name, and an
options hash.
The only option is +:required+, which if set to +true+ raises an error if a
constant you have requested was not found.
@param [#to_s] prefix
@param [Hash] options
@return
@option options [Boolean] :required
@overload initialize(prefix, options)
@overload initialize(prefix, options) { |gen| ... }
@yieldparam [ConstGenerator] gen new generator is passed to the block
When passed a block, {#calculate} is automatically called at the end of
the block, otherwise you must call it yourself.
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/tools/const_generator.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/tools/const_generator.rb
|
Apache-2.0
|
def const(name, format = nil, cast = '', ruby_name = nil, converter = nil,
&converter_proc)
format ||= '%d'
cast ||= ''
if converter_proc and converter then
raise ArgumentError, "Supply only converter or converter block"
end
converter = converter_proc if converter.nil?
const = Constant.new name, format, cast, ruby_name, converter
@constants[name.to_s] = const
return const
end
|
Request the value for C constant +name+.
@param [#to_s] name C constant name
@param [String] format a printf format string to print the value out
@param [String] cast a C cast for the value
@param ruby_name alternate ruby name for {#to_ruby}
@overload const(name, format=nil, cast='', ruby_name=nil, converter=nil)
+converter+ is a Method or a Proc.
@param [#call] converter convert the value from a string to the appropriate
type for {#to_ruby}.
@overload const(name, format=nil, cast='', ruby_name=nil) { |value| ... }
Use a converter block. This block convert the value from a string to the
appropriate type for {#to_ruby}.
@yieldparam value constant value
|
const
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/tools/const_generator.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/tools/const_generator.rb
|
Apache-2.0
|
def calculate(options = {})
binary_path = nil
Tempfile.open("#{@prefix}.const_generator") do |f|
binary_path = f.path + ".bin"
@includes.each do |inc|
f.puts "#include <#{inc}>"
end
f.puts "\nint main(int argc, char **argv)\n{"
@constants.each_value do |const|
f.puts <<-EOF
#ifdef #{const.name}
printf("#{const.name} #{const.format}\\n", #{const.cast}#{const.name});
#endif
EOF
end
f.puts "\n\treturn 0;\n}"
f.flush
cc = ENV['CC'] || 'gcc'
output = `#{cc} #{options[:cppflags]} -D_DARWIN_USE_64_BIT_INODE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -x c -Wall -Werror #{f.path} -o #{binary_path} 2>&1`
unless $?.success? then
output = output.split("\n").map { |l| "\t#{l}" }.join "\n"
raise "Compilation error generating constants #{@prefix}:\n#{output}"
end
end
output = `#{binary_path}`
File.unlink(binary_path + (FFI::Platform.windows? ? ".exe" : ""))
output.each_line do |line|
line =~ /^(\S+)\s(.*)$/
const = @constants[$1]
const.value = $2
end
missing_constants = @constants.select do |name, constant|
constant.value.nil?
end.map { |name,| name }
if @required and not missing_constants.empty? then
raise "Missing required constants for #{@prefix}: #{missing_constants.join ', '}"
end
end
|
Calculate constants values.
@param [Hash] options
@option options [String] :cppflags flags for C compiler
@return [nil]
@raise if a constant is missing and +:required+ was set to +true+ (see {#initialize})
|
calculate
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/tools/const_generator.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/tools/const_generator.rb
|
Apache-2.0
|
def dump_constants(io)
@constants.each do |name, constant|
name = [@prefix, name].join '.' if @prefix
io.puts "#{name} = #{constant.converted_value}"
end
end
|
Dump constants to +io+.
@param [#puts] io
@return [nil]
|
dump_constants
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/tools/const_generator.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/tools/const_generator.rb
|
Apache-2.0
|
def include(*i)
@includes |= i.flatten
end
|
Add additional C include file(s) to calculate constants from.
@note +stdio.h+ and +stddef.h+ automatically included
@param [List<String>, Array<String>] i include file(s)
@return [Array<String>] array of include files
|
include
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/tools/const_generator.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/tools/const_generator.rb
|
Apache-2.0
|
def initialize(name, format, cast, ruby_name = nil, converter=nil)
@name = name
@format = format
@cast = cast
@ruby_name = ruby_name
@converter = converter
@value = nil
end
|
@param [#to_s] name
@param [String] format a printf format string to print the value out
@param [String] cast a C cast for the value
@param ruby_name alternate ruby name for {#to_ruby}
@param [#call] converter convert the value from a string to the appropriate
type for {#to_ruby}.
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/tools/const_generator.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/tools/const_generator.rb
|
Apache-2.0
|
def converted_value
if @converter
@converter.call(@value)
else
@value
end
end
|
Return constant value (converted if a +converter+ was defined).
@return constant value.
|
converted_value
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/tools/const_generator.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/tools/const_generator.rb
|
Apache-2.0
|
def ruby_name
@ruby_name || @name
end
|
get constant ruby name
@return [String]
|
ruby_name
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/tools/const_generator.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/tools/const_generator.rb
|
Apache-2.0
|
def to_ruby
"#{ruby_name} = #{converted_value}"
end
|
Get an evaluable string from constant.
@return [String]
|
to_ruby
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/tools/const_generator.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ffi-1.15.5/lib/ffi/tools/const_generator.rb
|
Apache-2.0
|
def def_hash_delegator(hash, method, key: method, **kwd)
prefix, suffix, wrap = prepare_delegate(**kwd)
if suffix
method = method.to_s.gsub(
/\?$/, ""
)
end
class_eval delegate_debug(<<-STR), __FILE__, __LINE__ - 9
def #{method}#{suffix}(*args)
#{wrap}(
#{prefix}#{hash}[#{key.inspect}]
)
rescue Exception
if !Forwardable.debug && $@ && [email protected]_to?(:delete_if)
[email protected]_if do |source|
source =~ %r"#{Regexp.escape(__FILE__)}"o
end
end
raise
end
STR
end
|
------------------------------------------------------------------------
Delegate a method to a hash and key.
------------------------------------------------------------------------
|
def_hash_delegator
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/forwardable-extended-2.6.0/lib/forwardable/extended.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/forwardable-extended-2.6.0/lib/forwardable/extended.rb
|
Apache-2.0
|
def def_ivar_delegator(ivar, alias_ = ivar, **kwd)
prefix, suffix, wrap = prepare_delegate(**kwd)
if suffix
alias_ = alias_.to_s.gsub(
/\?$/, ""
)
end
class_eval delegate_debug(<<-STR), __FILE__, __LINE__ - 9
def #{alias_.to_s.gsub(/\A@/, "")}#{suffix}
#{wrap}(
#{prefix}#{ivar}
)
rescue Exception
if !Forwardable.debug && $@ && [email protected]_to?(:delete_if)
[email protected]_if do |source|
source =~ %r"#{Regexp.escape(__FILE__)}"o
end
end
raise
end
STR
end
|
------------------------------------------------------------------------
Delegate a method to an instance variable.
------------------------------------------------------------------------
|
def_ivar_delegator
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/forwardable-extended-2.6.0/lib/forwardable/extended.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/forwardable-extended-2.6.0/lib/forwardable/extended.rb
|
Apache-2.0
|
def def_modern_delegator(accessor, method, alias_ = method, args: \
{ :before => [], :after => [] }, **kwd)
prefix, suffix, wrap = prepare_delegate(**kwd)
args = { :before => args } unless args.is_a?(Hash)
b = [args[:before]].flatten.compact.map(&:to_s).join(", ")
a = [args[ :after]].flatten.compact.map(&:to_s).join(", ")
b = b + ", " unless args[:before].nil? || args[:before].empty?
a = ", " + a unless args[ :after].nil? || args[ :after].empty?
alias_ = alias_.to_s.gsub(/\?$/, "") if suffix
class_eval delegate_debug(<<-STR), __FILE__, __LINE__ - 10
def #{alias_}#{suffix}(*args, &block)
#{wrap}(#{prefix}#{accessor}.send(
#{method.inspect}, #{b}*args#{a}, &block
))
rescue Exception
if !Forwardable.debug && $@ && [email protected]_to?(:delete_if)
[email protected]_if do |source|
source =~ %r"#{Regexp.escape(__FILE__)}"o
end
end
raise
end
STR
end
|
------------------------------------------------------------------------
Like def_delegator but allows you to send args and do other stuff.
------------------------------------------------------------------------
|
def_modern_delegator
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/forwardable-extended-2.6.0/lib/forwardable/extended.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/forwardable-extended-2.6.0/lib/forwardable/extended.rb
|
Apache-2.0
|
def def_delegator(accessor, method, alias_ = method, **kwd)
kwd, alias_ = alias_, method if alias_.is_a?(Hash) && !kwd.any?
if alias_.is_a?(Hash) || !kwd.any?
Forwardable.instance_method(:def_delegator).bind(self) \
.call(accessor, method, alias_)
elsif !kwd[:type]
def_modern_delegator(
accessor, method, alias_, **kwd
)
else
raise ArgumentError, "Alias not supported." if alias_ != method
send("def_#{kwd[:type]}_delegator", accessor, method, **kwd.tap do |obj|
obj.delete(:type)
end)
end
end
|
------------------------------------------------------------------------
Wraps around traditional delegation and modern delegation.
------------------------------------------------------------------------
|
def_delegator
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/forwardable-extended-2.6.0/lib/forwardable/extended.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/forwardable-extended-2.6.0/lib/forwardable/extended.rb
|
Apache-2.0
|
def create(name)
emoji = Emoji::Character.new(name)
self.all << edit_emoji(emoji) { yield emoji if block_given? }
emoji
end
|
Public: Initialize an Emoji::Character instance and yield it to the block.
The character is added to the `Emoji.all` set.
|
create
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/gemoji-3.0.1/lib/emoji.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/gemoji-3.0.1/lib/emoji.rb
|
Apache-2.0
|
def edit_emoji(emoji)
@names_index ||= Hash.new
@unicodes_index ||= Hash.new
yield emoji
emoji.aliases.each do |name|
@names_index[name] = emoji
end
emoji.unicode_aliases.each do |unicode|
@unicodes_index[unicode] = emoji
end
emoji
end
|
Public: Yield an emoji to the block and update the indices in case its
aliases or unicode_aliases lists changed.
|
edit_emoji
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/gemoji-3.0.1/lib/emoji.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/gemoji-3.0.1/lib/emoji.rb
|
Apache-2.0
|
def parse_ttc(io)
header_name = io.read(4).unpack('a*')[0]
raise unless "ttcf" == header_name
header_version, num_fonts = io.read(4*2).unpack('l>N')
# parse_version(header_version) #=> 2.0
io.read(4 * num_fonts).unpack('N*')
end
|
https://www.microsoft.com/typography/otspec/otff.htm
|
parse_ttc
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/gemoji-3.0.1/lib/emoji/extractor.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/gemoji-3.0.1/lib/emoji/extractor.rb
|
Apache-2.0
|
def each_glyph_bitmap(io, tables, glyph_index)
io.pos = sbix_offset = tables.fetch('sbix')[:offset]
strike = extract_sbix_strike(io, glyph_index.length, size)
glyph_index.each_with_name do |glyph_id, glyph_name|
glyph_offset = strike[:glyph_data_offset][glyph_id]
next_glyph_offset = strike[:glyph_data_offset][glyph_id + 1]
if glyph_offset && next_glyph_offset && glyph_offset < next_glyph_offset
io.pos = sbix_offset + strike[:offset] + glyph_offset
x, y, type = io.read(2*2 + 4).unpack('s2A4')
yield glyph_name, type, -> { io.read(next_glyph_offset - glyph_offset - 8) }
end
end
end
|
https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6sbix.html
|
each_glyph_bitmap
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/gemoji-3.0.1/lib/emoji/extractor.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/gemoji-3.0.1/lib/emoji/extractor.rb
|
Apache-2.0
|
def effective_config(user_config)
# Merge user config into defaults
config = Jekyll::Utils.deep_merge_hashes(defaults_for_env, user_config)
.fix_common_issues
.add_default_collections
# Allow theme to be explicitly disabled via "theme: null"
config["theme"] = user_config["theme"] if user_config.key?("theme")
migrate_theme_to_remote_theme(config)
exclude_cname(config)
# Merge overwrites into user config
config = Jekyll::Utils.deep_merge_hashes config, OVERRIDES
restrict_and_config_markdown_processor(config)
configure_plugins(config)
config
end
|
Given a user's config, determines the effective configuration by building a user
configuration sandwhich with our overrides overriding the user's specified
values which themselves override our defaults.
Returns the effective Configuration
Note: this is a highly modified version of Jekyll#configuration
|
effective_config
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-228/lib/github-pages/configuration.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-228/lib/github-pages/configuration.rb
|
Apache-2.0
|
def set(site)
return if processed? site
debug_print_versions
set!(site)
processed(site)
end
|
Set the site's configuration. Implemented as an `after_reset` hook.
Equivalent #set! function contains the code of interest. This function
guards against double-processing via the value in #processed.
|
set
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-228/lib/github-pages/configuration.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-228/lib/github-pages/configuration.rb
|
Apache-2.0
|
def set!(site)
site.config = effective_config(site.config)
end
|
Set the site's configuration with all the proper defaults and overrides.
Should be called by #set to protect against multiple processings.
|
set!
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-228/lib/github-pages/configuration.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-228/lib/github-pages/configuration.rb
|
Apache-2.0
|
def restrict_and_config_markdown_processor(config)
config["markdown"] = "kramdown" unless \
%w(kramdown gfm commonmarkghpages).include?(config["markdown"].to_s.downcase)
return unless config["markdown"].to_s.casecmp("gfm").zero?
config["markdown"] = "CommonMarkGhPages"
config["commonmark"] = {
"extensions" => %w(table strikethrough autolink tagfilter),
"options" => %w(unsafe footnotes),
}
end
|
Ensure we're using Kramdown or GFM. Force to Kramdown if
neither of these.
This can get called multiply on the same config, so try to
be idempotentish.
|
restrict_and_config_markdown_processor
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-228/lib/github-pages/configuration.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-228/lib/github-pages/configuration.rb
|
Apache-2.0
|
def exclude_cname(config)
return unless config["exclude"].eql? Jekyll::Configuration::DEFAULTS["exclude"]
config["exclude"].concat(DEFAULTS["exclude"])
end
|
If the user's 'exclude' config is the default, also exclude the CNAME
|
exclude_cname
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-228/lib/github-pages/configuration.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-228/lib/github-pages/configuration.rb
|
Apache-2.0
|
def configure_plugins(config)
# Ensure we have those gems we want.
config["plugins"] = Array(config["plugins"]) | DEFAULT_PLUGINS
# To minimize errors, lazy-require jekyll-remote-theme if requested by the user
config["plugins"].push("jekyll-remote-theme") if config.key? "remote_theme"
return unless development?
if disable_whitelist?
config["whitelist"] = config["whitelist"] | config["plugins"]
end
config["whitelist"] = config["whitelist"] | DEVELOPMENT_PLUGINS
end
|
Requires default plugins and configures whitelist in development
|
configure_plugins
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-228/lib/github-pages/configuration.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-228/lib/github-pages/configuration.rb
|
Apache-2.0
|
def debug_print_versions
Jekyll.logger.debug "GitHub Pages:", "github-pages v#{GitHubPages::VERSION}"
Jekyll.logger.debug "GitHub Pages:", "jekyll v#{Jekyll::VERSION}"
end
|
Print the versions for github-pages and jekyll to the debug
stream for debugging purposes. See by running Jekyll with '--verbose'
|
debug_print_versions
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-228/lib/github-pages/configuration.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-228/lib/github-pages/configuration.rb
|
Apache-2.0
|
def initialize(options = {})
@name = options.fetch(:name) { self.class.name.split("::").last.downcase }
@path = options.fetch(:path) { default_config_path }
end
|
Internal: Create a new CDN info instance.
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/cdn.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/cdn.rb
|
Apache-2.0
|
def controls_ip?(address)
ranges.any? { |range| range.include?(address.to_s) }
end
|
Internal: Does this CDN control this address?
|
controls_ip?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/cdn.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/cdn.rb
|
Apache-2.0
|
def ranges
@ranges ||= load_ranges
end
|
Internal: The IP address ranges that cloudflare controls.
|
ranges
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/cdn.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/cdn.rb
|
Apache-2.0
|
def load_ranges
File.read(path).lines.map { |line| IPAddr.new(line.chomp) }
end
|
Internal: Load IPAddr ranges from #path
|
load_ranges
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/cdn.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/cdn.rb
|
Apache-2.0
|
def valid?
check!
true
rescue GitHubPages::HealthCheck::Error
false
end
|
Runs all checks, returns true if valid, otherwise false
|
valid?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/checkable.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/checkable.rb
|
Apache-2.0
|
def reason
check!
nil
rescue GitHubPages::HealthCheck::Error => e
e
end
|
Returns the reason the check failed, if any
|
reason
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/checkable.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/checkable.rb
|
Apache-2.0
|
def check!
raise Errors::InvalidDomainError.new :domain => self unless valid_domain?
raise Errors::InvalidDNSError.new :domain => self unless dns_resolves?
raise Errors::DeprecatedIPError.new :domain => self if deprecated_ip?
return true if proxied?
raise Errors::InvalidARecordError.new :domain => self if invalid_a_record?
raise Errors::InvalidCNAMEError.new :domain => self if invalid_cname?
raise Errors::InvalidAAAARecordError.new :domain => self if invalid_aaaa_record?
raise Errors::NotServedByPagesError.new :domain => self unless served_by_pages?
true
end
|
Runs all checks, raises an error if invalid
rubocop:disable Metrics/AbcSize
|
check!
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def valid_domain?
return @valid if defined? @valid
unicode_host = Addressable::IDNA.to_unicode(host)
@valid = PublicSuffix.valid?(unicode_host,
:default_rule => nil,
:ignore_private => true)
end
|
Is this a valid domain that PublicSuffix recognizes?
Used as an escape hatch to prevent false positives on DNS checkes
|
valid_domain?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def apex_domain?
return @apex_domain if defined?(@apex_domain)
return false unless valid_domain?
return true if dns_zone_soa? && dns_zone_ns?
# PublicSuffix.domain pulls out the apex-level domain name.
# E.g. PublicSuffix.domain("techblog.netflix.com") # => "netflix.com"
# It's aware of multi-step top-level domain names:
# E.g. PublicSuffix.domain("blog.digital.gov.uk") # => "digital.gov.uk"
# For apex-level domain names, DNS providers do not support CNAME records.
unicode_host = Addressable::IDNA.to_unicode(host)
PublicSuffix.domain(unicode_host,
:default_rule => nil,
:ignore_private => true) == unicode_host
end
|
Is this domain an apex domain, meaning a CNAME would be innapropriate
|
apex_domain?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def dns_zone_soa?
return @soa_records if defined?(@soa_records)
return false unless dns?
@soa_records = dns.any? do |answer|
answer.type == Dnsruby::Types::SOA && answer.name.to_s == host
end
end
|
Does the domain have an associated SOA record?
|
dns_zone_soa?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def dns_zone_ns?
return @ns_records if defined?(@ns_records)
return false unless dns?
@ns_records = dns.any? do |answer|
answer.type == Dnsruby::Types::NS && answer.name.to_s == host
end
end
|
Does the domain have assoicated NS records?
|
dns_zone_ns?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def should_be_a_record?
!pages_io_domain? && (apex_domain? || mx_records_present?)
end
|
Should the domain use an A record?
|
should_be_a_record?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def pointed_to_github_pages_ip?
return false unless address_record?
CURRENT_IP_ADDRESSES_ALL.include?(dns.first.address.to_s.downcase)
end
|
Is the domain's first response an A or AAAA record to a valid GitHub Pages IP?
|
pointed_to_github_pages_ip?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def non_github_pages_ip_present?
return unless dns?
dns
.select { |a| Dnsruby::Types::A == a.type || Dnsruby::Types::AAAA == a.type }
.any? { |a| !github_pages_ip?(a.address.to_s) }
end
|
Are any of the domain's A or AAAA records pointing elsewhere?
|
non_github_pages_ip_present?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def cname_to_github_user_domain?
cname? && !cname_to_pages_dot_github_dot_com? && cname.pages_domain?
end
|
Is the domain's first response a CNAME to a pages domain?
|
cname_to_github_user_domain?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def cname_to_pages_dot_github_dot_com?
cname? && cname.pages_dot_github_dot_com?
end
|
Is the given domain a CNAME to pages.github.(io|com)
instead of being CNAME'd to the user's subdomain?
domain - the domain to check, generaly the target of a cname
|
cname_to_pages_dot_github_dot_com?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def cname_to_fastly?
cname? && !pages_domain? && cname.fastly?
end
|
Is the given domain CNAME'd directly to our Fastly account?
|
cname_to_fastly?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def proxied?
return unless dns?
return true if cloudflare_ip?
return false if pointed_to_github_pages_ip?
return false if cname_to_github_user_domain?
return false if cname_to_pages_dot_github_dot_com?
return false if cname_to_fastly? || fastly_ip?
served_by_pages?
end
|
Does this non-GitHub-pages domain proxy a GitHub Pages site?
This can be:
1. A Cloudflare-owned IP address
2. A site that returns GitHub.com server headers, but
isn't CNAME'd to a GitHub domain
3. A site that returns GitHub.com server headers, but
isn't CNAME'd to a GitHub IP
|
proxied?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def dns
return @dns if defined? @dns
return unless valid_domain?
@dns = Timeout.timeout(TIMEOUT) do
GitHubPages::HealthCheck.without_warnings do
next if host.nil?
REQUESTED_RECORD_TYPES
.map { |type| resolver.query(type) }
.flatten.uniq
end
end
rescue StandardError
@dns = nil
end
|
Returns an array of DNS answers
|
dns
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def dns?
!(dns.nil? || dns.empty?)
end
|
Are we even able to get the DNS record?
|
dns?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def old_ip_address?
return unless dns?
dns.any? do |answer|
answer.type == Dnsruby::Types::A && legacy_ip?(answer.address.to_s)
end
end
|
Does this domain have *any* A record that points to the legacy IPs?
|
old_ip_address?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def a_record?
return @is_a_record if defined?(@is_a_record)
return unless dns?
@is_a_record = Dnsruby::Types::A == dns.first.type
end
|
Is this domain's first response an A record?
|
a_record?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def aaaa_record?
return @is_aaaa_record if defined?(@is_aaaa_record)
return unless dns?
@is_aaaa_record = Dnsruby::Types::AAAA == dns.first.type
end
|
Is this domain's first response an AAAA record?
|
aaaa_record?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def a_record_present?
return unless dns?
dns.any? { |answer| answer.type == Dnsruby::Types::A && answer.name.to_s == host }
end
|
Does this domain has an A record setup (not necessarily as the first record)?
|
a_record_present?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def aaaa_record_present?
return unless dns?
dns.any? { |answer| answer.type == Dnsruby::Types::AAAA && answer.name.to_s == host }
end
|
Does this domain has an AAAA record setup (not necessarily as the first record)?
|
aaaa_record_present?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def cname_record?
return unless dns?
return false unless cname
cname.valid_domain?
end
|
Is this domain's first response a CNAME record?
|
cname_record?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def cname
return unless dns?
cnames = dns.take_while { |answer| answer.type == Dnsruby::Types::CNAME }
return if cnames.empty?
@cname ||= Domain.new(cnames.last.cname.to_s)
end
|
The domain to which this domain's CNAME resolves
Returns nil if the domain is not a CNAME
|
cname
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def https?
https_response.return_code == :ok
end
|
Does this domain respond to HTTPS requests with a valid cert?
|
https?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def https_error
https_response.return_code unless https?
end
|
The response code of the HTTPS request, if it failed.
Useful for diagnosing cert errors
|
https_error
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def enforces_https?
return false unless https? && http_response.headers["Location"]
redirect = Addressable::URI.parse(http_response.headers["Location"])
redirect.scheme == "https" && redirect.host == host
end
|
Does this domain redirect HTTP requests to HTTPS?
|
enforces_https?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def https_eligible?
# Can't have any IP's which aren't GitHub's present.
return false if non_github_pages_ip_present?
# Must be a CNAME or point to our IPs.
# Only check the one domain if a CNAME. Don't check the parent domain.
return true if cname_to_github_user_domain?
# Check CAA records for the full domain and its parent domain.
pointed_to_github_pages_ip? && caa.lets_encrypt_allowed?
end
|
Can an HTTPS certificate be issued for this domain?
|
https_eligible?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def response
return @response if defined? @response
@response = Typhoeus.head(uri, TYPHOEUS_OPTIONS)
# Workaround for webmock not playing nicely with Typhoeus redirects
# See https://github.com/bblimke/webmock/issues/237
if @response.mock? && @response.headers["Location"]
@response = Typhoeus.head(response.headers["Location"], TYPHOEUS_OPTIONS)
end
@response
end
|
The domain's response to HTTP(S) requests, following redirects
|
response
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def http_response
options = TYPHOEUS_OPTIONS.merge(:followlocation => false)
@http_response ||= Typhoeus.head(uri(:scheme => "http"), options)
end
|
The domain's response to HTTP requests, without following redirects
|
http_response
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def https_response
options = TYPHOEUS_OPTIONS.merge(:followlocation => false)
@https_response ||= Typhoeus.head(uri(:scheme => "https"), options)
end
|
The domain's response to HTTPS requests, without following redirects
|
https_response
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def normalize_host(domain)
domain = domain.strip.chomp(".")
host = Addressable::URI.parse(domain).normalized_host
host ||= Addressable::URI.parse("http://#{domain}").normalized_host
host unless host.to_s.empty?
rescue Addressable::URI::InvalidURIError
nil
end
|
Parse the URI. Accept either domain names or full URI's.
Used by the initializer so we can be more flexible with inputs.
domain - a URI or domain name.
Examples
normalize_host("benbalter.github.com")
# => 'benbalter.github.com'
normalize_host("https://benbalter.github.com")
# => 'benbalter.github.com'
normalize_host("benbalter.github.com/help-me-im-a-path/")
# => 'benbalter.github.com'
Return the hostname.
|
normalize_host
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def absolute_domain
host.end_with?(".") ? host : "#{host}."
end
|
Adjust `domain` so that it won't be searched for with /etc/resolv.conf
GitHubPages::HealthCheck.new("anything.io").absolute_domain
=> "anything.io."
|
absolute_domain
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def cdn_ip?(cdn)
return unless dns?
address_records = dns.select do |answer|
Dnsruby::Types::A == answer.type || Dnsruby::Types::AAAA == answer.type
end
return false if !address_records || address_records.empty?
address_records.all? do |answer|
cdn.controls_ip?(answer.address)
end
end
|
Does the domain resolve to a CDN-owned IP
|
cdn_ip?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/domain.rb
|
Apache-2.0
|
def message_with_url
msg = message.gsub(/\s+/, " ").squeeze(" ").strip
msg << "." unless msg.end_with?(".") # add trailing period if not there
"#{msg} #{more_info}"
end
|
Error message, with get more info URL appended
|
message_with_url
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/error.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/error.rb
|
Apache-2.0
|
def initialize(domain, nameservers: :default)
@domain = domain
@nameservers = nameservers
end
|
Create a new resolver.
domain - the domain we're getting answers for
nameserver - (optional) a case
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/resolver.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/github-pages-health-check-1.17.9/lib/github-pages-health-check/resolver.rb
|
Apache-2.0
|
def call(html, context = {}, result = nil)
context = @default_context.merge(context)
context = context.freeze
result ||= @result_class.new
payload = default_payload filters: @filters.map(&:name),
context: context, result: result
instrument 'call_pipeline.html_pipeline', payload do
result[:output] =
@filters.inject(html) do |doc, filter|
perform_filter(filter, doc, context, result)
end
end
result
end
|
Apply all filters in the pipeline to the given HTML.
html - A String containing HTML or a DocumentFragment object.
context - The context hash passed to each filter. See the Filter docs
for more info on possible values. This object MUST NOT be modified
in place by filters. Use the Result for passing state back.
result - The result Hash passed to each filter for modification. This
is where Filters store extracted information from the content.
Returns the result Hash after being filtered by this Pipeline. Contains an
:output key with the DocumentFragment or String HTML markup based on the
output of the last filter in the pipeline.
|
call
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline.rb
|
Apache-2.0
|
def perform_filter(filter, doc, context, result)
payload = default_payload filter: filter.name,
context: context, result: result
instrument 'call_filter.html_pipeline', payload do
filter.call(doc, context, result)
end
end
|
Internal: Applies a specific filter to the supplied doc.
The filter is instrumented.
Returns the result of the filter.
|
perform_filter
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline.rb
|
Apache-2.0
|
def to_document(input, context = {}, result = nil)
result = call(input, context, result)
HTML::Pipeline.parse(result[:output])
end
|
Like call but guarantee the value returned is a DocumentFragment.
Pipelines may return a DocumentFragment or a String. Callers that need a
DocumentFragment should use this method.
|
to_document
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline.rb
|
Apache-2.0
|
def to_html(input, context = {}, result = nil)
result = call(input, context, result = nil)
output = result[:output]
if output.respond_to?(:to_html)
output.to_html
else
output.to_s
end
end
|
Like call but guarantee the value returned is a string of HTML markup.
|
to_html
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline.rb
|
Apache-2.0
|
def setup_instrumentation(name = nil, service = nil)
self.instrumentation_name = name
self.instrumentation_service =
service || self.class.default_instrumentation_service
end
|
Public: setup instrumentation for this pipeline.
Returns nothing.
|
setup_instrumentation
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline.rb
|
Apache-2.0
|
def instrument(event, payload = nil)
payload ||= default_payload
return yield(payload) unless instrumentation_service
instrumentation_service.instrument event, payload do |payload|
yield payload
end
end
|
Internal: if the `instrumentation_service` object is set, instruments the
block, otherwise the block is ran without instrumentation.
Returns the result of the provided block.
|
instrument
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline.rb
|
Apache-2.0
|
def default_payload(payload = {})
{ pipeline: instrumentation_name }.merge(payload)
end
|
Internal: Default payload for instrumentation.
Accepts a Hash of additional payload data to be merged.
Returns a Hash.
|
default_payload
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline.rb
|
Apache-2.0
|
def replace_with_encoding_fix(replacement)
if replacement.respond_to?(:to_str)
replacement = document.fragment("<div>#{replacement}</div>").children.first.children
end
replace_without_encoding_fix(replacement)
end
|
Work around an issue with utf-8 encoded data being erroneously converted to
... some other shit when replacing text nodes. See 'utf-8 output 2' in
user_content_test.rb for details.
|
replace_with_encoding_fix
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline.rb
|
Apache-2.0
|
def info_url
context[:info_url] || nil
end
|
The URL to provide when someone @mentions a "mention" name, such
as @mention or @mentioned, that will give them more info on mentions.
|
info_url
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/@mention_filter.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/@mention_filter.rb
|
Apache-2.0
|
def mention_link_filter(text, _base_url = '/', info_url = nil, username_pattern = UsernamePattern)
self.class.mentioned_logins_in(text, username_pattern) do |match, login, is_mentioned|
link =
if is_mentioned
link_to_mention_info(login, info_url)
else
link_to_mentioned_user(login)
end
link ? match.sub("@#{login}", link) : match
end
end
|
Replace user @mentions in text with links to the mentioned user's
profile page.
text - String text to replace @mention usernames in.
base_url - The base URL used to construct user profile URLs.
info_url - The "more info" URL used to link to more info on @mentions.
If nil we don't link @mention or @mentioned.
username_pattern - Regular expression used to identify usernames in
text
Returns a string with @mentions replaced with links. All links have a
'user-mention' class name attached for styling.
|
mention_link_filter
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/@mention_filter.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/@mention_filter.rb
|
Apache-2.0
|
def mention_link_filter(text, _base_url = '/', team_pattern = TeamPattern)
self.class.mentioned_teams_in(text, team_pattern) do |match, org, team|
link = link_to_mentioned_team(org, team)
link ? match.sub("@#{org}/#{team}", link) : match
end
end
|
Replace @org/team mentions in text with links to the mentioned team's
page.
text - String text to replace @mention team names in.
base_url - The base URL used to construct team page URLs.
team_pattern - Regular expression used to identify teams in text
Returns a string with @team mentions replaced with links. All links have a
'team-mention' class name attached for styling.
|
mention_link_filter
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/@team_mention_filter.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/@team_mention_filter.rb
|
Apache-2.0
|
def call
doc.search('img').each do |element|
next if element['src'].nil? || element['src'].empty?
src = element['src'].strip
next if src.start_with? 'http'
base = if src.start_with? '/'
image_base_url
else
image_subpage_url
end
begin
element['src'] = URI.join(base, src).to_s
rescue Exception
next
end
end
doc
end
|
HTML Filter for replacing relative and root relative image URLs with
fully qualified URLs
This is useful if an image is root relative but should really be going
through a cdn, or if the content for the page assumes the host is known
i.e. scraped webpages and some RSS feeds.
Context options:
:image_base_url - Base URL for image host for root relative src.
:image_subpage_url - For relative src.
This filter does not write additional information to the context.
This filter would need to be run before CamoFilter.
|
call
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/absolute_source_filter.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/absolute_source_filter.rb
|
Apache-2.0
|
def image_base_url
context[:image_base_url] || raise("Missing context :image_base_url for #{self.class.name}")
end
|
Private: the base url you want to use
|
image_base_url
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/absolute_source_filter.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/absolute_source_filter.rb
|
Apache-2.0
|
def image_subpage_url
context[:image_subpage_url] || raise("Missing context :image_subpage_url for #{self.class.name}")
end
|
Private: the relative url you want to use
|
image_subpage_url
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/absolute_source_filter.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/absolute_source_filter.rb
|
Apache-2.0
|
def initialize(body, context, pipeline)
@body = body
@context = context
@pipeline = pipeline
end
|
Public: Initialize a BodyContent.
body - A String body.
context - A Hash of context options for the filters.
pipeline - A HTML::Pipeline object with one or more Filters.
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/body_content.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/body_content.rb
|
Apache-2.0
|
def result
@result ||= @pipeline.call @body, @context
end
|
Public: Gets the memoized result of the body content as it passed through
the Pipeline.
Returns a Hash, or something similar as defined by @pipeline.result_class.
|
result
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/body_content.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/body_content.rb
|
Apache-2.0
|
def output
@output ||= result[:output]
end
|
Public: Gets the updated body from the Pipeline result.
Returns a String or DocumentFragment.
|
output
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/body_content.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/body_content.rb
|
Apache-2.0
|
def document
@document ||= HTML::Pipeline.parse output
end
|
Public: Parses the output into a DocumentFragment.
Returns a DocumentFragment.
|
document
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/body_content.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/body_content.rb
|
Apache-2.0
|
def call
return doc unless asset_proxy_enabled?
doc.search('img').each do |element|
original_src = element['src']
next unless original_src
begin
uri = URI.parse(original_src)
rescue Exception
next
end
next if uri.host.nil?
next if asset_host_allowed?(uri.host)
element['src'] = asset_proxy_url(original_src)
element['data-canonical-src'] = original_src
end
doc
end
|
Hijacks images in the markup provided, replacing them with URLs that
go through the github asset proxy.
|
call
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/camo_filter.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/camo_filter.rb
|
Apache-2.0
|
def validate
needs :asset_proxy, :asset_proxy_secret_key
end
|
Implementation of validate hook.
Errors should raise exceptions or use an existing validator.
|
validate
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/camo_filter.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/camo_filter.rb
|
Apache-2.0
|
def asset_url_hash(url)
OpenSSL::HMAC.hexdigest('sha1', asset_proxy_secret_key, url)
end
|
Private: calculate the HMAC digest for a image source URL.
|
asset_url_hash
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/camo_filter.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/camo_filter.rb
|
Apache-2.0
|
def call
found_hidden = nil
paragraphs = EmailReplyParser.read(text.dup).fragments.map do |fragment|
pieces = [CGI.escapeHTML(fragment.to_s.strip).gsub(/^\s*(>|>)/, '')]
if fragment.quoted?
if context[:hide_quoted_email_addresses]
pieces.map! do |piece|
piece.gsub(EMAIL_REGEX, HIDDEN_EMAIL_PATTERN)
end
end
pieces.unshift EMAIL_QUOTED_HEADER
pieces << EMAIL_HEADER_END
elsif fragment.signature?
pieces.unshift EMAIL_SIGNATURE_HEADER
pieces << EMAIL_HEADER_END
else
pieces.unshift EMAIL_FRAGMENT_HEADER
pieces << EMAIL_HEADER_END
end
if fragment.hidden? && !found_hidden
found_hidden = true
pieces.unshift EMAIL_HIDDEN_HEADER
end
pieces.join
end
paragraphs << EMAIL_HEADER_END if found_hidden
paragraphs.join("\n")
end
|
Scans an email body to determine which bits are quoted and which should
be hidden. EmailReplyParser is used to split the comment into an Array
of quoted or unquoted Blocks. Now, we loop through them and attempt to
add <div> tags around them so we can hide the hidden blocks, and style
the quoted blocks differently. Since multiple blocks may be hidden, be
sure to keep the "email-hidden-reply" <div>s around "email-quoted-reply"
<div> tags. Call this on each comment of a visible thread in the order
that they are displayed. Note: all comments are processed so we can
maintain a Set of SHAs of paragraphs. Only plaintext comments skip the
markdown step.
Returns the email comment HTML as a String
|
call
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/email_reply_filter.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/html-pipeline-2.14.3/lib/html/pipeline/email_reply_filter.rb
|
Apache-2.0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.