repo
stringlengths 5
58
| path
stringlengths 9
168
| func_name
stringlengths 9
130
| original_string
stringlengths 66
10.5k
| language
stringclasses 1
value | code
stringlengths 66
10.5k
| code_tokens
list | docstring
stringlengths 8
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 94
266
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
ruby-x/rubyx | lib/risc/position/position_listener.rb | Risc.PositionListener.position_changed | def position_changed(previous)
add = previous.object ? previous.object.padded_length : 0
next_at = previous.at + add
next_pos = Position.get(@object)
next_pos.set(next_at)
end | ruby | def position_changed(previous)
add = previous.object ? previous.object.padded_length : 0
next_at = previous.at + add
next_pos = Position.get(@object)
next_pos.set(next_at)
end | [
"def",
"position_changed",
"(",
"previous",
")",
"add",
"=",
"previous",
".",
"object",
"?",
"previous",
".",
"object",
".",
"padded_length",
":",
"0",
"next_at",
"=",
"previous",
".",
"at",
"+",
"add",
"next_pos",
"=",
"Position",
".",
"get",
"(",
"@object",
")",
"next_pos",
".",
"set",
"(",
"next_at",
")",
"end"
]
| when the argument changes position, we update the next objects
position to reflect that change | [
"when",
"the",
"argument",
"changes",
"position",
"we",
"update",
"the",
"next",
"objects",
"position",
"to",
"reflect",
"that",
"change"
]
| 1391667f6cf16c8e132cbf85cc6a5171fb8c444e | https://github.com/ruby-x/rubyx/blob/1391667f6cf16c8e132cbf85cc6a5171fb8c444e/lib/risc/position/position_listener.rb#L25-L30 | train |
ruby-x/rubyx | lib/risc/register_value.rb | Risc.RegisterValue.resolve_and_add | def resolve_and_add(slot , compiler)
index = resolve_index( slot )
new_left = get_new_left( slot , compiler )
compiler.add_code Risc::SlotToReg.new( "SlotLoad #{type}[#{slot}]" , self ,index, new_left)
new_left
end | ruby | def resolve_and_add(slot , compiler)
index = resolve_index( slot )
new_left = get_new_left( slot , compiler )
compiler.add_code Risc::SlotToReg.new( "SlotLoad #{type}[#{slot}]" , self ,index, new_left)
new_left
end | [
"def",
"resolve_and_add",
"(",
"slot",
",",
"compiler",
")",
"index",
"=",
"resolve_index",
"(",
"slot",
")",
"new_left",
"=",
"get_new_left",
"(",
"slot",
",",
"compiler",
")",
"compiler",
".",
"add_code",
"Risc",
"::",
"SlotToReg",
".",
"new",
"(",
"\"SlotLoad #{type}[#{slot}]\"",
",",
"self",
",",
"index",
",",
"new_left",
")",
"new_left",
"end"
]
| using the registers type, resolve the slot to an index
Using the index and the register, add a SlotToReg to the instruction | [
"using",
"the",
"registers",
"type",
"resolve",
"the",
"slot",
"to",
"an",
"index",
"Using",
"the",
"index",
"and",
"the",
"register",
"add",
"a",
"SlotToReg",
"to",
"the",
"instruction"
]
| 1391667f6cf16c8e132cbf85cc6a5171fb8c444e | https://github.com/ruby-x/rubyx/blob/1391667f6cf16c8e132cbf85cc6a5171fb8c444e/lib/risc/register_value.rb#L48-L53 | train |
ruby-x/rubyx | lib/risc/register_value.rb | Risc.RegisterValue.reduce_int | def reduce_int
reduce = Risc.slot_to_reg( "int -> fix" , self , Parfait::Integer.integer_index , self)
builder.add_code(reduce) if builder
reduce
end | ruby | def reduce_int
reduce = Risc.slot_to_reg( "int -> fix" , self , Parfait::Integer.integer_index , self)
builder.add_code(reduce) if builder
reduce
end | [
"def",
"reduce_int",
"reduce",
"=",
"Risc",
".",
"slot_to_reg",
"(",
"\"int -> fix\"",
",",
"self",
",",
"Parfait",
"::",
"Integer",
".",
"integer_index",
",",
"self",
")",
"builder",
".",
"add_code",
"(",
"reduce",
")",
"if",
"builder",
"reduce",
"end"
]
| reduce integer to fixnum and add instruction if builder is used | [
"reduce",
"integer",
"to",
"fixnum",
"and",
"add",
"instruction",
"if",
"builder",
"is",
"used"
]
| 1391667f6cf16c8e132cbf85cc6a5171fb8c444e | https://github.com/ruby-x/rubyx/blob/1391667f6cf16c8e132cbf85cc6a5171fb8c444e/lib/risc/register_value.rb#L65-L69 | train |
ruby-x/rubyx | lib/risc/register_value.rb | Risc.RegisterValue.next_reg_use | def next_reg_use( type , extra = {} )
int = @symbol[1,3].to_i
raise "No more registers #{self}" if int > 11
sym = "r#{int + 1}".to_sym
RegisterValue.new( sym , type, extra)
end | ruby | def next_reg_use( type , extra = {} )
int = @symbol[1,3].to_i
raise "No more registers #{self}" if int > 11
sym = "r#{int + 1}".to_sym
RegisterValue.new( sym , type, extra)
end | [
"def",
"next_reg_use",
"(",
"type",
",",
"extra",
"=",
"{",
"}",
")",
"int",
"=",
"@symbol",
"[",
"1",
",",
"3",
"]",
".",
"to_i",
"raise",
"\"No more registers #{self}\"",
"if",
"int",
">",
"11",
"sym",
"=",
"\"r#{int + 1}\"",
".",
"to_sym",
"RegisterValue",
".",
"new",
"(",
"sym",
",",
"type",
",",
"extra",
")",
"end"
]
| helper method to calculate with register symbols | [
"helper",
"method",
"to",
"calculate",
"with",
"register",
"symbols"
]
| 1391667f6cf16c8e132cbf85cc6a5171fb8c444e | https://github.com/ruby-x/rubyx/blob/1391667f6cf16c8e132cbf85cc6a5171fb8c444e/lib/risc/register_value.rb#L118-L123 | train |
ruby-x/rubyx | lib/risc/register_value.rb | Risc.RegisterValue.op | def op( operator , right)
ret = Risc.op( "operator #{operator}" , operator , self , right)
builder.add_code(ret) if builder
ret
end | ruby | def op( operator , right)
ret = Risc.op( "operator #{operator}" , operator , self , right)
builder.add_code(ret) if builder
ret
end | [
"def",
"op",
"(",
"operator",
",",
"right",
")",
"ret",
"=",
"Risc",
".",
"op",
"(",
"\"operator #{operator}\"",
",",
"operator",
",",
"self",
",",
"right",
")",
"builder",
".",
"add_code",
"(",
"ret",
")",
"if",
"builder",
"ret",
"end"
]
| create operator instruction for self and add
doesn't read quite as smoothly as one would like, but better than the compiler version | [
"create",
"operator",
"instruction",
"for",
"self",
"and",
"add",
"doesn",
"t",
"read",
"quite",
"as",
"smoothly",
"as",
"one",
"would",
"like",
"but",
"better",
"than",
"the",
"compiler",
"version"
]
| 1391667f6cf16c8e132cbf85cc6a5171fb8c444e | https://github.com/ruby-x/rubyx/blob/1391667f6cf16c8e132cbf85cc6a5171fb8c444e/lib/risc/register_value.rb#L184-L188 | train |
ruby-x/rubyx | lib/vool/statements.rb | Vool.Statements.to_mom | def to_mom( compiler )
raise "Empty list ? #{statements.length}" if empty?
stats = @statements.dup
first = stats.shift.to_mom(compiler)
while( nekst = stats.shift )
first.append nekst.to_mom(compiler)
end
first
end | ruby | def to_mom( compiler )
raise "Empty list ? #{statements.length}" if empty?
stats = @statements.dup
first = stats.shift.to_mom(compiler)
while( nekst = stats.shift )
first.append nekst.to_mom(compiler)
end
first
end | [
"def",
"to_mom",
"(",
"compiler",
")",
"raise",
"\"Empty list ? #{statements.length}\"",
"if",
"empty?",
"stats",
"=",
"@statements",
".",
"dup",
"first",
"=",
"stats",
".",
"shift",
".",
"to_mom",
"(",
"compiler",
")",
"while",
"(",
"nekst",
"=",
"stats",
".",
"shift",
")",
"first",
".",
"append",
"nekst",
".",
"to_mom",
"(",
"compiler",
")",
"end",
"first",
"end"
]
| to_mom all the statements. Append subsequent ones to the first, and return the
first.
For ClassStatements this creates and returns a MomCompiler | [
"to_mom",
"all",
"the",
"statements",
".",
"Append",
"subsequent",
"ones",
"to",
"the",
"first",
"and",
"return",
"the",
"first",
"."
]
| 1391667f6cf16c8e132cbf85cc6a5171fb8c444e | https://github.com/ruby-x/rubyx/blob/1391667f6cf16c8e132cbf85cc6a5171fb8c444e/lib/vool/statements.rb#L39-L47 | train |
ruby-x/rubyx | lib/parfait/type.rb | Parfait.Type.init_lists | def init_lists(hash)
self.methods = nil
self.names = List.new
self.types = List.new
raise "No type Type in #{hash}" unless hash[:type]
private_add_instance_variable(:type , hash[:type]) #first
hash.each do |name , type|
private_add_instance_variable(name , type) unless name == :type
end
end | ruby | def init_lists(hash)
self.methods = nil
self.names = List.new
self.types = List.new
raise "No type Type in #{hash}" unless hash[:type]
private_add_instance_variable(:type , hash[:type]) #first
hash.each do |name , type|
private_add_instance_variable(name , type) unless name == :type
end
end | [
"def",
"init_lists",
"(",
"hash",
")",
"self",
".",
"methods",
"=",
"nil",
"self",
".",
"names",
"=",
"List",
".",
"new",
"self",
".",
"types",
"=",
"List",
".",
"new",
"raise",
"\"No type Type in #{hash}\"",
"unless",
"hash",
"[",
":type",
"]",
"private_add_instance_variable",
"(",
":type",
",",
"hash",
"[",
":type",
"]",
")",
"hash",
".",
"each",
"do",
"|",
"name",
",",
"type",
"|",
"private_add_instance_variable",
"(",
"name",
",",
"type",
")",
"unless",
"name",
"==",
":type",
"end",
"end"
]
| this part of the init is seperate because at boot time we can not use normal new
new is overloaded to grab the type from space, and before boot, that is not set up | [
"this",
"part",
"of",
"the",
"init",
"is",
"seperate",
"because",
"at",
"boot",
"time",
"we",
"can",
"not",
"use",
"normal",
"new",
"new",
"is",
"overloaded",
"to",
"grab",
"the",
"type",
"from",
"space",
"and",
"before",
"boot",
"that",
"is",
"not",
"set",
"up"
]
| 1391667f6cf16c8e132cbf85cc6a5171fb8c444e | https://github.com/ruby-x/rubyx/blob/1391667f6cf16c8e132cbf85cc6a5171fb8c444e/lib/parfait/type.rb#L59-L68 | train |
ruby-x/rubyx | lib/parfait/type.rb | Parfait.Type.add_instance_variable | def add_instance_variable( name , type )
raise "No nil name" unless name
raise "No nil type" unless type
hash = to_hash
hash[name] = type
return Type.for_hash( object_class , hash)
end | ruby | def add_instance_variable( name , type )
raise "No nil name" unless name
raise "No nil type" unless type
hash = to_hash
hash[name] = type
return Type.for_hash( object_class , hash)
end | [
"def",
"add_instance_variable",
"(",
"name",
",",
"type",
")",
"raise",
"\"No nil name\"",
"unless",
"name",
"raise",
"\"No nil type\"",
"unless",
"type",
"hash",
"=",
"to_hash",
"hash",
"[",
"name",
"]",
"=",
"type",
"return",
"Type",
".",
"for_hash",
"(",
"object_class",
",",
"hash",
")",
"end"
]
| add the name of an instance variable
Type objects are immutable, so a new object is returned
As types are also unique, two same adds will result in identical results | [
"add",
"the",
"name",
"of",
"an",
"instance",
"variable",
"Type",
"objects",
"are",
"immutable",
"so",
"a",
"new",
"object",
"is",
"returned",
"As",
"types",
"are",
"also",
"unique",
"two",
"same",
"adds",
"will",
"result",
"in",
"identical",
"results"
]
| 1391667f6cf16c8e132cbf85cc6a5171fb8c444e | https://github.com/ruby-x/rubyx/blob/1391667f6cf16c8e132cbf85cc6a5171fb8c444e/lib/parfait/type.rb#L183-L189 | train |
ruby-x/rubyx | lib/arm/instructions/logic_instruction.rb | Arm.LogicInstruction.determine_operands | def determine_operands
if( @left.is_a?(Parfait::Object) or @left.is_a?(Risc::Label) or
(@left.is_a?(Symbol) and !Risc::RegisterValue.look_like_reg(@left)))
left = @left
left = left.address if left.is_a?(Risc::Label)
# do pc relative addressing with the difference to the instuction
# 8 is for the funny pipeline adjustment (ie pointing to fetch and not execute)
right = Risc::Position.get(left) - 8
right -= Risc::Position.get(self).at
if( (right < 0) && ((opcode == :add) || (opcode == :sub)) )
right *= -1 # this works as we never issue sub only add
set_opcode :sub # so (as we can't change the sign permanently) we can change the opcode
end # and the sign even for sub (beucase we created them)
raise "No negatives implemented #{self} #{right} " if right < 0
return :pc , right
else
return @left , @right
end
end | ruby | def determine_operands
if( @left.is_a?(Parfait::Object) or @left.is_a?(Risc::Label) or
(@left.is_a?(Symbol) and !Risc::RegisterValue.look_like_reg(@left)))
left = @left
left = left.address if left.is_a?(Risc::Label)
# do pc relative addressing with the difference to the instuction
# 8 is for the funny pipeline adjustment (ie pointing to fetch and not execute)
right = Risc::Position.get(left) - 8
right -= Risc::Position.get(self).at
if( (right < 0) && ((opcode == :add) || (opcode == :sub)) )
right *= -1 # this works as we never issue sub only add
set_opcode :sub # so (as we can't change the sign permanently) we can change the opcode
end # and the sign even for sub (beucase we created them)
raise "No negatives implemented #{self} #{right} " if right < 0
return :pc , right
else
return @left , @right
end
end | [
"def",
"determine_operands",
"if",
"(",
"@left",
".",
"is_a?",
"(",
"Parfait",
"::",
"Object",
")",
"or",
"@left",
".",
"is_a?",
"(",
"Risc",
"::",
"Label",
")",
"or",
"(",
"@left",
".",
"is_a?",
"(",
"Symbol",
")",
"and",
"!",
"Risc",
"::",
"RegisterValue",
".",
"look_like_reg",
"(",
"@left",
")",
")",
")",
"left",
"=",
"@left",
"left",
"=",
"left",
".",
"address",
"if",
"left",
".",
"is_a?",
"(",
"Risc",
"::",
"Label",
")",
"right",
"=",
"Risc",
"::",
"Position",
".",
"get",
"(",
"left",
")",
"-",
"8",
"right",
"-=",
"Risc",
"::",
"Position",
".",
"get",
"(",
"self",
")",
".",
"at",
"if",
"(",
"(",
"right",
"<",
"0",
")",
"&&",
"(",
"(",
"opcode",
"==",
":add",
")",
"||",
"(",
"opcode",
"==",
":sub",
")",
")",
")",
"right",
"*=",
"-",
"1",
"set_opcode",
":sub",
"end",
"raise",
"\"No negatives implemented #{self} #{right} \"",
"if",
"right",
"<",
"0",
"return",
":pc",
",",
"right",
"else",
"return",
"@left",
",",
"@right",
"end",
"end"
]
| don't overwrite instance variables, to make assembly repeatable
this also loads constants, which are issued as pc relative adds | [
"don",
"t",
"overwrite",
"instance",
"variables",
"to",
"make",
"assembly",
"repeatable",
"this",
"also",
"loads",
"constants",
"which",
"are",
"issued",
"as",
"pc",
"relative",
"adds"
]
| 1391667f6cf16c8e132cbf85cc6a5171fb8c444e | https://github.com/ruby-x/rubyx/blob/1391667f6cf16c8e132cbf85cc6a5171fb8c444e/lib/arm/instructions/logic_instruction.rb#L94-L112 | train |
feedreader/pluto | pluto-merge/lib/pluto/merge/manifest_helpers.rb | Pluto.ManifestHelper.installed_template_manifest_patterns | def installed_template_manifest_patterns
# 1) search . # that is, working/current dir
# 2) search <config_dir>
# 3) search <gem>/templates
###
# Note
# -- for now - no longer ship w/ builtin template packs
# - download on demand if needed
builtin_patterns = [
## "#{Pluto.root}/templates/*.txt"
]
config_patterns = [
## "#{File.expand_path(opts.config_path)}/*.txt",
"#{File.expand_path(opts.config_path)}/*/*.txt"
]
current_patterns = [
## "*.txt",
"*/*.txt",
"node_modules/*/*.txt", # note: add support for npm installs - use/make slideshow required in name? for namespace in the future???
]
patterns = []
patterns += current_patterns
patterns += config_patterns
patterns += builtin_patterns
end | ruby | def installed_template_manifest_patterns
# 1) search . # that is, working/current dir
# 2) search <config_dir>
# 3) search <gem>/templates
###
# Note
# -- for now - no longer ship w/ builtin template packs
# - download on demand if needed
builtin_patterns = [
## "#{Pluto.root}/templates/*.txt"
]
config_patterns = [
## "#{File.expand_path(opts.config_path)}/*.txt",
"#{File.expand_path(opts.config_path)}/*/*.txt"
]
current_patterns = [
## "*.txt",
"*/*.txt",
"node_modules/*/*.txt", # note: add support for npm installs - use/make slideshow required in name? for namespace in the future???
]
patterns = []
patterns += current_patterns
patterns += config_patterns
patterns += builtin_patterns
end | [
"def",
"installed_template_manifest_patterns",
"builtin_patterns",
"=",
"[",
"]",
"config_patterns",
"=",
"[",
"\"#{File.expand_path(opts.config_path)}/*/*.txt\"",
"]",
"current_patterns",
"=",
"[",
"\"*/*.txt\"",
",",
"\"node_modules/*/*.txt\"",
",",
"]",
"patterns",
"=",
"[",
"]",
"patterns",
"+=",
"current_patterns",
"patterns",
"+=",
"config_patterns",
"patterns",
"+=",
"builtin_patterns",
"end"
]
| shared methods for handling manifest lookups
note: required attribs (in host class) include:
- opts.config_path | [
"shared",
"methods",
"for",
"handling",
"manifest",
"lookups"
]
| d2e304441f8df42e2e1c296476f2a40c56a6f316 | https://github.com/feedreader/pluto/blob/d2e304441f8df42e2e1c296476f2a40c56a6f316/pluto-merge/lib/pluto/merge/manifest_helpers.rb#L17-L45 | train |
ruby-x/rubyx | lib/risc/text_writer.rb | Risc.TextWriter.write_as_string | def write_as_string
@stream = StringIO.new
write_init(@linker.cpu_init)
write_debug
write_objects
write_code
log.debug "Assembled 0x#{stream_position.to_s(16)} bytes"
return @stream.string
end | ruby | def write_as_string
@stream = StringIO.new
write_init(@linker.cpu_init)
write_debug
write_objects
write_code
log.debug "Assembled 0x#{stream_position.to_s(16)} bytes"
return @stream.string
end | [
"def",
"write_as_string",
"@stream",
"=",
"StringIO",
".",
"new",
"write_init",
"(",
"@linker",
".",
"cpu_init",
")",
"write_debug",
"write_objects",
"write_code",
"log",
".",
"debug",
"\"Assembled 0x#{stream_position.to_s(16)} bytes\"",
"return",
"@stream",
".",
"string",
"end"
]
| objects must be written in same order as positioned by the linker, namely
- intial jump
- all objects
- all BinaryCode | [
"objects",
"must",
"be",
"written",
"in",
"same",
"order",
"as",
"positioned",
"by",
"the",
"linker",
"namely",
"-",
"intial",
"jump",
"-",
"all",
"objects",
"-",
"all",
"BinaryCode"
]
| 1391667f6cf16c8e132cbf85cc6a5171fb8c444e | https://github.com/ruby-x/rubyx/blob/1391667f6cf16c8e132cbf85cc6a5171fb8c444e/lib/risc/text_writer.rb#L28-L36 | train |
ruby-x/rubyx | lib/risc/text_writer.rb | Risc.TextWriter.write_code | def write_code
@linker.assemblers.each do |asm|
asm.callable.each_binary do |code|
write_any(code)
end
end
end | ruby | def write_code
@linker.assemblers.each do |asm|
asm.callable.each_binary do |code|
write_any(code)
end
end
end | [
"def",
"write_code",
"@linker",
".",
"assemblers",
".",
"each",
"do",
"|",
"asm",
"|",
"asm",
".",
"callable",
".",
"each_binary",
"do",
"|",
"code",
"|",
"write_any",
"(",
"code",
")",
"end",
"end",
"end"
]
| Write the BinaryCode objects of all methods to stream.
Really like any other object, it's just about the ordering | [
"Write",
"the",
"BinaryCode",
"objects",
"of",
"all",
"methods",
"to",
"stream",
".",
"Really",
"like",
"any",
"other",
"object",
"it",
"s",
"just",
"about",
"the",
"ordering"
]
| 1391667f6cf16c8e132cbf85cc6a5171fb8c444e | https://github.com/ruby-x/rubyx/blob/1391667f6cf16c8e132cbf85cc6a5171fb8c444e/lib/risc/text_writer.rb#L61-L67 | train |
ruby-x/rubyx | lib/risc/text_writer.rb | Risc.TextWriter.write_any | def write_any( obj )
write_any_log( obj , "Write")
if stream_position != Position.get(obj).at
raise "Write #{obj.class}:0x#{obj.object_id.to_s(16)} at 0x#{stream_position.to_s(16)} not #{Position.get(obj)}"
end
write_any_out(obj)
write_any_log( obj , "Wrote")
Position.get(obj)
end | ruby | def write_any( obj )
write_any_log( obj , "Write")
if stream_position != Position.get(obj).at
raise "Write #{obj.class}:0x#{obj.object_id.to_s(16)} at 0x#{stream_position.to_s(16)} not #{Position.get(obj)}"
end
write_any_out(obj)
write_any_log( obj , "Wrote")
Position.get(obj)
end | [
"def",
"write_any",
"(",
"obj",
")",
"write_any_log",
"(",
"obj",
",",
"\"Write\"",
")",
"if",
"stream_position",
"!=",
"Position",
".",
"get",
"(",
"obj",
")",
".",
"at",
"raise",
"\"Write #{obj.class}:0x#{obj.object_id.to_s(16)} at 0x#{stream_position.to_s(16)} not #{Position.get(obj)}\"",
"end",
"write_any_out",
"(",
"obj",
")",
"write_any_log",
"(",
"obj",
",",
"\"Wrote\"",
")",
"Position",
".",
"get",
"(",
"obj",
")",
"end"
]
| Write any object just logs a bit and passes to write_any_out | [
"Write",
"any",
"object",
"just",
"logs",
"a",
"bit",
"and",
"passes",
"to",
"write_any_out"
]
| 1391667f6cf16c8e132cbf85cc6a5171fb8c444e | https://github.com/ruby-x/rubyx/blob/1391667f6cf16c8e132cbf85cc6a5171fb8c444e/lib/risc/text_writer.rb#L70-L78 | train |
ruby-x/rubyx | lib/risc/text_writer.rb | Risc.TextWriter.write_object | def write_object( object )
obj_written = write_object_variables(object)
log.debug "instances=#{object.get_instance_variables.inspect} mem_len=0x#{object.padded_length.to_s(16)}"
indexed_written = write_object_indexed(object)
log.debug "type #{obj_written} , total #{obj_written + indexed_written} (array #{indexed_written})"
log.debug "Len = 0x#{object.get_length.to_s(16)} , inst =0x#{object.get_type.instance_length.to_s(16)}" if object.is_a? Parfait::Type
pad_after( obj_written + indexed_written )
Position.get(object)
end | ruby | def write_object( object )
obj_written = write_object_variables(object)
log.debug "instances=#{object.get_instance_variables.inspect} mem_len=0x#{object.padded_length.to_s(16)}"
indexed_written = write_object_indexed(object)
log.debug "type #{obj_written} , total #{obj_written + indexed_written} (array #{indexed_written})"
log.debug "Len = 0x#{object.get_length.to_s(16)} , inst =0x#{object.get_type.instance_length.to_s(16)}" if object.is_a? Parfait::Type
pad_after( obj_written + indexed_written )
Position.get(object)
end | [
"def",
"write_object",
"(",
"object",
")",
"obj_written",
"=",
"write_object_variables",
"(",
"object",
")",
"log",
".",
"debug",
"\"instances=#{object.get_instance_variables.inspect} mem_len=0x#{object.padded_length.to_s(16)}\"",
"indexed_written",
"=",
"write_object_indexed",
"(",
"object",
")",
"log",
".",
"debug",
"\"type #{obj_written} , total #{obj_written + indexed_written} (array #{indexed_written})\"",
"log",
".",
"debug",
"\"Len = 0x#{object.get_length.to_s(16)} , inst =0x#{object.get_type.instance_length.to_s(16)}\"",
"if",
"object",
".",
"is_a?",
"Parfait",
"::",
"Type",
"pad_after",
"(",
"obj_written",
"+",
"indexed_written",
")",
"Position",
".",
"get",
"(",
"object",
")",
"end"
]
| write type of the instance, and the variables that are passed
variables ar values, ie int or refs. For refs the object needs to save the object first | [
"write",
"type",
"of",
"the",
"instance",
"and",
"the",
"variables",
"that",
"are",
"passed",
"variables",
"ar",
"values",
"ie",
"int",
"or",
"refs",
".",
"For",
"refs",
"the",
"object",
"needs",
"to",
"save",
"the",
"object",
"first"
]
| 1391667f6cf16c8e132cbf85cc6a5171fb8c444e | https://github.com/ruby-x/rubyx/blob/1391667f6cf16c8e132cbf85cc6a5171fb8c444e/lib/risc/text_writer.rb#L105-L113 | train |
ruby-x/rubyx | lib/risc/text_writer.rb | Risc.TextWriter.write_ref_for | def write_ref_for object
case object
when nil
@stream.write_signed_int_32(0)
when ::Integer
@stream.write_signed_int_32(object)
else
@stream.write_signed_int_32(Position.get(object) + @linker.platform.loaded_at)
end
end | ruby | def write_ref_for object
case object
when nil
@stream.write_signed_int_32(0)
when ::Integer
@stream.write_signed_int_32(object)
else
@stream.write_signed_int_32(Position.get(object) + @linker.platform.loaded_at)
end
end | [
"def",
"write_ref_for",
"object",
"case",
"object",
"when",
"nil",
"@stream",
".",
"write_signed_int_32",
"(",
"0",
")",
"when",
"::",
"Integer",
"@stream",
".",
"write_signed_int_32",
"(",
"object",
")",
"else",
"@stream",
".",
"write_signed_int_32",
"(",
"Position",
".",
"get",
"(",
"object",
")",
"+",
"@linker",
".",
"platform",
".",
"loaded_at",
")",
"end",
"end"
]
| write means we write the resulting address straight into the assembler stream
object means the object of which we write the address | [
"write",
"means",
"we",
"write",
"the",
"resulting",
"address",
"straight",
"into",
"the",
"assembler",
"stream",
"object",
"means",
"the",
"object",
"of",
"which",
"we",
"write",
"the",
"address"
]
| 1391667f6cf16c8e132cbf85cc6a5171fb8c444e | https://github.com/ruby-x/rubyx/blob/1391667f6cf16c8e132cbf85cc6a5171fb8c444e/lib/risc/text_writer.rb#L205-L214 | train |
ruby-x/rubyx | lib/parfait/list.rb | Parfait.List.index_of | def index_of( item )
max = self.get_length
#puts "length #{max} #{max.class}"
counter = 0
while( counter < max )
if( get(counter) == item)
return counter
end
counter = counter + 1
end
return nil
end | ruby | def index_of( item )
max = self.get_length
#puts "length #{max} #{max.class}"
counter = 0
while( counter < max )
if( get(counter) == item)
return counter
end
counter = counter + 1
end
return nil
end | [
"def",
"index_of",
"(",
"item",
")",
"max",
"=",
"self",
".",
"get_length",
"counter",
"=",
"0",
"while",
"(",
"counter",
"<",
"max",
")",
"if",
"(",
"get",
"(",
"counter",
")",
"==",
"item",
")",
"return",
"counter",
"end",
"counter",
"=",
"counter",
"+",
"1",
"end",
"return",
"nil",
"end"
]
| index of item
return nil if no such item | [
"index",
"of",
"item",
"return",
"nil",
"if",
"no",
"such",
"item"
]
| 1391667f6cf16c8e132cbf85cc6a5171fb8c444e | https://github.com/ruby-x/rubyx/blob/1391667f6cf16c8e132cbf85cc6a5171fb8c444e/lib/parfait/list.rb#L94-L105 | train |
ruby-x/rubyx | lib/parfait/list.rb | Parfait.List.next_value | def next_value(val)
index = index_of(val)
return nil unless index
return nil if index == (get_length - 1)
return get(index + 1)
end | ruby | def next_value(val)
index = index_of(val)
return nil unless index
return nil if index == (get_length - 1)
return get(index + 1)
end | [
"def",
"next_value",
"(",
"val",
")",
"index",
"=",
"index_of",
"(",
"val",
")",
"return",
"nil",
"unless",
"index",
"return",
"nil",
"if",
"index",
"==",
"(",
"get_length",
"-",
"1",
")",
"return",
"get",
"(",
"index",
"+",
"1",
")",
"end"
]
| return the next of given. Nil if item not in list or there is not next | [
"return",
"the",
"next",
"of",
"given",
".",
"Nil",
"if",
"item",
"not",
"in",
"list",
"or",
"there",
"is",
"not",
"next"
]
| 1391667f6cf16c8e132cbf85cc6a5171fb8c444e | https://github.com/ruby-x/rubyx/blob/1391667f6cf16c8e132cbf85cc6a5171fb8c444e/lib/parfait/list.rb#L108-L113 | train |
RISCfuture/dropbox | lib/dropbox/api.rb | Dropbox.API.download | def download(path, options={})
path = path.sub(/^\//, '')
rest = Dropbox.check_path(path).split('/')
rest << { :ssl => @ssl }
api_body :get, 'files', root(options), *rest
#TODO streaming, range queries
end | ruby | def download(path, options={})
path = path.sub(/^\//, '')
rest = Dropbox.check_path(path).split('/')
rest << { :ssl => @ssl }
api_body :get, 'files', root(options), *rest
#TODO streaming, range queries
end | [
"def",
"download",
"(",
"path",
",",
"options",
"=",
"{",
"}",
")",
"path",
"=",
"path",
".",
"sub",
"(",
"/",
"\\/",
"/",
",",
"''",
")",
"rest",
"=",
"Dropbox",
".",
"check_path",
"(",
"path",
")",
".",
"split",
"(",
"'/'",
")",
"rest",
"<<",
"{",
":ssl",
"=>",
"@ssl",
"}",
"api_body",
":get",
",",
"'files'",
",",
"root",
"(",
"options",
")",
",",
"*",
"rest",
"end"
]
| Downloads the file at the given path relative to the configured mode's
root.
Returns the contents of the downloaded file as a +String+. Support for
streaming downloads and range queries is available server-side, but not
available in this API client due to limitations of the OAuth gem.
Options:
+mode+:: Temporarily changes the API mode. See the MODES array. | [
"Downloads",
"the",
"file",
"at",
"the",
"given",
"path",
"relative",
"to",
"the",
"configured",
"mode",
"s",
"root",
"."
]
| 702c0f99a25bb319b4a191f3dac2dbbd60427f9d | https://github.com/RISCfuture/dropbox/blob/702c0f99a25bb319b4a191f3dac2dbbd60427f9d/lib/dropbox/api.rb#L84-L90 | train |
RISCfuture/dropbox | lib/dropbox/api.rb | Dropbox.API.delete | def delete(path, options={})
path = path.sub(/^\//, '')
path.sub! /\/$/, ''
begin
api_response(:post, 'fileops', 'delete', :path => Dropbox.check_path(path), :root => root(options), :ssl => @ssl)
rescue UnsuccessfulResponseError => error
raise FileNotFoundError.new(path) if error.response.kind_of?(Net::HTTPNotFound)
raise error
end
return true
end | ruby | def delete(path, options={})
path = path.sub(/^\//, '')
path.sub! /\/$/, ''
begin
api_response(:post, 'fileops', 'delete', :path => Dropbox.check_path(path), :root => root(options), :ssl => @ssl)
rescue UnsuccessfulResponseError => error
raise FileNotFoundError.new(path) if error.response.kind_of?(Net::HTTPNotFound)
raise error
end
return true
end | [
"def",
"delete",
"(",
"path",
",",
"options",
"=",
"{",
"}",
")",
"path",
"=",
"path",
".",
"sub",
"(",
"/",
"\\/",
"/",
",",
"''",
")",
"path",
".",
"sub!",
"/",
"\\/",
"/",
",",
"''",
"begin",
"api_response",
"(",
":post",
",",
"'fileops'",
",",
"'delete'",
",",
":path",
"=>",
"Dropbox",
".",
"check_path",
"(",
"path",
")",
",",
":root",
"=>",
"root",
"(",
"options",
")",
",",
":ssl",
"=>",
"@ssl",
")",
"rescue",
"UnsuccessfulResponseError",
"=>",
"error",
"raise",
"FileNotFoundError",
".",
"new",
"(",
"path",
")",
"if",
"error",
".",
"response",
".",
"kind_of?",
"(",
"Net",
"::",
"HTTPNotFound",
")",
"raise",
"error",
"end",
"return",
"true",
"end"
]
| Deletes a file or folder at the given path. The path is assumed to be
relative to the configured mode's root.
Raises FileNotFoundError if the file or folder does not exist at +path+.
Options:
+mode+:: Temporarily changes the API mode. See the MODES array.
TODO The API documentation says this method returns 404 if the path does not exist, but it actually returns 5xx. | [
"Deletes",
"a",
"file",
"or",
"folder",
"at",
"the",
"given",
"path",
".",
"The",
"path",
"is",
"assumed",
"to",
"be",
"relative",
"to",
"the",
"configured",
"mode",
"s",
"root",
"."
]
| 702c0f99a25bb319b4a191f3dac2dbbd60427f9d | https://github.com/RISCfuture/dropbox/blob/702c0f99a25bb319b4a191f3dac2dbbd60427f9d/lib/dropbox/api.rb#L288-L298 | train |
RISCfuture/dropbox | lib/dropbox/api.rb | Dropbox.API.rename | def rename(path, new_name, options={})
raise ArgumentError, "Names cannot have slashes in them" if new_name.include?('/')
path = path.sub(/\/$/, '')
destination = path.split('/')
destination[destination.size - 1] = new_name
destination = destination.join('/')
move path, destination, options
end | ruby | def rename(path, new_name, options={})
raise ArgumentError, "Names cannot have slashes in them" if new_name.include?('/')
path = path.sub(/\/$/, '')
destination = path.split('/')
destination[destination.size - 1] = new_name
destination = destination.join('/')
move path, destination, options
end | [
"def",
"rename",
"(",
"path",
",",
"new_name",
",",
"options",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"\"Names cannot have slashes in them\"",
"if",
"new_name",
".",
"include?",
"(",
"'/'",
")",
"path",
"=",
"path",
".",
"sub",
"(",
"/",
"\\/",
"/",
",",
"''",
")",
"destination",
"=",
"path",
".",
"split",
"(",
"'/'",
")",
"destination",
"[",
"destination",
".",
"size",
"-",
"1",
"]",
"=",
"new_name",
"destination",
"=",
"destination",
".",
"join",
"(",
"'/'",
")",
"move",
"path",
",",
"destination",
",",
"options",
"end"
]
| Renames a file. Takes the same options and raises the same exceptions as
the move method.
Calling
session.rename 'path/to/file', 'new_name'
is equivalent to calling
session.move 'path/to/file', 'path/to/new_name' | [
"Renames",
"a",
"file",
".",
"Takes",
"the",
"same",
"options",
"and",
"raises",
"the",
"same",
"exceptions",
"as",
"the",
"move",
"method",
"."
]
| 702c0f99a25bb319b4a191f3dac2dbbd60427f9d | https://github.com/RISCfuture/dropbox/blob/702c0f99a25bb319b4a191f3dac2dbbd60427f9d/lib/dropbox/api.rb#L343-L350 | train |
RISCfuture/dropbox | lib/dropbox/api.rb | Dropbox.API.link | def link(path, options={})
path = path.sub(/^\//, '')
begin
rest = Dropbox.check_path(path).split('/')
rest << { :ssl => @ssl }
api_response(:get, 'links', root(options), *rest)
rescue UnsuccessfulResponseError => error
return error.response['Location'] if error.response.kind_of?(Net::HTTPFound)
#TODO shouldn't be using rescue blocks for normal program flow
raise error
end
end | ruby | def link(path, options={})
path = path.sub(/^\//, '')
begin
rest = Dropbox.check_path(path).split('/')
rest << { :ssl => @ssl }
api_response(:get, 'links', root(options), *rest)
rescue UnsuccessfulResponseError => error
return error.response['Location'] if error.response.kind_of?(Net::HTTPFound)
#TODO shouldn't be using rescue blocks for normal program flow
raise error
end
end | [
"def",
"link",
"(",
"path",
",",
"options",
"=",
"{",
"}",
")",
"path",
"=",
"path",
".",
"sub",
"(",
"/",
"\\/",
"/",
",",
"''",
")",
"begin",
"rest",
"=",
"Dropbox",
".",
"check_path",
"(",
"path",
")",
".",
"split",
"(",
"'/'",
")",
"rest",
"<<",
"{",
":ssl",
"=>",
"@ssl",
"}",
"api_response",
"(",
":get",
",",
"'links'",
",",
"root",
"(",
"options",
")",
",",
"*",
"rest",
")",
"rescue",
"UnsuccessfulResponseError",
"=>",
"error",
"return",
"error",
".",
"response",
"[",
"'Location'",
"]",
"if",
"error",
".",
"response",
".",
"kind_of?",
"(",
"Net",
"::",
"HTTPFound",
")",
"raise",
"error",
"end",
"end"
]
| Returns a cookie-protected URL that the authorized user can use to view
the file at the given path. This URL requires an authorized user.
The path is assumed to be relative to the configured mode's root.
Options:
+mode+:: Temporarily changes the API mode. See the MODES array. | [
"Returns",
"a",
"cookie",
"-",
"protected",
"URL",
"that",
"the",
"authorized",
"user",
"can",
"use",
"to",
"view",
"the",
"file",
"at",
"the",
"given",
"path",
".",
"This",
"URL",
"requires",
"an",
"authorized",
"user",
"."
]
| 702c0f99a25bb319b4a191f3dac2dbbd60427f9d | https://github.com/RISCfuture/dropbox/blob/702c0f99a25bb319b4a191f3dac2dbbd60427f9d/lib/dropbox/api.rb#L361-L372 | train |
RISCfuture/dropbox | lib/dropbox/api.rb | Dropbox.API.shares | def shares(path, options={})
path = path.sub(/^\//, '')
rest = Dropbox.check_path(path).split('/')
begin
return JSON.parse( api_response(:post, 'shares', root(options), *rest).body ).symbolize_keys_recursively
rescue UnsuccessfulResponseError => error
return error.response['Location'] if error.response.kind_of?(Net::HTTPFound)
#TODO shouldn't be using rescue blocks for normal program flow
raise error
end
end | ruby | def shares(path, options={})
path = path.sub(/^\//, '')
rest = Dropbox.check_path(path).split('/')
begin
return JSON.parse( api_response(:post, 'shares', root(options), *rest).body ).symbolize_keys_recursively
rescue UnsuccessfulResponseError => error
return error.response['Location'] if error.response.kind_of?(Net::HTTPFound)
#TODO shouldn't be using rescue blocks for normal program flow
raise error
end
end | [
"def",
"shares",
"(",
"path",
",",
"options",
"=",
"{",
"}",
")",
"path",
"=",
"path",
".",
"sub",
"(",
"/",
"\\/",
"/",
",",
"''",
")",
"rest",
"=",
"Dropbox",
".",
"check_path",
"(",
"path",
")",
".",
"split",
"(",
"'/'",
")",
"begin",
"return",
"JSON",
".",
"parse",
"(",
"api_response",
"(",
":post",
",",
"'shares'",
",",
"root",
"(",
"options",
")",
",",
"*",
"rest",
")",
".",
"body",
")",
".",
"symbolize_keys_recursively",
"rescue",
"UnsuccessfulResponseError",
"=>",
"error",
"return",
"error",
".",
"response",
"[",
"'Location'",
"]",
"if",
"error",
".",
"response",
".",
"kind_of?",
"(",
"Net",
"::",
"HTTPFound",
")",
"raise",
"error",
"end",
"end"
]
| Creates and returns a shareable link to files or folders.
The path is assumed to be relative to the configured mode's root.
Options:
+mode+:: Temporarily changes the API mode. See the MODES array. | [
"Creates",
"and",
"returns",
"a",
"shareable",
"link",
"to",
"files",
"or",
"folders",
"."
]
| 702c0f99a25bb319b4a191f3dac2dbbd60427f9d | https://github.com/RISCfuture/dropbox/blob/702c0f99a25bb319b4a191f3dac2dbbd60427f9d/lib/dropbox/api.rb#L383-L394 | train |
RISCfuture/dropbox | lib/dropbox/api.rb | Dropbox.API.metadata | def metadata(path, options={})
path = path.sub(/^\//, '')
args = [
'metadata',
root(options)
]
args += Dropbox.check_path(path).split('/')
args << Hash.new
args.last[:file_limit] = options[:limit] if options[:limit]
args.last[:hash] = options[:prior_response].hash if options[:prior_response] and options[:prior_response].hash
args.last[:list] = !(options[:suppress_list].to_bool)
args.last[:ssl] = @ssl
begin
parse_metadata(get(*args)).to_struct_recursively
rescue UnsuccessfulResponseError => error
raise TooManyEntriesError.new(path) if error.response.kind_of?(Net::HTTPNotAcceptable)
raise FileNotFoundError.new(path) if error.response.kind_of?(Net::HTTPNotFound)
return options[:prior_response] if error.response.kind_of?(Net::HTTPNotModified)
raise error
end
end | ruby | def metadata(path, options={})
path = path.sub(/^\//, '')
args = [
'metadata',
root(options)
]
args += Dropbox.check_path(path).split('/')
args << Hash.new
args.last[:file_limit] = options[:limit] if options[:limit]
args.last[:hash] = options[:prior_response].hash if options[:prior_response] and options[:prior_response].hash
args.last[:list] = !(options[:suppress_list].to_bool)
args.last[:ssl] = @ssl
begin
parse_metadata(get(*args)).to_struct_recursively
rescue UnsuccessfulResponseError => error
raise TooManyEntriesError.new(path) if error.response.kind_of?(Net::HTTPNotAcceptable)
raise FileNotFoundError.new(path) if error.response.kind_of?(Net::HTTPNotFound)
return options[:prior_response] if error.response.kind_of?(Net::HTTPNotModified)
raise error
end
end | [
"def",
"metadata",
"(",
"path",
",",
"options",
"=",
"{",
"}",
")",
"path",
"=",
"path",
".",
"sub",
"(",
"/",
"\\/",
"/",
",",
"''",
")",
"args",
"=",
"[",
"'metadata'",
",",
"root",
"(",
"options",
")",
"]",
"args",
"+=",
"Dropbox",
".",
"check_path",
"(",
"path",
")",
".",
"split",
"(",
"'/'",
")",
"args",
"<<",
"Hash",
".",
"new",
"args",
".",
"last",
"[",
":file_limit",
"]",
"=",
"options",
"[",
":limit",
"]",
"if",
"options",
"[",
":limit",
"]",
"args",
".",
"last",
"[",
":hash",
"]",
"=",
"options",
"[",
":prior_response",
"]",
".",
"hash",
"if",
"options",
"[",
":prior_response",
"]",
"and",
"options",
"[",
":prior_response",
"]",
".",
"hash",
"args",
".",
"last",
"[",
":list",
"]",
"=",
"!",
"(",
"options",
"[",
":suppress_list",
"]",
".",
"to_bool",
")",
"args",
".",
"last",
"[",
":ssl",
"]",
"=",
"@ssl",
"begin",
"parse_metadata",
"(",
"get",
"(",
"*",
"args",
")",
")",
".",
"to_struct_recursively",
"rescue",
"UnsuccessfulResponseError",
"=>",
"error",
"raise",
"TooManyEntriesError",
".",
"new",
"(",
"path",
")",
"if",
"error",
".",
"response",
".",
"kind_of?",
"(",
"Net",
"::",
"HTTPNotAcceptable",
")",
"raise",
"FileNotFoundError",
".",
"new",
"(",
"path",
")",
"if",
"error",
".",
"response",
".",
"kind_of?",
"(",
"Net",
"::",
"HTTPNotFound",
")",
"return",
"options",
"[",
":prior_response",
"]",
"if",
"error",
".",
"response",
".",
"kind_of?",
"(",
"Net",
"::",
"HTTPNotModified",
")",
"raise",
"error",
"end",
"end"
]
| Returns a +Struct+ containing metadata on a given file or folder. The path
is assumed to be relative to the configured mode's root.
If you pass a directory for +path+, the metadata will also contain a
listing of the directory contents (unless the +suppress_list+ option is
true).
For information on the schema of the return struct, see the Dropbox API
at https://www.dropbox.com/developers/docs#metadata
The +modified+ key will be converted into a +Time+ instance. The +is_dir+
key will also be available as <tt>directory?</tt>.
Options:
+suppress_list+:: Set this to true to remove the directory list from
the result (only applicable if +path+ is a directory).
+limit+:: Set this value to limit the number of entries returned when
listing a directory. If the result has more than this number of
entries, a TooManyEntriesError will be raised.
+prior_response+:: The response from a prior call to metadata for the same
path. If the metadata has not changed since the prior
call, the entire metadata will not be re-downloaded.
Operation is undefined if the given value was for a
call to metadata with a different path.
+mode+:: Temporarily changes the API mode. See the MODES array. | [
"Returns",
"a",
"+",
"Struct",
"+",
"containing",
"metadata",
"on",
"a",
"given",
"file",
"or",
"folder",
".",
"The",
"path",
"is",
"assumed",
"to",
"be",
"relative",
"to",
"the",
"configured",
"mode",
"s",
"root",
"."
]
| 702c0f99a25bb319b4a191f3dac2dbbd60427f9d | https://github.com/RISCfuture/dropbox/blob/702c0f99a25bb319b4a191f3dac2dbbd60427f9d/lib/dropbox/api.rb#L424-L445 | train |
ruby-x/rubyx | lib/risc/position/instruction_listener.rb | Risc.InstructionListener.position_changed | def position_changed(position)
instruction = position.object
return unless instruction.is_a?(Label)
instruction.address.set_value(position.at)
end | ruby | def position_changed(position)
instruction = position.object
return unless instruction.is_a?(Label)
instruction.address.set_value(position.at)
end | [
"def",
"position_changed",
"(",
"position",
")",
"instruction",
"=",
"position",
".",
"object",
"return",
"unless",
"instruction",
".",
"is_a?",
"(",
"Label",
")",
"instruction",
".",
"address",
".",
"set_value",
"(",
"position",
".",
"at",
")",
"end"
]
| update label positions. All else done in position_changing | [
"update",
"label",
"positions",
".",
"All",
"else",
"done",
"in",
"position_changing"
]
| 1391667f6cf16c8e132cbf85cc6a5171fb8c444e | https://github.com/ruby-x/rubyx/blob/1391667f6cf16c8e132cbf85cc6a5171fb8c444e/lib/risc/position/instruction_listener.rb#L57-L61 | train |
ruby-x/rubyx | lib/parfait/dictionary.rb | Parfait.Dictionary.set | def set(key , value)
index = key_index(key)
if( index )
i_values.set(index , value)
else
i_keys.push(key)
i_values.push(value)
end
value
end | ruby | def set(key , value)
index = key_index(key)
if( index )
i_values.set(index , value)
else
i_keys.push(key)
i_values.push(value)
end
value
end | [
"def",
"set",
"(",
"key",
",",
"value",
")",
"index",
"=",
"key_index",
"(",
"key",
")",
"if",
"(",
"index",
")",
"i_values",
".",
"set",
"(",
"index",
",",
"value",
")",
"else",
"i_keys",
".",
"push",
"(",
"key",
")",
"i_values",
".",
"push",
"(",
"value",
")",
"end",
"value",
"end"
]
| set key with value, returns value | [
"set",
"key",
"with",
"value",
"returns",
"value"
]
| 1391667f6cf16c8e132cbf85cc6a5171fb8c444e | https://github.com/ruby-x/rubyx/blob/1391667f6cf16c8e132cbf85cc6a5171fb8c444e/lib/parfait/dictionary.rb#L66-L75 | train |
ruby-x/rubyx | lib/parfait/dictionary.rb | Parfait.Dictionary.each | def each
index = 0
while index < i_keys.get_length
key = i_keys.get(index)
value = i_values.get(index)
yield key , value
index = index + 1
end
self
end | ruby | def each
index = 0
while index < i_keys.get_length
key = i_keys.get(index)
value = i_values.get(index)
yield key , value
index = index + 1
end
self
end | [
"def",
"each",
"index",
"=",
"0",
"while",
"index",
"<",
"i_keys",
".",
"get_length",
"key",
"=",
"i_keys",
".",
"get",
"(",
"index",
")",
"value",
"=",
"i_values",
".",
"get",
"(",
"index",
")",
"yield",
"key",
",",
"value",
"index",
"=",
"index",
"+",
"1",
"end",
"self",
"end"
]
| yield to each key value pair | [
"yield",
"to",
"each",
"key",
"value",
"pair"
]
| 1391667f6cf16c8e132cbf85cc6a5171fb8c444e | https://github.com/ruby-x/rubyx/blob/1391667f6cf16c8e132cbf85cc6a5171fb8c444e/lib/parfait/dictionary.rb#L83-L92 | train |
ruby-x/rubyx | lib/ruby/ruby_compiler.rb | Ruby.RubyCompiler.on_array | def on_array expression
ArrayStatement.new expression.children.collect{ |elem| process(elem) }
end | ruby | def on_array expression
ArrayStatement.new expression.children.collect{ |elem| process(elem) }
end | [
"def",
"on_array",
"expression",
"ArrayStatement",
".",
"new",
"expression",
".",
"children",
".",
"collect",
"{",
"|",
"elem",
"|",
"process",
"(",
"elem",
")",
"}",
"end"
]
| Array + Hashes | [
"Array",
"+",
"Hashes"
]
| 1391667f6cf16c8e132cbf85cc6a5171fb8c444e | https://github.com/ruby-x/rubyx/blob/1391667f6cf16c8e132cbf85cc6a5171fb8c444e/lib/ruby/ruby_compiler.rb#L143-L145 | train |
ruby-x/rubyx | lib/ruby/ruby_compiler.rb | Ruby.RubyCompiler.on_super | def on_super( statement )
arguments = process_all(statement.children)
SendStatement.new( nil , SuperExpression.new , arguments)
end | ruby | def on_super( statement )
arguments = process_all(statement.children)
SendStatement.new( nil , SuperExpression.new , arguments)
end | [
"def",
"on_super",
"(",
"statement",
")",
"arguments",
"=",
"process_all",
"(",
"statement",
".",
"children",
")",
"SendStatement",
".",
"new",
"(",
"nil",
",",
"SuperExpression",
".",
"new",
",",
"arguments",
")",
"end"
]
| this is a call to super with args and
same name as current method, which is set later | [
"this",
"is",
"a",
"call",
"to",
"super",
"with",
"args",
"and",
"same",
"name",
"as",
"current",
"method",
"which",
"is",
"set",
"later"
]
| 1391667f6cf16c8e132cbf85cc6a5171fb8c444e | https://github.com/ruby-x/rubyx/blob/1391667f6cf16c8e132cbf85cc6a5171fb8c444e/lib/ruby/ruby_compiler.rb#L240-L243 | train |
ruby-x/rubyx | lib/parfait/behaviour.rb | Parfait.Behaviour.resolve_method | def resolve_method( m_name )
raise "resolve_method #{m_name}.#{m_name.class}" unless m_name.is_a?(Symbol)
method = get_instance_method(m_name)
return method if method
if( super_class_name && super_class_name != :Object )
method = self.super_class.resolve_method(m_name)
end
method
end | ruby | def resolve_method( m_name )
raise "resolve_method #{m_name}.#{m_name.class}" unless m_name.is_a?(Symbol)
method = get_instance_method(m_name)
return method if method
if( super_class_name && super_class_name != :Object )
method = self.super_class.resolve_method(m_name)
end
method
end | [
"def",
"resolve_method",
"(",
"m_name",
")",
"raise",
"\"resolve_method #{m_name}.#{m_name.class}\"",
"unless",
"m_name",
".",
"is_a?",
"(",
"Symbol",
")",
"method",
"=",
"get_instance_method",
"(",
"m_name",
")",
"return",
"method",
"if",
"method",
"if",
"(",
"super_class_name",
"&&",
"super_class_name",
"!=",
":Object",
")",
"method",
"=",
"self",
".",
"super_class",
".",
"resolve_method",
"(",
"m_name",
")",
"end",
"method",
"end"
]
| get the method and if not found, try superclasses. raise error if not found | [
"get",
"the",
"method",
"and",
"if",
"not",
"found",
"try",
"superclasses",
".",
"raise",
"error",
"if",
"not",
"found"
]
| 1391667f6cf16c8e132cbf85cc6a5171fb8c444e | https://github.com/ruby-x/rubyx/blob/1391667f6cf16c8e132cbf85cc6a5171fb8c444e/lib/parfait/behaviour.rb#L44-L52 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.create_albums | def create_albums(data=nil,generate_objects=false)
uri = URI.parse(@uri + '/Albums')
post(uri,data,generate_objects)
end | ruby | def create_albums(data=nil,generate_objects=false)
uri = URI.parse(@uri + '/Albums')
post(uri,data,generate_objects)
end | [
"def",
"create_albums",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"'/Albums'",
")",
"post",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Create Albums.
@param data [Single Albums Object, Array of Albums Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after updating object
@return [JSON object] HTTP response JSON object. Returns an Albums objects array if generate_objects flag is set
@example
rest_client.create_albums(albums_obj)
rest_client.create_albums(albums_obj_array)
rest_client.create_albums(albums_obj,true)
rest_client.create_albums(albums_obj_array,true) | [
"Create",
"Albums",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L283-L286 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.update_albums | def update_albums(data=nil,generate_objects=false)
uri = URI.parse(@uri + '/Albums')
put(uri,data,generate_objects)
end | ruby | def update_albums(data=nil,generate_objects=false)
uri = URI.parse(@uri + '/Albums')
put(uri,data,generate_objects)
end | [
"def",
"update_albums",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"'/Albums'",
")",
"put",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Modify Albums.
@param data [Single Albums Object, Array of Albums Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after updating object
@return [JSON object] HTTP response JSON object. Returns an Albums objects array if generate_objects flag is set
@example
rest_client.update_albums(albums_obj)
rest_client.update_albums(albums_obj,true)
rest_client.update_albums(albums_obj_array)
rest_client.update_albums(albums_obj_array,true) | [
"Modify",
"Albums",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L301-L304 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.update_categories | def update_categories(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Categories")
put(uri,data,generate_objects)
end | ruby | def update_categories(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Categories")
put(uri,data,generate_objects)
end | [
"def",
"update_categories",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Categories\"",
")",
"put",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Modify system Categories.
@param data [Single Categories Object, Array of Categories Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after updating object
@return [JSON object] HTTP response JSON object. Returns a Categories objects array if generate_objects flag is set
@example
rest_client.update_categories(categories_obj)
rest_client.update_categories(categories_obj,true)
rest_client.update_categories(categories_obj_array)
rest_client.update_categories(categories_obj_array,true) | [
"Modify",
"system",
"Categories",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L423-L426 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.create_copyright_holders | def create_copyright_holders(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/CopyrightHolders")
post(uri,data,generate_objects)
end | ruby | def create_copyright_holders(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/CopyrightHolders")
post(uri,data,generate_objects)
end | [
"def",
"create_copyright_holders",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/CopyrightHolders\"",
")",
"post",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Create CopyrightHoloders.
@param data [Single CopyrightPolicies Object, Array of CopyrightPolicies Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after object creation
@return [JSON object] HTTP response JSON object. Returns a CopyrightHolders objects array if generate_objects flag is set
@example
rest_client.create_copyright_holders(copyright_holders_obj)
rest_client.create_copyright_holders(copyright_holders_obj_array)
rest_client.create_copyright_holders(copyright_holders_obj,true)
rest_client.create_copyright_holders(copyright_holders_obj_array,true) | [
"Create",
"CopyrightHoloders",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L465-L468 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.update_copyright_holders | def update_copyright_holders(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/CopyrightHolders")
put(uri,data,generate_objects)
end | ruby | def update_copyright_holders(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/CopyrightHolders")
put(uri,data,generate_objects)
end | [
"def",
"update_copyright_holders",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/CopyrightHolders\"",
")",
"put",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Modify CopyrightHolders.
@param data [Single CopyrightHolders Object, Array of CopyrightHoloders Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after updating object
@return [JSON object] HTTP response JSON object. Returns a CopyrightHolders objects array if generate_objects flag is set
@example
rest_client.update_copyright_holders(copyright_holders_obj)
rest_client.update_copyright_holders(copyright_holders_obj,true)
rest_client.update_copyright_holders(copyright_holders_obj_array)
rest_client.update_copyright_holders(copyright_holders_obj_array,true) | [
"Modify",
"CopyrightHolders",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L483-L486 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.create_copyright_policies | def create_copyright_policies(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/CopyrightPolicies")
post(uri,data,generate_objects)
end | ruby | def create_copyright_policies(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/CopyrightPolicies")
post(uri,data,generate_objects)
end | [
"def",
"create_copyright_policies",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/CopyrightPolicies\"",
")",
"post",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Create CopyrightPolicies.
@param data [Single CopyrightPolicies Object, Array of CopyrightPolicies Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after object creation
@return [JSON object] HTTP response JSON object. Returns a CopyrightPolicies objects array if generate_objects flag is set
@example
rest_client.create_copyright_policies(copyright_policies_obj)
rest_client.create_copyright_policies(copyright_policies_obj_array)
rest_client.create_copyright_policies(copyright_policies_obj,true)
rest_client.create_copyright_policies(copyright_policies_obj_array,true) | [
"Create",
"CopyrightPolicies",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L539-L542 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.update_copyright_policies | def update_copyright_policies(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/CopyrightPolicies")
put(uri,data,generate_objects)
end | ruby | def update_copyright_policies(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/CopyrightPolicies")
put(uri,data,generate_objects)
end | [
"def",
"update_copyright_policies",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/CopyrightPolicies\"",
")",
"put",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Modify CopyrightPolicies.
@param data [Single CopyrightPolicies Object, Array of CopyrightPolicies Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after updating object
@return [JSON object] HTTP response JSON object. Returns a CopyrightPolicies objects array if generate_objects flag is set
@example
rest_client.update_copyright_policies(copyright_policies_obj)
rest_client.update_copyright_policies(copyright_policies_obj,true)
rest_client.update_copyright_policies(copyright_policies_obj_array)
rest_client.update_copyright_policies(copyright_policies_obj_array,true) | [
"Modify",
"CopyrightPolicies",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L557-L560 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.create_fields | def create_fields(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Fields")
post(uri,data,generate_objects)
end | ruby | def create_fields(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Fields")
post(uri,data,generate_objects)
end | [
"def",
"create_fields",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Fields\"",
")",
"post",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Create fields.
@param data [Single Fields Object, Array of Fields Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after object creation
@return [JSON object] HTTP response JSON object. Returns a Fields objects array if generate_objects flag is set
@example
rest_client.create_fields(fields_obj)
rest_client.create_fields(fields_obj_array)
rest_client.create_fields(fields_obj,true)
rest_client.create_fields(fields_obj_array,true) | [
"Create",
"fields",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L656-L659 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.update_fields | def update_fields(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Fields")
put(uri,data,generate_objects)
end | ruby | def update_fields(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Fields")
put(uri,data,generate_objects)
end | [
"def",
"update_fields",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Fields\"",
")",
"put",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Modify fields.
@param data [Single Fields Object, Array of Fields Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after updating object
@return [JSON object] HTTP response JSON object. Returns a Fields objects array if generate_objects flag is set
@example
rest_client.update_fields(fields_obj)
rest_client.update_fields(fields_obj,true)
rest_client.update_fields(fields_obj_array)
rest_client.update_fields(fields_obj_array,true) | [
"Modify",
"fields",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L674-L677 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.get_field_lookup_strings | def get_field_lookup_strings(field=nil,query_obj=nil,with_nested_resources=false,use_http_query=false)
id = Validator.validate_field_lookup_string_arg(field)
uri = URI.parse(@uri + "/Fields" + "/#{id}" + "/FieldLookupStrings")
handle_get_request(uri,query_obj,with_nested_resources,use_http_query)
end | ruby | def get_field_lookup_strings(field=nil,query_obj=nil,with_nested_resources=false,use_http_query=false)
id = Validator.validate_field_lookup_string_arg(field)
uri = URI.parse(@uri + "/Fields" + "/#{id}" + "/FieldLookupStrings")
handle_get_request(uri,query_obj,with_nested_resources,use_http_query)
end | [
"def",
"get_field_lookup_strings",
"(",
"field",
"=",
"nil",
",",
"query_obj",
"=",
"nil",
",",
"with_nested_resources",
"=",
"false",
",",
"use_http_query",
"=",
"false",
")",
"id",
"=",
"Validator",
".",
"validate_field_lookup_string_arg",
"(",
"field",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Fields\"",
"+",
"\"/#{id}\"",
"+",
"\"/FieldLookupStrings\"",
")",
"handle_get_request",
"(",
"uri",
",",
"query_obj",
",",
"with_nested_resources",
",",
"use_http_query",
")",
"end"
]
| FIELD LOOKUP STRINGS
Retrieves options for Fixed Suggestion, Suggestion, and Option field types.
@param field [Fields Object, Hash, String, Integer] Argument must specify the field id (Required)
@param query_obj[RestOptions Object] Takes a RestOptions object or a SQL WHERE clause (Optional)
@param with_nested_resources [Boolean] Returns any nested objects if applicable (Optional)
@param use_http_query [Boolean] Filtering done on the server when set - faster but less granular -> "or" operator not supported (Optional)
@return [Array] Array of FieldLookupStrings.
@example
rest_client.get_field_lookup_strings(27)
rest_client.get_field_lookup_strings(27,rest_options_object)
rest_client.get_field_lookup_strings(27,"where value = 'my value'",false,false)
rest_client.get_field_lookup_strings(27,"where value = 'my value'",false,true) | [
"FIELD",
"LOOKUP",
"STRINGS"
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L717-L722 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.create_field_lookup_strings | def create_field_lookup_strings(field=nil,data=nil,generate_objects=false)
id = Validator.validate_field_lookup_string_arg(field)
uri = URI.parse(@uri + "/Fields" + "/#{id}" + "/FieldLookupStrings")
post(uri,data,generate_objects)
end | ruby | def create_field_lookup_strings(field=nil,data=nil,generate_objects=false)
id = Validator.validate_field_lookup_string_arg(field)
uri = URI.parse(@uri + "/Fields" + "/#{id}" + "/FieldLookupStrings")
post(uri,data,generate_objects)
end | [
"def",
"create_field_lookup_strings",
"(",
"field",
"=",
"nil",
",",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"id",
"=",
"Validator",
".",
"validate_field_lookup_string_arg",
"(",
"field",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Fields\"",
"+",
"\"/#{id}\"",
"+",
"\"/FieldLookupStrings\"",
")",
"post",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| creates options for Fixed Suggestion, Suggestion, and Option field types.
@param field [Fields Object, Hash, String, Integer] Argument must specify the field id (Required)
@param data [Single FieldLookupString Object, Array of FieldLookupString Objects]
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after object creation
@return [JSON object] HTTP response JSON object. Returns Array of FieldLookupStrings objects if generate_objects flag is set
@example
rest_client.create_field_lookup_strings(field_obj,field_lookup_strings_obj)
rest_client.create_field_lookup_strings(field_obj,field_lookup_strings_obj,true)
rest_client.create_field_lookup_strings(field_obj,field_lookup_strings_obj_array)
rest_client.create_field_lookup_strings(field_obj,field_lookup_strings_obj_array,true) | [
"creates",
"options",
"for",
"Fixed",
"Suggestion",
"Suggestion",
"and",
"Option",
"field",
"types",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L738-L743 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.update_field_lookup_strings | def update_field_lookup_strings(field=nil,data=nil,generate_objects=false)
id = Validator.validate_field_lookup_string_arg(field)
uri = URI.parse(@uri + "/Fields" + "/#{id}" + "/FieldLookupStrings")
put(uri,data,generate_objects)
end | ruby | def update_field_lookup_strings(field=nil,data=nil,generate_objects=false)
id = Validator.validate_field_lookup_string_arg(field)
uri = URI.parse(@uri + "/Fields" + "/#{id}" + "/FieldLookupStrings")
put(uri,data,generate_objects)
end | [
"def",
"update_field_lookup_strings",
"(",
"field",
"=",
"nil",
",",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"id",
"=",
"Validator",
".",
"validate_field_lookup_string_arg",
"(",
"field",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Fields\"",
"+",
"\"/#{id}\"",
"+",
"\"/FieldLookupStrings\"",
")",
"put",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Modifies options for Fixed Suggestion, Suggestion, and Option field types.
@param field [Fields Object, Hash, String, Integer] Argument must specify the field id (Required)
@param data [Single FieldLookupString Object, Array of FieldLookupString Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after updating object
@return [JSON object] HTTP response JSON object. Returns Array of FieldLookupStrings objects if generate_objects flag is set
@example
rest_client.update_field_lookup_strings(field_obj,field_lookup_strings_obj)
rest_client.update_field_lookup_strings(field_obj,field_lookup_strings_obj,true)
rest_client.update_field_lookup_strings(field_obj,field_lookup_strings_obj_array)
rest_client.update_field_lookup_strings(field_obj,field_lookup_strings_obj_array,true) | [
"Modifies",
"options",
"for",
"Fixed",
"Suggestion",
"Suggestion",
"and",
"Option",
"field",
"types",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L759-L764 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.upload_file | def upload_file(file=nil,
category=nil,
project=nil,
generate_objects=false,
read_timeout=600,
low_priority_processing=false)
__upload_file(file,
category,
project,
generate_objects,
read_timeout,
low_priority_processing)
end | ruby | def upload_file(file=nil,
category=nil,
project=nil,
generate_objects=false,
read_timeout=600,
low_priority_processing=false)
__upload_file(file,
category,
project,
generate_objects,
read_timeout,
low_priority_processing)
end | [
"def",
"upload_file",
"(",
"file",
"=",
"nil",
",",
"category",
"=",
"nil",
",",
"project",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
",",
"read_timeout",
"=",
"600",
",",
"low_priority_processing",
"=",
"false",
")",
"__upload_file",
"(",
"file",
",",
"category",
",",
"project",
",",
"generate_objects",
",",
"read_timeout",
",",
"low_priority_processing",
")",
"end"
]
| Uploads a file to OpenAsset.
@param file [String] the path to the file being uploaded
@param category [Categories Object,String,Integer] containing Target Category ID in OpenAsset (Required)
@param project [Projects Object, String, Integer] Project ID in OpenAsset (Specified only when Category is project based)
@return [JSON Object] HTTP response JSON object. Returns Files objects array if generate_objects flag is set
FOR PROJECT UPLOADS
@example
rest_client.upload_file('/path/to/file', category_obj, project_obj)
rest_client.upload_file('/path/to/file','2','10')
rest_client.upload_file('/path/to/file', 2, 10)
rest_client.upload_file('/path/to/file', category_obj, project_obj, true)
rest_client.upload_file('/path/to/file','2','10', true)
rest_client.upload_file('/path/to/file', 2, 10, true)
FOR REFERENCE UPLOADS
@example
rest_client.upload_file('/path/to/file', category_obj)
rest_client.upload_file('/path/to/file','2')
rest_client.upload_file('/path/to/file', 2,)
rest_client.upload_file('/path/to/file', category_obj, nil, true)
rest_client.upload_file('/path/to/file','2', nil, true)
rest_client.upload_file('/path/to/file', 2, nil, true) | [
"Uploads",
"a",
"file",
"to",
"OpenAsset",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L840-L852 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.replace_file | def replace_file(original_file_object=nil,
replacement_file_path='',
retain_original_filename_in_oa=false,
generate_objects=false)
__replace_file(original_file_object,
replacement_file_path,
retain_original_filename_in_oa,
generate_objects)
end | ruby | def replace_file(original_file_object=nil,
replacement_file_path='',
retain_original_filename_in_oa=false,
generate_objects=false)
__replace_file(original_file_object,
replacement_file_path,
retain_original_filename_in_oa,
generate_objects)
end | [
"def",
"replace_file",
"(",
"original_file_object",
"=",
"nil",
",",
"replacement_file_path",
"=",
"''",
",",
"retain_original_filename_in_oa",
"=",
"false",
",",
"generate_objects",
"=",
"false",
")",
"__replace_file",
"(",
"original_file_object",
",",
"replacement_file_path",
",",
"retain_original_filename_in_oa",
",",
"generate_objects",
")",
"end"
]
| Replace a file in OpenAsset.
@param original_file_object [Single Files Object] (Required) File Object in OA
@param replacement_file_path [String] (Required)
@param retain_original_filename_in_oa [Boolean] (Optional, Default => false)
@param generate_objects [Boolean] Return an array of Files or JSON objects in response body (Optional, Default => false)
@return [JSON object or Files Object Array ]. Returns Files objects array if generate_objects flag is set
@example
rest_client.replace_file(file_obj,'C:\Users\root\Pictures\new_img.jpg')
rest_client.replace_file(file_obj,'C:\Users\root\Pictures\new_img.jpg',true,true)
rest_client.replace_file(file_obj,'C:\Users\root\Pictures\new_img.jpg',false,false)
rest_client.replace_file(file_obj,'C:\Users\root\Pictures\new_img.jpg',false,true)
rest_client.replace_file(file_obj,'C:\Users\root\Pictures\new_img.jpg',true,false) | [
"Replace",
"a",
"file",
"in",
"OpenAsset",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L868-L877 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.download_files | def download_files(files=nil,image_size='1',download_location='./Rest_Downloads')
# Put single files objects in an array for easy downloading with
# the Array class' DownloadHelper module
files = [files] unless files.is_a?(Array)
files.download(image_size,download_location)
end | ruby | def download_files(files=nil,image_size='1',download_location='./Rest_Downloads')
# Put single files objects in an array for easy downloading with
# the Array class' DownloadHelper module
files = [files] unless files.is_a?(Array)
files.download(image_size,download_location)
end | [
"def",
"download_files",
"(",
"files",
"=",
"nil",
",",
"image_size",
"=",
"'1'",
",",
"download_location",
"=",
"'./Rest_Downloads'",
")",
"files",
"=",
"[",
"files",
"]",
"unless",
"files",
".",
"is_a?",
"(",
"Array",
")",
"files",
".",
"download",
"(",
"image_size",
",",
"download_location",
")",
"end"
]
| Download Files.
@param files [Single Files Object, Array of Files Objects] (Required)
@param image_size [Integer, String] (Accepts image size id or postfix string:
Defaults to '1' => original image size id)
@param download_location [String] (Default: Creates folder called Rest_Downloads in the current directory.)
@return [nil].
@example
rest_client.download_files(File_object)
rest_client.download_files(File_objects_array)
rest_client.download_files(File_object,'C:\Folder\Path\Specified')
rest_client.download_files(File_objects_array,'C:\Folder\Path\Specified') | [
"Download",
"Files",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L928-L934 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.update_files | def update_files(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Files")
put(uri,data,generate_objects)
end | ruby | def update_files(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Files")
put(uri,data,generate_objects)
end | [
"def",
"update_files",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Files\"",
")",
"put",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Update Files.
@param data [Single Files Object, Array of Files Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after updating object
@return [JSON object] HTTP response JSON object. Returns Files objects array if generate_objects flag is set
@example
rest_client.update_files(files_obj)
rest_client.update_files(files_obj,true)
rest_client.update_files(files_obj_array)
rest_client.update_files(files_obj_array,true) | [
"Update",
"Files",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L949-L952 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.create_groups | def create_groups(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Groups")
post(uri,data,generate_objects)
end | ruby | def create_groups(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Groups")
post(uri,data,generate_objects)
end | [
"def",
"create_groups",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Groups\"",
")",
"post",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Create Groups.
@param data [Single Groups Object, Array of Groups Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after object creation
@return [JSON object] HTTP response JSON object. Returns Groups objects array if generate_objects flag is set
@example
rest_client.create_groups(groups_obj)
rest_client.create_groups(groups_obj,true)
rest_client.create_groups(groups_obj_array)
rest_client.create_groups(groups_obj_array,true) | [
"Create",
"Groups",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1009-L1012 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.update_groups | def update_groups(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Groups")
put(uri,data,generate_objects)
end | ruby | def update_groups(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Groups")
put(uri,data,generate_objects)
end | [
"def",
"update_groups",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Groups\"",
")",
"put",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Update Groups.
@param data [Single Groups Object, Array of Groups Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after object creation
@return [JSON object] HTTP response JSON object. Returns Groups objects array if generate_objects flag is set
@example
rest_client.update_groups(groups_obj)
rest_client.update_groups(groups_obj,true)
rest_client.update_groups(groups_obj_array)
rest_client.update_groups(groups_obj_array,true) | [
"Update",
"Groups",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1027-L1030 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.create_keywords | def create_keywords(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Keywords")
post(uri,data,generate_objects)
end | ruby | def create_keywords(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Keywords")
post(uri,data,generate_objects)
end | [
"def",
"create_keywords",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Keywords\"",
")",
"post",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Create new file Keywords in OpenAsset.
@param data [Single Keywords Object, Array of Keywords Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after object creation
@return [JSON object] HTTP response JSON object. Returns Keywords objects array if generate_objects flag is set
@example
rest_client.create_keywords(keywords_obj)
rest_client.create_keywords(keywords_obj_array)
rest_client.create_keywords(keywords_obj,true)
rest_client.create_keywords(keywords_obj_array,true) | [
"Create",
"new",
"file",
"Keywords",
"in",
"OpenAsset",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1087-L1090 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.update_keywords | def update_keywords(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Keywords")
put(uri,data,generate_objects)
end | ruby | def update_keywords(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Keywords")
put(uri,data,generate_objects)
end | [
"def",
"update_keywords",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Keywords\"",
")",
"put",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Modify file Keywords.
@param data [Single Keywords Object, Array of Keywords Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after updating object
@return [JSON object] HTTP response JSON object. Returns Keywords objects array if generate_objects flag is set
@example
rest_client.update_keywords(keywords_obj)
rest_client.update_keywords(keywords_obj,true)
rest_client.update_keywords(keywords_obj_array)
rest_client.update_keywords(keywords_obj_array,true) | [
"Modify",
"file",
"Keywords",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1105-L1108 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.merge_keywords | def merge_keywords(target,source)
uri = URI.parse(@uri + "/Keywords")
merge(uri,target,source)
end | ruby | def merge_keywords(target,source)
uri = URI.parse(@uri + "/Keywords")
merge(uri,target,source)
end | [
"def",
"merge_keywords",
"(",
"target",
",",
"source",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Keywords\"",
")",
"merge",
"(",
"uri",
",",
"target",
",",
"source",
")",
"end"
]
| Merge Keywords.
@param target [ Keywords Object, id ](Required)
@param source [ Array of Keywords objects or ids ](Required)
@return [JSON object] HTTP response JSON object.
@example
rest_client.merge_keywords(keywords_obj,keywords_obj_array)
rest_client.merge_keywords('1',['1','2','3']) | [
"Merge",
"Keywords",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1138-L1141 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.create_keyword_categories | def create_keyword_categories(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/KeywordCategories")
post(uri,data,generate_objects)
end | ruby | def create_keyword_categories(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/KeywordCategories")
post(uri,data,generate_objects)
end | [
"def",
"create_keyword_categories",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/KeywordCategories\"",
")",
"post",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Create file keyword categories.
@param data [Single KeywordCategories Object, Array of KeywordCategories Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after object creation
@return [JSON object] HTTP response JSON object. Returns KeywordCategories objects array if generate_objects flag is set
@example
rest_client.create_keyword_categories(keyword_categories_obj)
rest_client.create_keyword_categories(keyword_categories_obj_array)
rest_client.create_keyword_categories(keyword_categories_obj,true)
rest_client.create_keyword_categories(keyword_categories_obj_array,true) | [
"Create",
"file",
"keyword",
"categories",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1179-L1182 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.update_keyword_categories | def update_keyword_categories(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/KeywordCategories")
put(uri,data,generate_objects)
end | ruby | def update_keyword_categories(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/KeywordCategories")
put(uri,data,generate_objects)
end | [
"def",
"update_keyword_categories",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/KeywordCategories\"",
")",
"put",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Modify file keyword categories.
@param data [Single KeywordCategories Object, Array of KeywordCategories Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after updating object
@return [JSON object] HTTP response JSON object.. Returns KeywordCategories objects array if generate_objects flag is set
@example
rest_client.update_keyword_categories(keyword_categories_obj)
rest_client.update_keyword_categories(keyword_categories_obj,true)
rest_client.update_keyword_categories(keyword_categories_obj_array)
rest_client.update_keyword_categories(keyword_categories_obj_array,true) | [
"Modify",
"file",
"keyword",
"categories",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1197-L1200 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.merge_keyword_categories | def merge_keyword_categories(target,source)
uri = URI.parse(@uri + "/KeywordCategories")
merge(uri,target,source)
end | ruby | def merge_keyword_categories(target,source)
uri = URI.parse(@uri + "/KeywordCategories")
merge(uri,target,source)
end | [
"def",
"merge_keyword_categories",
"(",
"target",
",",
"source",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/KeywordCategories\"",
")",
"merge",
"(",
"uri",
",",
"target",
",",
"source",
")",
"end"
]
| Merge Keyword Categories.
@param target [ Keyword Categories Object, id ](Required)
@param source [ Array of Keyword Categories objects or ids ](Required)
@return [JSON object] HTTP response JSON object.
@example
rest_client.merge_keyword_categories(keywords_categories_obj,keyword_categories_obj_array)
rest_client.merge_keyword_categories('1',['1','2','3']) | [
"Merge",
"Keyword",
"Categories",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1230-L1233 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.create_photographers | def create_photographers(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Photographers")
post(uri,data,generate_objects)
end | ruby | def create_photographers(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Photographers")
post(uri,data,generate_objects)
end | [
"def",
"create_photographers",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Photographers\"",
")",
"post",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Create Photographers.
@param data [Single Photographers Object, Array of Photographers Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after object creation
@return [JSON object] HTTP response JSON object. Returns Photographers objects array if generate_objects flag is set
@example
rest_client.create_photographers(photographers_obj)
rest_client.create_photographers(photographers_obj,true)
rest_client.create_photographers(photographers_obj_array)
rest_client.create_photographers(photographers_obj_array,true) | [
"Create",
"Photographers",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1271-L1274 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.update_photographers | def update_photographers(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Photographers")
put(uri,data,generate_objects)
end | ruby | def update_photographers(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Photographers")
put(uri,data,generate_objects)
end | [
"def",
"update_photographers",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Photographers\"",
")",
"put",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Modify Photographers.
@param data [Single Photographers Object, Array of Photographers Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after updating object
@return [JSON object] HTTP response JSON object. Returns Photographers objects array if generate_objects flag is set
@example
rest_client.update_photographers(photographers_obj)
rest_client.update_photographers(photographers_obj,true)
rest_client.update_photographers(photographers_obj_array)
rest_client.update_photographers(photographers_obj_array,true) | [
"Modify",
"Photographers",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1289-L1292 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.create_projects | def create_projects(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Projects")
post(uri,data,generate_objects)
end | ruby | def create_projects(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Projects")
post(uri,data,generate_objects)
end | [
"def",
"create_projects",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Projects\"",
")",
"post",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Create Projects.
@param data [Single Projects Object, Array of Projects Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after object creation
@return [JSON object] HTTP response JSON object. Returns Projects objects array if generate_objects flag is set
@example
rest_client.create_projects(projects_obj)
rest_client.create_projects(projects_obj,true)
rest_client.create_projects(projects_obj_array)
rest_client.create_projects(projects_obj_array,true) | [
"Create",
"Projects",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1345-L1348 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.update_projects | def update_projects(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Projects")
put(uri,data,generate_objects)
end | ruby | def update_projects(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Projects")
put(uri,data,generate_objects)
end | [
"def",
"update_projects",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Projects\"",
")",
"put",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Modify Projects.
@param data [Single Projects Object, Array of Projects Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after updating object
@return [JSON object] HTTP response JSON object. Returns Projects objects array if generate_objects flag is set
@example
rest_client.update_projects(projects_obj)
rest_client.update_projects(projects_obj,true)
rest_client.update_projects(projects_obj_array)
rest_client.update_projects(projects_obj_array,true) | [
"Modify",
"Projects",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1364-L1367 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.create_project_keywords | def create_project_keywords(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/ProjectKeywords")
post(uri,data,generate_objects)
end | ruby | def create_project_keywords(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/ProjectKeywords")
post(uri,data,generate_objects)
end | [
"def",
"create_project_keywords",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/ProjectKeywords\"",
")",
"post",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Create Project Keywords.
@param data [Single ProjectKeywords Object, Array of ProjectKeywords Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after object creation
@return [JSON object] HTTP response JSON object. Returns ProjectKeywords objects array if generate_objects flag is set
@example
rest_client.create_project_keywords(project_keywords_obj)
rest_client.create_project_keywords(project_keywords_obj,true)
rest_client.create_project_keywords(project_keywords_obj_array)
rest_client.create_project_keywords(project_keywords_obj_array,true) | [
"Create",
"Project",
"Keywords",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1424-L1427 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.update_project_keywords | def update_project_keywords(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/ProjectKeywords")
put(uri,data,generate_objects)
end | ruby | def update_project_keywords(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/ProjectKeywords")
put(uri,data,generate_objects)
end | [
"def",
"update_project_keywords",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/ProjectKeywords\"",
")",
"put",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Modify Project Keywords.
@param data [Single ProjectKeywords Object, Array of ProjectKeywords Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after updating object
@return [JSON object] HTTP response JSON object. Returns ProjectKeywords objects array if generate_objects flag is set
@example
rest_client.update_project_keywords(project_keywords_obj)
rest_client.update_project_keywords(project_keywords_obj,true)
rest_client.update_project_keywords(project_keywords_obj_array)
rest_client.update_project_keywords(project_keywords_obj_array,true) | [
"Modify",
"Project",
"Keywords",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1442-L1445 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.merge_project_keywords | def merge_project_keywords(target,source)
uri = URI.parse(@uri + "/ProjectKeywords")
merge(uri,target,source)
end | ruby | def merge_project_keywords(target,source)
uri = URI.parse(@uri + "/ProjectKeywords")
merge(uri,target,source)
end | [
"def",
"merge_project_keywords",
"(",
"target",
",",
"source",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/ProjectKeywords\"",
")",
"merge",
"(",
"uri",
",",
"target",
",",
"source",
")",
"end"
]
| Merge Project Keywords
@param target [ Project Keywords Object, id ](Required)
@param source [ Array of Project Keywords objects or ids ](Required)
@return [JSON object] HTTP response JSON object.
@example
rest_client.merge_project_keywords(project_keywords_obj,project_keywords_obj_array)
rest_client.merge_project_keywords('1',['1','2','3']) | [
"Merge",
"Project",
"Keywords"
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1475-L1478 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.create_project_keyword_categories | def create_project_keyword_categories(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/ProjectKeywordCategories")
post(uri,data,generate_objects)
end | ruby | def create_project_keyword_categories(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/ProjectKeywordCategories")
post(uri,data,generate_objects)
end | [
"def",
"create_project_keyword_categories",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/ProjectKeywordCategories\"",
")",
"post",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Create project keyword categories.
@param data [Single ProjectKeywordCategories Object, Array of ProjectKeywordCategories Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after object creation
@return [JSON object] HTTP response JSON object. Returns ProjectKeywordCategories objects array if generate_objects flag is set
@example
rest_client.create_project_keyword_categories(project_keyword_categories_obj)
rest_client.create_project_keyword_categories(project_keyword_categories_obj,true)
rest_client.create_project_keyword_categories(project_keyword_categories_obj_array)
rest_client.create_project_keyword_categories(project_keyword_categories_obj_array,true) | [
"Create",
"project",
"keyword",
"categories",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1516-L1519 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.update_project_keyword_categories | def update_project_keyword_categories(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/ProjectKeywordCategories")
put(uri,data,generate_objects)
end | ruby | def update_project_keyword_categories(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/ProjectKeywordCategories")
put(uri,data,generate_objects)
end | [
"def",
"update_project_keyword_categories",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/ProjectKeywordCategories\"",
")",
"put",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Modify project keyword categories.
@param data [Single ProjectKeywordCategories Object, Array of ProjectKeywordCategories Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after updating object
@return [JSON object] HTTP response JSON object. Returns ProjectKeywordCategories objects array if generate_objects flag is set
@example
rest_client.update_project_keyword_categories(project_keyword_categories_obj)
rest_client.update_project_keyword_categories(project_keyword_categories_obj,true)
rest_client.update_project_keyword_categories(project_keyword_categories_obj_array)
rest_client.update_project_keyword_categories(project_keyword_categories_obj_array,true) | [
"Modify",
"project",
"keyword",
"categories",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1534-L1537 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.merge_project_keyword_categories | def merge_project_keyword_categories(target,source)
uri = URI.parse(@uri + "/ProjectKeywordCategories")
merge(uri,target,source)
end | ruby | def merge_project_keyword_categories(target,source)
uri = URI.parse(@uri + "/ProjectKeywordCategories")
merge(uri,target,source)
end | [
"def",
"merge_project_keyword_categories",
"(",
"target",
",",
"source",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/ProjectKeywordCategories\"",
")",
"merge",
"(",
"uri",
",",
"target",
",",
"source",
")",
"end"
]
| Merge Project Keyword Categories
@param target [ Project Keyword Categories Object, id ](Required)
@param source [ Array of Project Keyword Categories objects or ids ](Required)
@return [JSON object] HTTP response JSON object.
@example
rest_client.merge_project_keyword_categories(project_keywords_obj,project_keywords_obj_array)
rest_client.merge_project_keyword_categories('1',['1','2','3']) | [
"Merge",
"Project",
"Keyword",
"Categories"
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1567-L1570 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.create_employee_keywords | def create_employee_keywords(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/EmployeeKeywords")
post(uri,data,generate_objects)
end | ruby | def create_employee_keywords(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/EmployeeKeywords")
post(uri,data,generate_objects)
end | [
"def",
"create_employee_keywords",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/EmployeeKeywords\"",
")",
"post",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Create Employee Keywords.
@param data [Single EmployeeKeywords Object, Array of EmployeeKeywords Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after object creation
@return [JSON object] HTTP response JSON object. Returns EmployeeKeywords objects array if generate_objects flag is set
@example
rest_client.create_employee_keywords(employee_keywords_obj)
rest_client.create_employee_keywords(employee_keywords_obj,true)
rest_client.create_employee_keywords(employee_keywords_obj_array)
rest_client.create_employee_keywords(employee_keywords_obj_array,true) | [
"Create",
"Employee",
"Keywords",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1608-L1611 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.update_employee_keywords | def update_employee_keywords(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/EmployeeKeywords")
put(uri,data,generate_objects)
end | ruby | def update_employee_keywords(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/EmployeeKeywords")
put(uri,data,generate_objects)
end | [
"def",
"update_employee_keywords",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/EmployeeKeywords\"",
")",
"put",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Modify Employee Keywords.
@param data [Single EmployeeKeywords Object, Array of EmployeeKeywords Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after updating object
@return [JSON object] HTTP response JSON object. Returns EmployeeKeywords objects array if generate_objects flag is set
@example
rest_client.update_employee_keywords(employee_keywords_obj)
rest_client.update_employee_keywords(employee_keywords_obj,true)
rest_client.update_employee_keywords(employee_keywords_obj_array)
rest_client.update_employee_keywords(employee_keywords_obj_array,true) | [
"Modify",
"Employee",
"Keywords",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1626-L1629 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.merge_employee_keywords | def merge_employee_keywords(target,source)
uri = URI.parse(@uri + "/EmployeeKeywords")
merge(uri,target,source)
end | ruby | def merge_employee_keywords(target,source)
uri = URI.parse(@uri + "/EmployeeKeywords")
merge(uri,target,source)
end | [
"def",
"merge_employee_keywords",
"(",
"target",
",",
"source",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/EmployeeKeywords\"",
")",
"merge",
"(",
"uri",
",",
"target",
",",
"source",
")",
"end"
]
| Merge Employee Keywords
@param target [ Employee Keywords Object, id ](Required)
@param source [ Array of Employee Keywords objects or ids ](Required)
@return [JSON object] HTTP response JSON object.
@example
rest_client.merge_employee_keywords(employee_keywords_obj,employee_keywords_obj_array)
rest_client.merge_employee_keywords('1',['1','2','3']) | [
"Merge",
"Employee",
"Keywords"
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1659-L1662 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.create_employee_keyword_categories | def create_employee_keyword_categories(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/EmployeeKeywordCategories")
post(uri,data,generate_objects)
end | ruby | def create_employee_keyword_categories(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/EmployeeKeywordCategories")
post(uri,data,generate_objects)
end | [
"def",
"create_employee_keyword_categories",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/EmployeeKeywordCategories\"",
")",
"post",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Create employee keyword categories.
@param data [Single EmployeeKeywordCategories Object, Array of EmployeeKeywordCategories Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after object creation
@return [JSON object] HTTP response JSON object. Returns EmployeeKeywordCategories objects array if generate_objects flag is set
@example
rest_client.create_employee_keyword_categories(employee_keyword_categories_obj)
rest_client.create_employee_keyword_categories(employee_keyword_categories_obj,true)
rest_client.create_employee_keyword_categories(employee_keyword_categories_obj_array)
rest_client.create_employee_keyword_categories(employee_keyword_categories_obj_array,true) | [
"Create",
"employee",
"keyword",
"categories",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1700-L1703 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.update_employee_keyword_categories | def update_employee_keyword_categories(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/EmployeeKeywordCategories")
put(uri,data,generate_objects)
end | ruby | def update_employee_keyword_categories(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/EmployeeKeywordCategories")
put(uri,data,generate_objects)
end | [
"def",
"update_employee_keyword_categories",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/EmployeeKeywordCategories\"",
")",
"put",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Modify employee keyword categories.
@param data [Single EmployeeKeywordCategories Object, Array of EmployeeKeywordCategories Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after updating object
@return [JSON object] HTTP response JSON object. Returns EmployeeKeywordCategories objects array if generate_objects flag is set
@example
rest_client.update_employee_keyword_categories(employee_keyword_categories_obj)
rest_client.update_employee_keyword_categories(employee_keyword_categories_obj,true)
rest_client.update_employee_keyword_categories(employee_keyword_categories_obj_array)
rest_client.update_employee_keyword_categories(employee_keyword_categories_obj_array,true) | [
"Modify",
"employee",
"keyword",
"categories",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1718-L1721 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.merge_employee_keyword_categories | def merge_employee_keyword_categories(target,source)
uri = URI.parse(@uri + "/EmployeeKeywordCategories")
merge(uri,target,source)
end | ruby | def merge_employee_keyword_categories(target,source)
uri = URI.parse(@uri + "/EmployeeKeywordCategories")
merge(uri,target,source)
end | [
"def",
"merge_employee_keyword_categories",
"(",
"target",
",",
"source",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/EmployeeKeywordCategories\"",
")",
"merge",
"(",
"uri",
",",
"target",
",",
"source",
")",
"end"
]
| Merge Employee Keyword Categories
@param target [ Employee Keyword Categories Object, id ](Required)
@param source [ Array of Employee Keyword Categories objects or ids ](Required)
@return [JSON object] HTTP response JSON object.
@example
rest_client.merge_employee_keyword_categories(employee_keywords_obj,employee_keywords_obj_array)
rest_client.merge_employee_keyword_categories('1',['1','2','3']) | [
"Merge",
"Employee",
"Keyword",
"Categories"
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1751-L1754 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.create_searches | def create_searches(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Searches")
post(uri,data,generate_objects)
end | ruby | def create_searches(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Searches")
post(uri,data,generate_objects)
end | [
"def",
"create_searches",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Searches\"",
")",
"post",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Create Searches.
@param data [Single Searches Object, Array of Searches Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after object creation
@return [JSON object] HTTP response JSON object. Returns Searches objects array if generate_objects flag is set
@example
rest_client.create_searches(searches_obj)
rest_client.create_searches(searches_obj,true)
rest_client.create_searches(searches_obj_array)
rest_client.create_searches(searches_obj_array,true) | [
"Create",
"Searches",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1792-L1795 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.update_searches | def update_searches(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Searches")
put(uri,data,generate_objects)
end | ruby | def update_searches(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Searches")
put(uri,data,generate_objects)
end | [
"def",
"update_searches",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Searches\"",
")",
"put",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Modify Searches.
@param data [Single Searches Object, Array of Searches Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after updating object
@return [JSON object] HTTP response JSON object. Returns Searches objects array if generate_objects flag is set
@example
rest_client.update_searches(searches_obj)
rest_client.update_searches(searches_obj,true)
rest_client.update_searches(searches_obj_array)
rest_client.update_searches(searches_obj_array,true) | [
"Modify",
"Searches",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1810-L1813 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.create_image_sizes | def create_image_sizes(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Sizes")
post(uri,data,generate_objects)
end | ruby | def create_image_sizes(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Sizes")
post(uri,data,generate_objects)
end | [
"def",
"create_image_sizes",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Sizes\"",
")",
"post",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Create image Sizes.
@param data [Single Sizes Object, Array of Sizes Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after object creation
@return [JSON object] HTTP response JSON object. Returns ImageSizes objects array if generate_objects flag is set
@example
rest_client.create_image_sizes(image_sizes_obj)
rest_client.create_image_sizes(image_sizes_obj,true)
rest_client.create_image_sizes(image_sizes_obj_array)
rest_client.create_image_sizes(image_sizes_obj_array,true) | [
"Create",
"image",
"Sizes",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1852-L1855 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.update_image_sizes | def update_image_sizes(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Sizes")
put(uri,data,generate_objects)
end | ruby | def update_image_sizes(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Sizes")
put(uri,data,generate_objects)
end | [
"def",
"update_image_sizes",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Sizes\"",
")",
"put",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Modify image Sizes.
@param data [Single Sizes Object, Array of Sizes Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after updating object
@return [JSON object] HTTP response JSON object. Returns ImageSizes objects array if generate_objects flag is set
@example
rest_client.update_image_sizes(image_sizes_obj)
rest_client.update_image_sizes(image_sizes_obj,true)
rest_client.update_image_sizes(image_sizes_obj_array)
rest_client.update_image_sizes(image_sizes_obj_array,true) | [
"Modify",
"image",
"Sizes",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1870-L1873 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.create_users | def create_users(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Users")
post(uri,data,generate_objects)
end | ruby | def create_users(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Users")
post(uri,data,generate_objects)
end | [
"def",
"create_users",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Users\"",
")",
"post",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Create Users.
@param data [Single Users Object, Array of Users Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after object creation
@return [JSON object] HTTP response JSON object. Returns Users objects array if generate_objects flag is set
@example
rest_client.create_users(users_obj)
rest_client.create_users(users_obj,true)
rest_client.create_users(users_obj_array)
rest_client.create_users(users_obj_array,true) | [
"Create",
"Users",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1954-L1957 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.update_users | def update_users(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Users")
put(uri,data,generate_objects)
end | ruby | def update_users(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Users")
put(uri,data,generate_objects)
end | [
"def",
"update_users",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Users\"",
")",
"put",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Update Users.
@param data [Single Users Object, Array of Users Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after object creation
@return [JSON object] HTTP response JSON object. Returns Users objects array if generate_objects flag is set
@example
rest_client.update_users(users_obj)
rest_client.update_users(users_obj,true)
rest_client.update_users(users_obj_array)
rest_client.update_users(users_obj_array,true) | [
"Update",
"Users",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L1972-L1975 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.create_employees | def create_employees(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Employees")
post(uri,data,generate_objects)
end | ruby | def create_employees(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Employees")
post(uri,data,generate_objects)
end | [
"def",
"create_employees",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Employees\"",
")",
"post",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Create employees.
@param data [Single employees Object, Array of employees Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after object creation
@return [JSON object] HTTP response JSON object. Returns employees objects array if generate_objects flag is set
@example
rest_client.create_employees(employees_obj)
rest_client.create_employees(employees_obj,true)
rest_client.create_employees(employees_obj_array)
rest_client.create_employees(employees_obj_array,true) | [
"Create",
"employees",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L2032-L2035 | train |
axomic/openasset-rest-ruby | lib/openasset-rest-client.rb | OpenAsset.RestClient.update_employees | def update_employees(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Employees")
put(uri,data,generate_objects)
end | ruby | def update_employees(data=nil,generate_objects=false)
uri = URI.parse(@uri + "/Employees")
put(uri,data,generate_objects)
end | [
"def",
"update_employees",
"(",
"data",
"=",
"nil",
",",
"generate_objects",
"=",
"false",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"@uri",
"+",
"\"/Employees\"",
")",
"put",
"(",
"uri",
",",
"data",
",",
"generate_objects",
")",
"end"
]
| Update Employees.
@param data [Single Users Object, Array of Employees Objects] (Required)
@param generate_objects [Boolean] (Optional)
Caution: Hurts performance -> Only use if performing further edits after object creation
@return [JSON object] HTTP response JSON object. Returns Employees objects array if generate_objects flag is set
@example
rest_client.update_employees(employees_obj)
rest_client.update_employees(employees_obj,true)
rest_client.update_employees(employees_obj_array)
rest_client.update_employees(employees_obj_array,true) | [
"Update",
"Employees",
"."
]
| 74215403c8b06343b02fcbfb09f0dd550ef96eb2 | https://github.com/axomic/openasset-rest-ruby/blob/74215403c8b06343b02fcbfb09f0dd550ef96eb2/lib/openasset-rest-client.rb#L2050-L2053 | train |
DigitPaint/roger | lib/roger/server.rb | Roger.Server.set_options | def set_options(options)
self.port = options[:port].to_i if options.key?(:port)
self.handler = options[:handler] if options.key?(:handler)
self.host = options[:host] if options.key?(:host)
self.auto_port = options[:auto_port] if options.key?(:auto_port)
end | ruby | def set_options(options)
self.port = options[:port].to_i if options.key?(:port)
self.handler = options[:handler] if options.key?(:handler)
self.host = options[:host] if options.key?(:host)
self.auto_port = options[:auto_port] if options.key?(:auto_port)
end | [
"def",
"set_options",
"(",
"options",
")",
"self",
".",
"port",
"=",
"options",
"[",
":port",
"]",
".",
"to_i",
"if",
"options",
".",
"key?",
"(",
":port",
")",
"self",
".",
"handler",
"=",
"options",
"[",
":handler",
"]",
"if",
"options",
".",
"key?",
"(",
":handler",
")",
"self",
".",
"host",
"=",
"options",
"[",
":host",
"]",
"if",
"options",
".",
"key?",
"(",
":host",
")",
"self",
".",
"auto_port",
"=",
"options",
"[",
":auto_port",
"]",
"if",
"options",
".",
"key?",
"(",
":auto_port",
")",
"end"
]
| Sets the options, this is a separate method as we want to override certain
things set in the rogerfile from the commandline | [
"Sets",
"the",
"options",
"this",
"is",
"a",
"separate",
"method",
"as",
"we",
"want",
"to",
"override",
"certain",
"things",
"set",
"in",
"the",
"rogerfile",
"from",
"the",
"commandline"
]
| 1153119f170d1b0289b659a52fcbf054df2d9633 | https://github.com/DigitPaint/roger/blob/1153119f170d1b0289b659a52fcbf054df2d9633/lib/roger/server.rb#L57-L62 | train |
DigitPaint/roger | lib/roger/server.rb | Roger.Server.free_port_for_host_above | def free_port_for_host_above(host, port)
test_port = port
test_port += 1 until port_free?(host, test_port) || port + 100 <= test_port
test_port
end | ruby | def free_port_for_host_above(host, port)
test_port = port
test_port += 1 until port_free?(host, test_port) || port + 100 <= test_port
test_port
end | [
"def",
"free_port_for_host_above",
"(",
"host",
",",
"port",
")",
"test_port",
"=",
"port",
"test_port",
"+=",
"1",
"until",
"port_free?",
"(",
"host",
",",
"test_port",
")",
"||",
"port",
"+",
"100",
"<=",
"test_port",
"test_port",
"end"
]
| Get the first free port for host above port
Will only ever test 100 ports. | [
"Get",
"the",
"first",
"free",
"port",
"for",
"host",
"above",
"port",
"Will",
"only",
"ever",
"test",
"100",
"ports",
"."
]
| 1153119f170d1b0289b659a52fcbf054df2d9633 | https://github.com/DigitPaint/roger/blob/1153119f170d1b0289b659a52fcbf054df2d9633/lib/roger/server.rb#L132-L136 | train |
DigitPaint/roger | lib/roger/server.rb | Roger.Server.port_free? | def port_free?(host, port)
Addrinfo.tcp(host, port).listen.close
true
rescue SocketError, Errno::EADDRINUSE, Errno::EACCES
false
end | ruby | def port_free?(host, port)
Addrinfo.tcp(host, port).listen.close
true
rescue SocketError, Errno::EADDRINUSE, Errno::EACCES
false
end | [
"def",
"port_free?",
"(",
"host",
",",
"port",
")",
"Addrinfo",
".",
"tcp",
"(",
"host",
",",
"port",
")",
".",
"listen",
".",
"close",
"true",
"rescue",
"SocketError",
",",
"Errno",
"::",
"EADDRINUSE",
",",
"Errno",
"::",
"EACCES",
"false",
"end"
]
| See if a certain port is free on a certain host | [
"See",
"if",
"a",
"certain",
"port",
"is",
"free",
"on",
"a",
"certain",
"host"
]
| 1153119f170d1b0289b659a52fcbf054df2d9633 | https://github.com/DigitPaint/roger/blob/1153119f170d1b0289b659a52fcbf054df2d9633/lib/roger/server.rb#L139-L145 | train |
DigitPaint/roger | lib/roger/server.rb | Roger.Server.detect_valid_handler | def detect_valid_handler(servers)
handler = nil
while (server_name = servers.shift) && handler.nil?
begin
handler = ::Rack::Handler.get(server_name)
return [handler, server_name]
rescue LoadError
handler = nil
rescue NameError
handler = nil
end
end
end | ruby | def detect_valid_handler(servers)
handler = nil
while (server_name = servers.shift) && handler.nil?
begin
handler = ::Rack::Handler.get(server_name)
return [handler, server_name]
rescue LoadError
handler = nil
rescue NameError
handler = nil
end
end
end | [
"def",
"detect_valid_handler",
"(",
"servers",
")",
"handler",
"=",
"nil",
"while",
"(",
"server_name",
"=",
"servers",
".",
"shift",
")",
"&&",
"handler",
".",
"nil?",
"begin",
"handler",
"=",
"::",
"Rack",
"::",
"Handler",
".",
"get",
"(",
"server_name",
")",
"return",
"[",
"handler",
",",
"server_name",
"]",
"rescue",
"LoadError",
"handler",
"=",
"nil",
"rescue",
"NameError",
"handler",
"=",
"nil",
"end",
"end",
"end"
]
| See what handlers work | [
"See",
"what",
"handlers",
"work"
]
| 1153119f170d1b0289b659a52fcbf054df2d9633 | https://github.com/DigitPaint/roger/blob/1153119f170d1b0289b659a52fcbf054df2d9633/lib/roger/server.rb#L202-L214 | train |
DigitPaint/roger | lib/roger/template.rb | Roger.Template.render_with_tilt_template | def render_with_tilt_template(template_class, src, locals, &_block)
@current_tilt_template = template_class
template = template_class.new(source_path) { src }
block_content = if block_given?
yield
else
""
end
template.render(@context, locals) do |name|
if name
@context._content_for_blocks[name]
else
block_content
end
end
end | ruby | def render_with_tilt_template(template_class, src, locals, &_block)
@current_tilt_template = template_class
template = template_class.new(source_path) { src }
block_content = if block_given?
yield
else
""
end
template.render(@context, locals) do |name|
if name
@context._content_for_blocks[name]
else
block_content
end
end
end | [
"def",
"render_with_tilt_template",
"(",
"template_class",
",",
"src",
",",
"locals",
",",
"&",
"_block",
")",
"@current_tilt_template",
"=",
"template_class",
"template",
"=",
"template_class",
".",
"new",
"(",
"source_path",
")",
"{",
"src",
"}",
"block_content",
"=",
"if",
"block_given?",
"yield",
"else",
"\"\"",
"end",
"template",
".",
"render",
"(",
"@context",
",",
"locals",
")",
"do",
"|",
"name",
"|",
"if",
"name",
"@context",
".",
"_content_for_blocks",
"[",
"name",
"]",
"else",
"block_content",
"end",
"end",
"end"
]
| Render source with a specific tilt template class | [
"Render",
"source",
"with",
"a",
"specific",
"tilt",
"template",
"class"
]
| 1153119f170d1b0289b659a52fcbf054df2d9633 | https://github.com/DigitPaint/roger/blob/1153119f170d1b0289b659a52fcbf054df2d9633/lib/roger/template.rb#L70-L87 | train |
DigitPaint/roger | lib/roger/template.rb | Roger.Template.extract_front_matter | def extract_front_matter(source)
fm_regex = /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
return [{}, source] unless match = source.match(fm_regex)
source = source.sub(fm_regex, "")
begin
data = (YAML.safe_load(match[1]) || {}).inject({}) do |memo, (k, v)|
memo[k.to_sym] = v
memo
end
rescue *YAML_ERRORS => e
puts "YAML Exception: #{e.message}"
return false
end
[data, source]
rescue
[{}, source]
end | ruby | def extract_front_matter(source)
fm_regex = /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
return [{}, source] unless match = source.match(fm_regex)
source = source.sub(fm_regex, "")
begin
data = (YAML.safe_load(match[1]) || {}).inject({}) do |memo, (k, v)|
memo[k.to_sym] = v
memo
end
rescue *YAML_ERRORS => e
puts "YAML Exception: #{e.message}"
return false
end
[data, source]
rescue
[{}, source]
end | [
"def",
"extract_front_matter",
"(",
"source",
")",
"fm_regex",
"=",
"/",
"\\A",
"\\s",
"\\n",
"\\n",
"\\s",
"\\n",
"/m",
"return",
"[",
"{",
"}",
",",
"source",
"]",
"unless",
"match",
"=",
"source",
".",
"match",
"(",
"fm_regex",
")",
"source",
"=",
"source",
".",
"sub",
"(",
"fm_regex",
",",
"\"\"",
")",
"begin",
"data",
"=",
"(",
"YAML",
".",
"safe_load",
"(",
"match",
"[",
"1",
"]",
")",
"||",
"{",
"}",
")",
".",
"inject",
"(",
"{",
"}",
")",
"do",
"|",
"memo",
",",
"(",
"k",
",",
"v",
")",
"|",
"memo",
"[",
"k",
".",
"to_sym",
"]",
"=",
"v",
"memo",
"end",
"rescue",
"*",
"YAML_ERRORS",
"=>",
"e",
"puts",
"\"YAML Exception: #{e.message}\"",
"return",
"false",
"end",
"[",
"data",
",",
"source",
"]",
"rescue",
"[",
"{",
"}",
",",
"source",
"]",
"end"
]
| Get the front matter portion of the file and extract it. | [
"Get",
"the",
"front",
"matter",
"portion",
"of",
"the",
"file",
"and",
"extract",
"it",
"."
]
| 1153119f170d1b0289b659a52fcbf054df2d9633 | https://github.com/DigitPaint/roger/blob/1153119f170d1b0289b659a52fcbf054df2d9633/lib/roger/template.rb#L90-L110 | train |
DigitPaint/roger | lib/roger/release.rb | Roger.Release.use | def use(processor, options = {})
@stack << [self.class.get_callable(processor, Roger::Release::Processors.map), options]
end | ruby | def use(processor, options = {})
@stack << [self.class.get_callable(processor, Roger::Release::Processors.map), options]
end | [
"def",
"use",
"(",
"processor",
",",
"options",
"=",
"{",
"}",
")",
"@stack",
"<<",
"[",
"self",
".",
"class",
".",
"get_callable",
"(",
"processor",
",",
"Roger",
"::",
"Release",
"::",
"Processors",
".",
"map",
")",
",",
"options",
"]",
"end"
]
| Use a certain pre-processor
@examples
release.use :sprockets, sprockets_config | [
"Use",
"a",
"certain",
"pre",
"-",
"processor"
]
| 1153119f170d1b0289b659a52fcbf054df2d9633 | https://github.com/DigitPaint/roger/blob/1153119f170d1b0289b659a52fcbf054df2d9633/lib/roger/release.rb#L112-L114 | train |
DigitPaint/roger | lib/roger/release.rb | Roger.Release.run! | def run!
project.mode = :release
# Validate paths
validate_paths!
# Extract mockup
copy_source_path_to_build_path!
validate_stack!
# Run stack
run_stack!
# Cleanup
cleanup! if config[:cleanup_build]
ensure
project.mode = nil
end | ruby | def run!
project.mode = :release
# Validate paths
validate_paths!
# Extract mockup
copy_source_path_to_build_path!
validate_stack!
# Run stack
run_stack!
# Cleanup
cleanup! if config[:cleanup_build]
ensure
project.mode = nil
end | [
"def",
"run!",
"project",
".",
"mode",
"=",
":release",
"validate_paths!",
"copy_source_path_to_build_path!",
"validate_stack!",
"run_stack!",
"cleanup!",
"if",
"config",
"[",
":cleanup_build",
"]",
"ensure",
"project",
".",
"mode",
"=",
"nil",
"end"
]
| Actually perform the release | [
"Actually",
"perform",
"the",
"release"
]
| 1153119f170d1b0289b659a52fcbf054df2d9633 | https://github.com/DigitPaint/roger/blob/1153119f170d1b0289b659a52fcbf054df2d9633/lib/roger/release.rb#L171-L189 | train |
DigitPaint/roger | lib/roger/cli/serve.rb | Roger.Cli::Serve.serve | def serve
server_options = {}
options.each { |k, v| server_options[k.to_sym] = v }
server_options[:server] = {}
[:port, :handler, :host].each do |k|
server_options[:server][k] = server_options.delete(k) if server_options.key?(k)
end
@project.server.set_options(server_options[:server])
end | ruby | def serve
server_options = {}
options.each { |k, v| server_options[k.to_sym] = v }
server_options[:server] = {}
[:port, :handler, :host].each do |k|
server_options[:server][k] = server_options.delete(k) if server_options.key?(k)
end
@project.server.set_options(server_options[:server])
end | [
"def",
"serve",
"server_options",
"=",
"{",
"}",
"options",
".",
"each",
"{",
"|",
"k",
",",
"v",
"|",
"server_options",
"[",
"k",
".",
"to_sym",
"]",
"=",
"v",
"}",
"server_options",
"[",
":server",
"]",
"=",
"{",
"}",
"[",
":port",
",",
":handler",
",",
":host",
"]",
".",
"each",
"do",
"|",
"k",
"|",
"server_options",
"[",
":server",
"]",
"[",
"k",
"]",
"=",
"server_options",
".",
"delete",
"(",
"k",
")",
"if",
"server_options",
".",
"key?",
"(",
"k",
")",
"end",
"@project",
".",
"server",
".",
"set_options",
"(",
"server_options",
"[",
":server",
"]",
")",
"end"
]
| The handler to use | [
"The",
"handler",
"to",
"use"
]
| 1153119f170d1b0289b659a52fcbf054df2d9633 | https://github.com/DigitPaint/roger/blob/1153119f170d1b0289b659a52fcbf054df2d9633/lib/roger/cli/serve.rb#L10-L19 | train |
DigitPaint/roger | lib/roger/rogerfile.rb | Roger.Rogerfile.load | def load
return unless File.exist?(@path) && !loaded?
@source = File.read(@path)
context = Context.new(self)
eval @source, context.binding, @path.to_s, 1 # rubocop:disable Lint/Eval
@loaded = true
end | ruby | def load
return unless File.exist?(@path) && !loaded?
@source = File.read(@path)
context = Context.new(self)
eval @source, context.binding, @path.to_s, 1 # rubocop:disable Lint/Eval
@loaded = true
end | [
"def",
"load",
"return",
"unless",
"File",
".",
"exist?",
"(",
"@path",
")",
"&&",
"!",
"loaded?",
"@source",
"=",
"File",
".",
"read",
"(",
"@path",
")",
"context",
"=",
"Context",
".",
"new",
"(",
"self",
")",
"eval",
"@source",
",",
"context",
".",
"binding",
",",
"@path",
".",
"to_s",
",",
"1",
"@loaded",
"=",
"true",
"end"
]
| Actually load the rogerfile | [
"Actually",
"load",
"the",
"rogerfile"
]
| 1153119f170d1b0289b659a52fcbf054df2d9633 | https://github.com/DigitPaint/roger/blob/1153119f170d1b0289b659a52fcbf054df2d9633/lib/roger/rogerfile.rb#L36-L43 | train |
DigitPaint/roger | lib/roger/renderer.rb | Roger.Renderer.render | def render(path, options = {}, &block)
template, layout = template_and_layout_for_render(path, options)
# Set new current template
template_nesting.push(template)
# Copy data to our data store. A bit clunky; as this should be inherited
@data = {}.update(@data).update(template.data)
# Render the template first so we have access to
# it's data in the layout.
render_result = template.render(options[:locals] || {}, &block)
# Wrap it in a layout
layout.render do
render_result
end
ensure
# Only pop the template from the nesting if we actually
# put it on the nesting stack.
template_nesting.pop if template
end | ruby | def render(path, options = {}, &block)
template, layout = template_and_layout_for_render(path, options)
# Set new current template
template_nesting.push(template)
# Copy data to our data store. A bit clunky; as this should be inherited
@data = {}.update(@data).update(template.data)
# Render the template first so we have access to
# it's data in the layout.
render_result = template.render(options[:locals] || {}, &block)
# Wrap it in a layout
layout.render do
render_result
end
ensure
# Only pop the template from the nesting if we actually
# put it on the nesting stack.
template_nesting.pop if template
end | [
"def",
"render",
"(",
"path",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"template",
",",
"layout",
"=",
"template_and_layout_for_render",
"(",
"path",
",",
"options",
")",
"template_nesting",
".",
"push",
"(",
"template",
")",
"@data",
"=",
"{",
"}",
".",
"update",
"(",
"@data",
")",
".",
"update",
"(",
"template",
".",
"data",
")",
"render_result",
"=",
"template",
".",
"render",
"(",
"options",
"[",
":locals",
"]",
"||",
"{",
"}",
",",
"&",
"block",
")",
"layout",
".",
"render",
"do",
"render_result",
"end",
"ensure",
"template_nesting",
".",
"pop",
"if",
"template",
"end"
]
| The render function
The render function will take care of rendering the right thing
in the right context. It will:
- Wrap templates with layouts if it's defined in the frontmatter and
load them from the right layout path.
- Render only partials if called from within an existing template
If you just want to render an arbitrary file, use #render_file instead
@option options [Hash] :locals Locals to use during rendering
@option options [String] :source The source for the template
@option options [String, nil] :layout The default layout to use | [
"The",
"render",
"function"
]
| 1153119f170d1b0289b659a52fcbf054df2d9633 | https://github.com/DigitPaint/roger/blob/1153119f170d1b0289b659a52fcbf054df2d9633/lib/roger/renderer.rb#L122-L143 | train |
DigitPaint/roger | lib/roger/renderer.rb | Roger.Renderer.render_file | def render_file(path, options = {})
pn = absolute_path_from_current_template(path)
template = template(pn.to_s, nil)
# Track rendered file also on the rendered stack
template_nesting.push(template)
template.render(options[:locals] || {})
ensure
# Only pop the template from the nesting if we actually
# put it on the nesting stack.
template_nesting.pop if template
end | ruby | def render_file(path, options = {})
pn = absolute_path_from_current_template(path)
template = template(pn.to_s, nil)
# Track rendered file also on the rendered stack
template_nesting.push(template)
template.render(options[:locals] || {})
ensure
# Only pop the template from the nesting if we actually
# put it on the nesting stack.
template_nesting.pop if template
end | [
"def",
"render_file",
"(",
"path",
",",
"options",
"=",
"{",
"}",
")",
"pn",
"=",
"absolute_path_from_current_template",
"(",
"path",
")",
"template",
"=",
"template",
"(",
"pn",
".",
"to_s",
",",
"nil",
")",
"template_nesting",
".",
"push",
"(",
"template",
")",
"template",
".",
"render",
"(",
"options",
"[",
":locals",
"]",
"||",
"{",
"}",
")",
"ensure",
"template_nesting",
".",
"pop",
"if",
"template",
"end"
]
| Render any file on disk. No magic. Just rendering.
A couple of things to keep in mind:
- The file will be rendered in this rendering context
- Does not have layouts or block style
- When you pass a relative path and we are within another template
it will be relative to that template.
@options options [Hash] :locals | [
"Render",
"any",
"file",
"on",
"disk",
".",
"No",
"magic",
".",
"Just",
"rendering",
"."
]
| 1153119f170d1b0289b659a52fcbf054df2d9633 | https://github.com/DigitPaint/roger/blob/1153119f170d1b0289b659a52fcbf054df2d9633/lib/roger/renderer.rb#L154-L167 | train |
DigitPaint/roger | lib/roger/renderer.rb | Roger.Renderer.layout_for_template | def layout_for_template(template, options)
layout_name = if template.data.key?(:layout)
template.data[:layout]
else
get_default_layout(template, options)
end
# Only attempt to load layout when:
# - Template is the toplevel template
# - A layout_name is available
return BlankTemplate.new if current_template || !layout_name
template(layout_name, nil, :layout)
end | ruby | def layout_for_template(template, options)
layout_name = if template.data.key?(:layout)
template.data[:layout]
else
get_default_layout(template, options)
end
# Only attempt to load layout when:
# - Template is the toplevel template
# - A layout_name is available
return BlankTemplate.new if current_template || !layout_name
template(layout_name, nil, :layout)
end | [
"def",
"layout_for_template",
"(",
"template",
",",
"options",
")",
"layout_name",
"=",
"if",
"template",
".",
"data",
".",
"key?",
"(",
":layout",
")",
"template",
".",
"data",
"[",
":layout",
"]",
"else",
"get_default_layout",
"(",
"template",
",",
"options",
")",
"end",
"return",
"BlankTemplate",
".",
"new",
"if",
"current_template",
"||",
"!",
"layout_name",
"template",
"(",
"layout_name",
",",
"nil",
",",
":layout",
")",
"end"
]
| Gets the layout for a specific template | [
"Gets",
"the",
"layout",
"for",
"a",
"specific",
"template"
]
| 1153119f170d1b0289b659a52fcbf054df2d9633 | https://github.com/DigitPaint/roger/blob/1153119f170d1b0289b659a52fcbf054df2d9633/lib/roger/renderer.rb#L211-L224 | train |
DigitPaint/roger | lib/roger/renderer.rb | Roger.Renderer.prevent_recursion! | def prevent_recursion!(template)
# If this template is not a real file it cannot ever conflict.
return unless template.real_source_path
caller_templates = template_nesting.select do |t|
t.real_source_path == template.real_source_path
end
# We're good, no deeper recursion then MAX_ALLOWED_TEMPLATE_NESTING
return if caller_templates.length <= MAX_ALLOWED_TEMPLATE_NESTING
err = "Recursive render detected for '#{template.source_path}'"
err += " in '#{current_template.source_path}'"
raise ArgumentError, err
end | ruby | def prevent_recursion!(template)
# If this template is not a real file it cannot ever conflict.
return unless template.real_source_path
caller_templates = template_nesting.select do |t|
t.real_source_path == template.real_source_path
end
# We're good, no deeper recursion then MAX_ALLOWED_TEMPLATE_NESTING
return if caller_templates.length <= MAX_ALLOWED_TEMPLATE_NESTING
err = "Recursive render detected for '#{template.source_path}'"
err += " in '#{current_template.source_path}'"
raise ArgumentError, err
end | [
"def",
"prevent_recursion!",
"(",
"template",
")",
"return",
"unless",
"template",
".",
"real_source_path",
"caller_templates",
"=",
"template_nesting",
".",
"select",
"do",
"|",
"t",
"|",
"t",
".",
"real_source_path",
"==",
"template",
".",
"real_source_path",
"end",
"return",
"if",
"caller_templates",
".",
"length",
"<=",
"MAX_ALLOWED_TEMPLATE_NESTING",
"err",
"=",
"\"Recursive render detected for '#{template.source_path}'\"",
"err",
"+=",
"\" in '#{current_template.source_path}'\"",
"raise",
"ArgumentError",
",",
"err",
"end"
]
| Will check the template nesting if we haven't already
rendered this path before. If it has we'll throw an argumenteerror | [
"Will",
"check",
"the",
"template",
"nesting",
"if",
"we",
"haven",
"t",
"already",
"rendered",
"this",
"path",
"before",
".",
"If",
"it",
"has",
"we",
"ll",
"throw",
"an",
"argumenteerror"
]
| 1153119f170d1b0289b659a52fcbf054df2d9633 | https://github.com/DigitPaint/roger/blob/1153119f170d1b0289b659a52fcbf054df2d9633/lib/roger/renderer.rb#L237-L252 | train |
DigitPaint/roger | lib/roger/renderer.rb | Roger.Renderer.template | def template(path, source, type = :template)
if source
template = Template.new(source, @context, source_path: path)
else
template_path = case type
when :partial
find_partial(path)
when :layout
find_layout(path)
else
path
end
if template_path && File.exist?(template_path)
template = Template.open(template_path, @context)
else
template_not_found!(type, path)
end
end
prevent_recursion!(template)
template
end | ruby | def template(path, source, type = :template)
if source
template = Template.new(source, @context, source_path: path)
else
template_path = case type
when :partial
find_partial(path)
when :layout
find_layout(path)
else
path
end
if template_path && File.exist?(template_path)
template = Template.open(template_path, @context)
else
template_not_found!(type, path)
end
end
prevent_recursion!(template)
template
end | [
"def",
"template",
"(",
"path",
",",
"source",
",",
"type",
"=",
":template",
")",
"if",
"source",
"template",
"=",
"Template",
".",
"new",
"(",
"source",
",",
"@context",
",",
"source_path",
":",
"path",
")",
"else",
"template_path",
"=",
"case",
"type",
"when",
":partial",
"find_partial",
"(",
"path",
")",
"when",
":layout",
"find_layout",
"(",
"path",
")",
"else",
"path",
"end",
"if",
"template_path",
"&&",
"File",
".",
"exist?",
"(",
"template_path",
")",
"template",
"=",
"Template",
".",
"open",
"(",
"template_path",
",",
"@context",
")",
"else",
"template_not_found!",
"(",
"type",
",",
"path",
")",
"end",
"end",
"prevent_recursion!",
"(",
"template",
")",
"template",
"end"
]
| Will instantiate a Template or throw an ArgumentError
if it could not find the template | [
"Will",
"instantiate",
"a",
"Template",
"or",
"throw",
"an",
"ArgumentError",
"if",
"it",
"could",
"not",
"find",
"the",
"template"
]
| 1153119f170d1b0289b659a52fcbf054df2d9633 | https://github.com/DigitPaint/roger/blob/1153119f170d1b0289b659a52fcbf054df2d9633/lib/roger/renderer.rb#L256-L279 | train |
DigitPaint/roger | lib/roger/renderer.rb | Roger.Renderer.find_partial | def find_partial(name)
current_path, current_ext = current_template_path_and_extension
# Try to find _ named partials first.
# This will alaso search for partials relative to the current path
local_name = [File.dirname(name), "_" + File.basename(name)].join("/")
resolver = Resolver.new([File.dirname(current_path)] + @paths[:partials])
result = resolver.find_template(local_name, prefer: current_ext)
return result if result
# Try to look for templates the old way
resolver = Resolver.new(@paths[:partials])
resolver.find_template(name, prefer: current_ext)
end | ruby | def find_partial(name)
current_path, current_ext = current_template_path_and_extension
# Try to find _ named partials first.
# This will alaso search for partials relative to the current path
local_name = [File.dirname(name), "_" + File.basename(name)].join("/")
resolver = Resolver.new([File.dirname(current_path)] + @paths[:partials])
result = resolver.find_template(local_name, prefer: current_ext)
return result if result
# Try to look for templates the old way
resolver = Resolver.new(@paths[:partials])
resolver.find_template(name, prefer: current_ext)
end | [
"def",
"find_partial",
"(",
"name",
")",
"current_path",
",",
"current_ext",
"=",
"current_template_path_and_extension",
"local_name",
"=",
"[",
"File",
".",
"dirname",
"(",
"name",
")",
",",
"\"_\"",
"+",
"File",
".",
"basename",
"(",
"name",
")",
"]",
".",
"join",
"(",
"\"/\"",
")",
"resolver",
"=",
"Resolver",
".",
"new",
"(",
"[",
"File",
".",
"dirname",
"(",
"current_path",
")",
"]",
"+",
"@paths",
"[",
":partials",
"]",
")",
"result",
"=",
"resolver",
".",
"find_template",
"(",
"local_name",
",",
"prefer",
":",
"current_ext",
")",
"return",
"result",
"if",
"result",
"resolver",
"=",
"Resolver",
".",
"new",
"(",
"@paths",
"[",
":partials",
"]",
")",
"resolver",
".",
"find_template",
"(",
"name",
",",
"prefer",
":",
"current_ext",
")",
"end"
]
| Find a partial | [
"Find",
"a",
"partial"
]
| 1153119f170d1b0289b659a52fcbf054df2d9633 | https://github.com/DigitPaint/roger/blob/1153119f170d1b0289b659a52fcbf054df2d9633/lib/roger/renderer.rb#L288-L302 | train |
DigitPaint/roger | lib/roger/renderer.rb | Roger.Renderer.prepare_context | def prepare_context(env)
context = Roger::Template::TemplateContext.new(self, env)
# Extend context with all helpers
self.class.helpers.each do |mod|
context.extend(mod)
end
context
end | ruby | def prepare_context(env)
context = Roger::Template::TemplateContext.new(self, env)
# Extend context with all helpers
self.class.helpers.each do |mod|
context.extend(mod)
end
context
end | [
"def",
"prepare_context",
"(",
"env",
")",
"context",
"=",
"Roger",
"::",
"Template",
"::",
"TemplateContext",
".",
"new",
"(",
"self",
",",
"env",
")",
"self",
".",
"class",
".",
"helpers",
".",
"each",
"do",
"|",
"mod",
"|",
"context",
".",
"extend",
"(",
"mod",
")",
"end",
"context",
"end"
]
| Will set up a new template context for this renderer | [
"Will",
"set",
"up",
"a",
"new",
"template",
"context",
"for",
"this",
"renderer"
]
| 1153119f170d1b0289b659a52fcbf054df2d9633 | https://github.com/DigitPaint/roger/blob/1153119f170d1b0289b659a52fcbf054df2d9633/lib/roger/renderer.rb#L325-L334 | train |
DigitPaint/roger | lib/roger/release/processors/mockup.rb | Roger::Release::Processors.Mockup.run_on_file | def run_on_file(file_path, env = {})
renderer = Roger::Renderer.new(
env.dup,
partials_path: project.partial_path,
layouts_path: project.layouts_path
)
renderer.render(file_path, project.options[:renderer] || {})
end | ruby | def run_on_file(file_path, env = {})
renderer = Roger::Renderer.new(
env.dup,
partials_path: project.partial_path,
layouts_path: project.layouts_path
)
renderer.render(file_path, project.options[:renderer] || {})
end | [
"def",
"run_on_file",
"(",
"file_path",
",",
"env",
"=",
"{",
"}",
")",
"renderer",
"=",
"Roger",
"::",
"Renderer",
".",
"new",
"(",
"env",
".",
"dup",
",",
"partials_path",
":",
"project",
".",
"partial_path",
",",
"layouts_path",
":",
"project",
".",
"layouts_path",
")",
"renderer",
".",
"render",
"(",
"file_path",
",",
"project",
".",
"options",
"[",
":renderer",
"]",
"||",
"{",
"}",
")",
"end"
]
| Runs the template on a single file and return processed source. | [
"Runs",
"the",
"template",
"on",
"a",
"single",
"file",
"and",
"return",
"processed",
"source",
"."
]
| 1153119f170d1b0289b659a52fcbf054df2d9633 | https://github.com/DigitPaint/roger/blob/1153119f170d1b0289b659a52fcbf054df2d9633/lib/roger/release/processors/mockup.rb#L59-L66 | train |
DigitPaint/roger | lib/roger/resolver.rb | Roger.Resolver.find_template_path | def find_template_path(name, options = {})
options = {
prefer: "html", # Prefer a template with extension
}.update(options)
path = sanitize_name(name, options[:prefer])
# Exact match
return Pathname.new(path) if File.exist?(path)
# Split extension and path
path_extension, path_without_extension = split_path(path)
# Get possible output extensions for path_extension
template_extensions = template_extensions_for_output(path_extension, options[:prefer])
# Let's look at the disk to see what files we've got
files = Dir.glob(path_without_extension + ".*")
results = filter_files(files, path, path_without_extension, template_extensions)
if !results[0]
# No results found, but maybe there is a directory
# with the same name and it contains an index.XYZ
find_template_path(File.join(name, "index")) if File.directory?(name)
else
Pathname.new(results[0])
end
end | ruby | def find_template_path(name, options = {})
options = {
prefer: "html", # Prefer a template with extension
}.update(options)
path = sanitize_name(name, options[:prefer])
# Exact match
return Pathname.new(path) if File.exist?(path)
# Split extension and path
path_extension, path_without_extension = split_path(path)
# Get possible output extensions for path_extension
template_extensions = template_extensions_for_output(path_extension, options[:prefer])
# Let's look at the disk to see what files we've got
files = Dir.glob(path_without_extension + ".*")
results = filter_files(files, path, path_without_extension, template_extensions)
if !results[0]
# No results found, but maybe there is a directory
# with the same name and it contains an index.XYZ
find_template_path(File.join(name, "index")) if File.directory?(name)
else
Pathname.new(results[0])
end
end | [
"def",
"find_template_path",
"(",
"name",
",",
"options",
"=",
"{",
"}",
")",
"options",
"=",
"{",
"prefer",
":",
"\"html\"",
",",
"}",
".",
"update",
"(",
"options",
")",
"path",
"=",
"sanitize_name",
"(",
"name",
",",
"options",
"[",
":prefer",
"]",
")",
"return",
"Pathname",
".",
"new",
"(",
"path",
")",
"if",
"File",
".",
"exist?",
"(",
"path",
")",
"path_extension",
",",
"path_without_extension",
"=",
"split_path",
"(",
"path",
")",
"template_extensions",
"=",
"template_extensions_for_output",
"(",
"path_extension",
",",
"options",
"[",
":prefer",
"]",
")",
"files",
"=",
"Dir",
".",
"glob",
"(",
"path_without_extension",
"+",
"\".*\"",
")",
"results",
"=",
"filter_files",
"(",
"files",
",",
"path",
",",
"path_without_extension",
",",
"template_extensions",
")",
"if",
"!",
"results",
"[",
"0",
"]",
"find_template_path",
"(",
"File",
".",
"join",
"(",
"name",
",",
"\"index\"",
")",
")",
"if",
"File",
".",
"directory?",
"(",
"name",
")",
"else",
"Pathname",
".",
"new",
"(",
"results",
"[",
"0",
"]",
")",
"end",
"end"
]
| Finds the template path for "name" | [
"Finds",
"the",
"template",
"path",
"for",
"name"
]
| 1153119f170d1b0289b659a52fcbf054df2d9633 | https://github.com/DigitPaint/roger/blob/1153119f170d1b0289b659a52fcbf054df2d9633/lib/roger/resolver.rb#L117-L145 | train |
DigitPaint/roger | lib/roger/resolver.rb | Roger.Resolver.filter_files | def filter_files(files, path, path_without_extension, template_extensions)
results = []
files.each do |file|
match = if file.start_with?(path)
path
else
path_without_extension
end
processable_extensions = file[(match.length + 1)..-1].split(".")
# All processable_extensions must be processable
# by a template_extension
next unless (processable_extensions - template_extensions).empty?
if file.start_with?(path)
# The whole path is found in the filename, not just
# the path without the extension.
# it must have priority over all else
results.unshift(file)
else
results.push(file)
end
end
results
end | ruby | def filter_files(files, path, path_without_extension, template_extensions)
results = []
files.each do |file|
match = if file.start_with?(path)
path
else
path_without_extension
end
processable_extensions = file[(match.length + 1)..-1].split(".")
# All processable_extensions must be processable
# by a template_extension
next unless (processable_extensions - template_extensions).empty?
if file.start_with?(path)
# The whole path is found in the filename, not just
# the path without the extension.
# it must have priority over all else
results.unshift(file)
else
results.push(file)
end
end
results
end | [
"def",
"filter_files",
"(",
"files",
",",
"path",
",",
"path_without_extension",
",",
"template_extensions",
")",
"results",
"=",
"[",
"]",
"files",
".",
"each",
"do",
"|",
"file",
"|",
"match",
"=",
"if",
"file",
".",
"start_with?",
"(",
"path",
")",
"path",
"else",
"path_without_extension",
"end",
"processable_extensions",
"=",
"file",
"[",
"(",
"match",
".",
"length",
"+",
"1",
")",
"..",
"-",
"1",
"]",
".",
"split",
"(",
"\".\"",
")",
"next",
"unless",
"(",
"processable_extensions",
"-",
"template_extensions",
")",
".",
"empty?",
"if",
"file",
".",
"start_with?",
"(",
"path",
")",
"results",
".",
"unshift",
"(",
"file",
")",
"else",
"results",
".",
"push",
"(",
"file",
")",
"end",
"end",
"results",
"end"
]
| Filter a list of files to see wether or not we can process them.
Will take into account that the longest match with path will
be the first result. | [
"Filter",
"a",
"list",
"of",
"files",
"to",
"see",
"wether",
"or",
"not",
"we",
"can",
"process",
"them",
".",
"Will",
"take",
"into",
"account",
"that",
"the",
"longest",
"match",
"with",
"path",
"will",
"be",
"the",
"first",
"result",
"."
]
| 1153119f170d1b0289b659a52fcbf054df2d9633 | https://github.com/DigitPaint/roger/blob/1153119f170d1b0289b659a52fcbf054df2d9633/lib/roger/resolver.rb#L150-L176 | train |
DigitPaint/roger | lib/roger/resolver.rb | Roger.Resolver.sanitize_name | def sanitize_name(name, prefer = nil)
path = name.to_s
# Check if we haven't got an extension
# we'll assume you're looking for prefer or "html" otherwise
path += ".#{prefer || 'html'}" unless File.basename(path).include?(".")
path
end | ruby | def sanitize_name(name, prefer = nil)
path = name.to_s
# Check if we haven't got an extension
# we'll assume you're looking for prefer or "html" otherwise
path += ".#{prefer || 'html'}" unless File.basename(path).include?(".")
path
end | [
"def",
"sanitize_name",
"(",
"name",
",",
"prefer",
"=",
"nil",
")",
"path",
"=",
"name",
".",
"to_s",
"path",
"+=",
"\".#{prefer || 'html'}\"",
"unless",
"File",
".",
"basename",
"(",
"path",
")",
".",
"include?",
"(",
"\".\"",
")",
"path",
"end"
]
| Check if the name is a directory and append index
Append preferred extension or html if it doesn't have one yet | [
"Check",
"if",
"the",
"name",
"is",
"a",
"directory",
"and",
"append",
"index",
"Append",
"preferred",
"extension",
"or",
"html",
"if",
"it",
"doesn",
"t",
"have",
"one",
"yet"
]
| 1153119f170d1b0289b659a52fcbf054df2d9633 | https://github.com/DigitPaint/roger/blob/1153119f170d1b0289b659a52fcbf054df2d9633/lib/roger/resolver.rb#L180-L188 | train |
para-cms/para | lib/para/cloneable.rb | Para.Cloneable.build_clone_callback | def build_clone_callback(callback)
case callback
when Proc
callback
when Symbol
->(original, clone) {
original.send(callback, clone) if original.respond_to?(callback, true)
}
end
end | ruby | def build_clone_callback(callback)
case callback
when Proc
callback
when Symbol
->(original, clone) {
original.send(callback, clone) if original.respond_to?(callback, true)
}
end
end | [
"def",
"build_clone_callback",
"(",
"callback",
")",
"case",
"callback",
"when",
"Proc",
"callback",
"when",
"Symbol",
"->",
"(",
"original",
",",
"clone",
")",
"{",
"original",
".",
"send",
"(",
"callback",
",",
"clone",
")",
"if",
"original",
".",
"respond_to?",
"(",
"callback",
",",
"true",
")",
"}",
"end",
"end"
]
| We ensure that the passed callback is actually callable on the object
we're cloning. This is needed for associations because deep_cloneable
calls the callback for every associated object. | [
"We",
"ensure",
"that",
"the",
"passed",
"callback",
"is",
"actually",
"callable",
"on",
"the",
"object",
"we",
"re",
"cloning",
".",
"This",
"is",
"needed",
"for",
"associations",
"because",
"deep_cloneable",
"calls",
"the",
"callback",
"for",
"every",
"associated",
"object",
"."
]
| 97364cf5ec91225d7f1a7665c47cd65514f2b072 | https://github.com/para-cms/para/blob/97364cf5ec91225d7f1a7665c47cd65514f2b072/lib/para/cloneable.rb#L36-L45 | train |
ManageIQ/more_core_extensions | lib/more_core_extensions/core_ext/benchmark/realtime_store.rb | MoreCoreExtensions.BenchmarkRealtimeStore.realtime_store | def realtime_store(hash, key)
ret = nil
r0 = Time.now
begin
ret = yield
ensure
r1 = Time.now
hash[key] = (hash[key] || 0) + (r1.to_f - r0.to_f)
end
ret
end | ruby | def realtime_store(hash, key)
ret = nil
r0 = Time.now
begin
ret = yield
ensure
r1 = Time.now
hash[key] = (hash[key] || 0) + (r1.to_f - r0.to_f)
end
ret
end | [
"def",
"realtime_store",
"(",
"hash",
",",
"key",
")",
"ret",
"=",
"nil",
"r0",
"=",
"Time",
".",
"now",
"begin",
"ret",
"=",
"yield",
"ensure",
"r1",
"=",
"Time",
".",
"now",
"hash",
"[",
"key",
"]",
"=",
"(",
"hash",
"[",
"key",
"]",
"||",
"0",
")",
"+",
"(",
"r1",
".",
"to_f",
"-",
"r0",
".",
"to_f",
")",
"end",
"ret",
"end"
]
| Stores the elapsed real time used to execute the given block in the given
hash for the given key and returns the result from the block. If the hash
already has a value for that key, the time is accumulated.
timings = {}
Benchmark.realtime_store(timings, :sleep) { sleep 2; "foo" } # => "foo"
timings # => {:sleep => 2.00}
Benchmark.realtime_store(timings, :sleep) { sleep 2; "bar" } # => "bar"
timings # => {:sleep => 4.00} | [
"Stores",
"the",
"elapsed",
"real",
"time",
"used",
"to",
"execute",
"the",
"given",
"block",
"in",
"the",
"given",
"hash",
"for",
"the",
"given",
"key",
"and",
"returns",
"the",
"result",
"from",
"the",
"block",
".",
"If",
"the",
"hash",
"already",
"has",
"a",
"value",
"for",
"that",
"key",
"the",
"time",
"is",
"accumulated",
"."
]
| 13f97a2a07155354117ea638eb0892fad09d5e44 | https://github.com/ManageIQ/more_core_extensions/blob/13f97a2a07155354117ea638eb0892fad09d5e44/lib/more_core_extensions/core_ext/benchmark/realtime_store.rb#L16-L26 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.