repo
stringlengths
5
67
path
stringlengths
4
218
func_name
stringlengths
0
151
original_string
stringlengths
52
373k
language
stringclasses
6 values
code
stringlengths
52
373k
code_tokens
listlengths
10
512
docstring
stringlengths
3
47.2k
docstring_tokens
listlengths
3
234
sha
stringlengths
40
40
url
stringlengths
85
339
partition
stringclasses
3 values
zold-io/zold
lib/zold/commands/node.rb
Zold.Node.exec
def exec(cmd, nohup_log) start = Time.now Open3.popen2e({ 'MALLOC_ARENA_MAX' => '2' }, cmd) do |stdin, stdout, thr| nohup_log.print("Started process ##{thr.pid} from process ##{Process.pid}: #{cmd}\n") stdin.close until stdout.eof? begin line = stdout.gets rescue IOError => e line = Backtrace.new(e).to_s end nohup_log.print(line) end nohup_log.print("Nothing else left to read from ##{thr.pid}\n") code = thr.value.to_i nohup_log.print("Exit code of process ##{thr.pid} is #{code}, was alive for #{Age.new(start)}: #{cmd}\n") code end end
ruby
def exec(cmd, nohup_log) start = Time.now Open3.popen2e({ 'MALLOC_ARENA_MAX' => '2' }, cmd) do |stdin, stdout, thr| nohup_log.print("Started process ##{thr.pid} from process ##{Process.pid}: #{cmd}\n") stdin.close until stdout.eof? begin line = stdout.gets rescue IOError => e line = Backtrace.new(e).to_s end nohup_log.print(line) end nohup_log.print("Nothing else left to read from ##{thr.pid}\n") code = thr.value.to_i nohup_log.print("Exit code of process ##{thr.pid} is #{code}, was alive for #{Age.new(start)}: #{cmd}\n") code end end
[ "def", "exec", "(", "cmd", ",", "nohup_log", ")", "start", "=", "Time", ".", "now", "Open3", ".", "popen2e", "(", "{", "'MALLOC_ARENA_MAX'", "=>", "'2'", "}", ",", "cmd", ")", "do", "|", "stdin", ",", "stdout", ",", "thr", "|", "nohup_log", ".", "p...
Returns exit code
[ "Returns", "exit", "code" ]
7e0f69307786846186bc3436dcc72d91d393ddd4
https://github.com/zold-io/zold/blob/7e0f69307786846186bc3436dcc72d91d393ddd4/lib/zold/commands/node.rb#L374-L392
valid
zold-io/zold
lib/zold/thread_pool.rb
Zold.ThreadPool.add
def add raise 'Block must be given to start()' unless block_given? latch = Concurrent::CountDownLatch.new(1) thread = Thread.start do Thread.current.name = @title VerboseThread.new(@log).run do latch.count_down yield end end latch.wait Thread.current.thread_variable_set( :kids, (Thread.current.thread_variable_get(:kids) || []) + [thread] ) @threads << thread end
ruby
def add raise 'Block must be given to start()' unless block_given? latch = Concurrent::CountDownLatch.new(1) thread = Thread.start do Thread.current.name = @title VerboseThread.new(@log).run do latch.count_down yield end end latch.wait Thread.current.thread_variable_set( :kids, (Thread.current.thread_variable_get(:kids) || []) + [thread] ) @threads << thread end
[ "def", "add", "raise", "'Block must be given to start()'", "unless", "block_given?", "latch", "=", "Concurrent", "::", "CountDownLatch", ".", "new", "(", "1", ")", "thread", "=", "Thread", ".", "start", "do", "Thread", ".", "current", ".", "name", "=", "@title...
Add a new thread
[ "Add", "a", "new", "thread" ]
7e0f69307786846186bc3436dcc72d91d393ddd4
https://github.com/zold-io/zold/blob/7e0f69307786846186bc3436dcc72d91d393ddd4/lib/zold/thread_pool.rb#L42-L58
valid
zold-io/zold
lib/zold/thread_pool.rb
Zold.ThreadPool.kill
def kill if @threads.empty? @log.debug("Thread pool \"#{@title}\" terminated with no threads") return end @log.debug("Stopping \"#{@title}\" thread pool with #{@threads.count} threads: \ #{@threads.map { |t| "#{t.name}/#{t.status}" }.join(', ')}...") start = Time.new begin join(0.1) ensure @threads.each do |t| (t.thread_variable_get(:kids) || []).each(&:kill) t.kill sleep(0.001) while t.alive? # I believe it's a bug in Ruby, this line fixes it Thread.current.thread_variable_set( :kids, (Thread.current.thread_variable_get(:kids) || []) - [t] ) end @log.debug("Thread pool \"#{@title}\" terminated all threads in #{Age.new(start)}, \ it was alive for #{Age.new(@start)}: #{@threads.map { |t| "#{t.name}/#{t.status}" }.join(', ')}") @threads.clear end end
ruby
def kill if @threads.empty? @log.debug("Thread pool \"#{@title}\" terminated with no threads") return end @log.debug("Stopping \"#{@title}\" thread pool with #{@threads.count} threads: \ #{@threads.map { |t| "#{t.name}/#{t.status}" }.join(', ')}...") start = Time.new begin join(0.1) ensure @threads.each do |t| (t.thread_variable_get(:kids) || []).each(&:kill) t.kill sleep(0.001) while t.alive? # I believe it's a bug in Ruby, this line fixes it Thread.current.thread_variable_set( :kids, (Thread.current.thread_variable_get(:kids) || []) - [t] ) end @log.debug("Thread pool \"#{@title}\" terminated all threads in #{Age.new(start)}, \ it was alive for #{Age.new(@start)}: #{@threads.map { |t| "#{t.name}/#{t.status}" }.join(', ')}") @threads.clear end end
[ "def", "kill", "if", "@threads", ".", "empty?", "@log", ".", "debug", "(", "\"Thread pool \\\"#{@title}\\\" terminated with no threads\"", ")", "return", "end", "@log", ".", "debug", "(", "\"Stopping \\\"#{@title}\\\" thread pool with #{@threads.count} threads: \\#{@threads.map {...
Kill them all immediately and close the pool
[ "Kill", "them", "all", "immediately", "and", "close", "the", "pool" ]
7e0f69307786846186bc3436dcc72d91d393ddd4
https://github.com/zold-io/zold/blob/7e0f69307786846186bc3436dcc72d91d393ddd4/lib/zold/thread_pool.rb#L65-L89
valid
zold-io/zold
lib/zold/thread_pool.rb
Zold.ThreadPool.to_json
def to_json @threads.map do |t| { name: t.name, status: t.status, alive: t.alive?, vars: Hash[t.thread_variables.map { |v| [v.to_s, t.thread_variable_get(v)] }] } end end
ruby
def to_json @threads.map do |t| { name: t.name, status: t.status, alive: t.alive?, vars: Hash[t.thread_variables.map { |v| [v.to_s, t.thread_variable_get(v)] }] } end end
[ "def", "to_json", "@threads", ".", "map", "do", "|", "t", "|", "{", "name", ":", "t", ".", "name", ",", "status", ":", "t", ".", "status", ",", "alive", ":", "t", ".", "alive?", ",", "vars", ":", "Hash", "[", "t", ".", "thread_variables", ".", ...
As a hash map
[ "As", "a", "hash", "map" ]
7e0f69307786846186bc3436dcc72d91d393ddd4
https://github.com/zold-io/zold/blob/7e0f69307786846186bc3436dcc72d91d393ddd4/lib/zold/thread_pool.rb#L107-L116
valid
zold-io/zold
lib/zold/thread_pool.rb
Zold.ThreadPool.to_s
def to_s @threads.map do |t| [ "#{t.name}: status=#{t.status}; alive=#{t.alive?}", 'Vars: ' + t.thread_variables.map { |v| "#{v}=\"#{t.thread_variable_get(v)}\"" }.join('; '), t.backtrace.nil? ? 'NO BACKTRACE' : " #{t.backtrace.join("\n ")}" ].join("\n") end end
ruby
def to_s @threads.map do |t| [ "#{t.name}: status=#{t.status}; alive=#{t.alive?}", 'Vars: ' + t.thread_variables.map { |v| "#{v}=\"#{t.thread_variable_get(v)}\"" }.join('; '), t.backtrace.nil? ? 'NO BACKTRACE' : " #{t.backtrace.join("\n ")}" ].join("\n") end end
[ "def", "to_s", "@threads", ".", "map", "do", "|", "t", "|", "[", "\"#{t.name}: status=#{t.status}; alive=#{t.alive?}\"", ",", "'Vars: '", "+", "t", ".", "thread_variables", ".", "map", "{", "|", "v", "|", "\"#{v}=\\\"#{t.thread_variable_get(v)}\\\"\"", "}", ".", "...
As a text
[ "As", "a", "text" ]
7e0f69307786846186bc3436dcc72d91d393ddd4
https://github.com/zold-io/zold/blob/7e0f69307786846186bc3436dcc72d91d393ddd4/lib/zold/thread_pool.rb#L119-L127
valid
zold-io/zold
lib/zold/patch.rb
Zold.Patch.legacy
def legacy(wallet, hours: 24) raise 'You can\'t add legacy to a non-empty patch' unless @id.nil? wallet.txns.each do |txn| @txns << txn if txn.amount.negative? && txn.date < Time.now - hours * 60 * 60 end end
ruby
def legacy(wallet, hours: 24) raise 'You can\'t add legacy to a non-empty patch' unless @id.nil? wallet.txns.each do |txn| @txns << txn if txn.amount.negative? && txn.date < Time.now - hours * 60 * 60 end end
[ "def", "legacy", "(", "wallet", ",", "hours", ":", "24", ")", "raise", "'You can\\'t add legacy to a non-empty patch'", "unless", "@id", ".", "nil?", "wallet", ".", "txns", ".", "each", "do", "|", "txn", "|", "@txns", "<<", "txn", "if", "txn", ".", "amount...
Add legacy transactions first, since they are negative and can't be deleted ever. This method is called by merge.rb in order to add legacy negative transactions to the patch before everything else. They are not supposed to be disputed, ever.
[ "Add", "legacy", "transactions", "first", "since", "they", "are", "negative", "and", "can", "t", "be", "deleted", "ever", ".", "This", "method", "is", "called", "by", "merge", ".", "rb", "in", "order", "to", "add", "legacy", "negative", "transactions", "to...
7e0f69307786846186bc3436dcc72d91d393ddd4
https://github.com/zold-io/zold/blob/7e0f69307786846186bc3436dcc72d91d393ddd4/lib/zold/patch.rb#L51-L56
valid
zold-io/zold
lib/zold/patch.rb
Zold.Patch.save
def save(file, overwrite: false, allow_negative_balance: false) raise 'You have to join at least one wallet in' if empty? before = '' wallet = Wallet.new(file) before = wallet.digest if wallet.exists? Tempfile.open([@id, Wallet::EXT]) do |f| temp = Wallet.new(f.path) temp.init(@id, @key, overwrite: overwrite, network: @network) File.open(f.path, 'a') do |t| @txns.each do |txn| next if Id::BANNED.include?(txn.bnf.to_s) t.print "#{txn}\n" end end temp.refurbish if temp.balance.negative? && !temp.id.root? && !allow_negative_balance if wallet.exists? @log.info("The balance is negative, won't merge #{temp.mnemo} on top of #{wallet.mnemo}") else @log.info("The balance is negative, won't save #{temp.mnemo}") end else FileUtils.mkdir_p(File.dirname(file)) IO.write(file, IO.read(f.path)) end end before != wallet.digest end
ruby
def save(file, overwrite: false, allow_negative_balance: false) raise 'You have to join at least one wallet in' if empty? before = '' wallet = Wallet.new(file) before = wallet.digest if wallet.exists? Tempfile.open([@id, Wallet::EXT]) do |f| temp = Wallet.new(f.path) temp.init(@id, @key, overwrite: overwrite, network: @network) File.open(f.path, 'a') do |t| @txns.each do |txn| next if Id::BANNED.include?(txn.bnf.to_s) t.print "#{txn}\n" end end temp.refurbish if temp.balance.negative? && !temp.id.root? && !allow_negative_balance if wallet.exists? @log.info("The balance is negative, won't merge #{temp.mnemo} on top of #{wallet.mnemo}") else @log.info("The balance is negative, won't save #{temp.mnemo}") end else FileUtils.mkdir_p(File.dirname(file)) IO.write(file, IO.read(f.path)) end end before != wallet.digest end
[ "def", "save", "(", "file", ",", "overwrite", ":", "false", ",", "allow_negative_balance", ":", "false", ")", "raise", "'You have to join at least one wallet in'", "if", "empty?", "before", "=", "''", "wallet", "=", "Wallet", ".", "new", "(", "file", ")", "bef...
Returns TRUE if the file was actually modified
[ "Returns", "TRUE", "if", "the", "file", "was", "actually", "modified" ]
7e0f69307786846186bc3436dcc72d91d393ddd4
https://github.com/zold-io/zold/blob/7e0f69307786846186bc3436dcc72d91d393ddd4/lib/zold/patch.rb#L186-L213
valid
zold-io/zold
lib/zold/copies.rb
Zold.Copies.clean
def clean(max: 24 * 60 * 60) Futex.new(file, log: @log).open do list = load list.reject! do |s| if s[:time] >= Time.now - max false else @log.debug("Copy ##{s[:name]}/#{s[:host]}:#{s[:port]} is too old, over #{Age.new(s[:time])}") true end end save(list) deleted = 0 files.each do |f| next unless list.find { |s| s[:name] == File.basename(f, Copies::EXT) }.nil? file = File.join(@dir, f) size = File.size(file) File.delete(file) @log.debug("Copy at #{f} deleted: #{Size.new(size)}") deleted += 1 end list.select! do |s| cp = File.join(@dir, "#{s[:name]}#{Copies::EXT}") wallet = Wallet.new(cp) begin wallet.refurbish raise "Invalid protocol #{wallet.protocol} in #{cp}" unless wallet.protocol == Zold::PROTOCOL true rescue StandardError => e FileUtils.rm_rf(cp) @log.debug("Copy at #{cp} deleted: #{Backtrace.new(e)}") deleted += 1 false end end save(list) deleted end end
ruby
def clean(max: 24 * 60 * 60) Futex.new(file, log: @log).open do list = load list.reject! do |s| if s[:time] >= Time.now - max false else @log.debug("Copy ##{s[:name]}/#{s[:host]}:#{s[:port]} is too old, over #{Age.new(s[:time])}") true end end save(list) deleted = 0 files.each do |f| next unless list.find { |s| s[:name] == File.basename(f, Copies::EXT) }.nil? file = File.join(@dir, f) size = File.size(file) File.delete(file) @log.debug("Copy at #{f} deleted: #{Size.new(size)}") deleted += 1 end list.select! do |s| cp = File.join(@dir, "#{s[:name]}#{Copies::EXT}") wallet = Wallet.new(cp) begin wallet.refurbish raise "Invalid protocol #{wallet.protocol} in #{cp}" unless wallet.protocol == Zold::PROTOCOL true rescue StandardError => e FileUtils.rm_rf(cp) @log.debug("Copy at #{cp} deleted: #{Backtrace.new(e)}") deleted += 1 false end end save(list) deleted end end
[ "def", "clean", "(", "max", ":", "24", "*", "60", "*", "60", ")", "Futex", ".", "new", "(", "file", ",", "log", ":", "@log", ")", ".", "open", "do", "list", "=", "load", "list", ".", "reject!", "do", "|", "s", "|", "if", "s", "[", ":time", ...
Delete all copies that are older than the "max" age provided, in seconds.
[ "Delete", "all", "copies", "that", "are", "older", "than", "the", "max", "age", "provided", "in", "seconds", "." ]
7e0f69307786846186bc3436dcc72d91d393ddd4
https://github.com/zold-io/zold/blob/7e0f69307786846186bc3436dcc72d91d393ddd4/lib/zold/copies.rb#L57-L95
valid
zold-io/zold
lib/zold/copies.rb
Zold.Copies.add
def add(content, host, port, score, time: Time.now, master: false) raise "Content can't be empty" if content.empty? raise 'TCP port must be of type Integer' unless port.is_a?(Integer) raise "TCP port can't be negative: #{port}" if port.negative? raise 'Time must be of type Time' unless time.is_a?(Time) raise "Time must be in the past: #{time}" if time > Time.now raise 'Score must be Integer' unless score.is_a?(Integer) raise "Score can't be negative: #{score}" if score.negative? FileUtils.mkdir_p(@dir) Futex.new(file, log: @log).open do list = load target = list.find do |s| f = File.join(@dir, "#{s[:name]}#{Copies::EXT}") digest = OpenSSL::Digest::SHA256.new(content).hexdigest File.exist?(f) && OpenSSL::Digest::SHA256.file(f).hexdigest == digest end if target.nil? max = DirItems.new(@dir).fetch .select { |f| File.basename(f, Copies::EXT) =~ /^[0-9]+$/ } .map(&:to_i) .max max = 0 if max.nil? name = (max + 1).to_s IO.write(File.join(@dir, "#{name}#{Copies::EXT}"), content) else name = target[:name] end list.reject! { |s| s[:host] == host && s[:port] == port } list << { name: name, host: host, port: port, score: score, time: time, master: master } save(list) name end end
ruby
def add(content, host, port, score, time: Time.now, master: false) raise "Content can't be empty" if content.empty? raise 'TCP port must be of type Integer' unless port.is_a?(Integer) raise "TCP port can't be negative: #{port}" if port.negative? raise 'Time must be of type Time' unless time.is_a?(Time) raise "Time must be in the past: #{time}" if time > Time.now raise 'Score must be Integer' unless score.is_a?(Integer) raise "Score can't be negative: #{score}" if score.negative? FileUtils.mkdir_p(@dir) Futex.new(file, log: @log).open do list = load target = list.find do |s| f = File.join(@dir, "#{s[:name]}#{Copies::EXT}") digest = OpenSSL::Digest::SHA256.new(content).hexdigest File.exist?(f) && OpenSSL::Digest::SHA256.file(f).hexdigest == digest end if target.nil? max = DirItems.new(@dir).fetch .select { |f| File.basename(f, Copies::EXT) =~ /^[0-9]+$/ } .map(&:to_i) .max max = 0 if max.nil? name = (max + 1).to_s IO.write(File.join(@dir, "#{name}#{Copies::EXT}"), content) else name = target[:name] end list.reject! { |s| s[:host] == host && s[:port] == port } list << { name: name, host: host, port: port, score: score, time: time, master: master } save(list) name end end
[ "def", "add", "(", "content", ",", "host", ",", "port", ",", "score", ",", "time", ":", "Time", ".", "now", ",", "master", ":", "false", ")", "raise", "\"Content can't be empty\"", "if", "content", ".", "empty?", "raise", "'TCP port must be of type Integer'", ...
Returns the name of the copy
[ "Returns", "the", "name", "of", "the", "copy" ]
7e0f69307786846186bc3436dcc72d91d393ddd4
https://github.com/zold-io/zold/blob/7e0f69307786846186bc3436dcc72d91d393ddd4/lib/zold/copies.rb#L104-L143
valid
zold-io/zold
lib/zold/remotes.rb
Zold.Remotes.iterate
def iterate(log, farm: Farm::Empty.new, threads: 1) raise 'Log can\'t be nil' if log.nil? raise 'Farm can\'t be nil' if farm.nil? Hands.exec(threads, all) do |r, idx| Thread.current.name = "remotes-#{idx}@#{r[:host]}:#{r[:port]}" start = Time.now best = farm.best[0] node = RemoteNode.new( host: r[:host], port: r[:port], score: best.nil? ? Score::ZERO : best, idx: idx, master: master?(r[:host], r[:port]), log: log, network: @network ) begin yield node raise 'Took too long to execute' if (Time.now - start).round > @timeout unerror(r[:host], r[:port]) if node.touched rescue StandardError => e error(r[:host], r[:port]) if e.is_a?(RemoteNode::CantAssert) || e.is_a?(Fetch::Error) log.debug("#{Rainbow(node).red}: \"#{e.message.strip}\" in #{Age.new(start)}") else log.info("#{Rainbow(node).red}: \"#{e.message.strip}\" in #{Age.new(start)}") log.debug(Backtrace.new(e).to_s) end remove(r[:host], r[:port]) if r[:errors] > TOLERANCE end end end
ruby
def iterate(log, farm: Farm::Empty.new, threads: 1) raise 'Log can\'t be nil' if log.nil? raise 'Farm can\'t be nil' if farm.nil? Hands.exec(threads, all) do |r, idx| Thread.current.name = "remotes-#{idx}@#{r[:host]}:#{r[:port]}" start = Time.now best = farm.best[0] node = RemoteNode.new( host: r[:host], port: r[:port], score: best.nil? ? Score::ZERO : best, idx: idx, master: master?(r[:host], r[:port]), log: log, network: @network ) begin yield node raise 'Took too long to execute' if (Time.now - start).round > @timeout unerror(r[:host], r[:port]) if node.touched rescue StandardError => e error(r[:host], r[:port]) if e.is_a?(RemoteNode::CantAssert) || e.is_a?(Fetch::Error) log.debug("#{Rainbow(node).red}: \"#{e.message.strip}\" in #{Age.new(start)}") else log.info("#{Rainbow(node).red}: \"#{e.message.strip}\" in #{Age.new(start)}") log.debug(Backtrace.new(e).to_s) end remove(r[:host], r[:port]) if r[:errors] > TOLERANCE end end end
[ "def", "iterate", "(", "log", ",", "farm", ":", "Farm", "::", "Empty", ".", "new", ",", "threads", ":", "1", ")", "raise", "'Log can\\'t be nil'", "if", "log", ".", "nil?", "raise", "'Farm can\\'t be nil'", "if", "farm", ".", "nil?", "Hands", ".", "exec"...
Go through the list of remotes and call a provided block for each of them. See how it's used, for example, in fetch.rb.
[ "Go", "through", "the", "list", "of", "remotes", "and", "call", "a", "provided", "block", "for", "each", "of", "them", ".", "See", "how", "it", "s", "used", "for", "example", "in", "fetch", ".", "rb", "." ]
7e0f69307786846186bc3436dcc72d91d393ddd4
https://github.com/zold-io/zold/blob/7e0f69307786846186bc3436dcc72d91d393ddd4/lib/zold/remotes.rb#L206-L237
valid
thredded/thredded
app/models/concerns/thredded/post_common.rb
Thredded.PostCommon.mark_as_unread
def mark_as_unread(user) if previous_post.nil? read_state = postable.user_read_states.find_by(user_id: user.id) read_state.destroy if read_state else postable.user_read_states.touch!(user.id, previous_post, overwrite_newer: true) end end
ruby
def mark_as_unread(user) if previous_post.nil? read_state = postable.user_read_states.find_by(user_id: user.id) read_state.destroy if read_state else postable.user_read_states.touch!(user.id, previous_post, overwrite_newer: true) end end
[ "def", "mark_as_unread", "(", "user", ")", "if", "previous_post", ".", "nil?", "read_state", "=", "postable", ".", "user_read_states", ".", "find_by", "(", "user_id", ":", "user", ".", "id", ")", "read_state", ".", "destroy", "if", "read_state", "else", "pos...
Marks all the posts from the given one as unread for the given user @param [Thredded.user_class] user
[ "Marks", "all", "the", "posts", "from", "the", "given", "one", "as", "unread", "for", "the", "given", "user" ]
f1874fba333444255979c0789ba17f8dc24a4d6f
https://github.com/thredded/thredded/blob/f1874fba333444255979c0789ba17f8dc24a4d6f/app/models/concerns/thredded/post_common.rb#L67-L74
valid
thredded/thredded
app/mailers/thredded/base_mailer.rb
Thredded.BaseMailer.find_record
def find_record(klass, id_or_record) # Check by name because in development the Class might have been reloaded after id was initialized id_or_record.class.name == klass.name ? id_or_record : klass.find(id_or_record) end
ruby
def find_record(klass, id_or_record) # Check by name because in development the Class might have been reloaded after id was initialized id_or_record.class.name == klass.name ? id_or_record : klass.find(id_or_record) end
[ "def", "find_record", "(", "klass", ",", "id_or_record", ")", "id_or_record", ".", "class", ".", "name", "==", "klass", ".", "name", "?", "id_or_record", ":", "klass", ".", "find", "(", "id_or_record", ")", "end" ]
Find a record by ID, or return the passed record. @param [Class<ActiveRecord::Base>] klass @param [Integer, String, klass] id_or_record @return [klass]
[ "Find", "a", "record", "by", "ID", "or", "return", "the", "passed", "record", "." ]
f1874fba333444255979c0789ba17f8dc24a4d6f
https://github.com/thredded/thredded/blob/f1874fba333444255979c0789ba17f8dc24a4d6f/app/mailers/thredded/base_mailer.rb#L13-L16
valid
thredded/thredded
app/models/concerns/thredded/content_moderation_state.rb
Thredded.ContentModerationState.moderation_state_visible_to_user?
def moderation_state_visible_to_user?(user) moderation_state_visible_to_all? || (!user.thredded_anonymous? && (user_id == user.id || user.thredded_can_moderate_messageboard?(messageboard))) end
ruby
def moderation_state_visible_to_user?(user) moderation_state_visible_to_all? || (!user.thredded_anonymous? && (user_id == user.id || user.thredded_can_moderate_messageboard?(messageboard))) end
[ "def", "moderation_state_visible_to_user?", "(", "user", ")", "moderation_state_visible_to_all?", "||", "(", "!", "user", ".", "thredded_anonymous?", "&&", "(", "user_id", "==", "user", ".", "id", "||", "user", ".", "thredded_can_moderate_messageboard?", "(", "message...
Whether this is visible to the given user based on the moderation state.
[ "Whether", "this", "is", "visible", "to", "the", "given", "user", "based", "on", "the", "moderation", "state", "." ]
f1874fba333444255979c0789ba17f8dc24a4d6f
https://github.com/thredded/thredded/blob/f1874fba333444255979c0789ba17f8dc24a4d6f/app/models/concerns/thredded/content_moderation_state.rb#L55-L59
valid
zdavatz/spreadsheet
lib/spreadsheet/worksheet.rb
Spreadsheet.Worksheet.protect!
def protect! password = '' @protected = true password = password.to_s if password.size == 0 @password_hash = 0 else @password_hash = Excel::Password.password_hash password end end
ruby
def protect! password = '' @protected = true password = password.to_s if password.size == 0 @password_hash = 0 else @password_hash = Excel::Password.password_hash password end end
[ "def", "protect!", "password", "=", "''", "@protected", "=", "true", "password", "=", "password", ".", "to_s", "if", "password", ".", "size", "==", "0", "@password_hash", "=", "0", "else", "@password_hash", "=", "Excel", "::", "Password", ".", "password_hash...
Set worklist protection
[ "Set", "worklist", "protection" ]
0ab10ae72d0c04027168154d938fa9355e478d58
https://github.com/zdavatz/spreadsheet/blob/0ab10ae72d0c04027168154d938fa9355e478d58/lib/spreadsheet/worksheet.rb#L130-L138
valid
zdavatz/spreadsheet
lib/spreadsheet/worksheet.rb
Spreadsheet.Worksheet.format_column
def format_column idx, format=nil, opts={} opts[:worksheet] = self res = case idx when Integer column = nil if format column = Column.new(idx, format, opts) end @columns[idx] = column else idx.collect do |col| format_column col, format, opts end end shorten @columns res end
ruby
def format_column idx, format=nil, opts={} opts[:worksheet] = self res = case idx when Integer column = nil if format column = Column.new(idx, format, opts) end @columns[idx] = column else idx.collect do |col| format_column col, format, opts end end shorten @columns res end
[ "def", "format_column", "idx", ",", "format", "=", "nil", ",", "opts", "=", "{", "}", "opts", "[", ":worksheet", "]", "=", "self", "res", "=", "case", "idx", "when", "Integer", "column", "=", "nil", "if", "format", "column", "=", "Column", ".", "new"...
Sets the default Format of the column at _idx_. _idx_ may be an Integer, or an Enumerable that iterates over a number of Integers. _format_ is a Format, or nil if you want to remove the Formatting at _idx_ Returns an instance of Column if _idx_ is an Integer, an Array of Columns otherwise.
[ "Sets", "the", "default", "Format", "of", "the", "column", "at", "_idx_", "." ]
0ab10ae72d0c04027168154d938fa9355e478d58
https://github.com/zdavatz/spreadsheet/blob/0ab10ae72d0c04027168154d938fa9355e478d58/lib/spreadsheet/worksheet.rb#L178-L192
valid
zdavatz/spreadsheet
lib/spreadsheet/worksheet.rb
Spreadsheet.Worksheet.update_row
def update_row idx, *cells res = if row = @rows[idx] row[0, cells.size] = cells row else Row.new self, idx, cells end row_updated idx, res res end
ruby
def update_row idx, *cells res = if row = @rows[idx] row[0, cells.size] = cells row else Row.new self, idx, cells end row_updated idx, res res end
[ "def", "update_row", "idx", ",", "*", "cells", "res", "=", "if", "row", "=", "@rows", "[", "idx", "]", "row", "[", "0", ",", "cells", ".", "size", "]", "=", "cells", "row", "else", "Row", ".", "new", "self", ",", "idx", ",", "cells", "end", "ro...
Updates the Row at _idx_ with the following arguments.
[ "Updates", "the", "Row", "at", "_idx_", "with", "the", "following", "arguments", "." ]
0ab10ae72d0c04027168154d938fa9355e478d58
https://github.com/zdavatz/spreadsheet/blob/0ab10ae72d0c04027168154d938fa9355e478d58/lib/spreadsheet/worksheet.rb#L280-L289
valid
zdavatz/spreadsheet
lib/spreadsheet/worksheet.rb
Spreadsheet.Worksheet.merge_cells
def merge_cells start_row, start_col, end_row, end_col # FIXME enlarge or dup check @merged_cells.push [start_row, end_row, start_col, end_col] end
ruby
def merge_cells start_row, start_col, end_row, end_col # FIXME enlarge or dup check @merged_cells.push [start_row, end_row, start_col, end_col] end
[ "def", "merge_cells", "start_row", ",", "start_col", ",", "end_row", ",", "end_col", "@merged_cells", ".", "push", "[", "start_row", ",", "end_row", ",", "start_col", ",", "end_col", "]", "end" ]
Merges multiple cells into one.
[ "Merges", "multiple", "cells", "into", "one", "." ]
0ab10ae72d0c04027168154d938fa9355e478d58
https://github.com/zdavatz/spreadsheet/blob/0ab10ae72d0c04027168154d938fa9355e478d58/lib/spreadsheet/worksheet.rb#L314-L317
valid
zdavatz/spreadsheet
lib/spreadsheet/row.rb
Spreadsheet.Row.formatted
def formatted copy = dup Helpers.rcompact(@formats) if copy.length < @formats.size copy.concat Array.new(@formats.size - copy.length) end copy end
ruby
def formatted copy = dup Helpers.rcompact(@formats) if copy.length < @formats.size copy.concat Array.new(@formats.size - copy.length) end copy end
[ "def", "formatted", "copy", "=", "dup", "Helpers", ".", "rcompact", "(", "@formats", ")", "if", "copy", ".", "length", "<", "@formats", ".", "size", "copy", ".", "concat", "Array", ".", "new", "(", "@formats", ".", "size", "-", "copy", ".", "length", ...
Returns a copy of self with nil-values appended for empty cells that have an associated Format. This is primarily a helper-function for the writer classes.
[ "Returns", "a", "copy", "of", "self", "with", "nil", "-", "values", "appended", "for", "empty", "cells", "that", "have", "an", "associated", "Format", ".", "This", "is", "primarily", "a", "helper", "-", "function", "for", "the", "writer", "classes", "." ]
0ab10ae72d0c04027168154d938fa9355e478d58
https://github.com/zdavatz/spreadsheet/blob/0ab10ae72d0c04027168154d938fa9355e478d58/lib/spreadsheet/row.rb#L97-L104
valid
zdavatz/spreadsheet
lib/spreadsheet/workbook.rb
Spreadsheet.Workbook.set_custom_color
def set_custom_color idx, red, green, blue raise 'Invalid format' if [red, green, blue].find { |c| ! (0..255).include?(c) } @palette[idx] = [red, green, blue] end
ruby
def set_custom_color idx, red, green, blue raise 'Invalid format' if [red, green, blue].find { |c| ! (0..255).include?(c) } @palette[idx] = [red, green, blue] end
[ "def", "set_custom_color", "idx", ",", "red", ",", "green", ",", "blue", "raise", "'Invalid format'", "if", "[", "red", ",", "green", ",", "blue", "]", ".", "find", "{", "|", "c", "|", "!", "(", "0", "..", "255", ")", ".", "include?", "(", "c", "...
Change the RGB components of the elements in the colour palette.
[ "Change", "the", "RGB", "components", "of", "the", "elements", "in", "the", "colour", "palette", "." ]
0ab10ae72d0c04027168154d938fa9355e478d58
https://github.com/zdavatz/spreadsheet/blob/0ab10ae72d0c04027168154d938fa9355e478d58/lib/spreadsheet/workbook.rb#L59-L63
valid
zdavatz/spreadsheet
lib/spreadsheet/workbook.rb
Spreadsheet.Workbook.format
def format idx case idx when Integer @formats[idx] || @default_format || Format.new when String @formats.find do |fmt| fmt.name == idx end end end
ruby
def format idx case idx when Integer @formats[idx] || @default_format || Format.new when String @formats.find do |fmt| fmt.name == idx end end end
[ "def", "format", "idx", "case", "idx", "when", "Integer", "@formats", "[", "idx", "]", "||", "@default_format", "||", "Format", ".", "new", "when", "String", "@formats", ".", "find", "do", "|", "fmt", "|", "fmt", ".", "name", "==", "idx", "end", "end",...
The Format at _idx_, or - if _idx_ is a String - the Format with name == _idx_
[ "The", "Format", "at", "_idx_", "or", "-", "if", "_idx_", "is", "a", "String", "-", "the", "Format", "with", "name", "==", "_idx_" ]
0ab10ae72d0c04027168154d938fa9355e478d58
https://github.com/zdavatz/spreadsheet/blob/0ab10ae72d0c04027168154d938fa9355e478d58/lib/spreadsheet/workbook.rb#L89-L96
valid
zdavatz/spreadsheet
lib/spreadsheet/workbook.rb
Spreadsheet.Workbook.worksheet
def worksheet idx case idx when Integer @worksheets[idx] when String @worksheets.find do |sheet| sheet.name == idx end end end
ruby
def worksheet idx case idx when Integer @worksheets[idx] when String @worksheets.find do |sheet| sheet.name == idx end end end
[ "def", "worksheet", "idx", "case", "idx", "when", "Integer", "@worksheets", "[", "idx", "]", "when", "String", "@worksheets", ".", "find", "do", "|", "sheet", "|", "sheet", ".", "name", "==", "idx", "end", "end", "end" ]
The Worksheet at _idx_, or - if _idx_ is a String - the Worksheet with name == _idx_
[ "The", "Worksheet", "at", "_idx_", "or", "-", "if", "_idx_", "is", "a", "String", "-", "the", "Worksheet", "with", "name", "==", "_idx_" ]
0ab10ae72d0c04027168154d938fa9355e478d58
https://github.com/zdavatz/spreadsheet/blob/0ab10ae72d0c04027168154d938fa9355e478d58/lib/spreadsheet/workbook.rb#L114-L121
valid
zdavatz/spreadsheet
lib/spreadsheet/workbook.rb
Spreadsheet.Workbook.write
def write io_path_or_writer if io_path_or_writer.is_a? Writer io_path_or_writer.write self else writer(io_path_or_writer).write(self) end end
ruby
def write io_path_or_writer if io_path_or_writer.is_a? Writer io_path_or_writer.write self else writer(io_path_or_writer).write(self) end end
[ "def", "write", "io_path_or_writer", "if", "io_path_or_writer", ".", "is_a?", "Writer", "io_path_or_writer", ".", "write", "self", "else", "writer", "(", "io_path_or_writer", ")", ".", "write", "(", "self", ")", "end", "end" ]
Write this Workbook to a File, IO Stream or Writer Object. The latter will make more sense once there are more than just an Excel-Writer available.
[ "Write", "this", "Workbook", "to", "a", "File", "IO", "Stream", "or", "Writer", "Object", ".", "The", "latter", "will", "make", "more", "sense", "once", "there", "are", "more", "than", "just", "an", "Excel", "-", "Writer", "available", "." ]
0ab10ae72d0c04027168154d938fa9355e478d58
https://github.com/zdavatz/spreadsheet/blob/0ab10ae72d0c04027168154d938fa9355e478d58/lib/spreadsheet/workbook.rb#L125-L131
valid
zendesk/zendesk_api_client_rb
lib/zendesk_api/sideloading.rb
ZendeskAPI.Sideloading._side_load
def _side_load(name, klass, resources) associations = klass.associated_with(name) associations.each do |association| association.side_load(resources, @included[name]) end resources.each do |resource| loaded_associations = resource.loaded_associations loaded_associations.each do |association| loaded = resource.send(association[:name]) next unless loaded _side_load(name, association[:class], to_array(loaded)) end end end
ruby
def _side_load(name, klass, resources) associations = klass.associated_with(name) associations.each do |association| association.side_load(resources, @included[name]) end resources.each do |resource| loaded_associations = resource.loaded_associations loaded_associations.each do |association| loaded = resource.send(association[:name]) next unless loaded _side_load(name, association[:class], to_array(loaded)) end end end
[ "def", "_side_load", "(", "name", ",", "klass", ",", "resources", ")", "associations", "=", "klass", ".", "associated_with", "(", "name", ")", "associations", ".", "each", "do", "|", "association", "|", "association", ".", "side_load", "(", "resources", ",",...
Traverses the resource looking for associations then descends into those associations and checks for applicable resources to side load
[ "Traverses", "the", "resource", "looking", "for", "associations", "then", "descends", "into", "those", "associations", "and", "checks", "for", "applicable", "resources", "to", "side", "load" ]
4237daa923c6e353a888473adae2a808352f4b26
https://github.com/zendesk/zendesk_api_client_rb/blob/4237daa923c6e353a888473adae2a808352f4b26/lib/zendesk_api/sideloading.rb#L33-L48
valid
zendesk/zendesk_api_client_rb
lib/zendesk_api/collection.rb
ZendeskAPI.Collection.<<
def <<(item) fetch if item.is_a?(Resource) if item.is_a?(@resource_class) @resources << item else raise "this collection is for #{@resource_class}" end else @resources << wrap_resource(item, true) end end
ruby
def <<(item) fetch if item.is_a?(Resource) if item.is_a?(@resource_class) @resources << item else raise "this collection is for #{@resource_class}" end else @resources << wrap_resource(item, true) end end
[ "def", "<<", "(", "item", ")", "fetch", "if", "item", ".", "is_a?", "(", "Resource", ")", "if", "item", ".", "is_a?", "(", "@resource_class", ")", "@resources", "<<", "item", "else", "raise", "\"this collection is for #{@resource_class}\"", "end", "else", "@re...
Adds an item to this collection @option item [ZendeskAPI::Data] the resource to add @raise [ArgumentError] if the resource doesn't belong in this collection
[ "Adds", "an", "item", "to", "this", "collection" ]
4237daa923c6e353a888473adae2a808352f4b26
https://github.com/zendesk/zendesk_api_client_rb/blob/4237daa923c6e353a888473adae2a808352f4b26/lib/zendesk_api/collection.rb#L161-L173
valid
zendesk/zendesk_api_client_rb
lib/zendesk_api/collection.rb
ZendeskAPI.Collection.fetch!
def fetch!(reload = false) if @resources && (!@fetchable || !reload) return @resources elsif association && association.options.parent && association.options.parent.new_record? return (@resources = []) end @response = get_response(@query || path) handle_response(@response.body) @resources end
ruby
def fetch!(reload = false) if @resources && (!@fetchable || !reload) return @resources elsif association && association.options.parent && association.options.parent.new_record? return (@resources = []) end @response = get_response(@query || path) handle_response(@response.body) @resources end
[ "def", "fetch!", "(", "reload", "=", "false", ")", "if", "@resources", "&&", "(", "!", "@fetchable", "||", "!", "reload", ")", "return", "@resources", "elsif", "association", "&&", "association", ".", "options", ".", "parent", "&&", "association", ".", "op...
Executes actual GET from API and loads resources into proper class. @param [Boolean] reload Whether to disregard cache
[ "Executes", "actual", "GET", "from", "API", "and", "loads", "resources", "into", "proper", "class", "." ]
4237daa923c6e353a888473adae2a808352f4b26
https://github.com/zendesk/zendesk_api_client_rb/blob/4237daa923c6e353a888473adae2a808352f4b26/lib/zendesk_api/collection.rb#L182-L193
valid
zendesk/zendesk_api_client_rb
lib/zendesk_api/collection.rb
ZendeskAPI.Collection.method_missing
def method_missing(name, *args, &block) if resource_methods.include?(name) collection_method(name, *args, &block) elsif [].respond_to?(name, false) array_method(name, *args, &block) else next_collection(name, *args, &block) end end
ruby
def method_missing(name, *args, &block) if resource_methods.include?(name) collection_method(name, *args, &block) elsif [].respond_to?(name, false) array_method(name, *args, &block) else next_collection(name, *args, &block) end end
[ "def", "method_missing", "(", "name", ",", "*", "args", ",", "&", "block", ")", "if", "resource_methods", ".", "include?", "(", "name", ")", "collection_method", "(", "name", ",", "*", "args", ",", "&", "block", ")", "elsif", "[", "]", ".", "respond_to...
Sends methods to underlying array of resources.
[ "Sends", "methods", "to", "underlying", "array", "of", "resources", "." ]
4237daa923c6e353a888473adae2a808352f4b26
https://github.com/zendesk/zendesk_api_client_rb/blob/4237daa923c6e353a888473adae2a808352f4b26/lib/zendesk_api/collection.rb#L294-L302
valid
zendesk/zendesk_api_client_rb
lib/zendesk_api/association.rb
ZendeskAPI.Association.side_load
def side_load(resources, side_loads) key = "#{options.name}_id" plural_key = "#{Inflection.singular options.name.to_s}_ids" resources.each do |resource| if resource.key?(plural_key) # Grab associations from child_ids field on resource side_load_from_child_ids(resource, side_loads, plural_key) elsif resource.key?(key) || options.singular side_load_from_child_or_parent_id(resource, side_loads, key) else # Grab associations from parent_id field from multiple child resources side_load_from_parent_id(resource, side_loads, key) end end end
ruby
def side_load(resources, side_loads) key = "#{options.name}_id" plural_key = "#{Inflection.singular options.name.to_s}_ids" resources.each do |resource| if resource.key?(plural_key) # Grab associations from child_ids field on resource side_load_from_child_ids(resource, side_loads, plural_key) elsif resource.key?(key) || options.singular side_load_from_child_or_parent_id(resource, side_loads, key) else # Grab associations from parent_id field from multiple child resources side_load_from_parent_id(resource, side_loads, key) end end end
[ "def", "side_load", "(", "resources", ",", "side_loads", ")", "key", "=", "\"#{options.name}_id\"", "plural_key", "=", "\"#{Inflection.singular options.name.to_s}_ids\"", "resources", ".", "each", "do", "|", "resource", "|", "if", "resource", ".", "key?", "(", "plur...
Tries to place side loads onto given resources.
[ "Tries", "to", "place", "side", "loads", "onto", "given", "resources", "." ]
4237daa923c6e353a888473adae2a808352f4b26
https://github.com/zendesk/zendesk_api_client_rb/blob/4237daa923c6e353a888473adae2a808352f4b26/lib/zendesk_api/association.rb#L83-L96
valid
zendesk/zendesk_api_client_rb
lib/zendesk_api/actions.rb
ZendeskAPI.Save.save
def save(options = {}, &block) save!(options, &block) rescue ZendeskAPI::Error::RecordInvalid => e @errors = e.errors false rescue ZendeskAPI::Error::ClientError false end
ruby
def save(options = {}, &block) save!(options, &block) rescue ZendeskAPI::Error::RecordInvalid => e @errors = e.errors false rescue ZendeskAPI::Error::ClientError false end
[ "def", "save", "(", "options", "=", "{", "}", ",", "&", "block", ")", "save!", "(", "options", ",", "&", "block", ")", "rescue", "ZendeskAPI", "::", "Error", "::", "RecordInvalid", "=>", "e", "@errors", "=", "e", ".", "errors", "false", "rescue", "Ze...
Saves, returning false if it fails and attaching the errors
[ "Saves", "returning", "false", "if", "it", "fails", "and", "attaching", "the", "errors" ]
4237daa923c6e353a888473adae2a808352f4b26
https://github.com/zendesk/zendesk_api_client_rb/blob/4237daa923c6e353a888473adae2a808352f4b26/lib/zendesk_api/actions.rb#L46-L53
valid
zendesk/zendesk_api_client_rb
lib/zendesk_api/actions.rb
ZendeskAPI.Save.save_associations
def save_associations self.class.associations.each do |association_data| association_name = association_data[:name] next unless send("#{association_name}_used?") && association = send(association_name) inline_creation = association_data[:inline] == :create && new_record? changed = association.is_a?(Collection) || association.changed? if association.respond_to?(:save) && changed && !inline_creation && association.save send("#{association_name}=", association) # set id/ids columns end if (association_data[:inline] == true || inline_creation) && changed attributes[association_name] = association.to_param end end end
ruby
def save_associations self.class.associations.each do |association_data| association_name = association_data[:name] next unless send("#{association_name}_used?") && association = send(association_name) inline_creation = association_data[:inline] == :create && new_record? changed = association.is_a?(Collection) || association.changed? if association.respond_to?(:save) && changed && !inline_creation && association.save send("#{association_name}=", association) # set id/ids columns end if (association_data[:inline] == true || inline_creation) && changed attributes[association_name] = association.to_param end end end
[ "def", "save_associations", "self", ".", "class", ".", "associations", ".", "each", "do", "|", "association_data", "|", "association_name", "=", "association_data", "[", ":name", "]", "next", "unless", "send", "(", "\"#{association_name}_used?\"", ")", "&&", "asso...
Saves associations Takes into account inlining, collections, and id setting on the parent resource.
[ "Saves", "associations", "Takes", "into", "account", "inlining", "collections", "and", "id", "setting", "on", "the", "parent", "resource", "." ]
4237daa923c6e353a888473adae2a808352f4b26
https://github.com/zendesk/zendesk_api_client_rb/blob/4237daa923c6e353a888473adae2a808352f4b26/lib/zendesk_api/actions.rb#L65-L82
valid
zendesk/zendesk_api_client_rb
lib/zendesk_api/actions.rb
ZendeskAPI.Read.reload!
def reload! response = @client.connection.get(path) do |req| yield req if block_given? end handle_response(response) attributes.clear_changes self end
ruby
def reload! response = @client.connection.get(path) do |req| yield req if block_given? end handle_response(response) attributes.clear_changes self end
[ "def", "reload!", "response", "=", "@client", ".", "connection", ".", "get", "(", "path", ")", "do", "|", "req", "|", "yield", "req", "if", "block_given?", "end", "handle_response", "(", "response", ")", "attributes", ".", "clear_changes", "self", "end" ]
Reloads a resource.
[ "Reloads", "a", "resource", "." ]
4237daa923c6e353a888473adae2a808352f4b26
https://github.com/zendesk/zendesk_api_client_rb/blob/4237daa923c6e353a888473adae2a808352f4b26/lib/zendesk_api/actions.rb#L94-L102
valid
zendesk/zendesk_api_client_rb
lib/zendesk_api/actions.rb
ZendeskAPI.CreateMany.create_many!
def create_many!(client, attributes_array, association = Association.new(:class => self)) response = client.connection.post("#{association.generate_path}/create_many") do |req| req.body = { resource_name => attributes_array } yield req if block_given? end JobStatus.new_from_response(client, response) end
ruby
def create_many!(client, attributes_array, association = Association.new(:class => self)) response = client.connection.post("#{association.generate_path}/create_many") do |req| req.body = { resource_name => attributes_array } yield req if block_given? end JobStatus.new_from_response(client, response) end
[ "def", "create_many!", "(", "client", ",", "attributes_array", ",", "association", "=", "Association", ".", "new", "(", ":class", "=>", "self", ")", ")", "response", "=", "client", ".", "connection", ".", "post", "(", "\"#{association.generate_path}/create_many\""...
Creates multiple resources using the create_many endpoint. @param [Client] client The {Client} object to be used @param [Array] attributes_array An array of resources to be created. @return [JobStatus] the {JobStatus} instance for this create job
[ "Creates", "multiple", "resources", "using", "the", "create_many", "endpoint", "." ]
4237daa923c6e353a888473adae2a808352f4b26
https://github.com/zendesk/zendesk_api_client_rb/blob/4237daa923c6e353a888473adae2a808352f4b26/lib/zendesk_api/actions.rb#L173-L181
valid
zendesk/zendesk_api_client_rb
lib/zendesk_api/actions.rb
ZendeskAPI.CreateOrUpdate.create_or_update!
def create_or_update!(client, attributes, association = Association.new(:class => self)) response = client.connection.post("#{association.generate_path}/create_or_update") do |req| req.body = { resource_name => attributes } yield req if block_given? end new_from_response(client, response, Array(association.options[:include])) end
ruby
def create_or_update!(client, attributes, association = Association.new(:class => self)) response = client.connection.post("#{association.generate_path}/create_or_update") do |req| req.body = { resource_name => attributes } yield req if block_given? end new_from_response(client, response, Array(association.options[:include])) end
[ "def", "create_or_update!", "(", "client", ",", "attributes", ",", "association", "=", "Association", ".", "new", "(", ":class", "=>", "self", ")", ")", "response", "=", "client", ".", "connection", ".", "post", "(", "\"#{association.generate_path}/create_or_updat...
Creates or updates resource using the create_or_update endpoint. @param [Client] client The {Client} object to be used @param [Hash] attributes The attributes to create.
[ "Creates", "or", "updates", "resource", "using", "the", "create_or_update", "endpoint", "." ]
4237daa923c6e353a888473adae2a808352f4b26
https://github.com/zendesk/zendesk_api_client_rb/blob/4237daa923c6e353a888473adae2a808352f4b26/lib/zendesk_api/actions.rb#L188-L196
valid
zendesk/zendesk_api_client_rb
lib/zendesk_api/actions.rb
ZendeskAPI.CreateOrUpdateMany.create_or_update_many!
def create_or_update_many!(client, attributes) association = Association.new(:class => self) response = client.connection.post("#{association.generate_path}/create_or_update_many") do |req| req.body = { resource_name => attributes } yield req if block_given? end JobStatus.new_from_response(client, response) end
ruby
def create_or_update_many!(client, attributes) association = Association.new(:class => self) response = client.connection.post("#{association.generate_path}/create_or_update_many") do |req| req.body = { resource_name => attributes } yield req if block_given? end JobStatus.new_from_response(client, response) end
[ "def", "create_or_update_many!", "(", "client", ",", "attributes", ")", "association", "=", "Association", ".", "new", "(", ":class", "=>", "self", ")", "response", "=", "client", ".", "connection", ".", "post", "(", "\"#{association.generate_path}/create_or_update_...
Creates or updates multiple resources using the create_or_update_many endpoint. @param [Client] client The {Client} object to be used @param [Array<Hash>] attributes The attributes to update resources with @return [JobStatus] the {JobStatus} instance for this destroy job
[ "Creates", "or", "updates", "multiple", "resources", "using", "the", "create_or_update_many", "endpoint", "." ]
4237daa923c6e353a888473adae2a808352f4b26
https://github.com/zendesk/zendesk_api_client_rb/blob/4237daa923c6e353a888473adae2a808352f4b26/lib/zendesk_api/actions.rb#L206-L216
valid
zendesk/zendesk_api_client_rb
lib/zendesk_api/actions.rb
ZendeskAPI.Destroy.destroy!
def destroy! return false if destroyed? || new_record? @client.connection.delete(url || path) do |req| yield req if block_given? end @destroyed = true end
ruby
def destroy! return false if destroyed? || new_record? @client.connection.delete(url || path) do |req| yield req if block_given? end @destroyed = true end
[ "def", "destroy!", "return", "false", "if", "destroyed?", "||", "new_record?", "@client", ".", "connection", ".", "delete", "(", "url", "||", "path", ")", "do", "|", "req", "|", "yield", "req", "if", "block_given?", "end", "@destroyed", "=", "true", "end" ...
If this resource hasn't already been deleted, then do so. @return [Boolean] Successful?
[ "If", "this", "resource", "hasn", "t", "already", "been", "deleted", "then", "do", "so", "." ]
4237daa923c6e353a888473adae2a808352f4b26
https://github.com/zendesk/zendesk_api_client_rb/blob/4237daa923c6e353a888473adae2a808352f4b26/lib/zendesk_api/actions.rb#L231-L239
valid
zendesk/zendesk_api_client_rb
lib/zendesk_api/actions.rb
ZendeskAPI.DestroyMany.destroy_many!
def destroy_many!(client, ids, association = Association.new(:class => self)) response = client.connection.delete("#{association.generate_path}/destroy_many") do |req| req.params = { :ids => ids.join(',') } yield req if block_given? end JobStatus.new_from_response(client, response) end
ruby
def destroy_many!(client, ids, association = Association.new(:class => self)) response = client.connection.delete("#{association.generate_path}/destroy_many") do |req| req.params = { :ids => ids.join(',') } yield req if block_given? end JobStatus.new_from_response(client, response) end
[ "def", "destroy_many!", "(", "client", ",", "ids", ",", "association", "=", "Association", ".", "new", "(", ":class", "=>", "self", ")", ")", "response", "=", "client", ".", "connection", ".", "delete", "(", "\"#{association.generate_path}/destroy_many\"", ")", ...
Destroys multiple resources using the destroy_many endpoint. @param [Client] client The {Client} object to be used @param [Array] ids An array of ids to destroy @return [JobStatus] the {JobStatus} instance for this destroy job
[ "Destroys", "multiple", "resources", "using", "the", "destroy_many", "endpoint", "." ]
4237daa923c6e353a888473adae2a808352f4b26
https://github.com/zendesk/zendesk_api_client_rb/blob/4237daa923c6e353a888473adae2a808352f4b26/lib/zendesk_api/actions.rb#L272-L280
valid
zendesk/zendesk_api_client_rb
lib/zendesk_api/actions.rb
ZendeskAPI.UpdateMany.update_many!
def update_many!(client, ids_or_attributes, attributes = {}) association = attributes.delete(:association) || Association.new(:class => self) response = client.connection.put("#{association.generate_path}/update_many") do |req| if attributes == {} req.body = { resource_name => ids_or_attributes } else req.params = { :ids => ids_or_attributes.join(',') } req.body = { singular_resource_name => attributes } end yield req if block_given? end JobStatus.new_from_response(client, response) end
ruby
def update_many!(client, ids_or_attributes, attributes = {}) association = attributes.delete(:association) || Association.new(:class => self) response = client.connection.put("#{association.generate_path}/update_many") do |req| if attributes == {} req.body = { resource_name => ids_or_attributes } else req.params = { :ids => ids_or_attributes.join(',') } req.body = { singular_resource_name => attributes } end yield req if block_given? end JobStatus.new_from_response(client, response) end
[ "def", "update_many!", "(", "client", ",", "ids_or_attributes", ",", "attributes", "=", "{", "}", ")", "association", "=", "attributes", ".", "delete", "(", ":association", ")", "||", "Association", ".", "new", "(", ":class", "=>", "self", ")", "response", ...
Updates multiple resources using the update_many endpoint. @param [Client] client The {Client} object to be used @param [Array] ids_or_attributes An array of ids or arributes including ids to update @param [Hash] attributes The attributes to update resources with @return [JobStatus] the {JobStatus} instance for this destroy job
[ "Updates", "multiple", "resources", "using", "the", "update_many", "endpoint", "." ]
4237daa923c6e353a888473adae2a808352f4b26
https://github.com/zendesk/zendesk_api_client_rb/blob/4237daa923c6e353a888473adae2a808352f4b26/lib/zendesk_api/actions.rb#L317-L332
valid
zendesk/zendesk_api_client_rb
lib/zendesk_api/resources.rb
ZendeskAPI.Macro.apply!
def apply!(ticket = nil) path = "#{self.path}/apply" if ticket path = "#{ticket.path}/#{path}" end response = @client.connection.get(path) SilentMash.new(response.body.fetch("result", {})) end
ruby
def apply!(ticket = nil) path = "#{self.path}/apply" if ticket path = "#{ticket.path}/#{path}" end response = @client.connection.get(path) SilentMash.new(response.body.fetch("result", {})) end
[ "def", "apply!", "(", "ticket", "=", "nil", ")", "path", "=", "\"#{self.path}/apply\"", "if", "ticket", "path", "=", "\"#{ticket.path}/#{path}\"", "end", "response", "=", "@client", ".", "connection", ".", "get", "(", "path", ")", "SilentMash", ".", "new", "...
Returns the update to a ticket that happens when a macro will be applied. @param [Ticket] ticket Optional {Ticket} to apply this macro to. @raise [Faraday::Error::ClientError] Raised for any non-200 response.
[ "Returns", "the", "update", "to", "a", "ticket", "that", "happens", "when", "a", "macro", "will", "be", "applied", "." ]
4237daa923c6e353a888473adae2a808352f4b26
https://github.com/zendesk/zendesk_api_client_rb/blob/4237daa923c6e353a888473adae2a808352f4b26/lib/zendesk_api/resources.rb#L616-L625
valid
zendesk/zendesk_api_client_rb
lib/zendesk_api/client.rb
ZendeskAPI.Client.method_missing
def method_missing(method, *args, &block) method = method.to_s options = args.last.is_a?(Hash) ? args.pop : {} @resource_cache[method] ||= { :class => nil, :cache => ZendeskAPI::LRUCache.new } if !options.delete(:reload) && (cached = @resource_cache[method][:cache].read(options.hash)) cached else @resource_cache[method][:class] ||= method_as_class(method) raise "Resource for #{method} does not exist" unless @resource_cache[method][:class] @resource_cache[method][:cache].write(options.hash, ZendeskAPI::Collection.new(self, @resource_cache[method][:class], options)) end end
ruby
def method_missing(method, *args, &block) method = method.to_s options = args.last.is_a?(Hash) ? args.pop : {} @resource_cache[method] ||= { :class => nil, :cache => ZendeskAPI::LRUCache.new } if !options.delete(:reload) && (cached = @resource_cache[method][:cache].read(options.hash)) cached else @resource_cache[method][:class] ||= method_as_class(method) raise "Resource for #{method} does not exist" unless @resource_cache[method][:class] @resource_cache[method][:cache].write(options.hash, ZendeskAPI::Collection.new(self, @resource_cache[method][:class], options)) end end
[ "def", "method_missing", "(", "method", ",", "*", "args", ",", "&", "block", ")", "method", "=", "method", ".", "to_s", "options", "=", "args", ".", "last", ".", "is_a?", "(", "Hash", ")", "?", "args", ".", "pop", ":", "{", "}", "@resource_cache", ...
Handles resources such as 'tickets'. Any options are passed to the underlying collection, except reload which disregards memoization and creates a new Collection instance. @return [Collection] Collection instance for resource
[ "Handles", "resources", "such", "as", "tickets", ".", "Any", "options", "are", "passed", "to", "the", "underlying", "collection", "except", "reload", "which", "disregards", "memoization", "and", "creates", "a", "new", "Collection", "instance", "." ]
4237daa923c6e353a888473adae2a808352f4b26
https://github.com/zendesk/zendesk_api_client_rb/blob/4237daa923c6e353a888473adae2a808352f4b26/lib/zendesk_api/client.rb#L39-L51
valid
interagent/pliny
lib/pliny/router.rb
Pliny.Router.version
def version(*versions, &block) condition = lambda { |env| versions.include?(env["HTTP_X_API_VERSION"]) } with_conditions(condition, &block) end
ruby
def version(*versions, &block) condition = lambda { |env| versions.include?(env["HTTP_X_API_VERSION"]) } with_conditions(condition, &block) end
[ "def", "version", "(", "*", "versions", ",", "&", "block", ")", "condition", "=", "lambda", "{", "|", "env", "|", "versions", ".", "include?", "(", "env", "[", "\"HTTP_X_API_VERSION\"", "]", ")", "}", "with_conditions", "(", "condition", ",", "&", "block...
yield to a builder block in which all defined apps will only respond for the given version
[ "yield", "to", "a", "builder", "block", "in", "which", "all", "defined", "apps", "will", "only", "respond", "for", "the", "given", "version" ]
8add57f22e7be9404334222bbe7095af83bb8607
https://github.com/interagent/pliny/blob/8add57f22e7be9404334222bbe7095af83bb8607/lib/pliny/router.rb#L8-L13
valid
assaf/vanity
lib/vanity/metric/base.rb
Vanity.Metric.track_args
def track_args(args) case args when Hash timestamp, identity, values = args.values_at(:timestamp, :identity, :values) when Array values = args when Numeric values = [args] end identity ||= Vanity.context.vanity_identity rescue nil [timestamp || Time.now, identity, values || [1]] end
ruby
def track_args(args) case args when Hash timestamp, identity, values = args.values_at(:timestamp, :identity, :values) when Array values = args when Numeric values = [args] end identity ||= Vanity.context.vanity_identity rescue nil [timestamp || Time.now, identity, values || [1]] end
[ "def", "track_args", "(", "args", ")", "case", "args", "when", "Hash", "timestamp", ",", "identity", ",", "values", "=", "args", ".", "values_at", "(", ":timestamp", ",", ":identity", ",", ":values", ")", "when", "Array", "values", "=", "args", "when", "...
Parses arguments to track! method and return array with timestamp, identity and array of values.
[ "Parses", "arguments", "to", "track!", "method", "and", "return", "array", "with", "timestamp", "identity", "and", "array", "of", "values", "." ]
5bdd3ab21d3e495fb6e3f2596d2a048c453ca27a
https://github.com/assaf/vanity/blob/5bdd3ab21d3e495fb6e3f2596d2a048c453ca27a/lib/vanity/metric/base.rb#L146-L157
valid
assaf/vanity
lib/vanity/commands/report.rb
Vanity.Render.render
def render(path_or_options, locals = {}) if path_or_options.respond_to?(:keys) render_erb( path_or_options[:file] || path_or_options[:partial], path_or_options[:locals] ) else render_erb(path_or_options, locals) end end
ruby
def render(path_or_options, locals = {}) if path_or_options.respond_to?(:keys) render_erb( path_or_options[:file] || path_or_options[:partial], path_or_options[:locals] ) else render_erb(path_or_options, locals) end end
[ "def", "render", "(", "path_or_options", ",", "locals", "=", "{", "}", ")", "if", "path_or_options", ".", "respond_to?", "(", ":keys", ")", "render_erb", "(", "path_or_options", "[", ":file", "]", "||", "path_or_options", "[", ":partial", "]", ",", "path_or_...
Render the named template. Used for reporting and the dashboard.
[ "Render", "the", "named", "template", ".", "Used", "for", "reporting", "and", "the", "dashboard", "." ]
5bdd3ab21d3e495fb6e3f2596d2a048c453ca27a
https://github.com/assaf/vanity/blob/5bdd3ab21d3e495fb6e3f2596d2a048c453ca27a/lib/vanity/commands/report.rb#L11-L20
valid
assaf/vanity
lib/vanity/commands/report.rb
Vanity.Render.method_missing
def method_missing(method, *args, &block) %w(url_for flash).include?(method.to_s) ? ProxyEmpty.new : super end
ruby
def method_missing(method, *args, &block) %w(url_for flash).include?(method.to_s) ? ProxyEmpty.new : super end
[ "def", "method_missing", "(", "method", ",", "*", "args", ",", "&", "block", ")", "%w(", "url_for", "flash", ")", ".", "include?", "(", "method", ".", "to_s", ")", "?", "ProxyEmpty", ".", "new", ":", "super", "end" ]
prevent certain url helper methods from failing so we can run erb templates outside of rails for reports.
[ "prevent", "certain", "url", "helper", "methods", "from", "failing", "so", "we", "can", "run", "erb", "templates", "outside", "of", "rails", "for", "reports", "." ]
5bdd3ab21d3e495fb6e3f2596d2a048c453ca27a
https://github.com/assaf/vanity/blob/5bdd3ab21d3e495fb6e3f2596d2a048c453ca27a/lib/vanity/commands/report.rb#L36-L38
valid
assaf/vanity
lib/vanity/commands/report.rb
Vanity.Render.vanity_simple_format
def vanity_simple_format(text, options={}) open = "<p #{options.map { |k,v| "#{k}=\"#{CGI.escapeHTML v}\"" }.join(" ")}>" text = open + text.gsub(/\r\n?/, "\n"). # \r\n and \r -> \n gsub(/\n\n+/, "</p>\n\n#{open}"). # 2+ newline -> paragraph gsub(/([^\n]\n)(?=[^\n])/, '\1<br />') + # 1 newline -> br "</p>" end
ruby
def vanity_simple_format(text, options={}) open = "<p #{options.map { |k,v| "#{k}=\"#{CGI.escapeHTML v}\"" }.join(" ")}>" text = open + text.gsub(/\r\n?/, "\n"). # \r\n and \r -> \n gsub(/\n\n+/, "</p>\n\n#{open}"). # 2+ newline -> paragraph gsub(/([^\n]\n)(?=[^\n])/, '\1<br />') + # 1 newline -> br "</p>" end
[ "def", "vanity_simple_format", "(", "text", ",", "options", "=", "{", "}", ")", "open", "=", "\"<p #{options.map { |k,v| \"#{k}=\\\"#{CGI.escapeHTML v}\\\"\" }.join(\" \")}>\"", "text", "=", "open", "+", "text", ".", "gsub", "(", "/", "\\r", "\\n", "/", ",", "\"\\...
Dumbed down from Rails' simple_format.
[ "Dumbed", "down", "from", "Rails", "simple_format", "." ]
5bdd3ab21d3e495fb6e3f2596d2a048c453ca27a
https://github.com/assaf/vanity/blob/5bdd3ab21d3e495fb6e3f2596d2a048c453ca27a/lib/vanity/commands/report.rb#L41-L47
valid
assaf/vanity
lib/vanity/playground.rb
Vanity.Playground.experiment
def experiment(name) id = name.to_s.downcase.gsub(/\W/, "_").to_sym Vanity.logger.warn("Deprecated: Please call experiment method with experiment identifier (a Ruby symbol)") unless id == name experiments[id.to_sym] or raise NoExperimentError, "No experiment #{id}" end
ruby
def experiment(name) id = name.to_s.downcase.gsub(/\W/, "_").to_sym Vanity.logger.warn("Deprecated: Please call experiment method with experiment identifier (a Ruby symbol)") unless id == name experiments[id.to_sym] or raise NoExperimentError, "No experiment #{id}" end
[ "def", "experiment", "(", "name", ")", "id", "=", "name", ".", "to_s", ".", "downcase", ".", "gsub", "(", "/", "\\W", "/", ",", "\"_\"", ")", ".", "to_sym", "Vanity", ".", "logger", ".", "warn", "(", "\"Deprecated: Please call experiment method with experime...
Returns the experiment. You may not have guessed, but this method raises an exception if it cannot load the experiment's definition. @see Vanity::Experiment @deprecated
[ "Returns", "the", "experiment", ".", "You", "may", "not", "have", "guessed", "but", "this", "method", "raises", "an", "exception", "if", "it", "cannot", "load", "the", "experiment", "s", "definition", "." ]
5bdd3ab21d3e495fb6e3f2596d2a048c453ca27a
https://github.com/assaf/vanity/blob/5bdd3ab21d3e495fb6e3f2596d2a048c453ca27a/lib/vanity/playground.rb#L180-L184
valid
assaf/vanity
lib/vanity/templates.rb
Vanity.Templates.custom_template_path_valid?
def custom_template_path_valid? Vanity.playground.custom_templates_path && File.exist?(Vanity.playground.custom_templates_path) && !Dir[File.join(Vanity.playground.custom_templates_path, '*')].empty? end
ruby
def custom_template_path_valid? Vanity.playground.custom_templates_path && File.exist?(Vanity.playground.custom_templates_path) && !Dir[File.join(Vanity.playground.custom_templates_path, '*')].empty? end
[ "def", "custom_template_path_valid?", "Vanity", ".", "playground", ".", "custom_templates_path", "&&", "File", ".", "exist?", "(", "Vanity", ".", "playground", ".", "custom_templates_path", ")", "&&", "!", "Dir", "[", "File", ".", "join", "(", "Vanity", ".", "...
Check to make sure we set a custome path, it exists, and there are non- dotfiles in the directory.
[ "Check", "to", "make", "sure", "we", "set", "a", "custome", "path", "it", "exists", "and", "there", "are", "non", "-", "dotfiles", "in", "the", "directory", "." ]
5bdd3ab21d3e495fb6e3f2596d2a048c453ca27a
https://github.com/assaf/vanity/blob/5bdd3ab21d3e495fb6e3f2596d2a048c453ca27a/lib/vanity/templates.rb#L24-L28
valid
benchmark-driver/benchmark-driver
lib/benchmark_driver/ruby_interface.rb
BenchmarkDriver.RubyInterface.run
def run unless @executables.empty? @config.executables = @executables end jobs = @jobs.flat_map do |job| BenchmarkDriver::JobParser.parse({ type: @config.runner_type, prelude: @prelude, loop_count: @loop_count, }.merge!(job)) end BenchmarkDriver::Runner.run(jobs, config: @config) end
ruby
def run unless @executables.empty? @config.executables = @executables end jobs = @jobs.flat_map do |job| BenchmarkDriver::JobParser.parse({ type: @config.runner_type, prelude: @prelude, loop_count: @loop_count, }.merge!(job)) end BenchmarkDriver::Runner.run(jobs, config: @config) end
[ "def", "run", "unless", "@executables", ".", "empty?", "@config", ".", "executables", "=", "@executables", "end", "jobs", "=", "@jobs", ".", "flat_map", "do", "|", "job", "|", "BenchmarkDriver", "::", "JobParser", ".", "parse", "(", "{", "type", ":", "@con...
Build jobs and run. This is NOT interface for users.
[ "Build", "jobs", "and", "run", ".", "This", "is", "NOT", "interface", "for", "users", "." ]
96759fb9f0faf4376d97bfdba1c9e56113531ca3
https://github.com/benchmark-driver/benchmark-driver/blob/96759fb9f0faf4376d97bfdba1c9e56113531ca3/lib/benchmark_driver/ruby_interface.rb#L8-L21
valid
WinRb/Viewpoint
lib/ews/soap/exchange_user_configuration.rb
Viewpoint::EWS::SOAP.ExchangeUserConfiguration.get_user_configuration
def get_user_configuration(opts) opts = opts.clone [:user_config_name, :user_config_props].each do |k| validate_param(opts, k, true) end req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.GetUserConfiguration {|x| x.parent.default_namespace = @default_ns builder.user_configuration_name!(opts[:user_config_name]) builder.user_configuration_properties!(opts[:user_config_props]) } end end do_soap_request(req, response_class: EwsSoapAvailabilityResponse) end
ruby
def get_user_configuration(opts) opts = opts.clone [:user_config_name, :user_config_props].each do |k| validate_param(opts, k, true) end req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.GetUserConfiguration {|x| x.parent.default_namespace = @default_ns builder.user_configuration_name!(opts[:user_config_name]) builder.user_configuration_properties!(opts[:user_config_props]) } end end do_soap_request(req, response_class: EwsSoapAvailabilityResponse) end
[ "def", "get_user_configuration", "(", "opts", ")", "opts", "=", "opts", ".", "clone", "[", ":user_config_name", ",", ":user_config_props", "]", ".", "each", "do", "|", "k", "|", "validate_param", "(", "opts", ",", "k", ",", "true", ")", "end", "req", "="...
The GetUserConfiguration operation gets a user configuration object from a folder. @see http://msdn.microsoft.com/en-us/library/aa563465.aspx @param [Hash] opts @option opts [Hash] :user_config_name @option opts [String] :user_config_props
[ "The", "GetUserConfiguration", "operation", "gets", "a", "user", "configuration", "object", "from", "a", "folder", "." ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/exchange_user_configuration.rb#L14-L30
valid
WinRb/Viewpoint
lib/ews/soap/builders/ews_builder.rb
Viewpoint::EWS::SOAP.EwsBuilder.folder_shape!
def folder_shape!(folder_shape) @nbuild.FolderShape { @nbuild.parent.default_namespace = @default_ns base_shape!(folder_shape[:base_shape]) if(folder_shape[:additional_properties]) additional_properties!(folder_shape[:additional_properties]) end } end
ruby
def folder_shape!(folder_shape) @nbuild.FolderShape { @nbuild.parent.default_namespace = @default_ns base_shape!(folder_shape[:base_shape]) if(folder_shape[:additional_properties]) additional_properties!(folder_shape[:additional_properties]) end } end
[ "def", "folder_shape!", "(", "folder_shape", ")", "@nbuild", ".", "FolderShape", "{", "@nbuild", ".", "parent", ".", "default_namespace", "=", "@default_ns", "base_shape!", "(", "folder_shape", "[", ":base_shape", "]", ")", "if", "(", "folder_shape", "[", ":addi...
Build the FolderShape element @see http://msdn.microsoft.com/en-us/library/aa494311.aspx @param [Hash] folder_shape The folder shape structure to build from @todo need fully support all options
[ "Build", "the", "FolderShape", "element" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/builders/ews_builder.rb#L117-L125
valid
WinRb/Viewpoint
lib/ews/soap/builders/ews_builder.rb
Viewpoint::EWS::SOAP.EwsBuilder.item_shape!
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) body_type!(item_shape[:body_type]) if item_shape[:body_type] if(item_shape[:additional_properties]) additional_properties!(item_shape[:additional_properties]) end } end
ruby
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) body_type!(item_shape[:body_type]) if item_shape[:body_type] if(item_shape[:additional_properties]) additional_properties!(item_shape[:additional_properties]) end } end
[ "def", "item_shape!", "(", "item_shape", ")", "@nbuild", "[", "NS_EWS_MESSAGES", "]", ".", "ItemShape", "{", "@nbuild", ".", "parent", ".", "default_namespace", "=", "@default_ns", "base_shape!", "(", "item_shape", "[", ":base_shape", "]", ")", "mime_content!", ...
Build the ItemShape element @see http://msdn.microsoft.com/en-us/library/aa565261.aspx @param [Hash] item_shape The item shape structure to build from @todo need fully support all options
[ "Build", "the", "ItemShape", "element" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/builders/ews_builder.rb#L131-L141
valid
WinRb/Viewpoint
lib/ews/soap/builders/ews_builder.rb
Viewpoint::EWS::SOAP.EwsBuilder.indexed_page_item_view!
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} @nbuild[NS_EWS_MESSAGES].IndexedPageItemView(attribs) end
ruby
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} @nbuild[NS_EWS_MESSAGES].IndexedPageItemView(attribs) end
[ "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", "}", "@nbuild...
Build the IndexedPageItemView element @see http://msdn.microsoft.com/en-us/library/exchange/aa563549(v=exchg.150).aspx @todo needs peer check
[ "Build", "the", "IndexedPageItemView", "element" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/builders/ews_builder.rb#L146-L150
valid
WinRb/Viewpoint
lib/ews/soap/builders/ews_builder.rb
Viewpoint::EWS::SOAP.EwsBuilder.folder_ids!
def folder_ids!(fids, act_as=nil) ns = @nbuild.parent.name.match(/subscription/i) ? NS_EWS_TYPES : NS_EWS_MESSAGES @nbuild[ns].FolderIds { fids.each do |fid| fid[:act_as] = act_as if act_as != nil dispatch_folder_id!(fid) end } end
ruby
def folder_ids!(fids, act_as=nil) ns = @nbuild.parent.name.match(/subscription/i) ? NS_EWS_TYPES : NS_EWS_MESSAGES @nbuild[ns].FolderIds { fids.each do |fid| fid[:act_as] = act_as if act_as != nil dispatch_folder_id!(fid) end } end
[ "def", "folder_ids!", "(", "fids", ",", "act_as", "=", "nil", ")", "ns", "=", "@nbuild", ".", "parent", ".", "name", ".", "match", "(", "/", "/i", ")", "?", "NS_EWS_TYPES", ":", "NS_EWS_MESSAGES", "@nbuild", "[", "ns", "]", ".", "FolderIds", "{", "fi...
Build the FolderIds element @see http://msdn.microsoft.com/en-us/library/aa580509.aspx
[ "Build", "the", "FolderIds", "element" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/builders/ews_builder.rb#L192-L200
valid
WinRb/Viewpoint
lib/ews/soap/builders/ews_builder.rb
Viewpoint::EWS::SOAP.EwsBuilder.distinguished_folder_id!
def distinguished_folder_id!(dfid, change_key = nil, act_as = nil) attribs = {'Id' => dfid.to_s} attribs['ChangeKey'] = change_key if change_key @nbuild[NS_EWS_TYPES].DistinguishedFolderId(attribs) { if ! act_as.nil? mailbox!({:email_address => act_as}) end } end
ruby
def distinguished_folder_id!(dfid, change_key = nil, act_as = nil) attribs = {'Id' => dfid.to_s} attribs['ChangeKey'] = change_key if change_key @nbuild[NS_EWS_TYPES].DistinguishedFolderId(attribs) { if ! act_as.nil? mailbox!({:email_address => act_as}) end } end
[ "def", "distinguished_folder_id!", "(", "dfid", ",", "change_key", "=", "nil", ",", "act_as", "=", "nil", ")", "attribs", "=", "{", "'Id'", "=>", "dfid", ".", "to_s", "}", "attribs", "[", "'ChangeKey'", "]", "=", "change_key", "if", "change_key", "@nbuild"...
Build the DistinguishedFolderId element @see http://msdn.microsoft.com/en-us/library/aa580808.aspx @todo add support for the Mailbox child object
[ "Build", "the", "DistinguishedFolderId", "element" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/builders/ews_builder.rb#L213-L221
valid
WinRb/Viewpoint
lib/ews/soap/builders/ews_builder.rb
Viewpoint::EWS::SOAP.EwsBuilder.folder_id!
def folder_id!(fid, change_key = nil) attribs = {'Id' => fid} attribs['ChangeKey'] = change_key if change_key @nbuild[NS_EWS_TYPES].FolderId(attribs) end
ruby
def folder_id!(fid, change_key = nil) attribs = {'Id' => fid} attribs['ChangeKey'] = change_key if change_key @nbuild[NS_EWS_TYPES].FolderId(attribs) end
[ "def", "folder_id!", "(", "fid", ",", "change_key", "=", "nil", ")", "attribs", "=", "{", "'Id'", "=>", "fid", "}", "attribs", "[", "'ChangeKey'", "]", "=", "change_key", "if", "change_key", "@nbuild", "[", "NS_EWS_TYPES", "]", ".", "FolderId", "(", "att...
Build the FolderId element @see http://msdn.microsoft.com/en-us/library/aa579461.aspx
[ "Build", "the", "FolderId", "element" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/builders/ews_builder.rb#L225-L229
valid
WinRb/Viewpoint
lib/ews/soap/builders/ews_builder.rb
Viewpoint::EWS::SOAP.EwsBuilder.additional_properties!
def additional_properties!(addprops) @nbuild[NS_EWS_TYPES].AdditionalProperties { addprops.each_pair {|k,v| dispatch_field_uri!({k => v}, NS_EWS_TYPES) } } end
ruby
def additional_properties!(addprops) @nbuild[NS_EWS_TYPES].AdditionalProperties { addprops.each_pair {|k,v| dispatch_field_uri!({k => v}, NS_EWS_TYPES) } } end
[ "def", "additional_properties!", "(", "addprops", ")", "@nbuild", "[", "NS_EWS_TYPES", "]", ".", "AdditionalProperties", "{", "addprops", ".", "each_pair", "{", "|", "k", ",", "v", "|", "dispatch_field_uri!", "(", "{", "k", "=>", "v", "}", ",", "NS_EWS_TYPES...
Build the AdditionalProperties element @see http://msdn.microsoft.com/en-us/library/aa563810.aspx
[ "Build", "the", "AdditionalProperties", "element" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/builders/ews_builder.rb#L346-L352
valid
WinRb/Viewpoint
lib/ews/soap/builders/ews_builder.rb
Viewpoint::EWS::SOAP.EwsBuilder.mailbox!
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 mbox[:address] # for Availability query routing_type!(mbox[:routing_type]) if mbox[:routing_type] mailbox_type!(mbox[:mailbox_type]) if mbox[:mailbox_type] item_id!(mbox[:item_id]) if mbox[:item_id] } end
ruby
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 mbox[:address] # for Availability query routing_type!(mbox[:routing_type]) if mbox[:routing_type] mailbox_type!(mbox[:mailbox_type]) if mbox[:mailbox_type] item_id!(mbox[:item_id]) if mbox[:item_id] } end
[ "def", "mailbox!", "(", "mbox", ")", "nbuild", "[", "NS_EWS_TYPES", "]", ".", "Mailbox", "{", "name!", "(", "mbox", "[", ":name", "]", ")", "if", "mbox", "[", ":name", "]", "email_address!", "(", "mbox", "[", ":email_address", "]", ")", "if", "mbox", ...
Build the Mailbox element. This element is commonly used for delegation. Typically passing an email_address is sufficient @see http://msdn.microsoft.com/en-us/library/aa565036.aspx @param [Hash] mailbox A well-formated hash
[ "Build", "the", "Mailbox", "element", ".", "This", "element", "is", "commonly", "used", "for", "delegation", ".", "Typically", "passing", "an", "email_address", "is", "sufficient" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/builders/ews_builder.rb#L359-L368
valid
WinRb/Viewpoint
lib/ews/soap/builders/ews_builder.rb
Viewpoint::EWS::SOAP.EwsBuilder.get_server_time_zones!
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 get_time_zone_options[:ids].each do |id| nbuild[NS_EWS_TYPES].Id id end end end end end
ruby
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 get_time_zone_options[:ids].each do |id| nbuild[NS_EWS_TYPES].Id id end end end end end
[ "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"...
Request all known time_zones from server
[ "Request", "all", "known", "time_zones", "from", "server" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/builders/ews_builder.rb#L477-L487
valid
WinRb/Viewpoint
lib/ews/soap/builders/ews_builder.rb
Viewpoint::EWS::SOAP.EwsBuilder.start_time_zone!
def start_time_zone!(zone) attributes = {} attributes['Id'] = zone[:id] if zone[:id] attributes['Name'] = zone[:name] if zone[:name] nbuild[NS_EWS_TYPES].StartTimeZone(attributes) end
ruby
def start_time_zone!(zone) attributes = {} attributes['Id'] = zone[:id] if zone[:id] attributes['Name'] = zone[:name] if zone[:name] nbuild[NS_EWS_TYPES].StartTimeZone(attributes) end
[ "def", "start_time_zone!", "(", "zone", ")", "attributes", "=", "{", "}", "attributes", "[", "'Id'", "]", "=", "zone", "[", ":id", "]", "if", "zone", "[", ":id", "]", "attributes", "[", "'Name'", "]", "=", "zone", "[", ":name", "]", "if", "zone", "...
Specifies an optional time zone for the start time @param [Hash] attributes @option attributes :id [String] ID of the Microsoft well known time zone @option attributes :name [String] Optional name of the time zone @todo Implement sub elements Periods, TransitionsGroups and Transitions to override zone @see http://msdn.microsoft.com/en-us/library/exchange/dd899524.aspx
[ "Specifies", "an", "optional", "time", "zone", "for", "the", "start", "time" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/builders/ews_builder.rb#L495-L500
valid
WinRb/Viewpoint
lib/ews/soap/builders/ews_builder.rb
Viewpoint::EWS::SOAP.EwsBuilder.end_time_zone!
def end_time_zone!(zone) attributes = {} attributes['Id'] = zone[:id] if zone[:id] attributes['Name'] = zone[:name] if zone[:name] nbuild[NS_EWS_TYPES].EndTimeZone(attributes) end
ruby
def end_time_zone!(zone) attributes = {} attributes['Id'] = zone[:id] if zone[:id] attributes['Name'] = zone[:name] if zone[:name] nbuild[NS_EWS_TYPES].EndTimeZone(attributes) end
[ "def", "end_time_zone!", "(", "zone", ")", "attributes", "=", "{", "}", "attributes", "[", "'Id'", "]", "=", "zone", "[", ":id", "]", "if", "zone", "[", ":id", "]", "attributes", "[", "'Name'", "]", "=", "zone", "[", ":name", "]", "if", "zone", "["...
Specifies an optional time zone for the end time @param [Hash] attributes @option attributes :id [String] ID of the Microsoft well known time zone @option attributes :name [String] Optional name of the time zone @todo Implement sub elements Periods, TransitionsGroups and Transitions to override zone @see http://msdn.microsoft.com/en-us/library/exchange/dd899434.aspx
[ "Specifies", "an", "optional", "time", "zone", "for", "the", "end", "time" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/builders/ews_builder.rb#L508-L513
valid
WinRb/Viewpoint
lib/ews/soap/builders/ews_builder.rb
Viewpoint::EWS::SOAP.EwsBuilder.time_zone_definition!
def time_zone_definition!(zone) attributes = {'Id' => zone[:id]} attributes['Name'] = zone[:name] if zone[:name] nbuild[NS_EWS_TYPES].TimeZoneDefinition(attributes) end
ruby
def time_zone_definition!(zone) attributes = {'Id' => zone[:id]} attributes['Name'] = zone[:name] if zone[:name] nbuild[NS_EWS_TYPES].TimeZoneDefinition(attributes) end
[ "def", "time_zone_definition!", "(", "zone", ")", "attributes", "=", "{", "'Id'", "=>", "zone", "[", ":id", "]", "}", "attributes", "[", "'Name'", "]", "=", "zone", "[", ":name", "]", "if", "zone", "[", ":name", "]", "nbuild", "[", "NS_EWS_TYPES", "]",...
Specify a time zone @todo Implement subelements Periods, TransitionsGroups and Transitions to override zone @see http://msdn.microsoft.com/en-us/library/exchange/dd899488.aspx
[ "Specify", "a", "time", "zone" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/builders/ews_builder.rb#L518-L522
valid
WinRb/Viewpoint
lib/ews/soap/builders/ews_builder.rb
Viewpoint::EWS::SOAP.EwsBuilder.restriction!
def restriction!(restriction) @nbuild[NS_EWS_MESSAGES].Restriction { restriction.each_pair do |k,v| self.send normalize_type(k), v end } end
ruby
def restriction!(restriction) @nbuild[NS_EWS_MESSAGES].Restriction { restriction.each_pair do |k,v| self.send normalize_type(k), v end } end
[ "def", "restriction!", "(", "restriction", ")", "@nbuild", "[", "NS_EWS_MESSAGES", "]", ".", "Restriction", "{", "restriction", ".", "each_pair", "do", "|", "k", ",", "v", "|", "self", ".", "send", "normalize_type", "(", "k", ")", ",", "v", "end", "}", ...
Build the Restriction element @see http://msdn.microsoft.com/en-us/library/aa563791.aspx @param [Hash] restriction a well-formatted Hash that can be fed to #build_xml!
[ "Build", "the", "Restriction", "element" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/builders/ews_builder.rb#L527-L533
valid
WinRb/Viewpoint
lib/ews/soap/builders/ews_builder.rb
Viewpoint::EWS::SOAP.EwsBuilder.calendar_view!
def calendar_view!(cal_view) attribs = {} cal_view.each_pair {|k,v| attribs[camel_case(k)] = v.to_s} @nbuild[NS_EWS_MESSAGES].CalendarView(attribs) end
ruby
def calendar_view!(cal_view) attribs = {} cal_view.each_pair {|k,v| attribs[camel_case(k)] = v.to_s} @nbuild[NS_EWS_MESSAGES].CalendarView(attribs) end
[ "def", "calendar_view!", "(", "cal_view", ")", "attribs", "=", "{", "}", "cal_view", ".", "each_pair", "{", "|", "k", ",", "v", "|", "attribs", "[", "camel_case", "(", "k", ")", "]", "=", "v", ".", "to_s", "}", "@nbuild", "[", "NS_EWS_MESSAGES", "]",...
Build the CalendarView element
[ "Build", "the", "CalendarView", "element" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/builders/ews_builder.rb#L695-L699
valid
WinRb/Viewpoint
lib/ews/soap/builders/ews_builder.rb
Viewpoint::EWS::SOAP.EwsBuilder.contacts_view!
def contacts_view!(con_view) attribs = {} con_view.each_pair {|k,v| attribs[camel_case(k)] = v.to_s} @nbuild[NS_EWS_MESSAGES].ContactsView(attribs) end
ruby
def contacts_view!(con_view) attribs = {} con_view.each_pair {|k,v| attribs[camel_case(k)] = v.to_s} @nbuild[NS_EWS_MESSAGES].ContactsView(attribs) end
[ "def", "contacts_view!", "(", "con_view", ")", "attribs", "=", "{", "}", "con_view", ".", "each_pair", "{", "|", "k", ",", "v", "|", "attribs", "[", "camel_case", "(", "k", ")", "]", "=", "v", ".", "to_s", "}", "@nbuild", "[", "NS_EWS_MESSAGES", "]",...
Build the ContactsView element
[ "Build", "the", "ContactsView", "element" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/builders/ews_builder.rb#L702-L706
valid
WinRb/Viewpoint
lib/ews/soap/builders/ews_builder.rb
Viewpoint::EWS::SOAP.EwsBuilder.attachment_ids!
def attachment_ids!(aids) @nbuild.AttachmentIds { @nbuild.parent.default_namespace = @default_ns aids.each do |aid| attachment_id!(aid) end } end
ruby
def attachment_ids!(aids) @nbuild.AttachmentIds { @nbuild.parent.default_namespace = @default_ns aids.each do |aid| attachment_id!(aid) end } end
[ "def", "attachment_ids!", "(", "aids", ")", "@nbuild", ".", "AttachmentIds", "{", "@nbuild", ".", "parent", ".", "default_namespace", "=", "@default_ns", "aids", ".", "each", "do", "|", "aid", "|", "attachment_id!", "(", "aid", ")", "end", "}", "end" ]
Build the AttachmentIds element @see http://msdn.microsoft.com/en-us/library/aa580686.aspx
[ "Build", "the", "AttachmentIds", "element" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/builders/ews_builder.rb#L1137-L1144
valid
WinRb/Viewpoint
lib/ews/soap/builders/ews_builder.rb
Viewpoint::EWS::SOAP.EwsBuilder.dispatch_item_id!
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 recurring_master_item_id!(item) else raise EwsBadArgumentError, "Bad ItemId type. #{type}" end end
ruby
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 recurring_master_item_id!(item) else raise EwsBadArgumentError, "Bad ItemId type. #{type}" end end
[ "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!", "(", "...
A helper method to dispatch to an ItemId, OccurrenceItemId, or a RecurringMasterItemId @param [Hash] iid The item id of some type
[ "A", "helper", "method", "to", "dispatch", "to", "an", "ItemId", "OccurrenceItemId", "or", "a", "RecurringMasterItemId" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/builders/ews_builder.rb#L1182-L1195
valid
WinRb/Viewpoint
lib/ews/soap/builders/ews_builder.rb
Viewpoint::EWS::SOAP.EwsBuilder.dispatch_update_type!
def dispatch_update_type!(update) type = update.keys.first upd = update[type] case type when :append_to_item_field append_to_item_field!(upd) when :set_item_field set_item_field!(upd) when :delete_item_field delete_item_field!(upd) else raise EwsBadArgumentError, "Bad Update type. #{type}" end end
ruby
def dispatch_update_type!(update) type = update.keys.first upd = update[type] case type when :append_to_item_field append_to_item_field!(upd) when :set_item_field set_item_field!(upd) when :delete_item_field delete_item_field!(upd) else raise EwsBadArgumentError, "Bad Update type. #{type}" end end
[ "def", "dispatch_update_type!", "(", "update", ")", "type", "=", "update", ".", "keys", ".", "first", "upd", "=", "update", "[", "type", "]", "case", "type", "when", ":append_to_item_field", "append_to_item_field!", "(", "upd", ")", "when", ":set_item_field", ...
A helper method to dispatch to a AppendToItemField, SetItemField, or DeleteItemField @param [Hash] update An update of some type
[ "A", "helper", "method", "to", "dispatch", "to", "a", "AppendToItemField", "SetItemField", "or", "DeleteItemField" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/builders/ews_builder.rb#L1200-L1213
valid
WinRb/Viewpoint
lib/ews/soap/builders/ews_builder.rb
Viewpoint::EWS::SOAP.EwsBuilder.dispatch_field_uri!
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] nbuild.parent['PropertySetId'] = val[:property_set_id] if val[:property_set_id] nbuild.parent['PropertyTag'] = val[:property_tag] if val[:property_tag] nbuild.parent['PropertyName'] = val[:property_name] if val[:property_name] nbuild.parent['PropertyId'] = val[:property_id] if val[:property_id] nbuild.parent['PropertyType'] = val[:property_type] if val[:property_type] } end else raise EwsBadArgumentError, "Bad URI type. #{type}" end end
ruby
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] nbuild.parent['PropertySetId'] = val[:property_set_id] if val[:property_set_id] nbuild.parent['PropertyTag'] = val[:property_tag] if val[:property_tag] nbuild.parent['PropertyName'] = val[:property_name] if val[:property_name] nbuild.parent['PropertyId'] = val[:property_id] if val[:property_id] nbuild.parent['PropertyType'] = val[:property_type] if val[:property_type] } end else raise EwsBadArgumentError, "Bad URI type. #{type}" end end
[ "def", "dispatch_field_uri!", "(", "uri", ",", "ns", "=", "NS_EWS_MESSAGES", ")", "type", "=", "uri", ".", "keys", ".", "first", "vals", "=", "uri", "[", "type", "]", ".", "is_a?", "(", "Array", ")", "?", "uri", "[", "type", "]", ":", "[", "uri", ...
A helper to dispatch to a FieldURI, IndexedFieldURI, or an ExtendedFieldURI @todo Implement ExtendedFieldURI
[ "A", "helper", "to", "dispatch", "to", "a", "FieldURI", "IndexedFieldURI", "or", "an", "ExtendedFieldURI" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/builders/ews_builder.rb#L1217-L1247
valid
WinRb/Viewpoint
lib/ews/soap/builders/ews_builder.rb
Viewpoint::EWS::SOAP.EwsBuilder.dispatch_field_item!
def dispatch_field_item!(item, ns_prefix = nil) item.values.first[:xmlns_attribute] = ns_prefix if ns_prefix build_xml!(item) end
ruby
def dispatch_field_item!(item, ns_prefix = nil) item.values.first[:xmlns_attribute] = ns_prefix if ns_prefix build_xml!(item) end
[ "def", "dispatch_field_item!", "(", "item", ",", "ns_prefix", "=", "nil", ")", "item", ".", "values", ".", "first", "[", ":xmlns_attribute", "]", "=", "ns_prefix", "if", "ns_prefix", "build_xml!", "(", "item", ")", "end" ]
Insert item, enforce xmlns attribute if prefix is present
[ "Insert", "item", "enforce", "xmlns", "attribute", "if", "prefix", "is", "present" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/builders/ews_builder.rb#L1250-L1253
valid
WinRb/Viewpoint
lib/ews/types/calendar_item.rb
Viewpoint::EWS::Types.CalendarItem.update_item!
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} end end item_updates << {set_item_field: field.merge(calendar_item: {sub_elements: item_attributes})} else # Ignore unknown attribute end end if item_updates.any? data = {} data[:conflict_resolution] = options[:conflict_resolution] || 'AutoResolve' data[:send_meeting_invitations_or_cancellations] = options[:send_meeting_invitations_or_cancellations] || 'SendToNone' data[:item_changes] = [{item_id: self.item_id, updates: item_updates}] rm = ews.update_item(data).response_messages.first if rm && rm.success? self.get_all_properties! self else raise EwsCreateItemError, "Could not update calendar item. #{rm.code}: #{rm.message_text}" unless rm end end end
ruby
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} end end item_updates << {set_item_field: field.merge(calendar_item: {sub_elements: item_attributes})} else # Ignore unknown attribute end end if item_updates.any? data = {} data[:conflict_resolution] = options[:conflict_resolution] || 'AutoResolve' data[:send_meeting_invitations_or_cancellations] = options[:send_meeting_invitations_or_cancellations] || 'SendToNone' data[:item_changes] = [{item_id: self.item_id, updates: item_updates}] rm = ews.update_item(data).response_messages.first if rm && rm.success? self.get_all_properties! self else raise EwsCreateItemError, "Could not update calendar item. #{rm.code}: #{rm.message_text}" unless rm end end end
[ "def", "update_item!", "(", "updates", ",", "options", "=", "{", "}", ")", "item_updates", "=", "[", "]", "updates", ".", "each", "do", "|", "attribute", ",", "value", "|", "item_field", "=", "FIELD_URIS", "[", "attribute", "]", "[", ":text", "]", "if"...
Updates the specified item attributes Uses `SetItemField` if value is present and `DeleteItemField` if value is nil @param updates [Hash] with (:attribute => value) @param options [Hash] @option options :conflict_resolution [String] one of 'NeverOverwrite', 'AutoResolve' (default) or 'AlwaysOverwrite' @option options :send_meeting_invitations_or_cancellations [String] one of 'SendToNone' (default), 'SendOnlyToAll', 'SendOnlyToChanged', 'SendToAllAndSaveCopy' or 'SendToChangedAndSaveCopy' @return [CalendarItem, false] @example Update Subject and Body item = #... item.update_item!(subject: 'New subject', body: 'New Body') @see http://msdn.microsoft.com/en-us/library/exchange/aa580254.aspx @todo AppendToItemField updates not implemented
[ "Updates", "the", "specified", "item", "attributes" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/types/calendar_item.rb#L57-L106
valid
WinRb/Viewpoint
lib/ews/soap/exchange_synchronization.rb
Viewpoint::EWS::SOAP.ExchangeSynchronization.sync_folder_hierarchy
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 builder.folder_shape!(opts[:folder_shape]) builder.sync_folder_id!(opts[:sync_folder_id]) if opts[:sync_folder_id] builder.sync_state!(opts[:sync_state]) if opts[:sync_state] } end end do_soap_request(req, response_class: EwsResponse) end
ruby
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 builder.folder_shape!(opts[:folder_shape]) builder.sync_folder_id!(opts[:sync_folder_id]) if opts[:sync_folder_id] builder.sync_state!(opts[:sync_state]) if opts[:sync_state] } end end do_soap_request(req, response_class: EwsResponse) end
[ "def", "sync_folder_hierarchy", "(", "opts", ")", "opts", "=", "opts", ".", "clone", "req", "=", "build_soap!", "do", "|", "type", ",", "builder", "|", "if", "(", "type", "==", ":header", ")", "else", "builder", ".", "nbuild", ".", "SyncFolderHierarchy", ...
Defines a request to synchronize a folder hierarchy on a client @see http://msdn.microsoft.com/en-us/library/aa580990.aspx @param [Hash] opts @option opts [Hash] :folder_shape The folder shape properties Ex: {:base_shape => 'Default', :additional_properties => 'bla bla bla'} @option opts [Hash] :sync_folder_id An optional Hash that represents a FolderId or DistinguishedFolderId. Ex: {:id => :inbox} @option opts [Hash] :sync_state The Base64 sync state id. If this is the first time syncing this does not need to be passed.
[ "Defines", "a", "request", "to", "synchronize", "a", "folder", "hierarchy", "on", "a", "client" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/exchange_synchronization.rb#L36-L50
valid
WinRb/Viewpoint
lib/ews/soap/exchange_synchronization.rb
Viewpoint::EWS::SOAP.ExchangeSynchronization.sync_folder_items
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] builder.ignore!(opts[:ignore]) if opts[:ignore] builder.max_changes_returned!(opts[:max_changes_returned]) builder.sync_scope!(opts[:sync_scope]) if opts[:sync_scope] } end end do_soap_request(req, response_class: EwsResponse) end
ruby
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] builder.ignore!(opts[:ignore]) if opts[:ignore] builder.max_changes_returned!(opts[:max_changes_returned]) builder.sync_scope!(opts[:sync_scope]) if opts[:sync_scope] } end end do_soap_request(req, response_class: EwsResponse) end
[ "def", "sync_folder_items", "(", "opts", ")", "opts", "=", "opts", ".", "clone", "req", "=", "build_soap!", "do", "|", "type", ",", "builder", "|", "if", "(", "type", "==", ":header", ")", "else", "builder", ".", "nbuild", ".", "SyncFolderItems", "{", ...
Synchronizes items between the Exchange server and the client @see http://msdn.microsoft.com/en-us/library/aa563967(v=EXCHG.140).aspx @param [Hash] opts @option opts [Hash] :item_shape The item shape properties Ex: {:base_shape => 'Default', :additional_properties => 'bla bla bla'} @option opts [Hash] :sync_folder_id A Hash that represents a FolderId or DistinguishedFolderId. [ Ex: {:id => :inbox} ] OPTIONAL @option opts [String] :sync_state The Base64 sync state id. If this is the first time syncing this does not need to be passed. OPTIONAL on first call @option opts [Array <String>] :ignore An Array of ItemIds for items to ignore during the sync process. Ex: [{:id => 'id1', :change_key => 'ck'}, {:id => 'id2'}] OPTIONAL @option opts [Integer] :max_changes_returned ('required') The amount of items to sync per call. @option opts [String] :sync_scope specifies whether just items or items and folder associated information are returned. OPTIONAL options: 'NormalItems' or 'NormalAndAssociatedItems' @example { :item_shape => {:base_shape => 'Default'}, :sync_folder_id => {:id => :inbox}, :sync_state => myBase64id, :max_changes_returned => 256 }
[ "Synchronizes", "items", "between", "the", "Exchange", "server", "and", "the", "client" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/exchange_synchronization.rb#L73-L90
valid
WinRb/Viewpoint
lib/ews/types/mailbox_user.rb
Viewpoint::EWS::Types.MailboxUser.get_user_availability
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: end_time}, } } resp = (Viewpoint::EWS::EWS.instance).ews.get_user_availability(opts) if(resp.status == 'Success') return resp.items else raise EwsError, "GetUserAvailability produced an error: #{resp.code}: #{resp.message}" end end
ruby
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: end_time}, } } resp = (Viewpoint::EWS::EWS.instance).ews.get_user_availability(opts) if(resp.status == 'Success') return resp.items else raise EwsError, "GetUserAvailability produced an error: #{resp.code}: #{resp.message}" end end
[ "def", "get_user_availability", "(", "email_address", ",", "start_time", ",", "end_time", ")", "opts", "=", "{", "mailbox_data", ":", "[", ":email", "=>", "{", ":address", "=>", "email_address", "}", "]", ",", "free_busy_view_options", ":", "{", "time_window", ...
Get information about when the user with the given email address is available. @param [String] email_address The email address of the person to find availability for. @param [DateTime] start_time The start of the time range to check as an xs:dateTime. @param [DateTime] end_time The end of the time range to check as an xs:dateTime. @see http://msdn.microsoft.com/en-us/library/aa563800(v=exchg.140)
[ "Get", "information", "about", "when", "the", "user", "with", "the", "given", "email", "address", "is", "available", "." ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/types/mailbox_user.rb#L64-L77
valid
WinRb/Viewpoint
lib/ews/types/item.rb
Viewpoint::EWS::Types.Item.move!
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? obj = rmsg.items.first itype = obj.keys.first obj[itype][:elems][0][:item_id][:attribs][:id] else raise EwsError, "Could not move item. #{resp.code}: #{resp.message}" end end
ruby
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? obj = rmsg.items.first itype = obj.keys.first obj[itype][:elems][0][:item_id][:attribs][:id] else raise EwsError, "Could not move item. #{resp.code}: #{resp.message}" end end
[ "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", "=>", "...
Move this item to a new folder @param [String,Symbol,GenericFolder] new_folder The new folder to move it to. This should be a subclass of GenericFolder, a DistinguishedFolderId (must me a Symbol) or a FolderId (String) @return [String] the new Id of the moved item
[ "Move", "this", "item", "to", "a", "new", "folder" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/types/item.rb#L137-L153
valid
WinRb/Viewpoint
lib/ews/types/item.rb
Viewpoint::EWS::Types.Item.copy
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 itype = obj.keys.first obj[itype][:elems][0][:item_id][:attribs][:id] else raise EwsError, "Could not copy item. #{rmsg.response_code}: #{rmsg.message_text}" end end
ruby
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 itype = obj.keys.first obj[itype][:elems][0][:item_id][:attribs][:id] else raise EwsError, "Could not copy item. #{rmsg.response_code}: #{rmsg.message_text}" end end
[ "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", "=>", "[...
Copy this item to a new folder @param [String,Symbol,GenericFolder] new_folder The new folder to move it to. This should be a subclass of GenericFolder, a DistinguishedFolderId (must me a Symbol) or a FolderId (String) @return [String] the new Id of the copied item
[ "Copy", "this", "item", "to", "a", "new", "folder" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/types/item.rb#L159-L175
valid
WinRb/Viewpoint
lib/ews/types/item.rb
Viewpoint::EWS::Types.Item.get_item
def get_item(opts = {}) args = get_item_args(opts) resp = ews.get_item(args) get_item_parser(resp) end
ruby
def get_item(opts = {}) args = get_item_args(opts) resp = ews.get_item(args) get_item_parser(resp) end
[ "def", "get_item", "(", "opts", "=", "{", "}", ")", "args", "=", "get_item_args", "(", "opts", ")", "resp", "=", "ews", ".", "get_item", "(", "args", ")", "get_item_parser", "(", "resp", ")", "end" ]
Get a specific item by its ID. @param [Hash] opts Misc options to control request @option opts [String] :base_shape IdOnly/Default/AllProperties @raise [EwsError] raised when the backend SOAP method returns an error.
[ "Get", "a", "specific", "item", "by", "its", "ID", "." ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/types/item.rb#L317-L321
valid
WinRb/Viewpoint
lib/ews/types/item.rb
Viewpoint::EWS::Types.Item.dispatch_create_item!
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| next unless f.kind_of?(File) resp.add_file_attachment(f) end if draft resp.submit_attachments! resp else resp.submit! end else resp = ews.create_item(msg.to_ews) validate_created_item resp end end
ruby
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| next unless f.kind_of?(File) resp.add_file_attachment(f) end if draft resp.submit_attachments! resp else resp.submit! end else resp = ews.create_item(msg.to_ews) validate_created_item resp end end
[ "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", ")"...
Handles the CreateItem call for Forward, ReplyTo, and ReplyAllTo It will handle the neccessary actions for adding attachments.
[ "Handles", "the", "CreateItem", "call", "for", "Forward", "ReplyTo", "and", "ReplyAllTo", "It", "will", "handle", "the", "neccessary", "actions", "for", "adding", "attachments", "." ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/types/item.rb#L405-L424
valid
WinRb/Viewpoint
lib/ews/types/item.rb
Viewpoint::EWS::Types.Item.validate_created_item
def validate_created_item(response) msg = response.response_messages[0] if(msg.status == 'Success') msg.items.empty? ? true : parse_created_item(msg.items.first) else raise EwsCreateItemError, "#{msg.code}: #{msg.message_text}" end end
ruby
def validate_created_item(response) msg = response.response_messages[0] if(msg.status == 'Success') msg.items.empty? ? true : parse_created_item(msg.items.first) else raise EwsCreateItemError, "#{msg.code}: #{msg.message_text}" end end
[ "def", "validate_created_item", "(", "response", ")", "msg", "=", "response", ".", "response_messages", "[", "0", "]", "if", "(", "msg", ".", "status", "==", "'Success'", ")", "msg", ".", "items", ".", "empty?", "?", "true", ":", "parse_created_item", "(",...
validate the CreateItem response. @return [Boolean, Item] returns true if items is empty and status is "Success" if items is not empty it will return the first Item since we are only dealing with single items here. @raise EwsCreateItemError on failure
[ "validate", "the", "CreateItem", "response", "." ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/types/item.rb#L431-L439
valid
WinRb/Viewpoint
lib/ews/types/generic_folder.rb
Viewpoint::EWS::Types.GenericFolder.items_since
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 restr = {:restriction => {:is_greater_than_or_equal_to => [{:field_uRI => {:field_uRI=>'item:DateTimeReceived'}}, {:field_uRI_or_constant =>{:constant => {:value=>date_time.to_datetime}}}] }} items(opts.merge(restr)) end
ruby
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 restr = {:restriction => {:is_greater_than_or_equal_to => [{:field_uRI => {:field_uRI=>'item:DateTimeReceived'}}, {:field_uRI_or_constant =>{:constant => {:value=>date_time.to_datetime}}}] }} items(opts.merge(restr)) end
[ "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", "re...
Fetch items since a give DateTime @param [DateTime] date_time the time to fetch Items since.
[ "Fetch", "items", "since", "a", "give", "DateTime" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/types/generic_folder.rb#L85-L96
valid
WinRb/Viewpoint
lib/ews/types/generic_folder.rb
Viewpoint::EWS::Types.GenericFolder.items_between
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 => [ {:field_uRI => {:field_uRI=>'item:DateTimeReceived'}}, {:field_uRI_or_constant=>{:constant => {:value =>end_date}}} ] } ] } end end
ruby
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 => [ {:field_uRI => {:field_uRI=>'item:DateTimeReceived'}}, {:field_uRI_or_constant=>{:constant => {:value =>end_date}}} ] } ] } end end
[ "def", "items_between", "(", "start_date", ",", "end_date", ",", "opts", "=", "{", "}", ")", "items", "do", "|", "obj", "|", "obj", ".", "restriction", "=", "{", ":and", "=>", "[", "{", ":is_greater_than_or_equal_to", "=>", "[", "{", ":field_uRI", "=>", ...
Fetch items between a given time period @param [DateTime] start_date the time to start fetching Items from @param [DateTime] end_date the time to stop fetching Items from
[ "Fetch", "items", "between", "a", "given", "time", "period" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/types/generic_folder.rb#L106-L125
valid
WinRb/Viewpoint
lib/ews/types/generic_folder.rb
Viewpoint::EWS::Types.GenericFolder.search_by_subject
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', :field_uRI => {:field_uRI=>'item:Subject'}, :constant => {:value =>exclude_str} }} } match[:and] = [{:contains => match.delete(:contains)}, excl] end obj.restriction = match end end
ruby
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', :field_uRI => {:field_uRI=>'item:Subject'}, :constant => {:value =>exclude_str} }} } match[:and] = [{:contains => match.delete(:contains)}, excl] end obj.restriction = match end end
[ "def", "search_by_subject", "(", "match_str", ",", "exclude_str", "=", "nil", ")", "items", "do", "|", "obj", "|", "match", "=", "{", ":contains", "=>", "{", ":containment_mode", "=>", "'Substring'", ",", ":containment_comparison", "=>", "'IgnoreCase'", ",", "...
Search on the item subject @param [String] match_str A simple string paramater to match against the subject. The search ignores case and does not accept regexes... only strings. @param [String,nil] exclude_str A string to exclude from matches against the subject. This is optional.
[ "Search", "on", "the", "item", "subject" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/types/generic_folder.rb#L132-L154
valid
WinRb/Viewpoint
lib/ews/types/generic_folder.rb
Viewpoint::EWS::Types.GenericFolder.sync_items!
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) if ctype == :delete || ctype == :read_flag_change rhash[ctype] << c[ctype][:elems][0][:item_id][:attribs] else type = c[ctype][:elems][0].keys.first item = class_by_name(type).new(ews, c[ctype][:elems][0][type]) rhash[ctype] << item end end rhash else raise EwsError, "Could not synchronize: #{rmsg.code}: #{rmsg.message_text}" end end
ruby
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) if ctype == :delete || ctype == :read_flag_change rhash[ctype] << c[ctype][:elems][0][:item_id][:attribs] else type = c[ctype][:elems][0].keys.first item = class_by_name(type).new(ews, c[ctype][:elems][0][type]) rhash[ctype] << item end end rhash else raise EwsError, "Could not synchronize: #{rmsg.code}: #{rmsg.message_text}" end end
[ "def", "sync_items!", "(", "sync_state", "=", "nil", ",", "sync_amount", "=", "256", ",", "sync_all", "=", "false", ",", "opts", "=", "{", "}", ")", "item_shape", "=", "opts", ".", "has_key?", "(", ":item_shape", ")", "?", "opts", ".", "delete", "(", ...
Syncronize Items in this folder. If this method is issued multiple times it will continue where the last sync completed. @param [Integer] sync_amount The number of items to synchronize per sync @param [Boolean] sync_all Whether to sync all the data by looping through. The default is to just sync the first set. You can manually loop through with multiple calls to #sync_items! @return [Hash] Returns a hash with keys for each change type that ocurred. Possible key values are: (:create/:udpate/:delete/:read_flag_change). For :deleted and :read_flag_change items a simple hash with :id and :change_key is returned. See: http://msdn.microsoft.com/en-us/library/aa565609.aspx
[ "Syncronize", "Items", "in", "this", "folder", ".", "If", "this", "method", "is", "issued", "multiple", "times", "it", "will", "continue", "where", "the", "last", "sync", "completed", "." ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/types/generic_folder.rb#L186-L213
valid
WinRb/Viewpoint
lib/ews/types/generic_folder.rb
Viewpoint::EWS::Types.GenericFolder.subscribe
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? @subscription_id = rmsg.subscription_id @watermark = rmsg.watermark true else raise EwsSubscriptionError, "Could not subscribe: #{rmsg.code}: #{rmsg.message_text}" end end
ruby
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? @subscription_id = rmsg.subscription_id @watermark = rmsg.watermark true else raise EwsSubscriptionError, "Could not subscribe: #{rmsg.code}: #{rmsg.message_text}" end end
[ "def", "subscribe", "(", "evtypes", "=", "[", ":all", "]", ",", "watermark", "=", "nil", ",", "timeout", "=", "240", ")", "unsubscribe", "if", "subscribed?", "event_types", "=", "normalize_event_names", "(", "evtypes", ")", "folder", "=", "{", "id", ":", ...
Subscribe this folder to events. This method initiates an Exchange pull type subscription. @param event_types [Array] Which event types to subscribe to. By default we subscribe to all Exchange event types: :all, :copied, :created, :deleted, :modified, :moved, :new_mail, :free_busy_changed @param watermark [String] pass a watermark if you wish to start the subscription at a specific point. @param timeout [Fixnum] the time in minutes that the subscription can remain idle between calls to #get_events. default: 240 minutes @return [Boolean] Did the subscription happen successfully?
[ "Subscribe", "this", "folder", "to", "events", ".", "This", "method", "initiates", "an", "Exchange", "pull", "type", "subscription", "." ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/types/generic_folder.rb#L230-L245
valid
WinRb/Viewpoint
lib/ews/types/generic_folder.rb
Viewpoint::EWS::Types.GenericFolder.unsubscribe
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 else raise EwsSubscriptionError, "Could not unsubscribe: #{rmsg.code}: #{rmsg.message_text}" end end
ruby
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 else raise EwsSubscriptionError, "Could not unsubscribe: #{rmsg.code}: #{rmsg.message_text}" end end
[ "def", "unsubscribe", "return", "true", "if", "@subscription_id", ".", "nil?", "resp", "=", "ews", ".", "unsubscribe", "(", "@subscription_id", ")", "rmsg", "=", "resp", ".", "response_messages", ".", "first", "if", "rmsg", ".", "success?", "@subscription_id", ...
Unsubscribe this folder from further Exchange events. @return [Boolean] Did we unsubscribe successfully?
[ "Unsubscribe", "this", "folder", "from", "further", "Exchange", "events", "." ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/types/generic_folder.rb#L270-L281
valid
WinRb/Viewpoint
lib/ews/types/generic_folder.rb
Viewpoint::EWS::Types.GenericFolder.get_events
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| type = ev.keys.first class_by_name(type).new(ews, ev[type]) } else raise EwsSubscriptionError, "Folder <#{self.display_name}> not subscribed to. Issue a Folder#subscribe before checking events." end rescue EwsSubscriptionTimeout => e @subscription_id, @watermark = nil, nil raise e end end
ruby
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| type = ev.keys.first class_by_name(type).new(ews, ev[type]) } else raise EwsSubscriptionError, "Folder <#{self.display_name}> not subscribed to. Issue a Folder#subscribe before checking events." end rescue EwsSubscriptionTimeout => e @subscription_id, @watermark = nil, nil raise e end end
[ "def", "get_events", "begin", "if", "subscribed?", "resp", "=", "ews", ".", "get_events", "(", "@subscription_id", ",", "@watermark", ")", "rmsg", "=", "resp", ".", "response_messages", "[", "0", "]", "@watermark", "=", "rmsg", ".", "new_watermark", "rmsg", ...
Checks a subscribed folder for events @return [Array] An array of Event items
[ "Checks", "a", "subscribed", "folder", "for", "events" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/types/generic_folder.rb#L285-L303
valid
WinRb/Viewpoint
lib/ews/types/generic_folder.rb
Viewpoint::EWS::Types.GenericFolder.get_folder
def get_folder(opts = {}) args = get_folder_args(opts) resp = ews.get_folder(args) get_folder_parser(resp) end
ruby
def get_folder(opts = {}) args = get_folder_args(opts) resp = ews.get_folder(args) get_folder_parser(resp) end
[ "def", "get_folder", "(", "opts", "=", "{", "}", ")", "args", "=", "get_folder_args", "(", "opts", ")", "resp", "=", "ews", ".", "get_folder", "(", "args", ")", "get_folder_parser", "(", "resp", ")", "end" ]
Get a specific folder by its ID. @param [Hash] opts Misc options to control request @option opts [String] :base_shape IdOnly/Default/AllProperties @raise [EwsError] raised when the backend SOAP method returns an error.
[ "Get", "a", "specific", "folder", "by", "its", "ID", "." ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/types/generic_folder.rb#L341-L345
valid
WinRb/Viewpoint
lib/ews/soap/exchange_time_zones.rb
Viewpoint::EWS::SOAP.ExchangeTimeZones.get_time_zones
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| data = { id: definition[:time_zone_definition][:attribs][:id], name: definition[:time_zone_definition][:attribs][:name] } zones << OpenStruct.new(data) end end zones else raise EwsError, "Could not get time zones" end end
ruby
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| data = { id: definition[:time_zone_definition][:attribs][:id], name: definition[:time_zone_definition][:attribs][:name] } zones << OpenStruct.new(data) end end zones else raise EwsError, "Could not get time zones" end end
[ "def", "get_time_zones", "(", "full", "=", "false", ",", "ids", "=", "nil", ")", "req", "=", "build_soap!", "do", "|", "type", ",", "builder", "|", "unless", "type", "==", ":header", "builder", ".", "get_server_time_zones!", "(", "full", ":", "full", ","...
Request list of server known time zones @param full [Boolean] Request full time zone definition? Returns only name and id if false. @param ids [Array] Returns only the specified time zones instead of all if present @return [Array] Array of Objects responding to #id() and #name() @example Retrieving server time zones ews_client = Viewpoint::EWSClient.new # ... zones = ews_client.ews.get_time_zones @todo Implement TimeZoneDefinition with sub elements Periods, TransitionsGroups and Transitions
[ "Request", "list", "of", "server", "known", "time", "zones" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/exchange_time_zones.rb#L14-L38
valid
WinRb/Viewpoint
lib/ews/soap/exchange_data_services.rb
Viewpoint::EWS::SOAP.ExchangeDataServices.copy_folder
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 builder.to_folder_id!(to_folder_id) builder.folder_ids!(sources.flatten) } end end do_soap_request(req) end
ruby
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 builder.to_folder_id!(to_folder_id) builder.folder_ids!(sources.flatten) } end end do_soap_request(req) end
[ "def", "copy_folder", "(", "to_folder_id", ",", "*", "sources", ")", "req", "=", "build_soap!", "do", "|", "type", ",", "builder", "|", "if", "(", "type", "==", ":header", ")", "else", "builder", ".", "nbuild", ".", "CopyFolder", "{", "builder", ".", "...
Defines a request to copy folders in the Exchange store @see http://msdn.microsoft.com/en-us/library/aa563949.aspx @param [Hash] to_folder_id The target FolderId {:id => <myid>, :change_key => <optional ck>} @param [Array<Hash>] *sources The source Folders {:id => <myid>, :change_key => <optional_ck>}, {:id => <myid2>, :change_key => <optional_ck>}
[ "Defines", "a", "request", "to", "copy", "folders", "in", "the", "Exchange", "store" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/exchange_data_services.rb#L428-L440
valid
WinRb/Viewpoint
lib/ews/soap/exchange_data_services.rb
Viewpoint::EWS::SOAP.ExchangeDataServices.move_folder
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 builder.to_folder_id!(to_folder_id) builder.folder_ids!(sources.flatten) } end end do_soap_request(req) end
ruby
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 builder.to_folder_id!(to_folder_id) builder.folder_ids!(sources.flatten) } end end do_soap_request(req) end
[ "def", "move_folder", "(", "to_folder_id", ",", "*", "sources", ")", "req", "=", "build_soap!", "do", "|", "type", ",", "builder", "|", "if", "(", "type", "==", ":header", ")", "else", "builder", ".", "nbuild", ".", "MoveFolder", "{", "builder", ".", "...
Defines a request to move folders in the Exchange store @see http://msdn.microsoft.com/en-us/library/aa566202.aspx @param [Hash] to_folder_id The target FolderId {:id => <myid>, :change_key => <optional ck>} @param [Array<Hash>] *sources The source Folders {:id => <myid>, :change_key => <optional_ck>}, {:id => <myid2>, :change_key => <optional_ck>}
[ "Defines", "a", "request", "to", "move", "folders", "in", "the", "Exchange", "store" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/exchange_data_services.rb#L548-L560
valid
WinRb/Viewpoint
lib/ews/soap/exchange_data_services.rb
Viewpoint::EWS::SOAP.ExchangeDataServices.update_folder
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) builder[NS_EWS_TYPES].Updates { # @todo finish implementation } } end } } end end do_soap_request(req) end
ruby
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) builder[NS_EWS_TYPES].Updates { # @todo finish implementation } } end } } end end do_soap_request(req) end
[ "def", "update_folder", "(", "folder_changes", ")", "req", "=", "build_soap!", "do", "|", "type", ",", "builder", "|", "if", "(", "type", "==", ":header", ")", "else", "builder", ".", "nbuild", ".", "UpdateFolder", "{", "builder", ".", "nbuild", ".", "pa...
Update properties for a specified folder There is a lot more building in this method because most of the builders are only used for this operation so there was no need to externalize them for re-use. @see http://msdn.microsoft.com/en-us/library/aa580519(v=EXCHG.140).aspx @param [Array<Hash>] folder_changes an Array of well formatted Hashes
[ "Update", "properties", "for", "a", "specified", "folder", "There", "is", "a", "lot", "more", "building", "in", "this", "method", "because", "most", "of", "the", "builders", "are", "only", "used", "for", "this", "operation", "so", "there", "was", "no", "ne...
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/exchange_data_services.rb#L568-L588
valid
WinRb/Viewpoint
lib/ews/soap/exchange_data_services.rb
Viewpoint::EWS::SOAP.ExchangeDataServices.empty_folder
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 builder.nbuild.EmptyFolder(ef_opts) {|x| builder.nbuild.parent.default_namespace = @default_ns builder.folder_ids!(fids) } end end do_soap_request(req) end
ruby
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 builder.nbuild.EmptyFolder(ef_opts) {|x| builder.nbuild.parent.default_namespace = @default_ns builder.folder_ids!(fids) } end end do_soap_request(req) end
[ "def", "empty_folder", "(", "opts", ")", "validate_version", "(", "VERSION_2010_SP1", ")", "ef_opts", "=", "{", "}", "[", ":delete_type", ",", ":delete_sub_folders", "]", ".", "each", "do", "|", "k", "|", "ef_opts", "[", "camel_case", "(", "k", ")", "]", ...
Empties folders in a mailbox. @see http://msdn.microsoft.com/en-us/library/ff709484.aspx @param [Hash] opts @option opts [String] :delete_type Must be one of ExchangeDataServices::HARD_DELETE, SOFT_DELETE, or MOVE_TO_DELETED_ITEMS @option opts [Boolean] :delete_sub_folders @option opts [Array<Hash>] :folder_ids An array of folder_ids in the form: [ {:id => 'myfolderID##asdfs', :change_key => 'asdfasdf'}, {:id => 'blah'} ] @todo Finish
[ "Empties", "folders", "in", "a", "mailbox", "." ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/exchange_data_services.rb#L600-L618
valid
WinRb/Viewpoint
lib/ews/soap/exchange_data_services.rb
Viewpoint::EWS::SOAP.ExchangeDataServices.create_attachment
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) end opts[:items].each do |ia| builder.item_attachment!(ia) end opts[:inline_files].each do |fi| builder.inline_attachment!(fi) end } } end end do_soap_request(req, response_class: EwsResponse) end
ruby
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) end opts[:items].each do |ia| builder.item_attachment!(ia) end opts[:inline_files].each do |fi| builder.inline_attachment!(fi) end } } end end do_soap_request(req, response_class: EwsResponse) end
[ "def", "create_attachment", "(", "opts", ")", "opts", "=", "opts", ".", "clone", "[", ":parent_id", "]", ".", "each", "do", "|", "k", "|", "validate_param", "(", "opts", ",", "k", ",", "true", ")", "end", "validate_param", "(", "opts", ",", ":files", ...
Creates either an item or file attachment and attaches it to the specified item. @see http://msdn.microsoft.com/en-us/library/aa565877.aspx @param [Hash] opts @option opts [Hash] :parent_id {id: <id>, change_key: <ck>} @option opts [Array<Hash>] :files An Array of Base64 encoded Strings with an associated name: {:name => <name>, :content => <Base64 encoded string>} @option opts [Array] :items Exchange Items to attach to this Item @todo Need to implement attachment of Item types
[ "Creates", "either", "an", "item", "or", "file", "attachment", "and", "attaches", "it", "to", "the", "specified", "item", "." ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/exchange_data_services.rb#L657-L686
valid
WinRb/Viewpoint
lib/ews/soap/exchange_data_services.rb
Viewpoint::EWS::SOAP.ExchangeDataServices.resolve_names
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] x.parent.default_namespace = @default_ns # @todo builder.nbuild.ParentFolderIds x.UnresolvedEntry(opts[:name]) } end end do_soap_request(req) end
ruby
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] x.parent.default_namespace = @default_ns # @todo builder.nbuild.ParentFolderIds x.UnresolvedEntry(opts[:name]) } end end do_soap_request(req) end
[ "def", "resolve_names", "(", "opts", ")", "opts", "=", "opts", ".", "clone", "fcd", "=", "opts", ".", "has_key?", "(", ":full_contact_data", ")", "?", "opts", "[", ":full_contact_data", "]", ":", "true", "req", "=", "build_soap!", "do", "|", "type", ",",...
Resolve ambiguous e-mail addresses and display names @see http://msdn.microsoft.com/en-us/library/aa565329.aspx ResolveNames @see http://msdn.microsoft.com/en-us/library/aa581054.aspx UnresolvedEntry @param [Hash] opts @option opts [String] :name the unresolved entry @option opts [Boolean] :full_contact_data (true) Whether or not to return the full contact details. @option opts [String] :search_scope where to seach for this entry, one of SOAP::Contacts, SOAP::ActiveDirectory, SOAP::ActiveDirectoryContacts (default), SOAP::ContactsActiveDirectory @option opts [String, FolderId] :parent_folder_id either the name of a folder or it's numerical ID. @see http://msdn.microsoft.com/en-us/library/aa565998.aspx
[ "Resolve", "ambiguous", "e", "-", "mail", "addresses", "and", "display", "names" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/exchange_data_services.rb#L732-L748
valid
WinRb/Viewpoint
lib/ews/soap/exchange_data_services.rb
Viewpoint::EWS::SOAP.ExchangeDataServices.convert_id
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 x.parent['DestinationFormat'] = opts[:destination_format].to_s.camel_case x.SourceIds { |x| x[NS_EWS_TYPES].AlternateId { |x| x.parent['Format'] = opts[:format].to_s.camel_case x.parent['Id'] = opts[:id] x.parent['Mailbox'] = opts[:mailbox] } } } end end do_soap_request(req, response_class: EwsResponse) end
ruby
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 x.parent['DestinationFormat'] = opts[:destination_format].to_s.camel_case x.SourceIds { |x| x[NS_EWS_TYPES].AlternateId { |x| x.parent['Format'] = opts[:format].to_s.camel_case x.parent['Id'] = opts[:id] x.parent['Mailbox'] = opts[:mailbox] } } } end end do_soap_request(req, response_class: EwsResponse) end
[ "def", "convert_id", "(", "opts", ")", "opts", "=", "opts", ".", "clone", "[", ":id", ",", ":format", ",", ":destination_format", ",", ":mailbox", "]", ".", "each", "do", "|", "k", "|", "validate_param", "(", "opts", ",", "k", ",", "true", ")", "end"...
Converts item and folder identifiers between formats. @see http://msdn.microsoft.com/en-us/library/bb799665.aspx @todo Needs to be finished
[ "Converts", "item", "and", "folder", "identifiers", "between", "formats", "." ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/exchange_data_services.rb#L753-L777
valid
WinRb/Viewpoint
lib/ews/types/calendar_folder.rb
Viewpoint::EWS::Types.CalendarFolder.create_item
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? CalendarItem.new ews, rm.items.first[:calendar_item][:elems].first else raise EwsCreateItemError, "Could not create item in folder. #{rm.code}: #{rm.message_text}" unless rm end end
ruby
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? CalendarItem.new ews, rm.items.first[:calendar_item][:elems].first else raise EwsCreateItemError, "Could not create item in folder. #{rm.code}: #{rm.message_text}" unless rm end end
[ "def", "create_item", "(", "attributes", ",", "to_ews_create_opts", "=", "{", "}", ")", "template", "=", "Viewpoint", "::", "EWS", "::", "Template", "::", "CalendarItem", ".", "new", "attributes", "template", ".", "saved_item_folder_id", "=", "{", "id", ":", ...
Creates a new appointment @param attributes [Hash] Parameters of the calendar item. Some example attributes are listed below. @option attributes :subject [String] @option attributes :start [Time] @option attributes :end [Time] @return [CalendarItem] @see Template::CalendarItem
[ "Creates", "a", "new", "appointment" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/types/calendar_folder.rb#L38-L47
valid
WinRb/Viewpoint
lib/ews/soap/exchange_web_service.rb
Viewpoint::EWS::SOAP.ExchangeWebService.get_user_availability
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]) builder.nbuild.MailboxDataArray { opts[:mailbox_data].each do |mbd| builder.mailbox_data!(mbd) end } builder.free_busy_view_options!(opts[:free_busy_view_options]) builder.suggestions_view_options!(opts[:suggestions_view_options]) } end end do_soap_request(req, response_class: EwsSoapFreeBusyResponse) end
ruby
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]) builder.nbuild.MailboxDataArray { opts[:mailbox_data].each do |mbd| builder.mailbox_data!(mbd) end } builder.free_busy_view_options!(opts[:free_busy_view_options]) builder.suggestions_view_options!(opts[:suggestions_view_options]) } end end do_soap_request(req, response_class: EwsSoapFreeBusyResponse) end
[ "def", "get_user_availability", "(", "opts", ")", "opts", "=", "opts", ".", "clone", "req", "=", "build_soap!", "do", "|", "type", ",", "builder", "|", "if", "(", "type", "==", ":header", ")", "else", "builder", ".", "nbuild", ".", "GetUserAvailabilityRequ...
Provides detailed information about the availability of a set of users, rooms, and resources within a specified time window. @see http://msdn.microsoft.com/en-us/library/aa564001.aspx @param [Hash] opts @option opts [Hash] :time_zone The TimeZone data Example: {:bias => 'UTC offset in minutes', :standard_time => {:bias => 480, :time => '02:00:00', :day_order => 5, :month => 10, :day_of_week => 'Sunday'}, :daylight_time => {same options as :standard_time}} @option opts [Array<Hash>] :mailbox_data Data for the mailbox to query Example: [{:attendee_type => 'Organizer|Required|Optional|Room|Resource', :email =>{:name => 'name', :address => 'email', :routing_type => 'SMTP'}, :exclude_conflicts => true|false }] @option opts [Hash] :free_busy_view_options Example: {:time_window => {:start_time => DateTime,:end_time => DateTime}, :merged_free_busy_interval_in_minutes => minute_int, :requested_view => None|MergedOnly|FreeBusy|FreeBusyMerged|Detailed |DetailedMerged} (optional) @option opts [Hash] :suggestions_view_options (optional) @todo Finish out :suggestions_view_options
[ "Provides", "detailed", "information", "about", "the", "availability", "of", "a", "set", "of", "users", "rooms", "and", "resources", "within", "a", "specified", "time", "window", "." ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/exchange_web_service.rb#L149-L169
valid
WinRb/Viewpoint
lib/ews/soap/exchange_web_service.rb
Viewpoint::EWS::SOAP.ExchangeWebService.get_rooms
def get_rooms(roomDistributionList) req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.GetRooms {|x| x.parent.default_namespace = @default_ns builder.room_list!(roomDistributionList) } end end do_soap_request(req, response_class: EwsSoapRoomResponse) end
ruby
def get_rooms(roomDistributionList) req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.GetRooms {|x| x.parent.default_namespace = @default_ns builder.room_list!(roomDistributionList) } end end do_soap_request(req, response_class: EwsSoapRoomResponse) end
[ "def", "get_rooms", "(", "roomDistributionList", ")", "req", "=", "build_soap!", "do", "|", "type", ",", "builder", "|", "if", "(", "type", "==", ":header", ")", "else", "builder", ".", "nbuild", ".", "GetRooms", "{", "|", "x", "|", "x", ".", "parent",...
Gets the rooms that are in the specified room distribution list @see http://msdn.microsoft.com/en-us/library/aa563465.aspx @param [string] roomDistributionList
[ "Gets", "the", "rooms", "that", "are", "in", "the", "specified", "room", "distribution", "list" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/exchange_web_service.rb#L174-L185
valid
WinRb/Viewpoint
lib/ews/soap/exchange_web_service.rb
Viewpoint::EWS::SOAP.ExchangeWebService.get_room_lists
def get_room_lists req = build_soap! do |type, builder| if(type == :header) else builder.room_lists! end end do_soap_request(req, response_class: EwsSoapRoomlistResponse) end
ruby
def get_room_lists req = build_soap! do |type, builder| if(type == :header) else builder.room_lists! end end do_soap_request(req, response_class: EwsSoapRoomlistResponse) end
[ "def", "get_room_lists", "req", "=", "build_soap!", "do", "|", "type", ",", "builder", "|", "if", "(", "type", "==", ":header", ")", "else", "builder", ".", "room_lists!", "end", "end", "do_soap_request", "(", "req", ",", "response_class", ":", "EwsSoapRooml...
Gets the room lists that are available within the Exchange organization. @see http://msdn.microsoft.com/en-us/library/aa563465.aspx
[ "Gets", "the", "room", "lists", "that", "are", "available", "within", "the", "Exchange", "organization", "." ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/exchange_web_service.rb#L189-L197
valid
WinRb/Viewpoint
lib/ews/soap/exchange_web_service.rb
Viewpoint::EWS::SOAP.ExchangeWebService.validate_version
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})." msg << " You must be running at least version (#{exchange_version})." raise EwsServerVersionError, msg end end
ruby
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})." msg << " You must be running at least version (#{exchange_version})." raise EwsServerVersionError, msg end end
[ "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}).\"", "msg", "<<", "\...
Some operations only exist for certain versions of Exchange Server. This method should be called with the required version and we'll throw an exception of the currently set @server_version does not comply.
[ "Some", "operations", "only", "exist", "for", "certain", "versions", "of", "Exchange", "Server", ".", "This", "method", "should", "be", "called", "with", "the", "required", "version", "and", "we", "ll", "throw", "an", "exception", "of", "the", "currently", "...
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/exchange_web_service.rb#L247-L254
valid
WinRb/Viewpoint
lib/ews/soap/exchange_web_service.rb
Viewpoint::EWS::SOAP.ExchangeWebService.build_soap!
def build_soap!(&block) opts = { :server_version => server_version, :impersonation_type => impersonation_type, :impersonation_mail => impersonation_address } opts[:time_zone_context] = @time_zone_context if @time_zone_context EwsBuilder.new.build!(opts, &block) end
ruby
def build_soap!(&block) opts = { :server_version => server_version, :impersonation_type => impersonation_type, :impersonation_mail => impersonation_address } opts[:time_zone_context] = @time_zone_context if @time_zone_context EwsBuilder.new.build!(opts, &block) end
[ "def", "build_soap!", "(", "&", "block", ")", "opts", "=", "{", ":server_version", "=>", "server_version", ",", ":impersonation_type", "=>", "impersonation_type", ",", ":impersonation_mail", "=>", "impersonation_address", "}", "opts", "[", ":time_zone_context", "]", ...
Build the common elements in the SOAP message and yield to any custom elements.
[ "Build", "the", "common", "elements", "in", "the", "SOAP", "message", "and", "yield", "to", "any", "custom", "elements", "." ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/ews/soap/exchange_web_service.rb#L257-L261
valid
WinRb/Viewpoint
lib/viewpoint/string_utils.rb
Viewpoint.StringUtils.camel_case
def camel_case(input) input.to_s.split(/_/).map { |i| i.sub(/^./) { |s| s.upcase } }.join end
ruby
def camel_case(input) input.to_s.split(/_/).map { |i| i.sub(/^./) { |s| s.upcase } }.join end
[ "def", "camel_case", "(", "input", ")", "input", ".", "to_s", ".", "split", "(", "/", "/", ")", ".", "map", "{", "|", "i", "|", "i", ".", "sub", "(", "/", "/", ")", "{", "|", "s", "|", "s", ".", "upcase", "}", "}", ".", "join", "end" ]
Change a ruby_cased string to CamelCased
[ "Change", "a", "ruby_cased", "string", "to", "CamelCased" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/viewpoint/string_utils.rb#L52-L56
valid
WinRb/Viewpoint
lib/viewpoint/string_utils.rb
Viewpoint.StringUtils.iso8601_duration_to_seconds
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 duration += match_data[:hours].to_i * 3600 duration += match_data[:minutes].to_i * 60 duration += match_data[:seconds].to_i end
ruby
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 duration += match_data[:hours].to_i * 3600 duration += match_data[:minutes].to_i * 60 duration += match_data[:seconds].to_i end
[ "def", "iso8601_duration_to_seconds", "(", "input", ")", "return", "nil", "if", "input", ".", "nil?", "||", "input", ".", "empty?", "match_data", "=", "DURATION_RE", ".", "match", "(", "input", ")", "raise", "(", "StringFormatException", ",", "\"Invalid duration...
Convert an ISO8601 Duration format to seconds @see http://tools.ietf.org/html/rfc2445#section-4.3.6 @param [String] input @return [nil,Fixnum] the number of seconds in this duration nil if there is no known duration
[ "Convert", "an", "ISO8601", "Duration", "format", "to", "seconds" ]
e8fec4ab1af25fc128062cd96770afdb9fc38c68
https://github.com/WinRb/Viewpoint/blob/e8fec4ab1af25fc128062cd96770afdb9fc38c68/lib/viewpoint/string_utils.rb#L63-L73
valid