_id
stringlengths 2
6
| title
stringlengths 9
130
| partition
stringclasses 3
values | text
stringlengths 30
4.3k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q25100
|
Viewpoint::EWS::SOAP.EwsBuilder.folder_shape!
|
validation
|
def folder_shape!(folder_shape)
@nbuild.FolderShape {
@nbuild.parent.default_namespace = @default_ns
base_shape!(folder_shape[:base_shape])
|
ruby
|
{
"resource": ""
}
|
q25101
|
Viewpoint::EWS::SOAP.EwsBuilder.item_shape!
|
validation
|
def item_shape!(item_shape)
@nbuild[NS_EWS_MESSAGES].ItemShape {
@nbuild.parent.default_namespace = @default_ns
base_shape!(item_shape[:base_shape])
mime_content!(item_shape[:include_mime_content]) if item_shape.has_key?(:include_mime_content)
|
ruby
|
{
"resource": ""
}
|
q25102
|
Viewpoint::EWS::SOAP.EwsBuilder.indexed_page_item_view!
|
validation
|
def indexed_page_item_view!(indexed_page_item_view)
attribs = {}
indexed_page_item_view.each_pair {|k,v| attribs[camel_case(k)] = v.to_s}
|
ruby
|
{
"resource": ""
}
|
q25103
|
Viewpoint::EWS::SOAP.EwsBuilder.folder_ids!
|
validation
|
def folder_ids!(fids, act_as=nil)
ns = @nbuild.parent.name.match(/subscription/i) ? NS_EWS_TYPES : NS_EWS_MESSAGES
|
ruby
|
{
"resource": ""
}
|
q25104
|
Viewpoint::EWS::SOAP.EwsBuilder.distinguished_folder_id!
|
validation
|
def distinguished_folder_id!(dfid, change_key = nil, act_as = nil)
attribs = {'Id' => dfid.to_s}
attribs['ChangeKey'] =
|
ruby
|
{
"resource": ""
}
|
q25105
|
Viewpoint::EWS::SOAP.EwsBuilder.folder_id!
|
validation
|
def folder_id!(fid, change_key = nil)
attribs = {'Id' => fid}
attribs['ChangeKey'] = change_key if change_key
|
ruby
|
{
"resource": ""
}
|
q25106
|
Viewpoint::EWS::SOAP.EwsBuilder.additional_properties!
|
validation
|
def additional_properties!(addprops)
@nbuild[NS_EWS_TYPES].AdditionalProperties {
addprops.each_pair {|k,v|
|
ruby
|
{
"resource": ""
}
|
q25107
|
Viewpoint::EWS::SOAP.EwsBuilder.mailbox!
|
validation
|
def mailbox!(mbox)
nbuild[NS_EWS_TYPES].Mailbox {
name!(mbox[:name]) if mbox[:name]
email_address!(mbox[:email_address]) if mbox[:email_address]
address!(mbox[:address]) if
|
ruby
|
{
"resource": ""
}
|
q25108
|
Viewpoint::EWS::SOAP.EwsBuilder.get_server_time_zones!
|
validation
|
def get_server_time_zones!(get_time_zone_options)
nbuild[NS_EWS_MESSAGES].GetServerTimeZones('ReturnFullTimeZoneData' => get_time_zone_options[:full]) do
if get_time_zone_options[:ids] && get_time_zone_options[:ids].any?
nbuild[NS_EWS_MESSAGES].Ids do
|
ruby
|
{
"resource": ""
}
|
q25109
|
Viewpoint::EWS::SOAP.EwsBuilder.start_time_zone!
|
validation
|
def start_time_zone!(zone)
attributes = {}
attributes['Id'] = zone[:id] if zone[:id]
attributes['Name'] =
|
ruby
|
{
"resource": ""
}
|
q25110
|
Viewpoint::EWS::SOAP.EwsBuilder.end_time_zone!
|
validation
|
def end_time_zone!(zone)
attributes = {}
attributes['Id'] = zone[:id] if zone[:id]
attributes['Name'] =
|
ruby
|
{
"resource": ""
}
|
q25111
|
Viewpoint::EWS::SOAP.EwsBuilder.time_zone_definition!
|
validation
|
def time_zone_definition!(zone)
attributes = {'Id' => zone[:id]}
attributes['Name'] = zone[:name] if zone[:name]
|
ruby
|
{
"resource": ""
}
|
q25112
|
Viewpoint::EWS::SOAP.EwsBuilder.restriction!
|
validation
|
def restriction!(restriction)
@nbuild[NS_EWS_MESSAGES].Restriction {
restriction.each_pair do |k,v|
|
ruby
|
{
"resource": ""
}
|
q25113
|
Viewpoint::EWS::SOAP.EwsBuilder.calendar_view!
|
validation
|
def calendar_view!(cal_view)
attribs = {}
cal_view.each_pair {|k,v| attribs[camel_case(k)] = v.to_s}
|
ruby
|
{
"resource": ""
}
|
q25114
|
Viewpoint::EWS::SOAP.EwsBuilder.contacts_view!
|
validation
|
def contacts_view!(con_view)
attribs = {}
con_view.each_pair {|k,v| attribs[camel_case(k)] = v.to_s}
|
ruby
|
{
"resource": ""
}
|
q25115
|
Viewpoint::EWS::SOAP.EwsBuilder.attachment_ids!
|
validation
|
def attachment_ids!(aids)
@nbuild.AttachmentIds {
@nbuild.parent.default_namespace = @default_ns
|
ruby
|
{
"resource": ""
}
|
q25116
|
Viewpoint::EWS::SOAP.EwsBuilder.dispatch_item_id!
|
validation
|
def dispatch_item_id!(iid)
type = iid.keys.first
item = iid[type]
case type
when :item_id
item_id!(item)
when :occurrence_item_id
occurrence_item_id!(item)
when :recurring_master_item_id
|
ruby
|
{
"resource": ""
}
|
q25117
|
Viewpoint::EWS::SOAP.EwsBuilder.dispatch_update_type!
|
validation
|
def dispatch_update_type!(update)
type = update.keys.first
upd = update[type]
case type
when :append_to_item_field
append_to_item_field!(upd)
|
ruby
|
{
"resource": ""
}
|
q25118
|
Viewpoint::EWS::SOAP.EwsBuilder.dispatch_field_uri!
|
validation
|
def dispatch_field_uri!(uri, ns=NS_EWS_MESSAGES)
type = uri.keys.first
vals = uri[type].is_a?(Array) ? uri[type] : [uri[type]]
case type
when :field_uRI, :field_uri
vals.each do |val|
value = val.is_a?(Hash) ? val[type] : val
nbuild[ns].FieldURI('FieldURI' => value)
end
when :indexed_field_uRI, :indexed_field_uri
vals.each do |val|
nbuild[ns].IndexedFieldURI(
'FieldURI' => (val[:field_uRI] || val[:field_uri]),
'FieldIndex' => val[:field_index]
)
end
when :extended_field_uRI, :extended_field_uri
vals.each do |val|
nbuild[ns].ExtendedFieldURI {
nbuild.parent['DistinguishedPropertySetId'] = val[:distinguished_property_set_id] if val[:distinguished_property_set_id]
|
ruby
|
{
"resource": ""
}
|
q25119
|
Viewpoint::EWS::SOAP.EwsBuilder.dispatch_field_item!
|
validation
|
def dispatch_field_item!(item, ns_prefix = nil)
item.values.first[:xmlns_attribute] = ns_prefix
|
ruby
|
{
"resource": ""
}
|
q25120
|
Viewpoint::EWS::Types.CalendarItem.update_item!
|
validation
|
def update_item!(updates, options = {})
item_updates = []
updates.each do |attribute, value|
item_field = FIELD_URIS[attribute][:text] if FIELD_URIS.include? attribute
field = {field_uRI: {field_uRI: item_field}}
if value.nil? && item_field
# Build DeleteItemField Change
item_updates << {delete_item_field: field}
elsif item_field
# Build SetItemField Change
item = Viewpoint::EWS::Template::CalendarItem.new(attribute => value)
# Remap attributes because ews_builder #dispatch_field_item! uses #build_xml!
item_attributes = item.to_ews_item.map do |name, value|
if value.is_a? String
{name => {text: value}}
elsif value.is_a? Hash
node = {name => {}}
value.each do |attrib_key, attrib_value|
attrib_key = camel_case(attrib_key) unless attrib_key == :text
node[name][attrib_key] = attrib_value
end
node
else
{name => value}
|
ruby
|
{
"resource": ""
}
|
q25121
|
Viewpoint::EWS::SOAP.ExchangeSynchronization.sync_folder_hierarchy
|
validation
|
def sync_folder_hierarchy(opts)
opts = opts.clone
req = build_soap! do |type, builder|
if(type == :header)
else
builder.nbuild.SyncFolderHierarchy {
builder.nbuild.parent.default_namespace = @default_ns
|
ruby
|
{
"resource": ""
}
|
q25122
|
Viewpoint::EWS::SOAP.ExchangeSynchronization.sync_folder_items
|
validation
|
def sync_folder_items(opts)
opts = opts.clone
req = build_soap! do |type, builder|
if(type == :header)
else
builder.nbuild.SyncFolderItems {
builder.nbuild.parent.default_namespace = @default_ns
builder.item_shape!(opts[:item_shape])
builder.sync_folder_id!(opts[:sync_folder_id]) if opts[:sync_folder_id]
builder.sync_state!(opts[:sync_state]) if opts[:sync_state]
|
ruby
|
{
"resource": ""
}
|
q25123
|
Viewpoint::EWS::Types.MailboxUser.get_user_availability
|
validation
|
def get_user_availability(email_address, start_time, end_time)
opts = {
mailbox_data: [ :email =>{:address => email_address} ],
free_busy_view_options: {
time_window: {start_time: start_time, end_time:
|
ruby
|
{
"resource": ""
}
|
q25124
|
Viewpoint::EWS::Types.Item.move!
|
validation
|
def move!(new_folder)
new_folder = new_folder.id if new_folder.kind_of?(GenericFolder)
move_opts = {
:to_folder_id => {:id => new_folder},
:item_ids => [{:item_id => {:id => self.id}}]
}
resp = @ews.move_item(move_opts)
rmsg = resp.response_messages[0]
if rmsg.success?
|
ruby
|
{
"resource": ""
}
|
q25125
|
Viewpoint::EWS::Types.Item.copy
|
validation
|
def copy(new_folder)
new_folder = new_folder.id if new_folder.kind_of?(GenericFolder)
copy_opts = {
:to_folder_id => {:id => new_folder},
:item_ids => [{:item_id => {:id => self.id}}]
}
resp = @ews.copy_item(copy_opts)
rmsg = resp.response_messages[0]
if rmsg.success?
obj = rmsg.items.first
|
ruby
|
{
"resource": ""
}
|
q25126
|
Viewpoint::EWS::Types.Item.get_item
|
validation
|
def get_item(opts = {})
args = get_item_args(opts)
|
ruby
|
{
"resource": ""
}
|
q25127
|
Viewpoint::EWS::Types.Item.dispatch_create_item!
|
validation
|
def dispatch_create_item!(msg)
if msg.has_attachments?
draft = msg.draft
msg.draft = true
resp = validate_created_item(ews.create_item(msg.to_ews))
msg.file_attachments.each do |f|
|
ruby
|
{
"resource": ""
}
|
q25128
|
Viewpoint::EWS::Types.Item.validate_created_item
|
validation
|
def validate_created_item(response)
msg = response.response_messages[0]
if(msg.status == 'Success')
msg.items.empty? ? true : parse_created_item(msg.items.first)
|
ruby
|
{
"resource": ""
}
|
q25129
|
Viewpoint::EWS::Types.GenericFolder.items_since
|
validation
|
def items_since(date_time, opts = {})
opts = opts.clone
unless date_time.kind_of?(Date)
raise EwsBadArgumentError, "First argument must be a Date or DateTime"
end
|
ruby
|
{
"resource": ""
}
|
q25130
|
Viewpoint::EWS::Types.GenericFolder.items_between
|
validation
|
def items_between(start_date, end_date, opts={})
items do |obj|
obj.restriction = { :and =>
[
{:is_greater_than_or_equal_to =>
[
{:field_uRI => {:field_uRI=>'item:DateTimeReceived'}},
{:field_uRI_or_constant=>{:constant => {:value =>start_date}}}
]
},
{:is_less_than_or_equal_to =>
[
|
ruby
|
{
"resource": ""
}
|
q25131
|
Viewpoint::EWS::Types.GenericFolder.search_by_subject
|
validation
|
def search_by_subject(match_str, exclude_str = nil)
items do |obj|
match = {:contains => {
:containment_mode => 'Substring',
:containment_comparison => 'IgnoreCase',
:field_uRI => {:field_uRI=>'item:Subject'},
:constant => {:value =>match_str}
}}
unless exclude_str.nil?
excl = {:not =>
{:contains => {
:containment_mode => 'Substring',
:containment_comparison => 'IgnoreCase',
|
ruby
|
{
"resource": ""
}
|
q25132
|
Viewpoint::EWS::Types.GenericFolder.sync_items!
|
validation
|
def sync_items!(sync_state = nil, sync_amount = 256, sync_all = false, opts = {})
item_shape = opts.has_key?(:item_shape) ? opts.delete(:item_shape) : {:base_shape => :default}
sync_state ||= @sync_state
resp = ews.sync_folder_items item_shape: item_shape,
sync_folder_id: self.folder_id, max_changes_returned: sync_amount, sync_state: sync_state
rmsg = resp.response_messages[0]
if rmsg.success?
@synced = rmsg.includes_last_item_in_range?
@sync_state = rmsg.sync_state
rhash = {}
rmsg.changes.each do |c|
ctype = c.keys.first
rhash[ctype] = [] unless rhash.has_key?(ctype)
|
ruby
|
{
"resource": ""
}
|
q25133
|
Viewpoint::EWS::Types.GenericFolder.subscribe
|
validation
|
def subscribe(evtypes = [:all], watermark = nil, timeout = 240)
# Refresh the subscription if already subscribed
unsubscribe if subscribed?
event_types = normalize_event_names(evtypes)
folder = {id: self.id, change_key: self.change_key}
resp = ews.pull_subscribe_folder(folder, event_types, timeout, watermark)
rmsg = resp.response_messages.first
if rmsg.success?
|
ruby
|
{
"resource": ""
}
|
q25134
|
Viewpoint::EWS::Types.GenericFolder.unsubscribe
|
validation
|
def unsubscribe
return true if @subscription_id.nil?
resp = ews.unsubscribe(@subscription_id)
rmsg = resp.response_messages.first
if rmsg.success?
@subscription_id, @watermark = nil, nil
true
|
ruby
|
{
"resource": ""
}
|
q25135
|
Viewpoint::EWS::Types.GenericFolder.get_events
|
validation
|
def get_events
begin
if subscribed?
resp = ews.get_events(@subscription_id, @watermark)
rmsg = resp.response_messages[0]
@watermark = rmsg.new_watermark
# @todo if parms[:more_events] # get more events
rmsg.events.collect{|ev|
|
ruby
|
{
"resource": ""
}
|
q25136
|
Viewpoint::EWS::Types.GenericFolder.get_folder
|
validation
|
def get_folder(opts = {})
args = get_folder_args(opts)
|
ruby
|
{
"resource": ""
}
|
q25137
|
Viewpoint::EWS::SOAP.ExchangeTimeZones.get_time_zones
|
validation
|
def get_time_zones(full = false, ids = nil)
req = build_soap! do |type, builder|
unless type == :header
builder.get_server_time_zones!(full: full, ids: ids)
end
end
result = do_soap_request req, response_class: EwsSoapResponse
if result.success?
zones = []
result.response_messages.each do |message|
elements = message[:get_server_time_zones_response_message][:elems][:time_zone_definitions][:elems]
elements.each do |definition|
|
ruby
|
{
"resource": ""
}
|
q25138
|
Viewpoint::EWS::SOAP.ExchangeDataServices.copy_folder
|
validation
|
def copy_folder(to_folder_id, *sources)
req = build_soap! do |type, builder|
if(type == :header)
else
builder.nbuild.CopyFolder {
builder.nbuild.parent.default_namespace = @default_ns
|
ruby
|
{
"resource": ""
}
|
q25139
|
Viewpoint::EWS::SOAP.ExchangeDataServices.move_folder
|
validation
|
def move_folder(to_folder_id, *sources)
req = build_soap! do |type, builder|
if(type == :header)
else
builder.nbuild.MoveFolder {
builder.nbuild.parent.default_namespace = @default_ns
|
ruby
|
{
"resource": ""
}
|
q25140
|
Viewpoint::EWS::SOAP.ExchangeDataServices.update_folder
|
validation
|
def update_folder(folder_changes)
req = build_soap! do |type, builder|
if(type == :header)
else
builder.nbuild.UpdateFolder {
builder.nbuild.parent.default_namespace = @default_ns
builder.nbuild.FolderChanges {
folder_changes.each do |fc|
builder[NS_EWS_TYPES].FolderChange {
builder.dispatch_folder_id!(fc)
|
ruby
|
{
"resource": ""
}
|
q25141
|
Viewpoint::EWS::SOAP.ExchangeDataServices.empty_folder
|
validation
|
def empty_folder(opts)
validate_version(VERSION_2010_SP1)
ef_opts = {}
[:delete_type, :delete_sub_folders].each do |k|
ef_opts[camel_case(k)] = validate_param(opts, k, true)
end
fids = validate_param opts, :folder_ids, true
req = build_soap! do |type, builder|
if(type == :header)
else
|
ruby
|
{
"resource": ""
}
|
q25142
|
Viewpoint::EWS::SOAP.ExchangeDataServices.create_attachment
|
validation
|
def create_attachment(opts)
opts = opts.clone
[:parent_id].each do |k|
validate_param(opts, k, true)
end
validate_param(opts, :files, false, [])
validate_param(opts, :items, false, [])
req = build_soap! do |type, builder|
if(type == :header)
else
builder.nbuild.CreateAttachment {|x|
builder.nbuild.parent.default_namespace = @default_ns
builder.parent_item_id!(opts[:parent_id])
x.Attachments {
opts[:files].each do |fa|
builder.file_attachment!(fa)
|
ruby
|
{
"resource": ""
}
|
q25143
|
Viewpoint::EWS::SOAP.ExchangeDataServices.resolve_names
|
validation
|
def resolve_names(opts)
opts = opts.clone
fcd = opts.has_key?(:full_contact_data) ? opts[:full_contact_data] : true
req = build_soap! do |type, builder|
if(type == :header)
else
builder.nbuild.ResolveNames {|x|
x.parent['ReturnFullContactData'] = fcd.to_s
x.parent['SearchScope'] = opts[:search_scope] if opts[:search_scope]
|
ruby
|
{
"resource": ""
}
|
q25144
|
Viewpoint::EWS::SOAP.ExchangeDataServices.convert_id
|
validation
|
def convert_id(opts)
opts = opts.clone
[:id, :format, :destination_format, :mailbox ].each do |k|
validate_param(opts, k, true)
end
req = build_soap! do |type, builder|
if(type == :header)
else
builder.nbuild.ConvertId {|x|
builder.nbuild.parent.default_namespace = @default_ns
|
ruby
|
{
"resource": ""
}
|
q25145
|
Viewpoint::EWS::Types.CalendarFolder.create_item
|
validation
|
def create_item(attributes, to_ews_create_opts = {})
template = Viewpoint::EWS::Template::CalendarItem.new attributes
template.saved_item_folder_id = {id: self.id, change_key: self.change_key}
rm = ews.create_item(template.to_ews_create(to_ews_create_opts)).response_messages.first
if rm && rm.success?
|
ruby
|
{
"resource": ""
}
|
q25146
|
Viewpoint::EWS::SOAP.ExchangeWebService.get_user_availability
|
validation
|
def get_user_availability(opts)
opts = opts.clone
req = build_soap! do |type, builder|
if(type == :header)
else
builder.nbuild.GetUserAvailabilityRequest {|x|
x.parent.default_namespace = @default_ns
builder.time_zone!(opts[:time_zone])
|
ruby
|
{
"resource": ""
}
|
q25147
|
Viewpoint::EWS::SOAP.ExchangeWebService.get_rooms
|
validation
|
def get_rooms(roomDistributionList)
req = build_soap! do |type, builder|
if(type == :header)
else
builder.nbuild.GetRooms {|x|
x.parent.default_namespace = @default_ns
|
ruby
|
{
"resource": ""
}
|
q25148
|
Viewpoint::EWS::SOAP.ExchangeWebService.get_room_lists
|
validation
|
def get_room_lists
req = build_soap! do |type, builder|
if(type == :header)
else
builder.room_lists!
end
end
|
ruby
|
{
"resource": ""
}
|
q25149
|
Viewpoint::EWS::SOAP.ExchangeWebService.validate_version
|
validation
|
def validate_version(exchange_version)
if server_version < exchange_version
msg = 'The operation you are attempting to use is not compatible with'
msg << " your configured Exchange Server version(#{server_version})."
|
ruby
|
{
"resource": ""
}
|
q25150
|
Viewpoint::EWS::SOAP.ExchangeWebService.build_soap!
|
validation
|
def build_soap!(&block)
opts = { :server_version => server_version, :impersonation_type => impersonation_type, :impersonation_mail => impersonation_address }
|
ruby
|
{
"resource": ""
}
|
q25151
|
Viewpoint.StringUtils.camel_case
|
validation
|
def camel_case(input)
input.to_s.split(/_/).map { |i|
|
ruby
|
{
"resource": ""
}
|
q25152
|
Viewpoint.StringUtils.iso8601_duration_to_seconds
|
validation
|
def iso8601_duration_to_seconds(input)
return nil if input.nil? || input.empty?
match_data = DURATION_RE.match(input)
raise(StringFormatException, "Invalid duration given") if match_data.nil?
duration = 0
duration += match_data[:weeks].to_i * 604800
duration += match_data[:days].to_i * 86400
|
ruby
|
{
"resource": ""
}
|
q25153
|
Viewpoint::EWS::SOAP.ExchangeNotification.subscribe
|
validation
|
def subscribe(subscriptions)
req = build_soap! do |type, builder|
if(type == :header)
else
builder.nbuild.Subscribe {
builder.nbuild.parent.default_namespace = @default_ns
subscriptions.each do |sub|
subtype = sub.keys.first
if(builder.respond_to?(subtype))
builder.send subtype, sub[subtype]
else
|
ruby
|
{
"resource": ""
}
|
q25154
|
Viewpoint::EWS::SOAP.ExchangeNotification.push_subscribe_folder
|
validation
|
def push_subscribe_folder(folder, evtypes, url, status_frequency = nil, watermark = nil)
status_frequency ||= 30
psr = {
:subscribe_to_all_folders => false,
:folder_ids => [ {:id => folder[:id], :change_key => folder[:change_key]} ],
:event_types=>
|
ruby
|
{
"resource": ""
}
|
q25155
|
Contentful.DateCoercion.coerce
|
validation
|
def coerce(*)
return nil if value.nil?
return value
|
ruby
|
{
"resource": ""
}
|
q25156
|
Contentful.ResourceReferences.incoming_references
|
validation
|
def incoming_references(client = nil, query = {})
return false unless client
query = is_a?(Contentful::Entry) ? query.merge(links_to_entry:
|
ruby
|
{
"resource": ""
}
|
q25157
|
Contentful.Client.entry
|
validation
|
def entry(id, query = {})
normalize_select!(query)
query['sys.id'] = id
entries = Request.new(self, environment_url('/entries'), query).get
|
ruby
|
{
"resource": ""
}
|
q25158
|
Contentful.Client.os_info
|
validation
|
def os_info
os_name = case ::RbConfig::CONFIG['host_os']
when /(cygwin|mingw|mswin|windows)/i then 'Windows'
when /(darwin|macruby|mac os)/i then 'macOS'
when /(linux|bsd|aix|solarix)/i
|
ruby
|
{
"resource": ""
}
|
q25159
|
Contentful.Client.contentful_user_agent
|
validation
|
def contentful_user_agent
header = {
'sdk' => sdk_info,
'app' => app_info,
'integration' => integration_info,
'platform' => platform_info,
'os' => os_info
}
result = []
|
ruby
|
{
"resource": ""
}
|
q25160
|
Contentful.Client.request_headers
|
validation
|
def request_headers
headers = { 'X-Contentful-User-Agent' => contentful_user_agent }
headers['Authorization'] = "Bearer #{configuration[:access_token]}" if configuration[:authentication_mechanism] == :header
headers['Content-Type']
|
ruby
|
{
"resource": ""
}
|
q25161
|
Contentful.Client.run_request
|
validation
|
def run_request(request)
url = request.absolute? ? request.url : base_url + request.url
logger.info(request: { url: url, query: request.query, header: request_headers }) if logger
Response.new(
self.class.get_http(
url,
|
ruby
|
{
"resource": ""
}
|
q25162
|
Contentful.Client.do_build_resource
|
validation
|
def do_build_resource(response)
logger.debug(response: response) if logger
configuration[:resource_builder].new(
response.object,
configuration.merge(endpoint:
|
ruby
|
{
"resource": ""
}
|
q25163
|
Contentful.Link.resolve
|
validation
|
def resolve(client, query = {})
id_and_query = [(id unless link_type == 'Space')].compact +
|
ruby
|
{
"resource": ""
}
|
q25164
|
Contentful.FieldsResource.fields_with_locales
|
validation
|
def fields_with_locales
remapped_fields = {}
locales.each do |locale|
fields(locale).each do |name, value|
remapped_fields[name] ||= {}
|
ruby
|
{
"resource": ""
}
|
q25165
|
Contentful.BaseResource.reload
|
validation
|
def reload(client = nil)
return client.send(Support.snakify(self.class.name.split('::').last),
|
ruby
|
{
"resource": ""
}
|
q25166
|
Contentful.ContentType.field_for
|
validation
|
def field_for(field_id)
fields.detect {
|
ruby
|
{
"resource": ""
}
|
q25167
|
Contentful.Sync.each_page
|
validation
|
def each_page
page = first_page
yield page if block_given?
until completed?
page
|
ruby
|
{
"resource": ""
}
|
q25168
|
Contentful.Field.coerce
|
validation
|
def coerce(value, configuration)
return value if type.nil?
return value if value.nil?
options = {}
options[:coercion_class]
|
ruby
|
{
"resource": ""
}
|
q25169
|
IMS::LTI::Services.ToolConfig.set_ext_params
|
validation
|
def set_ext_params(ext_key, ext_params)
raise ArgumentError
|
ruby
|
{
"resource": ""
}
|
q25170
|
IMS::LTI::Services.ToolConfig.process_xml
|
validation
|
def process_xml(xml)
doc = REXML::Document.new xml
if root = REXML::XPath.first(doc, 'xmlns:cartridge_basiclti_link')
@title = get_node_text(root, 'blti:title')
@description = get_node_text(root, 'blti:description')
@launch_url = get_node_text(root, 'blti:launch_url')
@secure_launch_url = get_node_text(root, 'blti:secure_launch_url')
@icon = get_node_text(root, 'blti:icon')
@secure_icon = get_node_text(root, 'blti:secure_icon')
@cartridge_bundle = get_node_att(root, 'xmlns:cartridge_bundle', 'identifierref')
@cartridge_icon = get_node_att(root, 'xmlns:cartridge_icon', 'identifierref')
if vendor = REXML::XPath.first(root, 'blti:vendor')
@vendor_code = get_node_text(vendor, 'lticp:code')
@vendor_description = get_node_text(vendor, 'lticp:description')
@vendor_name = get_node_text(vendor, 'lticp:name')
@vendor_url = get_node_text(vendor, 'lticp:url')
@vendor_contact_email = get_node_text(vendor, '//lticp:contact/lticp:email')
@vendor_contact_name = get_node_text(vendor, '//lticp:contact/lticp:name')
|
ruby
|
{
"resource": ""
}
|
q25171
|
IMS::LTI::Services.ToolConfig.to_xml
|
validation
|
def to_xml(opts = {})
builder = Builder::XmlMarkup.new(:indent => opts[:indent] || 0)
builder.instruct!
builder.cartridge_basiclti_link("xmlns" => "http://www.imsglobal.org/xsd/imslticc_v1p0",
"xmlns:blti" => 'http://www.imsglobal.org/xsd/imsbasiclti_v1p0',
"xmlns:lticm" => 'http://www.imsglobal.org/xsd/imslticm_v1p0',
"xmlns:lticp" => 'http://www.imsglobal.org/xsd/imslticp_v1p0',
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
"xsi:schemaLocation" => "http://www.imsglobal.org/xsd/imslticc_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imslticc_v1p0.xsd http://www.imsglobal.org/xsd/imsbasiclti_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imsbasiclti_v1p0p1.xsd http://www.imsglobal.org/xsd/imslticm_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imslticm_v1p0.xsd http://www.imsglobal.org/xsd/imslticp_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imslticp_v1p0.xsd"
) do |blti_node|
%w{title description launch_url secure_launch_url icon secure_icon}.each do |key|
blti_node.blti key.to_sym, self.send(key) if self.send(key)
end
vendor_keys = %w{name code description url}
if vendor_keys.any? { |k| self.send("vendor_#{k}") } || vendor_contact_email
blti_node.blti :vendor do |v_node|
vendor_keys.each do |key|
v_node.lticp key.to_sym, self.send("vendor_#{key}") if self.send("vendor_#{key}")
end
if vendor_contact_email
v_node.lticp :contact do |c_node|
c_node.lticp :name, vendor_contact_name
c_node.lticp :email, vendor_contact_email
end
end
end
end
if !@custom_params.empty?
blti_node.tag!("blti:custom") do |custom_node|
@custom_params.keys.sort.each do |key|
val = @custom_params[key]
custom_node.lticm :property,
|
ruby
|
{
"resource": ""
}
|
q25172
|
SeedFu.ActiveRecordExtension.seed
|
validation
|
def seed(*args, &block)
SeedFu::Seeder.new(self,
|
ruby
|
{
"resource": ""
}
|
q25173
|
ImageProcessing.Pipeline.call
|
validation
|
def call(save: true)
if save == false
call_processor
elsif destination
handle_destination do
|
ruby
|
{
"resource": ""
}
|
q25174
|
ImageProcessing.Pipeline.destination_format
|
validation
|
def destination_format
format = File.extname(destination)[1..-1] if destination
|
ruby
|
{
"resource": ""
}
|
q25175
|
ImageProcessing.Pipeline.create_tempfile
|
validation
|
def create_tempfile
tempfile = Tempfile.new(["image_processing", ".#{destination_format}"], binmode: true)
yield tempfile
|
ruby
|
{
"resource": ""
}
|
q25176
|
ImageProcessing.Pipeline.handle_destination
|
validation
|
def handle_destination
destination_existed = File.exist?(destination)
|
ruby
|
{
"resource": ""
}
|
q25177
|
ImageProcessing.Chainable.apply
|
validation
|
def apply(operations)
operations.inject(self) do |builder, (name, argument)|
if argument == true || argument == nil
|
ruby
|
{
"resource": ""
}
|
q25178
|
ImageProcessing.Chainable.call
|
validation
|
def call(file = nil, destination: nil, **call_options)
options = {}
options = options.merge(source: file) if file
|
ruby
|
{
"resource": ""
}
|
q25179
|
ImageProcessing.Chainable.branch
|
validation
|
def branch(loader: nil, saver: nil, operations: nil, **other_options)
options = respond_to?(:options) ? self.options : DEFAULT_OPTIONS
options = options.merge(loader: options[:loader].merge(loader)) if loader
options = options.merge(saver: options[:saver].merge(saver)) if saver
options = options.merge(operations: options[:operations] + operations) if
|
ruby
|
{
"resource": ""
}
|
q25180
|
Spidr.Page.cookie_params
|
validation
|
def cookie_params
params = {}
cookies.each do |value|
value.split(';').each do |param|
param.strip!
name, value = param.split('=',2)
unless name =~ RESERVED_COOKIE_NAMES
|
ruby
|
{
"resource": ""
}
|
q25181
|
Spidr.SessionCache.active?
|
validation
|
def active?(url)
# normalize the url
url = URI(url)
# session key
key =
|
ruby
|
{
"resource": ""
}
|
q25182
|
Spidr.SessionCache.[]
|
validation
|
def [](url)
# normalize the url
url = URI(url)
# session key
key = key_for(url)
unless @sessions[key]
session = Net::HTTP::Proxy(
@proxy.host,
@proxy.port,
@proxy.user,
@proxy.password
).new(url.host,url.port)
session.open_timeout = @open_timeout if @open_timeout
|
ruby
|
{
"resource": ""
}
|
q25183
|
Spidr.SessionCache.kill!
|
validation
|
def kill!(url)
# normalize the url
url = URI(url)
# session key
key = key_for(url)
if (sess = @sessions[key])
begin
sess.finish
|
ruby
|
{
"resource": ""
}
|
q25184
|
Spidr.Agent.sanitize_url
|
validation
|
def sanitize_url(url)
url = URI(url)
url.fragment = nil if @strip_fragments
|
ruby
|
{
"resource": ""
}
|
q25185
|
Spidr.Page.doc
|
validation
|
def doc
unless body.empty?
doc_class = if html?
Nokogiri::HTML::Document
elsif rss? || atom? || xml? || xsl?
Nokogiri::XML::Document
end
if doc_class
begin
|
ruby
|
{
"resource": ""
}
|
q25186
|
Spidr.Page.content_charset
|
validation
|
def content_charset
content_types.each do |value|
if value.include?(';')
value.split(';').each do |param|
param.strip!
if param.start_with?('charset=')
|
ruby
|
{
"resource": ""
}
|
q25187
|
Spidr.Page.is_content_type?
|
validation
|
def is_content_type?(type)
if type.include?('/')
# otherwise only match the first param
content_types.any? do |value|
value = value.split(';',2).first
value == type
end
else
|
ruby
|
{
"resource": ""
}
|
q25188
|
Spidr.CookieJar.[]=
|
validation
|
def []=(host,cookies)
collected = self[host]
cookies.each do |key,value|
if collected[key] != value
collected.merge!(cookies)
|
ruby
|
{
"resource": ""
}
|
q25189
|
Spidr.CookieJar.from_page
|
validation
|
def from_page(page)
cookies = page.cookie_params
unless cookies.empty?
|
ruby
|
{
"resource": ""
}
|
q25190
|
Spidr.CookieJar.for_host
|
validation
|
def for_host(host)
if @dirty.include?(host)
values = []
cookies_for_host(host).each do |name,value|
|
ruby
|
{
"resource": ""
}
|
q25191
|
Spidr.AuthStore.[]
|
validation
|
def [](url)
# normalize the url
url = URI(url)
key = [url.scheme, url.host, url.port]
paths = @credentials[key]
return nil unless paths
# longest path first
|
ruby
|
{
"resource": ""
}
|
q25192
|
Spidr.AuthStore.[]=
|
validation
|
def []=(url,auth)
# normalize the url
url = URI(url)
# normalize the URL path
path = URI.expand_path(url.path)
key = [url.scheme, url.host, url.port]
|
ruby
|
{
"resource": ""
}
|
q25193
|
Spidr.Agent.run
|
validation
|
def run(&block)
@running = true
until (@queue.empty? || paused? || limit_reached?)
begin
visit_page(dequeue,&block)
|
ruby
|
{
"resource": ""
}
|
q25194
|
Spidr.Agent.enqueue
|
validation
|
def enqueue(url,level=0)
url = sanitize_url(url)
if (!(queued?(url)) && visit?(url))
link = url.to_s
begin
@every_url_blocks.each { |url_block| url_block.call(url) }
@every_url_like_blocks.each do |pattern,url_blocks|
match = case pattern
when Regexp
link =~ pattern
else
(pattern == link) || (pattern == url)
end
if match
url_blocks.each { |url_block| url_block.call(url) }
end
end
|
ruby
|
{
"resource": ""
}
|
q25195
|
Spidr.Agent.get_page
|
validation
|
def get_page(url)
url = URI(url)
prepare_request(url) do |session,path,headers|
new_page = Page.new(url,session.get(path,headers))
# save any new cookies
|
ruby
|
{
"resource": ""
}
|
q25196
|
Spidr.Agent.post_page
|
validation
|
def post_page(url,post_data='')
url = URI(url)
prepare_request(url) do |session,path,headers|
new_page = Page.new(url,session.post(path,post_data,headers))
# save any new cookies
|
ruby
|
{
"resource": ""
}
|
q25197
|
Spidr.Agent.visit_page
|
validation
|
def visit_page(url)
url = sanitize_url(url)
get_page(url) do |page|
@history << page.url
begin
@every_page_blocks.each { |page_block| page_block.call(page) }
yield page if block_given?
rescue Actions::Paused => action
raise(action)
rescue Actions::SkipPage
return nil
rescue Actions::Action
end
page.each_url do |next_url|
begin
@every_link_blocks.each do |link_block|
link_block.call(page.url,next_url)
|
ruby
|
{
"resource": ""
}
|
q25198
|
Spidr.Agent.prepare_request_headers
|
validation
|
def prepare_request_headers(url)
# set any additional HTTP headers
headers = @default_headers.dup
unless @host_headers.empty?
@host_headers.each do |name,header|
if url.host.match(name)
headers['Host'] = header
break
end
end
end
headers['Host'] ||= @host_header if @host_header
headers['User-Agent'] = @user_agent if
|
ruby
|
{
"resource": ""
}
|
q25199
|
Spidr.Agent.prepare_request
|
validation
|
def prepare_request(url,&block)
path = unless url.path.empty?
url.path
else
'/'
end
# append the URL query to the path
path += "?#{url.query}" if url.query
headers = prepare_request_headers(url)
begin
sleep(@delay) if @delay > 0
yield @sessions[url], path, headers
rescue SystemCallError,
Timeout::Error,
SocketError,
|
ruby
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.