id
int32
0
24.9k
repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
list
docstring
stringlengths
8
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
94
266
22,600
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/cli.rb
OneviewSDK.Cli.env
def env data = {} OneviewSDK::ENV_VARS.each { |k| data[k] = ENV[k] } if @options['format'] == 'human' data.each do |key, value| value = "'#{value}'" if value && !%w[true false].include?(value) printf "%-#{data.keys.max_by(&:length).length}s = %s\n", key, value || 'nil' ...
ruby
def env data = {} OneviewSDK::ENV_VARS.each { |k| data[k] = ENV[k] } if @options['format'] == 'human' data.each do |key, value| value = "'#{value}'" if value && !%w[true false].include?(value) printf "%-#{data.keys.max_by(&:length).length}s = %s\n", key, value || 'nil' ...
[ "def", "env", "data", "=", "{", "}", "OneviewSDK", "::", "ENV_VARS", ".", "each", "{", "|", "k", "|", "data", "[", "k", "]", "=", "ENV", "[", "k", "]", "}", "if", "@options", "[", "'format'", "]", "==", "'human'", "data", ".", "each", "do", "|"...
Show environment variables for oneview-sdk-ruby
[ "Show", "environment", "variables", "for", "oneview", "-", "sdk", "-", "ruby" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/cli.rb#L115-L126
22,601
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/cli.rb
OneviewSDK.Cli.show
def show(type, name) resource_class = parse_type(type) client_setup matches = resource_class.find_by(@client, name: name) fail_nice 'Not Found' if matches.empty? data = matches.first.data if options['attribute'] data = select_attributes(options['attribute'], data) end ...
ruby
def show(type, name) resource_class = parse_type(type) client_setup matches = resource_class.find_by(@client, name: name) fail_nice 'Not Found' if matches.empty? data = matches.first.data if options['attribute'] data = select_attributes(options['attribute'], data) end ...
[ "def", "show", "(", "type", ",", "name", ")", "resource_class", "=", "parse_type", "(", "type", ")", "client_setup", "matches", "=", "resource_class", ".", "find_by", "(", "@client", ",", "name", ":", "name", ")", "fail_nice", "'Not Found'", "if", "matches",...
Show resource details
[ "Show", "resource", "details" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/cli.rb#L176-L186
22,602
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/cli.rb
OneviewSDK.Cli.rest
def rest(method, uri) log_level = @options['log_level'] == :warn ? :error : @options['log_level'].to_sym # Default to :error client_setup('log_level' => log_level) uri_copy = uri.dup uri_copy.prepend('/') unless uri_copy.start_with?('/') if @options['data'] begin data = {...
ruby
def rest(method, uri) log_level = @options['log_level'] == :warn ? :error : @options['log_level'].to_sym # Default to :error client_setup('log_level' => log_level) uri_copy = uri.dup uri_copy.prepend('/') unless uri_copy.start_with?('/') if @options['data'] begin data = {...
[ "def", "rest", "(", "method", ",", "uri", ")", "log_level", "=", "@options", "[", "'log_level'", "]", "==", ":warn", "?", ":error", ":", "@options", "[", "'log_level'", "]", ".", "to_sym", "# Default to :error", "client_setup", "(", "'log_level'", "=>", "log...
Make REST call to the OneView API
[ "Make", "REST", "call", "to", "the", "OneView", "API" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/cli.rb#L238-L267
22,603
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/cli.rb
OneviewSDK.Cli.update
def update(type, name) resource_class = parse_type(type) client_setup fail_nice 'Must set the hash or json option' unless @options['hash'] || @options['json'] fail_nice 'Must set the hash OR json option. Not both' if @options['hash'] && @options['json'] begin data = @options['hash'...
ruby
def update(type, name) resource_class = parse_type(type) client_setup fail_nice 'Must set the hash or json option' unless @options['hash'] || @options['json'] fail_nice 'Must set the hash OR json option. Not both' if @options['hash'] && @options['json'] begin data = @options['hash'...
[ "def", "update", "(", "type", ",", "name", ")", "resource_class", "=", "parse_type", "(", "type", ")", "client_setup", "fail_nice", "'Must set the hash or json option'", "unless", "@options", "[", "'hash'", "]", "||", "@options", "[", "'json'", "]", "fail_nice", ...
Update resource by name
[ "Update", "resource", "by", "name" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/cli.rb#L280-L299
22,604
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/cli.rb
OneviewSDK.Cli.delete
def delete(type, name) resource_class = parse_type(type) client_setup matches = resource_class.find_by(@client, name: name) fail_nice('Not Found', 2) if matches.empty? resource = matches.first return unless options['force'] || agree("Delete '#{name}'? [Y/N] ") begin res...
ruby
def delete(type, name) resource_class = parse_type(type) client_setup matches = resource_class.find_by(@client, name: name) fail_nice('Not Found', 2) if matches.empty? resource = matches.first return unless options['force'] || agree("Delete '#{name}'? [Y/N] ") begin res...
[ "def", "delete", "(", "type", ",", "name", ")", "resource_class", "=", "parse_type", "(", "type", ")", "client_setup", "matches", "=", "resource_class", ".", "find_by", "(", "@client", ",", "name", ":", "name", ")", "fail_nice", "(", "'Not Found'", ",", "2...
Delete resource by name
[ "Delete", "resource", "by", "name" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/cli.rb#L307-L320
22,605
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/cli.rb
OneviewSDK.Cli.delete_from_file
def delete_from_file(file_path) client_setup resource = OneviewSDK::Resource.from_file(@client, file_path) fail_nice("#{resource.class.name.split('::').last} '#{resource[:name] || resource[:uri]}' Not Found", 2) unless resource.retrieve! return unless options['force'] || agree("Delete '#{resourc...
ruby
def delete_from_file(file_path) client_setup resource = OneviewSDK::Resource.from_file(@client, file_path) fail_nice("#{resource.class.name.split('::').last} '#{resource[:name] || resource[:uri]}' Not Found", 2) unless resource.retrieve! return unless options['force'] || agree("Delete '#{resourc...
[ "def", "delete_from_file", "(", "file_path", ")", "client_setup", "resource", "=", "OneviewSDK", "::", "Resource", ".", "from_file", "(", "@client", ",", "file_path", ")", "fail_nice", "(", "\"#{resource.class.name.split('::').last} '#{resource[:name] || resource[:uri]}' Not ...
Delete resource defined in file
[ "Delete", "resource", "defined", "in", "file" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/cli.rb#L328-L343
22,606
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/cli.rb
OneviewSDK.Cli.to_file
def to_file(type, name) file = File.expand_path(options['path']) resource_class = parse_type(type) client_setup resource = resource_class.find_by(@client, name: name).first fail_nice "#{resource_class.name.split('::').last} '#{name}' not found" unless resource resource.to_file(file, ...
ruby
def to_file(type, name) file = File.expand_path(options['path']) resource_class = parse_type(type) client_setup resource = resource_class.find_by(@client, name: name).first fail_nice "#{resource_class.name.split('::').last} '#{name}' not found" unless resource resource.to_file(file, ...
[ "def", "to_file", "(", "type", ",", "name", ")", "file", "=", "File", ".", "expand_path", "(", "options", "[", "'path'", "]", ")", "resource_class", "=", "parse_type", "(", "type", ")", "client_setup", "resource", "=", "resource_class", ".", "find_by", "("...
Save resource details to file
[ "Save", "resource", "details", "to", "file" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/cli.rb#L398-L408
22,607
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/cli.rb
OneviewSDK.Cli.cert
def cert(type, url = ENV['ONEVIEWSDK_URL']) case type.downcase when 'check' fail_nice 'Must specify a url' unless url puts "Checking certificate for '#{url}' ..." if OneviewSDK::SSLHelper.check_cert(url) puts 'Certificate is valid!' else fail_nice 'Certifi...
ruby
def cert(type, url = ENV['ONEVIEWSDK_URL']) case type.downcase when 'check' fail_nice 'Must specify a url' unless url puts "Checking certificate for '#{url}' ..." if OneviewSDK::SSLHelper.check_cert(url) puts 'Certificate is valid!' else fail_nice 'Certifi...
[ "def", "cert", "(", "type", ",", "url", "=", "ENV", "[", "'ONEVIEWSDK_URL'", "]", ")", "case", "type", ".", "downcase", "when", "'check'", "fail_nice", "'Must specify a url'", "unless", "url", "puts", "\"Checking certificate for '#{url}' ...\"", "if", "OneviewSDK", ...
Check, import, or list OneView certs
[ "Check", "import", "or", "list", "OneView", "certs" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/cli.rb#L412-L436
22,608
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/cli.rb
OneviewSDK.Cli.scmb
def scmb client_setup connection = OneviewSDK::SCMB.new_connection(@client) q = OneviewSDK::SCMB.new_queue(connection, @options['route']) puts 'Subscribing to OneView messages. To exit, press Ctrl + c' q.subscribe(block: true) do |_delivery_info, _properties, payload| data = JSON.p...
ruby
def scmb client_setup connection = OneviewSDK::SCMB.new_connection(@client) q = OneviewSDK::SCMB.new_queue(connection, @options['route']) puts 'Subscribing to OneView messages. To exit, press Ctrl + c' q.subscribe(block: true) do |_delivery_info, _properties, payload| data = JSON.p...
[ "def", "scmb", "client_setup", "connection", "=", "OneviewSDK", "::", "SCMB", ".", "new_connection", "(", "@client", ")", "q", "=", "OneviewSDK", "::", "SCMB", ".", "new_queue", "(", "connection", ",", "@options", "[", "'route'", "]", ")", "puts", "'Subscrib...
Subscribe to the OneView SCMB
[ "Subscribe", "to", "the", "OneView", "SCMB" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/cli.rb#L453-L463
22,609
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/cli.rb
OneviewSDK.Cli.parse_type
def parse_type(type) api_ver = (@options['api_version'] || ENV['ONEVIEWSDK_API_VERSION'] || OneviewSDK.api_version).to_i unless OneviewSDK::SUPPORTED_API_VERSIONS.include?(api_ver) # Find and use the best available match for the desired API version (round down to nearest) valid_api_ver = One...
ruby
def parse_type(type) api_ver = (@options['api_version'] || ENV['ONEVIEWSDK_API_VERSION'] || OneviewSDK.api_version).to_i unless OneviewSDK::SUPPORTED_API_VERSIONS.include?(api_ver) # Find and use the best available match for the desired API version (round down to nearest) valid_api_ver = One...
[ "def", "parse_type", "(", "type", ")", "api_ver", "=", "(", "@options", "[", "'api_version'", "]", "||", "ENV", "[", "'ONEVIEWSDK_API_VERSION'", "]", "||", "OneviewSDK", ".", "api_version", ")", ".", "to_i", "unless", "OneviewSDK", "::", "SUPPORTED_API_VERSIONS"...
Get resource class from given string
[ "Get", "resource", "class", "from", "given", "string" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/cli.rb#L487-L515
22,610
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/cli.rb
OneviewSDK.Cli.select_attributes
def select_attributes(attributes, data = {}) attributes = attributes.split(',').map(&:strip).reject(&:empty?).map { |a| a.split('.') } if attributes.is_a?(String) r_data = data.is_a?(Hash) ? data : data.data temp = {} attributes.each do |attr| temp_level = temp attr = [attr] if a...
ruby
def select_attributes(attributes, data = {}) attributes = attributes.split(',').map(&:strip).reject(&:empty?).map { |a| a.split('.') } if attributes.is_a?(String) r_data = data.is_a?(Hash) ? data : data.data temp = {} attributes.each do |attr| temp_level = temp attr = [attr] if a...
[ "def", "select_attributes", "(", "attributes", ",", "data", "=", "{", "}", ")", "attributes", "=", "attributes", ".", "split", "(", "','", ")", ".", "map", "(", ":strip", ")", ".", "reject", "(", ":empty?", ")", ".", "map", "{", "|", "a", "|", "a",...
Select a subset of attributes from a given resource @param attributes [String, Array<Array<String>>] Comma-separated string or array of array of strings The reason it's a nested array is to allow retrieval of nested keys. For example, the following 2 attribute params will return the same result: - [['key1']...
[ "Select", "a", "subset", "of", "attributes", "from", "a", "given", "resource" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/cli.rb#L556-L575
22,611
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/cli.rb
OneviewSDK.Cli.select_attributes_from_multiple
def select_attributes_from_multiple(attributes, data = []) attributes = attributes.split(',').map(&:strip).reject(&:empty?).map { |a| a.split('.') } if attributes.is_a?(String) result = [] data.each do |r| result.push(r['name'] => select_attributes(attributes, r)) end result en...
ruby
def select_attributes_from_multiple(attributes, data = []) attributes = attributes.split(',').map(&:strip).reject(&:empty?).map { |a| a.split('.') } if attributes.is_a?(String) result = [] data.each do |r| result.push(r['name'] => select_attributes(attributes, r)) end result en...
[ "def", "select_attributes_from_multiple", "(", "attributes", ",", "data", "=", "[", "]", ")", "attributes", "=", "attributes", ".", "split", "(", "','", ")", ".", "map", "(", ":strip", ")", ".", "reject", "(", ":empty?", ")", ".", "map", "{", "|", "a",...
Select a subset of attributes from a given set of resources @param attributes [String, Array<Array<String>>] Comma-separated string or array of array of strings The reason it's a nested array is to allow retrieval of nested keys. For example, the following 2 attribute params will return the same result: - [...
[ "Select", "a", "subset", "of", "attributes", "from", "a", "given", "set", "of", "resources" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/cli.rb#L589-L596
22,612
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/client.rb
OneviewSDK.Client.get_all
def get_all(type, api_ver = @api_version, variant = nil) klass = OneviewSDK.resource_named(type, api_ver, variant) raise TypeError, "Invalid resource type '#{type}'. OneviewSDK::API#{api_ver} does not contain a class like it." unless klass klass.get_all(self) end
ruby
def get_all(type, api_ver = @api_version, variant = nil) klass = OneviewSDK.resource_named(type, api_ver, variant) raise TypeError, "Invalid resource type '#{type}'. OneviewSDK::API#{api_ver} does not contain a class like it." unless klass klass.get_all(self) end
[ "def", "get_all", "(", "type", ",", "api_ver", "=", "@api_version", ",", "variant", "=", "nil", ")", "klass", "=", "OneviewSDK", ".", "resource_named", "(", "type", ",", "api_ver", ",", "variant", ")", "raise", "TypeError", ",", "\"Invalid resource type '#{typ...
Get array of all resources of a specified type @param [String] type Resource type @param [Integer] api_ver API module version to fetch resources from @param [String] variant API module variant to fetch resource from @return [Array<Resource>] Results @example Get all Ethernet Networks networks = @client.get_all(...
[ "Get", "array", "of", "all", "resources", "of", "a", "specified", "type" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/client.rb#L119-L123
22,613
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/client.rb
OneviewSDK.Client.wait_for
def wait_for(task_uri) raise ArgumentError, 'Must specify a task_uri!' if task_uri.nil? || task_uri.empty? loop do task_uri.gsub!(%r{https:(.*)\/rest}, '/rest') task = rest_get(task_uri) body = JSON.parse(task.body) case body['taskState'].downcase when 'completed' ...
ruby
def wait_for(task_uri) raise ArgumentError, 'Must specify a task_uri!' if task_uri.nil? || task_uri.empty? loop do task_uri.gsub!(%r{https:(.*)\/rest}, '/rest') task = rest_get(task_uri) body = JSON.parse(task.body) case body['taskState'].downcase when 'completed' ...
[ "def", "wait_for", "(", "task_uri", ")", "raise", "ArgumentError", ",", "'Must specify a task_uri!'", "if", "task_uri", ".", "nil?", "||", "task_uri", ".", "empty?", "loop", "do", "task_uri", ".", "gsub!", "(", "%r{", "\\/", "}", ",", "'/rest'", ")", "task",...
Wait for a task to complete @param [String] task_uri @raise [OneviewSDK::TaskError] if the task resulted in an error or early termination. @return [Hash] if the task completed successfully, return the task details
[ "Wait", "for", "a", "task", "to", "complete" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/client.rb#L129-L150
22,614
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/client.rb
OneviewSDK.Client.appliance_api_version
def appliance_api_version options = { 'Content-Type' => :none, 'X-API-Version' => :none, 'auth' => :none } response = rest_api(:get, '/rest/version', options) version = response_handler(response)['currentVersion'] raise ConnectionError, "Couldn't get API version" unless version version = v...
ruby
def appliance_api_version options = { 'Content-Type' => :none, 'X-API-Version' => :none, 'auth' => :none } response = rest_api(:get, '/rest/version', options) version = response_handler(response)['currentVersion'] raise ConnectionError, "Couldn't get API version" unless version version = v...
[ "def", "appliance_api_version", "options", "=", "{", "'Content-Type'", "=>", ":none", ",", "'X-API-Version'", "=>", ":none", ",", "'auth'", "=>", ":none", "}", "response", "=", "rest_api", "(", ":get", ",", "'/rest/version'", ",", "options", ")", "version", "=...
Get current api version from the OneView appliance
[ "Get", "current", "api", "version", "from", "the", "OneView", "appliance" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/client.rb#L189-L199
22,615
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/client.rb
OneviewSDK.Client.login
def login(retries = 2) options = { 'body' => { 'userName' => @user, 'password' => @password, 'authLoginDomain' => @domain } } response = rest_post('/rest/login-sessions', options) body = response_handler(response) return body['sessionID'] if bo...
ruby
def login(retries = 2) options = { 'body' => { 'userName' => @user, 'password' => @password, 'authLoginDomain' => @domain } } response = rest_post('/rest/login-sessions', options) body = response_handler(response) return body['sessionID'] if bo...
[ "def", "login", "(", "retries", "=", "2", ")", "options", "=", "{", "'body'", "=>", "{", "'userName'", "=>", "@user", ",", "'password'", "=>", "@password", ",", "'authLoginDomain'", "=>", "@domain", "}", "}", "response", "=", "rest_post", "(", "'/rest/logi...
Log in to OneView appliance and return the session token
[ "Log", "in", "to", "OneView", "appliance", "and", "return", "the", "session", "token" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/client.rb#L202-L218
22,616
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/rest.rb
OneviewSDK.Rest.rest_api
def rest_api(type, path, options = {}, api_ver = @api_version, redirect_limit = 3) @logger.debug "Making :#{type} rest call to #{@url}#{path}" raise InvalidRequest, 'Must specify path' unless path uri = URI.parse(Addressable::URI.escape(@url + path)) http = build_http_object(uri) request =...
ruby
def rest_api(type, path, options = {}, api_ver = @api_version, redirect_limit = 3) @logger.debug "Making :#{type} rest call to #{@url}#{path}" raise InvalidRequest, 'Must specify path' unless path uri = URI.parse(Addressable::URI.escape(@url + path)) http = build_http_object(uri) request =...
[ "def", "rest_api", "(", "type", ",", "path", ",", "options", "=", "{", "}", ",", "api_ver", "=", "@api_version", ",", "redirect_limit", "=", "3", ")", "@logger", ".", "debug", "\"Making :#{type} rest call to #{@url}#{path}\"", "raise", "InvalidRequest", ",", "'M...
in seconds, 5 minutes Makes a restful API request to OneView @param [Symbol] type The rest method/type Options: [:get, :post, :delete, :patch, :put] @param [String] path The path for the request. Usually starts with "/rest/" @param [Hash] options The options for the request @option options [String] :body Hash to b...
[ "in", "seconds", "5", "minutes", "Makes", "a", "restful", "API", "request", "to", "OneView" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/rest.rb#L36-L57
22,617
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/rest.rb
OneviewSDK.Rest.upload_file
def upload_file(file_path, path, options = {}, timeout = READ_TIMEOUT) raise NotFound, "ERROR: File '#{file_path}' not found!" unless File.file?(file_path) options = Hash[options.map { |k, v| [k.to_s, v] }] body_params = options['body'] || {} headers_params = options['header'] || {} header...
ruby
def upload_file(file_path, path, options = {}, timeout = READ_TIMEOUT) raise NotFound, "ERROR: File '#{file_path}' not found!" unless File.file?(file_path) options = Hash[options.map { |k, v| [k.to_s, v] }] body_params = options['body'] || {} headers_params = options['header'] || {} header...
[ "def", "upload_file", "(", "file_path", ",", "path", ",", "options", "=", "{", "}", ",", "timeout", "=", "READ_TIMEOUT", ")", "raise", "NotFound", ",", "\"ERROR: File '#{file_path}' not found!\"", "unless", "File", ".", "file?", "(", "file_path", ")", "options",...
Uploads a file to a specific uri @param [String] file_path @param [String] path The url path starting with "/" @param [Hash] options The options for the request. Default is {}. @option options [String] :body Hash to be converted into json and set as the request body @option options [String] :header Hash to be conv...
[ "Uploads", "a", "file", "to", "a", "specific", "uri" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/rest.rb#L132-L170
22,618
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/rest.rb
OneviewSDK.Rest.download_file
def download_file(path, local_drive_path) uri = URI.parse(Addressable::URI.escape(@url + path)) http_request = build_http_object(uri) req = build_request(:get, uri, {}, @api_version.to_s) http_request.start do |http| http.request(req) do |res| response_handler(res) unless res....
ruby
def download_file(path, local_drive_path) uri = URI.parse(Addressable::URI.escape(@url + path)) http_request = build_http_object(uri) req = build_request(:get, uri, {}, @api_version.to_s) http_request.start do |http| http.request(req) do |res| response_handler(res) unless res....
[ "def", "download_file", "(", "path", ",", "local_drive_path", ")", "uri", "=", "URI", ".", "parse", "(", "Addressable", "::", "URI", ".", "escape", "(", "@url", "+", "path", ")", ")", "http_request", "=", "build_http_object", "(", "uri", ")", "req", "=",...
Download a file from a specific uri @param [String] path The url path starting with "/" @param [String] local_drive_path Path to save file downloaded @return [Boolean] if file was downloaded
[ "Download", "a", "file", "from", "a", "specific", "uri" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/rest.rb#L176-L192
22,619
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/rest.rb
OneviewSDK.Rest.response_handler
def response_handler(response, wait_on_task = true) case response.code.to_i when RESPONSE_CODE_OK # Synchronous read/query begin return JSON.parse(response.body) rescue JSON::ParserError => e @logger.warn "Failed to parse JSON response. #{e}" return response.bod...
ruby
def response_handler(response, wait_on_task = true) case response.code.to_i when RESPONSE_CODE_OK # Synchronous read/query begin return JSON.parse(response.body) rescue JSON::ParserError => e @logger.warn "Failed to parse JSON response. #{e}" return response.bod...
[ "def", "response_handler", "(", "response", ",", "wait_on_task", "=", "true", ")", "case", "response", ".", "code", ".", "to_i", "when", "RESPONSE_CODE_OK", "# Synchronous read/query", "begin", "return", "JSON", ".", "parse", "(", "response", ".", "body", ")", ...
Handles the response from a rest call. If an asynchronous task was started, this waits for it to complete. @param [HTTPResponse] response HTTP response @param [Boolean] wait_on_task Wait on task (or just return task details) @raise [OneviewSDK::OneViewError] if the request failed or a task did not complete succes...
[ "Handles", "the", "response", "from", "a", "rest", "call", ".", "If", "an", "asynchronous", "task", "was", "started", "this", "waits", "for", "it", "to", "complete", "." ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/rest.rb#L208-L238
22,620
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/rest.rb
OneviewSDK.Rest.build_http_object
def build_http_object(uri) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true if uri.scheme == 'https' if @ssl_enabled http.cert_store = @cert_store if @cert_store else http.verify_mode = OpenSSL::SSL::VERIFY_NONE end http.read_timeout = @timeout if @timeout # Timeo...
ruby
def build_http_object(uri) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true if uri.scheme == 'https' if @ssl_enabled http.cert_store = @cert_store if @cert_store else http.verify_mode = OpenSSL::SSL::VERIFY_NONE end http.read_timeout = @timeout if @timeout # Timeo...
[ "def", "build_http_object", "(", "uri", ")", "http", "=", "Net", "::", "HTTP", ".", "new", "(", "uri", ".", "host", ",", "uri", ".", "port", ")", "http", ".", "use_ssl", "=", "true", "if", "uri", ".", "scheme", "==", "'https'", "if", "@ssl_enabled", ...
Builds a http object using the data given
[ "Builds", "a", "http", "object", "using", "the", "data", "given" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/rest.rb#L244-L254
22,621
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/rest.rb
OneviewSDK.Rest.build_request
def build_request(type, uri, options, api_ver) case type.downcase.to_sym when :get request = Net::HTTP::Get.new(uri.request_uri) when :post request = Net::HTTP::Post.new(uri.request_uri) when :put request = Net::HTTP::Put.new(uri.request_uri) when :patch req...
ruby
def build_request(type, uri, options, api_ver) case type.downcase.to_sym when :get request = Net::HTTP::Get.new(uri.request_uri) when :post request = Net::HTTP::Post.new(uri.request_uri) when :put request = Net::HTTP::Put.new(uri.request_uri) when :patch req...
[ "def", "build_request", "(", "type", ",", "uri", ",", "options", ",", "api_ver", ")", "case", "type", ".", "downcase", ".", "to_sym", "when", ":get", "request", "=", "Net", "::", "HTTP", "::", "Get", ".", "new", "(", "uri", ".", "request_uri", ")", "...
Builds a request object using the data given
[ "Builds", "a", "request", "object", "using", "the", "data", "given" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/rest.rb#L257-L290
22,622
antek-drzewiecki/wine_bouncer
lib/wine_bouncer/oauth2.rb
WineBouncer.OAuth2.doorkeeper_authorize!
def doorkeeper_authorize!(*scopes) scopes = Doorkeeper.configuration.default_scopes if scopes.empty? unless valid_doorkeeper_token?(*scopes) if !doorkeeper_token || !doorkeeper_token.accessible? error = Doorkeeper::OAuth::InvalidTokenResponse.from_access_token(doorkeeper_token) r...
ruby
def doorkeeper_authorize!(*scopes) scopes = Doorkeeper.configuration.default_scopes if scopes.empty? unless valid_doorkeeper_token?(*scopes) if !doorkeeper_token || !doorkeeper_token.accessible? error = Doorkeeper::OAuth::InvalidTokenResponse.from_access_token(doorkeeper_token) r...
[ "def", "doorkeeper_authorize!", "(", "*", "scopes", ")", "scopes", "=", "Doorkeeper", ".", "configuration", ".", "default_scopes", "if", "scopes", ".", "empty?", "unless", "valid_doorkeeper_token?", "(", "scopes", ")", "if", "!", "doorkeeper_token", "||", "!", "...
This method handles the authorization, raises errors if authorization has failed.
[ "This", "method", "handles", "the", "authorization", "raises", "errors", "if", "authorization", "has", "failed", "." ]
01d3b0d302c10300f9a0437702997c4017b5f0bc
https://github.com/antek-drzewiecki/wine_bouncer/blob/01d3b0d302c10300f9a0437702997c4017b5f0bc/lib/wine_bouncer/oauth2.rb#L61-L72
22,623
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/resource.rb
OneviewSDK.Resource.exists?
def exists?(header = self.class::DEFAULT_REQUEST_HEADER) retrieval_keys = self.class::UNIQUE_IDENTIFIERS.reject { |k| @data[k].nil? } raise IncompleteResource, "Must set resource #{self.class::UNIQUE_IDENTIFIERS.join(' or ')} before trying to retrieve!" if retrieval_keys.empty? retrieval_keys.each do ...
ruby
def exists?(header = self.class::DEFAULT_REQUEST_HEADER) retrieval_keys = self.class::UNIQUE_IDENTIFIERS.reject { |k| @data[k].nil? } raise IncompleteResource, "Must set resource #{self.class::UNIQUE_IDENTIFIERS.join(' or ')} before trying to retrieve!" if retrieval_keys.empty? retrieval_keys.each do ...
[ "def", "exists?", "(", "header", "=", "self", ".", "class", "::", "DEFAULT_REQUEST_HEADER", ")", "retrieval_keys", "=", "self", ".", "class", "::", "UNIQUE_IDENTIFIERS", ".", "reject", "{", "|", "k", "|", "@data", "[", "k", "]", ".", "nil?", "}", "raise"...
Check if a resource exists @note one of the UNIQUE_IDENTIFIERS, e.g. name or uri, must be specified in the resource @param [Hash] header The header options for the request (key-value pairs) @return [Boolean] Whether or not resource exists
[ "Check", "if", "a", "resource", "exists" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/resource.rb#L68-L76
22,624
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/resource.rb
OneviewSDK.Resource.deep_merge!
def deep_merge!(other_data, target_data = @data) raise 'Both arguments should be a object Hash' unless other_data.is_a?(Hash) && target_data.is_a?(Hash) other_data.each do |key, value| value_target = target_data[key.to_s] if value_target.is_a?(Hash) && value.is_a?(Hash) deep_merge!...
ruby
def deep_merge!(other_data, target_data = @data) raise 'Both arguments should be a object Hash' unless other_data.is_a?(Hash) && target_data.is_a?(Hash) other_data.each do |key, value| value_target = target_data[key.to_s] if value_target.is_a?(Hash) && value.is_a?(Hash) deep_merge!...
[ "def", "deep_merge!", "(", "other_data", ",", "target_data", "=", "@data", ")", "raise", "'Both arguments should be a object Hash'", "unless", "other_data", ".", "is_a?", "(", "Hash", ")", "&&", "target_data", ".", "is_a?", "(", "Hash", ")", "other_data", ".", "...
Merges the first hash data structure with the second @note both arguments should be a Ruby Hash object. The second hash should have strings as a keys. This method will change the second argument. @raise [StandardError] if the arguments, or one them, is not a Hash object
[ "Merges", "the", "first", "hash", "data", "structure", "with", "the", "second" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/resource.rb#L83-L93
22,625
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/resource.rb
OneviewSDK.Resource.set_all
def set_all(params = self.class::DEFAULT_REQUEST_HEADER) params = params.data if params.class <= Resource params = Hash[params.map { |(k, v)| [k.to_s, v] }] params.each { |key, value| set(key.to_s, value) } self end
ruby
def set_all(params = self.class::DEFAULT_REQUEST_HEADER) params = params.data if params.class <= Resource params = Hash[params.map { |(k, v)| [k.to_s, v] }] params.each { |key, value| set(key.to_s, value) } self end
[ "def", "set_all", "(", "params", "=", "self", ".", "class", "::", "DEFAULT_REQUEST_HEADER", ")", "params", "=", "params", ".", "data", "if", "params", ".", "class", "<=", "Resource", "params", "=", "Hash", "[", "params", ".", "map", "{", "|", "(", "k",...
Set the given hash of key-value pairs as resource data attributes @param [Hash, Resource] params The options for this resource (key-value pairs or resource object) @note All top-level keys will be converted to strings @return [Resource] self
[ "Set", "the", "given", "hash", "of", "key", "-", "value", "pairs", "as", "resource", "data", "attributes" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/resource.rb#L99-L104
22,626
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/resource.rb
OneviewSDK.Resource.set
def set(key, value) method_name = "validate_#{key}" send(method_name.to_sym, value) if respond_to?(method_name.to_sym) @data[key.to_s] = value end
ruby
def set(key, value) method_name = "validate_#{key}" send(method_name.to_sym, value) if respond_to?(method_name.to_sym) @data[key.to_s] = value end
[ "def", "set", "(", "key", ",", "value", ")", "method_name", "=", "\"validate_#{key}\"", "send", "(", "method_name", ".", "to_sym", ",", "value", ")", "if", "respond_to?", "(", "method_name", ".", "to_sym", ")", "@data", "[", "key", ".", "to_s", "]", "=",...
Set a resource attribute with the given value and call any validation method if necessary @param [String] key attribute name @param value value to assign to the given attribute @note Keys will be converted to strings
[ "Set", "a", "resource", "attribute", "with", "the", "given", "value", "and", "call", "any", "validation", "method", "if", "necessary" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/resource.rb#L110-L114
22,627
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/resource.rb
OneviewSDK.Resource.create
def create(header = self.class::DEFAULT_REQUEST_HEADER) ensure_client options = {}.merge(header).merge('body' => @data) response = @client.rest_post(self.class::BASE_URI, options, @api_version) body = @client.response_handler(response) set_all(body) self end
ruby
def create(header = self.class::DEFAULT_REQUEST_HEADER) ensure_client options = {}.merge(header).merge('body' => @data) response = @client.rest_post(self.class::BASE_URI, options, @api_version) body = @client.response_handler(response) set_all(body) self end
[ "def", "create", "(", "header", "=", "self", ".", "class", "::", "DEFAULT_REQUEST_HEADER", ")", "ensure_client", "options", "=", "{", "}", ".", "merge", "(", "header", ")", ".", "merge", "(", "'body'", "=>", "@data", ")", "response", "=", "@client", ".",...
Create the resource on OneView using the current data @note Calls the refresh method to set additional data @param [Hash] header The header options for the request (key-value pairs) @raise [OneviewSDK::IncompleteResource] if the client is not set @raise [StandardError] if the resource creation fails @return [Resou...
[ "Create", "the", "resource", "on", "OneView", "using", "the", "current", "data" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/resource.rb#L172-L179
22,628
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/resource.rb
OneviewSDK.Resource.create!
def create!(header = self.class::DEFAULT_REQUEST_HEADER) temp = self.class.new(@client, @data) temp.delete(header) if temp.retrieve!(header) create(header) end
ruby
def create!(header = self.class::DEFAULT_REQUEST_HEADER) temp = self.class.new(@client, @data) temp.delete(header) if temp.retrieve!(header) create(header) end
[ "def", "create!", "(", "header", "=", "self", ".", "class", "::", "DEFAULT_REQUEST_HEADER", ")", "temp", "=", "self", ".", "class", ".", "new", "(", "@client", ",", "@data", ")", "temp", ".", "delete", "(", "header", ")", "if", "temp", ".", "retrieve!"...
Delete the resource from OneView if it exists, then create it using the current data @note Calls refresh method to set additional data @param [Hash] header The header options for the request (key-value pairs) @raise [OneviewSDK::IncompleteResource] if the client is not set @raise [StandardError] if the resource cre...
[ "Delete", "the", "resource", "from", "OneView", "if", "it", "exists", "then", "create", "it", "using", "the", "current", "data" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/resource.rb#L187-L191
22,629
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/resource.rb
OneviewSDK.Resource.refresh
def refresh(header = self.class::DEFAULT_REQUEST_HEADER) ensure_client && ensure_uri response = @client.rest_get(@data['uri'], header, @api_version) body = @client.response_handler(response) set_all(body) self end
ruby
def refresh(header = self.class::DEFAULT_REQUEST_HEADER) ensure_client && ensure_uri response = @client.rest_get(@data['uri'], header, @api_version) body = @client.response_handler(response) set_all(body) self end
[ "def", "refresh", "(", "header", "=", "self", ".", "class", "::", "DEFAULT_REQUEST_HEADER", ")", "ensure_client", "&&", "ensure_uri", "response", "=", "@client", ".", "rest_get", "(", "@data", "[", "'uri'", "]", ",", "header", ",", "@api_version", ")", "body...
Updates this object using the data that exists on OneView @note Will overwrite any data that differs from OneView @param [Hash] header The header options for the request (key-value pairs) @return [Resource] self
[ "Updates", "this", "object", "using", "the", "data", "that", "exists", "on", "OneView" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/resource.rb#L197-L203
22,630
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/resource.rb
OneviewSDK.Resource.update
def update(attributes = {}, header = self.class::DEFAULT_REQUEST_HEADER) set_all(attributes) ensure_client && ensure_uri options = {}.merge(header).merge('body' => @data) response = @client.rest_put(@data['uri'], options, @api_version) @client.response_handler(response) self end
ruby
def update(attributes = {}, header = self.class::DEFAULT_REQUEST_HEADER) set_all(attributes) ensure_client && ensure_uri options = {}.merge(header).merge('body' => @data) response = @client.rest_put(@data['uri'], options, @api_version) @client.response_handler(response) self end
[ "def", "update", "(", "attributes", "=", "{", "}", ",", "header", "=", "self", ".", "class", "::", "DEFAULT_REQUEST_HEADER", ")", "set_all", "(", "attributes", ")", "ensure_client", "&&", "ensure_uri", "options", "=", "{", "}", ".", "merge", "(", "header",...
Set data and save to OneView @param [Hash] attributes The attributes to add/change for this resource (key-value pairs) @param [Hash] header The header options for the request (key-value pairs) @raise [OneviewSDK::IncompleteResource] if the client or uri is not set @raise [StandardError] if the resource save fails ...
[ "Set", "data", "and", "save", "to", "OneView" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/resource.rb#L211-L218
22,631
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/resource.rb
OneviewSDK.Resource.delete
def delete(header = self.class::DEFAULT_REQUEST_HEADER) ensure_client && ensure_uri response = @client.rest_delete(@data['uri'], header, @api_version) @client.response_handler(response) true end
ruby
def delete(header = self.class::DEFAULT_REQUEST_HEADER) ensure_client && ensure_uri response = @client.rest_delete(@data['uri'], header, @api_version) @client.response_handler(response) true end
[ "def", "delete", "(", "header", "=", "self", ".", "class", "::", "DEFAULT_REQUEST_HEADER", ")", "ensure_client", "&&", "ensure_uri", "response", "=", "@client", ".", "rest_delete", "(", "@data", "[", "'uri'", "]", ",", "header", ",", "@api_version", ")", "@c...
Delete resource from OneView @param [Hash] header The header options for the request (key-value pairs) @return [true] if resource was deleted successfully
[ "Delete", "resource", "from", "OneView" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/resource.rb#L223-L228
22,632
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/resource.rb
OneviewSDK.Resource.to_file
def to_file(file_path, format = :json) format = :yml if %w[.yml .yaml].include? File.extname(file_path) temp_data = { type: self.class.name, api_version: @api_version, data: @data } case format.to_sym when :json File.open(file_path, 'w') { |f| f.write(JSON.pretty_generate(temp_data)) } ...
ruby
def to_file(file_path, format = :json) format = :yml if %w[.yml .yaml].include? File.extname(file_path) temp_data = { type: self.class.name, api_version: @api_version, data: @data } case format.to_sym when :json File.open(file_path, 'w') { |f| f.write(JSON.pretty_generate(temp_data)) } ...
[ "def", "to_file", "(", "file_path", ",", "format", "=", ":json", ")", "format", "=", ":yml", "if", "%w[", ".yml", ".yaml", "]", ".", "include?", "File", ".", "extname", "(", "file_path", ")", "temp_data", "=", "{", "type", ":", "self", ".", "class", ...
Save resource to json or yaml file @param [String] file_path The full path to the file @param [Symbol] format The format. Options: [:json, :yml, :yaml]. Defaults to .json @note If a .yml or .yaml file extension is given in the file_path, the format will be set automatically @return [True] The Resource was saved suc...
[ "Save", "resource", "to", "json", "or", "yaml", "file" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/resource.rb#L235-L247
22,633
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/resource.rb
OneviewSDK.Resource.recursive_like?
def recursive_like?(other, data = @data) raise "Can't compare with object type: #{other.class}! Must respond_to :each" unless other.respond_to?(:each) other.each do |key, val| return false unless data && data.respond_to?(:[]) if val.is_a?(Hash) return false unless data.class == Has...
ruby
def recursive_like?(other, data = @data) raise "Can't compare with object type: #{other.class}! Must respond_to :each" unless other.respond_to?(:each) other.each do |key, val| return false unless data && data.respond_to?(:[]) if val.is_a?(Hash) return false unless data.class == Has...
[ "def", "recursive_like?", "(", "other", ",", "data", "=", "@data", ")", "raise", "\"Can't compare with object type: #{other.class}! Must respond_to :each\"", "unless", "other", ".", "respond_to?", "(", ":each", ")", "other", ".", "each", "do", "|", "key", ",", "val"...
Recursive helper method for like? Allows comparison of nested hash structures
[ "Recursive", "helper", "method", "for", "like?", "Allows", "comparison", "of", "nested", "hash", "structures" ]
c2b12297927e3a5cb18e097d066b0732203bd177
https://github.com/HewlettPackard/oneview-sdk-ruby/blob/c2b12297927e3a5cb18e097d066b0732203bd177/lib/oneview-sdk/resource.rb#L399-L416
22,634
payu-india/payuindia
lib/payuindia.rb
PayuIndia.Notification.amount_ok?
def amount_ok?( order_amount, order_discount = BigDecimal.new( '0.0' ) ) BigDecimal.new( gross ) == order_amount && BigDecimal.new( discount.to_s ) == order_discount end
ruby
def amount_ok?( order_amount, order_discount = BigDecimal.new( '0.0' ) ) BigDecimal.new( gross ) == order_amount && BigDecimal.new( discount.to_s ) == order_discount end
[ "def", "amount_ok?", "(", "order_amount", ",", "order_discount", "=", "BigDecimal", ".", "new", "(", "'0.0'", ")", ")", "BigDecimal", ".", "new", "(", "gross", ")", "==", "order_amount", "&&", "BigDecimal", ".", "new", "(", "discount", ".", "to_s", ")", ...
Order amount should be equal to gross - discount
[ "Order", "amount", "should", "be", "equal", "to", "gross", "-", "discount" ]
66d887615f893fa073ebc7cefa53adfd24e0f68d
https://github.com/payu-india/payuindia/blob/66d887615f893fa073ebc7cefa53adfd24e0f68d/lib/payuindia.rb#L91-L93
22,635
payu-india/payuindia
lib/payuindia/action_view_helper.rb
PayuIndia.ActionViewHelper.payment_form_for_payu
def payment_form_for_payu(key, salt, options = {}) if !options.is_a?(Hash) || !key.is_a?(String) || !salt.is_a?(String) concat("Something Wrong! params order -> key (String), salt (String), options (Hash) ") nil else form_options = options.delete(:html) || {} service = PayuIn...
ruby
def payment_form_for_payu(key, salt, options = {}) if !options.is_a?(Hash) || !key.is_a?(String) || !salt.is_a?(String) concat("Something Wrong! params order -> key (String), salt (String), options (Hash) ") nil else form_options = options.delete(:html) || {} service = PayuIn...
[ "def", "payment_form_for_payu", "(", "key", ",", "salt", ",", "options", "=", "{", "}", ")", "if", "!", "options", ".", "is_a?", "(", "Hash", ")", "||", "!", "key", ".", "is_a?", "(", "String", ")", "||", "!", "salt", ".", "is_a?", "(", "String", ...
This Helper creates form with all parameters added. <% payment_form_for_payu 'YOUR_KEY', 'YOUR_SALT', :txnid => @cart.id, :amount => @cart.total_price, :productinfo => 'Book', :firstname => 'abc', :email => 'abc@example.com', :phone => '1234567890', :surl => 'http://l...
[ "This", "Helper", "creates", "form", "with", "all", "parameters", "added", "." ]
66d887615f893fa073ebc7cefa53adfd24e0f68d
https://github.com/payu-india/payuindia/blob/66d887615f893fa073ebc7cefa53adfd24e0f68d/lib/payuindia/action_view_helper.rb#L21-L45
22,636
sprinkle-tool/sprinkle
lib/sprinkle/package/rendering.rb
Sprinkle::Package.Rendering.template
def template(src, context=binding) eruby = Erubis::Eruby.new(src) eruby.result(context) rescue Object => e raise Sprinkle::Errors::TemplateError.new(e, src, context) end
ruby
def template(src, context=binding) eruby = Erubis::Eruby.new(src) eruby.result(context) rescue Object => e raise Sprinkle::Errors::TemplateError.new(e, src, context) end
[ "def", "template", "(", "src", ",", "context", "=", "binding", ")", "eruby", "=", "Erubis", "::", "Eruby", ".", "new", "(", "src", ")", "eruby", ".", "result", "(", "context", ")", "rescue", "Object", "=>", "e", "raise", "Sprinkle", "::", "Errors", "...
render src as ERB
[ "render", "src", "as", "ERB" ]
883594d2531d99ac6cac3bcbd1749cd57caf5a0c
https://github.com/sprinkle-tool/sprinkle/blob/883594d2531d99ac6cac3bcbd1749cd57caf5a0c/lib/sprinkle/package/rendering.rb#L15-L20
22,637
sprinkle-tool/sprinkle
lib/sprinkle/package/rendering.rb
Sprinkle::Package.Rendering.render
def render(filename, context=binding) contents=File.read(expand_filename(filename)) template(contents, context) end
ruby
def render(filename, context=binding) contents=File.read(expand_filename(filename)) template(contents, context) end
[ "def", "render", "(", "filename", ",", "context", "=", "binding", ")", "contents", "=", "File", ".", "read", "(", "expand_filename", "(", "filename", ")", ")", "template", "(", "contents", ",", "context", ")", "end" ]
read in filename and render it as ERB
[ "read", "in", "filename", "and", "render", "it", "as", "ERB" ]
883594d2531d99ac6cac3bcbd1749cd57caf5a0c
https://github.com/sprinkle-tool/sprinkle/blob/883594d2531d99ac6cac3bcbd1749cd57caf5a0c/lib/sprinkle/package/rendering.rb#L23-L26
22,638
timothyf/gameday_api
lib/gameday_api/pitcher.rb
GamedayApi.Pitcher.load_from_id
def load_from_id(gid, pid) @gid = gid @pid = pid @position = 'P' @xml_data = GamedayFetcher.fetch_pitcher(gid, pid) @xml_doc = REXML::Document.new(@xml_data) @team_abbrev = @xml_doc.root.attributes["team"] @first_name = @xml_doc.root.attributes["first_name"] @last...
ruby
def load_from_id(gid, pid) @gid = gid @pid = pid @position = 'P' @xml_data = GamedayFetcher.fetch_pitcher(gid, pid) @xml_doc = REXML::Document.new(@xml_data) @team_abbrev = @xml_doc.root.attributes["team"] @first_name = @xml_doc.root.attributes["first_name"] @last...
[ "def", "load_from_id", "(", "gid", ",", "pid", ")", "@gid", "=", "gid", "@pid", "=", "pid", "@position", "=", "'P'", "@xml_data", "=", "GamedayFetcher", ".", "fetch_pitcher", "(", "gid", ",", "pid", ")", "@xml_doc", "=", "REXML", "::", "Document", ".", ...
Loads a Pitcher object given a game id and a player id
[ "Loads", "a", "Pitcher", "object", "given", "a", "game", "id", "and", "a", "player", "id" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/pitcher.rb#L18-L34
22,639
timothyf/gameday_api
lib/gameday_api/pitcher.rb
GamedayApi.Pitcher.get_all_starts
def get_all_starts(year) results = [] app = get_all_appearances(year) if app.start == true results << app end end
ruby
def get_all_starts(year) results = [] app = get_all_appearances(year) if app.start == true results << app end end
[ "def", "get_all_starts", "(", "year", ")", "results", "=", "[", "]", "app", "=", "get_all_appearances", "(", "year", ")", "if", "app", ".", "start", "==", "true", "results", "<<", "app", "end", "end" ]
Returns an array of PitchingAppearance objects for all of the pitchers starts
[ "Returns", "an", "array", "of", "PitchingAppearance", "objects", "for", "all", "of", "the", "pitchers", "starts" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/pitcher.rb#L38-L44
22,640
timothyf/gameday_api
lib/gameday_api/pitcher.rb
GamedayApi.Pitcher.get_vs_ab
def get_vs_ab results = [] abs = get_game.get_atbats abs.each do |ab| if ab.pitcher_id == @pid results << ab end end results end
ruby
def get_vs_ab results = [] abs = get_game.get_atbats abs.each do |ab| if ab.pitcher_id == @pid results << ab end end results end
[ "def", "get_vs_ab", "results", "=", "[", "]", "abs", "=", "get_game", ".", "get_atbats", "abs", ".", "each", "do", "|", "ab", "|", "if", "ab", ".", "pitcher_id", "==", "@pid", "results", "<<", "ab", "end", "end", "results", "end" ]
Returns an array of the atbats against this pitcher during this game
[ "Returns", "an", "array", "of", "the", "atbats", "against", "this", "pitcher", "during", "this", "game" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/pitcher.rb#L48-L57
22,641
timothyf/gameday_api
lib/gameday_api/pitcher.rb
GamedayApi.Pitcher.get_pitches
def get_pitches results = [] ab = get_vs_ab ab.each do |ab| results << ab.pitches end results.flatten end
ruby
def get_pitches results = [] ab = get_vs_ab ab.each do |ab| results << ab.pitches end results.flatten end
[ "def", "get_pitches", "results", "=", "[", "]", "ab", "=", "get_vs_ab", "ab", ".", "each", "do", "|", "ab", "|", "results", "<<", "ab", ".", "pitches", "end", "results", ".", "flatten", "end" ]
Returns an array of pitches thrown by this pitcher during this game
[ "Returns", "an", "array", "of", "pitches", "thrown", "by", "this", "pitcher", "during", "this", "game" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/pitcher.rb#L61-L68
22,642
timothyf/gameday_api
lib/gameday_api/box_score.rb
GamedayApi.BoxScore.load_from_id
def load_from_id(gid) @gid = gid @xml_data = GamedayFetcher.fetch_boxscore(gid) @xml_doc = REXML::Document.new(@xml_data) if @xml_doc.root @game = Game.new(@gid) @game.boxscore = self set_basic_info @linescore = LineScore.new @linescore.init(@xml_...
ruby
def load_from_id(gid) @gid = gid @xml_data = GamedayFetcher.fetch_boxscore(gid) @xml_doc = REXML::Document.new(@xml_data) if @xml_doc.root @game = Game.new(@gid) @game.boxscore = self set_basic_info @linescore = LineScore.new @linescore.init(@xml_...
[ "def", "load_from_id", "(", "gid", ")", "@gid", "=", "gid", "@xml_data", "=", "GamedayFetcher", ".", "fetch_boxscore", "(", "gid", ")", "@xml_doc", "=", "REXML", "::", "Document", ".", "new", "(", "@xml_data", ")", "if", "@xml_doc", ".", "root", "@game", ...
Loads the boxscore XML from the MLB gameday server and parses it using REXML
[ "Loads", "the", "boxscore", "XML", "from", "the", "MLB", "gameday", "server", "and", "parses", "it", "using", "REXML" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/box_score.rb#L32-L51
22,643
timothyf/gameday_api
lib/gameday_api/box_score.rb
GamedayApi.BoxScore.to_html
def to_html(template_filename) gameday_info = GamedayUtil.parse_gameday_id('gid_' + gid) template = ERB.new File.new(File.expand_path(File.dirname(__FILE__) + "/" + template_filename)).read, nil, "%" return template.result(binding) end
ruby
def to_html(template_filename) gameday_info = GamedayUtil.parse_gameday_id('gid_' + gid) template = ERB.new File.new(File.expand_path(File.dirname(__FILE__) + "/" + template_filename)).read, nil, "%" return template.result(binding) end
[ "def", "to_html", "(", "template_filename", ")", "gameday_info", "=", "GamedayUtil", ".", "parse_gameday_id", "(", "'gid_'", "+", "gid", ")", "template", "=", "ERB", ".", "new", "File", ".", "new", "(", "File", ".", "expand_path", "(", "File", ".", "dirnam...
Converts the boxscore into a formatted HTML representation. Relies on the boxscore.html.erb template for describing the layout
[ "Converts", "the", "boxscore", "into", "a", "formatted", "HTML", "representation", ".", "Relies", "on", "the", "boxscore", ".", "html", ".", "erb", "template", "for", "describing", "the", "layout" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/box_score.rb#L62-L66
22,644
timothyf/gameday_api
lib/gameday_api/box_score.rb
GamedayApi.BoxScore.set_basic_info
def set_basic_info @game_id = @xml_doc.root.attributes["game_id"] @game_pk = @xml_doc.root.attributes["game_pk"] @home_sport_code = @xml_doc.root.attributes["home_sport_code"] @away_team_code = @xml_doc.root.attributes["away_team_code"] @home_team_code = @xml_doc.root.attributes["home...
ruby
def set_basic_info @game_id = @xml_doc.root.attributes["game_id"] @game_pk = @xml_doc.root.attributes["game_pk"] @home_sport_code = @xml_doc.root.attributes["home_sport_code"] @away_team_code = @xml_doc.root.attributes["away_team_code"] @home_team_code = @xml_doc.root.attributes["home...
[ "def", "set_basic_info", "@game_id", "=", "@xml_doc", ".", "root", ".", "attributes", "[", "\"game_id\"", "]", "@game_pk", "=", "@xml_doc", ".", "root", ".", "attributes", "[", "\"game_pk\"", "]", "@home_sport_code", "=", "@xml_doc", ".", "root", ".", "attribu...
Retrieves basic game data from the XML root element and sets in object
[ "Retrieves", "basic", "game", "data", "from", "the", "XML", "root", "element", "and", "sets", "in", "object" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/box_score.rb#L102-L120
22,645
timothyf/gameday_api
lib/gameday_api/box_score.rb
GamedayApi.BoxScore.set_pitchers
def set_pitchers @pitchers, away_pitchers, home_pitchers = [], [], [] count = 1 @xml_doc.elements.each("boxscore/pitching[@team_flag='away']/pitcher") { |element| pitcher = PitchingAppearance.new pitcher.init(@gid, element, count) count += 1 away_pitchers.push p...
ruby
def set_pitchers @pitchers, away_pitchers, home_pitchers = [], [], [] count = 1 @xml_doc.elements.each("boxscore/pitching[@team_flag='away']/pitcher") { |element| pitcher = PitchingAppearance.new pitcher.init(@gid, element, count) count += 1 away_pitchers.push p...
[ "def", "set_pitchers", "@pitchers", ",", "away_pitchers", ",", "home_pitchers", "=", "[", "]", ",", "[", "]", ",", "[", "]", "count", "=", "1", "@xml_doc", ".", "elements", ".", "each", "(", "\"boxscore/pitching[@team_flag='away']/pitcher\"", ")", "{", "|", ...
Sets an array of hashes where each hash holds data for a pitcher whom appeared in the game. Specify either home or away team pitchers.
[ "Sets", "an", "array", "of", "hashes", "where", "each", "hash", "holds", "data", "for", "a", "pitcher", "whom", "appeared", "in", "the", "game", ".", "Specify", "either", "home", "or", "away", "team", "pitchers", "." ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/box_score.rb#L150-L168
22,646
timothyf/gameday_api
lib/gameday_api/box_score.rb
GamedayApi.BoxScore.set_batters
def set_batters @batters, away_batters, home_batters = [], [], [] @xml_doc.elements.each("boxscore/batting[@team_flag='away']/batter") { |element| batter = BattingAppearance.new batter.init(element) away_batters.push batter } @xml_doc.elements.each("boxscore/batti...
ruby
def set_batters @batters, away_batters, home_batters = [], [], [] @xml_doc.elements.each("boxscore/batting[@team_flag='away']/batter") { |element| batter = BattingAppearance.new batter.init(element) away_batters.push batter } @xml_doc.elements.each("boxscore/batti...
[ "def", "set_batters", "@batters", ",", "away_batters", ",", "home_batters", "=", "[", "]", ",", "[", "]", ",", "[", "]", "@xml_doc", ".", "elements", ".", "each", "(", "\"boxscore/batting[@team_flag='away']/batter\"", ")", "{", "|", "element", "|", "batter", ...
Sets an array of hashes where each hash holds data for a batter whom appeared in the game. Specify either home or away team batters.
[ "Sets", "an", "array", "of", "hashes", "where", "each", "hash", "holds", "data", "for", "a", "batter", "whom", "appeared", "in", "the", "game", ".", "Specify", "either", "home", "or", "away", "team", "batters", "." ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/box_score.rb#L173-L187
22,647
timothyf/gameday_api
lib/gameday_api/team.rb
GamedayApi.Team.all_games
def all_games(year) if !@games puts 'Finding all games for team...' results = [] (START_MONTH..END_MONTH).each do |month| puts "Month: " + month.to_s month_s = GamedayUtil.convert_digit_to_string(month) (1..31).each do |date| if !GamedayUti...
ruby
def all_games(year) if !@games puts 'Finding all games for team...' results = [] (START_MONTH..END_MONTH).each do |month| puts "Month: " + month.to_s month_s = GamedayUtil.convert_digit_to_string(month) (1..31).each do |date| if !GamedayUti...
[ "def", "all_games", "(", "year", ")", "if", "!", "@games", "puts", "'Finding all games for team...'", "results", "=", "[", "]", "(", "START_MONTH", "..", "END_MONTH", ")", ".", "each", "do", "|", "month", "|", "puts", "\"Month: \"", "+", "month", ".", "to_...
Returns an array of all games for this team for the specified season
[ "Returns", "an", "array", "of", "all", "games", "for", "this", "team", "for", "the", "specified", "season" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/team.rb#L93-L118
22,648
timothyf/gameday_api
lib/gameday_api/team.rb
GamedayApi.Team.all_home_games
def all_home_games(year) games = all_games(year) results = games.select {|g| g.home_team_abbrev == @abrev } end
ruby
def all_home_games(year) games = all_games(year) results = games.select {|g| g.home_team_abbrev == @abrev } end
[ "def", "all_home_games", "(", "year", ")", "games", "=", "all_games", "(", "year", ")", "results", "=", "games", ".", "select", "{", "|", "g", "|", "g", ".", "home_team_abbrev", "==", "@abrev", "}", "end" ]
Returns an array of all home games for this team for the specified season
[ "Returns", "an", "array", "of", "all", "home", "games", "for", "this", "team", "for", "the", "specified", "season" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/team.rb#L122-L125
22,649
timothyf/gameday_api
lib/gameday_api/team.rb
GamedayApi.Team.all_away_games
def all_away_games(year) games = all_games(year) results = games.select {|g| g.visit_team_abbrev == @abrev } end
ruby
def all_away_games(year) games = all_games(year) results = games.select {|g| g.visit_team_abbrev == @abrev } end
[ "def", "all_away_games", "(", "year", ")", "games", "=", "all_games", "(", "year", ")", "results", "=", "games", ".", "select", "{", "|", "g", "|", "g", ".", "visit_team_abbrev", "==", "@abrev", "}", "end" ]
Returns an array of all away games for this team for the specified season
[ "Returns", "an", "array", "of", "all", "away", "games", "for", "this", "team", "for", "the", "specified", "season" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/team.rb#L129-L132
22,650
timothyf/gameday_api
lib/gameday_api/team.rb
GamedayApi.Team.games_for_date
def games_for_date(year, month, day) games_page = GamedayFetcher.fetch_games_page(year, month, day) gids = find_gid_for_date(year, month, day, games_page) if gids results = gids.collect {|gid| Game.new(gid) } else results = nil end results end
ruby
def games_for_date(year, month, day) games_page = GamedayFetcher.fetch_games_page(year, month, day) gids = find_gid_for_date(year, month, day, games_page) if gids results = gids.collect {|gid| Game.new(gid) } else results = nil end results end
[ "def", "games_for_date", "(", "year", ",", "month", ",", "day", ")", "games_page", "=", "GamedayFetcher", ".", "fetch_games_page", "(", "year", ",", "month", ",", "day", ")", "gids", "=", "find_gid_for_date", "(", "year", ",", "month", ",", "day", ",", "...
Returns an array of the team's game objects for the date passed in.
[ "Returns", "an", "array", "of", "the", "team", "s", "game", "objects", "for", "the", "date", "passed", "in", "." ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/team.rb#L136-L145
22,651
timothyf/gameday_api
lib/gameday_api/team.rb
GamedayApi.Team.get_leadoff_hitters_by_year
def get_leadoff_hitters_by_year(year) results = [] games = all_games(year) games.each do |game| boxscore = game.get_boxscore leadoffs = boxscore.get_leadoff_hitters if game.home_team_abbrev == @abrev results << leadoffs[1] else results << le...
ruby
def get_leadoff_hitters_by_year(year) results = [] games = all_games(year) games.each do |game| boxscore = game.get_boxscore leadoffs = boxscore.get_leadoff_hitters if game.home_team_abbrev == @abrev results << leadoffs[1] else results << le...
[ "def", "get_leadoff_hitters_by_year", "(", "year", ")", "results", "=", "[", "]", "games", "=", "all_games", "(", "year", ")", "games", ".", "each", "do", "|", "game", "|", "boxscore", "=", "game", ".", "get_boxscore", "leadoffs", "=", "boxscore", ".", "...
Returns an array of BattingAppearance containing the leadoff hitters for each game of the specified season.
[ "Returns", "an", "array", "of", "BattingAppearance", "containing", "the", "leadoff", "hitters", "for", "each", "game", "of", "the", "specified", "season", "." ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/team.rb#L149-L162
22,652
timothyf/gameday_api
lib/gameday_api/team.rb
GamedayApi.Team.get_leadoff_hitters_unique
def get_leadoff_hitters_unique(year) hitters = get_leadoff_hitters_by_year(year) h = {} hitters.each {|hitter| h[hitter.batter_name]=hitter} h.values end
ruby
def get_leadoff_hitters_unique(year) hitters = get_leadoff_hitters_by_year(year) h = {} hitters.each {|hitter| h[hitter.batter_name]=hitter} h.values end
[ "def", "get_leadoff_hitters_unique", "(", "year", ")", "hitters", "=", "get_leadoff_hitters_by_year", "(", "year", ")", "h", "=", "{", "}", "hitters", ".", "each", "{", "|", "hitter", "|", "h", "[", "hitter", ".", "batter_name", "]", "=", "hitter", "}", ...
Returns an array of BattingAppearance of all hitters who have led off at least one game during the specified season
[ "Returns", "an", "array", "of", "BattingAppearance", "of", "all", "hitters", "who", "have", "led", "off", "at", "least", "one", "game", "during", "the", "specified", "season" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/team.rb#L166-L171
22,653
timothyf/gameday_api
lib/gameday_api/team.rb
GamedayApi.Team.get_cleanup_hitters_by_year
def get_cleanup_hitters_by_year(year) results = [] games = all_games(year) games.each do |game| boxscore = game.get_boxscore hitters = boxscore.get_cleanup_hitters if game.home_team_abbrev == @abrev results << hitters[1] else results << hitt...
ruby
def get_cleanup_hitters_by_year(year) results = [] games = all_games(year) games.each do |game| boxscore = game.get_boxscore hitters = boxscore.get_cleanup_hitters if game.home_team_abbrev == @abrev results << hitters[1] else results << hitt...
[ "def", "get_cleanup_hitters_by_year", "(", "year", ")", "results", "=", "[", "]", "games", "=", "all_games", "(", "year", ")", "games", ".", "each", "do", "|", "game", "|", "boxscore", "=", "game", ".", "get_boxscore", "hitters", "=", "boxscore", ".", "g...
Returns an array containing the cleanup hitters for each game of the specified season. The cleanup hitter is the 4th hitter in the batting order
[ "Returns", "an", "array", "containing", "the", "cleanup", "hitters", "for", "each", "game", "of", "the", "specified", "season", ".", "The", "cleanup", "hitter", "is", "the", "4th", "hitter", "in", "the", "batting", "order" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/team.rb#L176-L189
22,654
timothyf/gameday_api
lib/gameday_api/team.rb
GamedayApi.Team.get_starters_unique
def get_starters_unique(year) pitchers = get_start_pitcher_appearances_by_year(year) h = {} pitchers.each {|pitcher| h[pitcher.pitcher_name]=pitcher} h.values end
ruby
def get_starters_unique(year) pitchers = get_start_pitcher_appearances_by_year(year) h = {} pitchers.each {|pitcher| h[pitcher.pitcher_name]=pitcher} h.values end
[ "def", "get_starters_unique", "(", "year", ")", "pitchers", "=", "get_start_pitcher_appearances_by_year", "(", "year", ")", "h", "=", "{", "}", "pitchers", ".", "each", "{", "|", "pitcher", "|", "h", "[", "pitcher", ".", "pitcher_name", "]", "=", "pitcher", ...
Returns an array of all pitchers who have started at least one game during the specified season
[ "Returns", "an", "array", "of", "all", "pitchers", "who", "have", "started", "at", "least", "one", "game", "during", "the", "specified", "season" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/team.rb#L217-L222
22,655
timothyf/gameday_api
lib/gameday_api/team.rb
GamedayApi.Team.get_closers_unique
def get_closers_unique(year) pitchers = get_close_pitcher_appearances_by_year(year) h = {} pitchers.each {|pitcher| h[pitcher.pitcher_name]=pitcher} h.values end
ruby
def get_closers_unique(year) pitchers = get_close_pitcher_appearances_by_year(year) h = {} pitchers.each {|pitcher| h[pitcher.pitcher_name]=pitcher} h.values end
[ "def", "get_closers_unique", "(", "year", ")", "pitchers", "=", "get_close_pitcher_appearances_by_year", "(", "year", ")", "h", "=", "{", "}", "pitchers", ".", "each", "{", "|", "pitcher", "|", "h", "[", "pitcher", ".", "pitcher_name", "]", "=", "pitcher", ...
Returns an array of all pitchers who have closed at least one game during the specified season
[ "Returns", "an", "array", "of", "all", "pitchers", "who", "have", "closed", "at", "least", "one", "game", "during", "the", "specified", "season" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/team.rb#L241-L246
22,656
timothyf/gameday_api
lib/gameday_api/team.rb
GamedayApi.Team.quality_starts_count
def quality_starts_count(year) count = 0 games = all_games(year) games.each do |game| starters = game.get_starting_pitchers if game.home_team_abbrev == @abrev if starters[1].quality_start? count = count + 1 end else if starter...
ruby
def quality_starts_count(year) count = 0 games = all_games(year) games.each do |game| starters = game.get_starting_pitchers if game.home_team_abbrev == @abrev if starters[1].quality_start? count = count + 1 end else if starter...
[ "def", "quality_starts_count", "(", "year", ")", "count", "=", "0", "games", "=", "all_games", "(", "year", ")", "games", ".", "each", "do", "|", "game", "|", "starters", "=", "game", ".", "get_starting_pitchers", "if", "game", ".", "home_team_abbrev", "==...
Returns a count of the number of quality starts for this team for the specified year.
[ "Returns", "a", "count", "of", "the", "number", "of", "quality", "starts", "for", "this", "team", "for", "the", "specified", "year", "." ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/team.rb#L250-L266
22,657
timothyf/gameday_api
lib/gameday_api/team.rb
GamedayApi.Team.get_opening_day_game
def get_opening_day_game(year) schedule = Schedule.new(year) oday = schedule.get_opening_day oday_array = GamedayUtil.parse_date_string(oday) games = games_for_date(oday_array[0], oday_array[1], oday_array[2]) if games[0] == nil games = games_for_date(oday_array[0], ...
ruby
def get_opening_day_game(year) schedule = Schedule.new(year) oday = schedule.get_opening_day oday_array = GamedayUtil.parse_date_string(oday) games = games_for_date(oday_array[0], oday_array[1], oday_array[2]) if games[0] == nil games = games_for_date(oday_array[0], ...
[ "def", "get_opening_day_game", "(", "year", ")", "schedule", "=", "Schedule", ".", "new", "(", "year", ")", "oday", "=", "schedule", ".", "get_opening_day", "oday_array", "=", "GamedayUtil", ".", "parse_date_string", "(", "oday", ")", "games", "=", "games_for_...
Returns a game object representing the opening day game for this team for the season passed in.
[ "Returns", "a", "game", "object", "representing", "the", "opening", "day", "game", "for", "this", "team", "for", "the", "season", "passed", "in", "." ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/team.rb#L283-L294
22,658
timothyf/gameday_api
lib/gameday_api/team.rb
GamedayApi.Team.opening_day_roster
def opening_day_roster(year) game = get_opening_day_game(year) rosters = game.get_rosters rosters[0].team_name == city + ' ' + name ? rosters[0] : rosters[1] end
ruby
def opening_day_roster(year) game = get_opening_day_game(year) rosters = game.get_rosters rosters[0].team_name == city + ' ' + name ? rosters[0] : rosters[1] end
[ "def", "opening_day_roster", "(", "year", ")", "game", "=", "get_opening_day_game", "(", "year", ")", "rosters", "=", "game", ".", "get_rosters", "rosters", "[", "0", "]", ".", "team_name", "==", "city", "+", "' '", "+", "name", "?", "rosters", "[", "0",...
Returns a Roster object representing the opening day roster for this team for the specified year.
[ "Returns", "a", "Roster", "object", "representing", "the", "opening", "day", "roster", "for", "this", "team", "for", "the", "specified", "year", "." ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/team.rb#L299-L303
22,659
timothyf/gameday_api
lib/gameday_api/gameday.rb
GamedayApi.Gameday.get_all_gids_for_date
def get_all_gids_for_date(year, month, day) begin gids = [] url = GamedayUtil.build_day_url(year, month, date) connection = GamedayUtil.get_connection(url) if connection @hp = Hpricot(connection) a = @hp.at('ul') (a/"a").each do |link| ...
ruby
def get_all_gids_for_date(year, month, day) begin gids = [] url = GamedayUtil.build_day_url(year, month, date) connection = GamedayUtil.get_connection(url) if connection @hp = Hpricot(connection) a = @hp.at('ul') (a/"a").each do |link| ...
[ "def", "get_all_gids_for_date", "(", "year", ",", "month", ",", "day", ")", "begin", "gids", "=", "[", "]", "url", "=", "GamedayUtil", ".", "build_day_url", "(", "year", ",", "month", ",", "date", ")", "connection", "=", "GamedayUtil", ".", "get_connection...
Returns an array of game id's for the given date
[ "Returns", "an", "array", "of", "game", "id", "s", "for", "the", "given", "date" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/gameday.rb#L22-L42
22,660
timothyf/gameday_api
lib/gameday_api/player.rb
GamedayApi.Player.load_from_id
def load_from_id(gid, pid) @gid = gid @pid = pid # fetch players.xml file @xml_data = GamedayFetcher.fetch_players(gid) @xml_doc = REXML::Document.new(@xml_data) # find specific player in the file pelement = @xml_doc.root.elements["team/player[@id=#{pid}]"] init(p...
ruby
def load_from_id(gid, pid) @gid = gid @pid = pid # fetch players.xml file @xml_data = GamedayFetcher.fetch_players(gid) @xml_doc = REXML::Document.new(@xml_data) # find specific player in the file pelement = @xml_doc.root.elements["team/player[@id=#{pid}]"] init(p...
[ "def", "load_from_id", "(", "gid", ",", "pid", ")", "@gid", "=", "gid", "@pid", "=", "pid", "# fetch players.xml file\r", "@xml_data", "=", "GamedayFetcher", ".", "fetch_players", "(", "gid", ")", "@xml_doc", "=", "REXML", "::", "Document", ".", "new", "(", ...
Initializes a Player object by reading the player data from the players.xml file for the player specified by game id and player id.
[ "Initializes", "a", "Player", "object", "by", "reading", "the", "player", "data", "from", "the", "players", ".", "xml", "file", "for", "the", "player", "specified", "by", "game", "id", "and", "player", "id", "." ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/player.rb#L20-L29
22,661
timothyf/gameday_api
lib/gameday_api/player.rb
GamedayApi.Player.init_pitcher_from_scoreboard
def init_pitcher_from_scoreboard(element) @first = element.attributes['first'] @last = element.attributes['last'] @wins = element.attributes['wins'] @losses = element.attributes['losses'] @era = element.attributes['era'] end
ruby
def init_pitcher_from_scoreboard(element) @first = element.attributes['first'] @last = element.attributes['last'] @wins = element.attributes['wins'] @losses = element.attributes['losses'] @era = element.attributes['era'] end
[ "def", "init_pitcher_from_scoreboard", "(", "element", ")", "@first", "=", "element", ".", "attributes", "[", "'first'", "]", "@last", "=", "element", ".", "attributes", "[", "'last'", "]", "@wins", "=", "element", ".", "attributes", "[", "'wins'", "]", "@lo...
Initializes pitcher info from data read from the masterscoreboard.xml file
[ "Initializes", "pitcher", "info", "from", "data", "read", "from", "the", "masterscoreboard", ".", "xml", "file" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/player.rb#L33-L39
22,662
timothyf/gameday_api
lib/gameday_api/player.rb
GamedayApi.Player.at_bats_count
def at_bats_count gameday_info = GamedayUtil.parse_gameday_id(@gid) appearances = get_all_appearances(gameday_info["year"]) count = appearances.inject(0) {|sum, a| sum + a.ab.to_i } end
ruby
def at_bats_count gameday_info = GamedayUtil.parse_gameday_id(@gid) appearances = get_all_appearances(gameday_info["year"]) count = appearances.inject(0) {|sum, a| sum + a.ab.to_i } end
[ "def", "at_bats_count", "gameday_info", "=", "GamedayUtil", ".", "parse_gameday_id", "(", "@gid", ")", "appearances", "=", "get_all_appearances", "(", "gameday_info", "[", "\"year\"", "]", ")", "count", "=", "appearances", ".", "inject", "(", "0", ")", "{", "|...
Returns the number of at bats over the entire season for this player
[ "Returns", "the", "number", "of", "at", "bats", "over", "the", "entire", "season", "for", "this", "player" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/player.rb#L69-L73
22,663
timothyf/gameday_api
lib/gameday_api/player.rb
GamedayApi.Player.init
def init(element, gid) @gid = gid @pid = element.attributes['id'] @first = element.attributes['first'] @last = element.attributes['last'] @num= element.attributes['num'] @boxname = element.attributes['boxname'] @rl, = element.attributes['rl'] @position = element.a...
ruby
def init(element, gid) @gid = gid @pid = element.attributes['id'] @first = element.attributes['first'] @last = element.attributes['last'] @num= element.attributes['num'] @boxname = element.attributes['boxname'] @rl, = element.attributes['rl'] @position = element.a...
[ "def", "init", "(", "element", ",", "gid", ")", "@gid", "=", "gid", "@pid", "=", "element", ".", "attributes", "[", "'id'", "]", "@first", "=", "element", ".", "attributes", "[", "'first'", "]", "@last", "=", "element", ".", "attributes", "[", "'last'"...
Initialize a player object by reading data from the players.xml file
[ "Initialize", "a", "player", "object", "by", "reading", "data", "from", "the", "players", ".", "xml", "file" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/player.rb#L96-L115
22,664
timothyf/gameday_api
lib/gameday_api/data_downloader.rb
GamedayApi.DataDownloader.download_all_for_game
def download_all_for_game(gid) download_xml_for_game(gid) download_batters_for_game(gid) download_inning_for_game(gid) download_media_for_game(gid) download_notification_for_game(gid) download_onbase_for_game(gid) download_pitchers_for_game(gid) end
ruby
def download_all_for_game(gid) download_xml_for_game(gid) download_batters_for_game(gid) download_inning_for_game(gid) download_media_for_game(gid) download_notification_for_game(gid) download_onbase_for_game(gid) download_pitchers_for_game(gid) end
[ "def", "download_all_for_game", "(", "gid", ")", "download_xml_for_game", "(", "gid", ")", "download_batters_for_game", "(", "gid", ")", "download_inning_for_game", "(", "gid", ")", "download_media_for_game", "(", "gid", ")", "download_notification_for_game", "(", "gid"...
Downloads all data files associated with the game specified by the game id passed in.
[ "Downloads", "all", "data", "files", "associated", "with", "the", "game", "specified", "by", "the", "game", "id", "passed", "in", "." ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/data_downloader.rb#L22-L30
22,665
timothyf/gameday_api
lib/gameday_api/data_downloader.rb
GamedayApi.DataDownloader.write_file
def write_file(file_path, gd_data) if gd_data && !File.exists?(file_path) FileUtils.mkdir_p(File.dirname(file_path)) File.open(file_path, "wb") do |data| data << gd_data end end end
ruby
def write_file(file_path, gd_data) if gd_data && !File.exists?(file_path) FileUtils.mkdir_p(File.dirname(file_path)) File.open(file_path, "wb") do |data| data << gd_data end end end
[ "def", "write_file", "(", "file_path", ",", "gd_data", ")", "if", "gd_data", "&&", "!", "File", ".", "exists?", "(", "file_path", ")", "FileUtils", ".", "mkdir_p", "(", "File", ".", "dirname", "(", "file_path", ")", ")", "File", ".", "open", "(", "file...
Writes the gameday data to the file specified. Does not overwrite existing files.
[ "Writes", "the", "gameday", "data", "to", "the", "file", "specified", ".", "Does", "not", "overwrite", "existing", "files", "." ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/data_downloader.rb#L224-L231
22,666
timothyf/gameday_api
lib/gameday_api/game.rb
GamedayApi.Game.load_from_scoreboard
def load_from_scoreboard(element) @away_innings = [] @home_innings = [] @scoreboard_game_id = element.attributes['id'] @ampm = element.attributes['ampm'] @venue = element.attributes['venue'] @game_pk = element.attributes['game_pk'] @time = element.attribute...
ruby
def load_from_scoreboard(element) @away_innings = [] @home_innings = [] @scoreboard_game_id = element.attributes['id'] @ampm = element.attributes['ampm'] @venue = element.attributes['venue'] @game_pk = element.attributes['game_pk'] @time = element.attribute...
[ "def", "load_from_scoreboard", "(", "element", ")", "@away_innings", "=", "[", "]", "@home_innings", "=", "[", "]", "@scoreboard_game_id", "=", "element", ".", "attributes", "[", "'id'", "]", "@ampm", "=", "element", ".", "attributes", "[", "'ampm'", "]", "@...
Setup a Game object from data read from the master_scoreboard.xml file
[ "Setup", "a", "Game", "object", "from", "data", "read", "from", "the", "master_scoreboard", ".", "xml", "file" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/game.rb#L73-L116
22,667
timothyf/gameday_api
lib/gameday_api/game.rb
GamedayApi.Game.set_status
def set_status(element) element.elements.each("status") { |status| @status = GameStatus.new @status.status = status.attributes['status'] @status.ind = status.attributes['ind'] @status.reason = status.attributes['reason'] @status.inning = status.attributes[...
ruby
def set_status(element) element.elements.each("status") { |status| @status = GameStatus.new @status.status = status.attributes['status'] @status.ind = status.attributes['ind'] @status.reason = status.attributes['reason'] @status.inning = status.attributes[...
[ "def", "set_status", "(", "element", ")", "element", ".", "elements", ".", "each", "(", "\"status\"", ")", "{", "|", "status", "|", "@status", "=", "GameStatus", ".", "new", "@status", ".", "status", "=", "status", ".", "attributes", "[", "'status'", "]"...
Sets the game status from data in the master_scoreboard.xml file
[ "Sets", "the", "game", "status", "from", "data", "in", "the", "master_scoreboard", ".", "xml", "file" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/game.rb#L120-L132
22,668
timothyf/gameday_api
lib/gameday_api/game.rb
GamedayApi.Game.set_innings
def set_innings(element) element.elements.each("linescore/inning") { |element| @away_innings << element.attributes['away'] @home_innings << element.attributes['home'] } end
ruby
def set_innings(element) element.elements.each("linescore/inning") { |element| @away_innings << element.attributes['away'] @home_innings << element.attributes['home'] } end
[ "def", "set_innings", "(", "element", ")", "element", ".", "elements", ".", "each", "(", "\"linescore/inning\"", ")", "{", "|", "element", "|", "@away_innings", "<<", "element", ".", "attributes", "[", "'away'", "]", "@home_innings", "<<", "element", ".", "a...
Sets the away and home innings array containing scores by inning from data in the master_scoreboard.xml file
[ "Sets", "the", "away", "and", "home", "innings", "array", "containing", "scores", "by", "inning", "from", "data", "in", "the", "master_scoreboard", ".", "xml", "file" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/game.rb#L136-L141
22,669
timothyf/gameday_api
lib/gameday_api/game.rb
GamedayApi.Game.set_homeruns
def set_homeruns(element) @homeruns = [] element.elements.each("home_runs/player") do |hr| player = Player.new player.last = hr.attributes['last'] player.first = hr.attributes['first'] player.hr = hr.attributes['hr'] player.std_hr = hr.attributes[...
ruby
def set_homeruns(element) @homeruns = [] element.elements.each("home_runs/player") do |hr| player = Player.new player.last = hr.attributes['last'] player.first = hr.attributes['first'] player.hr = hr.attributes['hr'] player.std_hr = hr.attributes[...
[ "def", "set_homeruns", "(", "element", ")", "@homeruns", "=", "[", "]", "element", ".", "elements", ".", "each", "(", "\"home_runs/player\"", ")", "do", "|", "hr", "|", "player", "=", "Player", ".", "new", "player", ".", "last", "=", "hr", ".", "attrib...
Sets a list of players who had homeruns in this game from data in the master_scoreboard.xml file
[ "Sets", "a", "list", "of", "players", "who", "had", "homeruns", "in", "this", "game", "from", "data", "in", "the", "master_scoreboard", ".", "xml", "file" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/game.rb#L162-L173
22,670
timothyf/gameday_api
lib/gameday_api/game.rb
GamedayApi.Game.get_pitchers
def get_pitchers(home_or_away) if self.gid bs = get_boxscore if home_or_away == 'away' bs.pitchers[0] else bs.pitchers[1] end else puts "No data for input specified" end end
ruby
def get_pitchers(home_or_away) if self.gid bs = get_boxscore if home_or_away == 'away' bs.pitchers[0] else bs.pitchers[1] end else puts "No data for input specified" end end
[ "def", "get_pitchers", "(", "home_or_away", ")", "if", "self", ".", "gid", "bs", "=", "get_boxscore", "if", "home_or_away", "==", "'away'", "bs", ".", "pitchers", "[", "0", "]", "else", "bs", ".", "pitchers", "[", "1", "]", "end", "else", "puts", "\"No...
Returns an array of all pitchers for either the home team or the away team. The values in the returned array are PitchingAppearance instances
[ "Returns", "an", "array", "of", "all", "pitchers", "for", "either", "the", "home", "team", "or", "the", "away", "team", ".", "The", "values", "in", "the", "returned", "array", "are", "PitchingAppearance", "instances" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/game.rb#L325-L336
22,671
timothyf/gameday_api
lib/gameday_api/game.rb
GamedayApi.Game.get_pitches
def get_pitches(pid) results = [] atbats = get_atbats atbats.each do |ab| if ab.pitcher_id == pid results << ab.pitches end end results.flatten end
ruby
def get_pitches(pid) results = [] atbats = get_atbats atbats.each do |ab| if ab.pitcher_id == pid results << ab.pitches end end results.flatten end
[ "def", "get_pitches", "(", "pid", ")", "results", "=", "[", "]", "atbats", "=", "get_atbats", "atbats", ".", "each", "do", "|", "ab", "|", "if", "ab", ".", "pitcher_id", "==", "pid", "results", "<<", "ab", ".", "pitches", "end", "end", "results", "."...
Returns an array of pitches from this game for the pitcher identified by pid
[ "Returns", "an", "array", "of", "pitches", "from", "this", "game", "for", "the", "pitcher", "identified", "by", "pid" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/game.rb#L340-L349
22,672
timothyf/gameday_api
lib/gameday_api/game.rb
GamedayApi.Game.get_batters
def get_batters(home_or_away) if self.gid bs = get_boxscore if home_or_away == 'away' bs.batters[0] else bs.batters[1] end else puts "No data for input specified" end end
ruby
def get_batters(home_or_away) if self.gid bs = get_boxscore if home_or_away == 'away' bs.batters[0] else bs.batters[1] end else puts "No data for input specified" end end
[ "def", "get_batters", "(", "home_or_away", ")", "if", "self", ".", "gid", "bs", "=", "get_boxscore", "if", "home_or_away", "==", "'away'", "bs", ".", "batters", "[", "0", "]", "else", "bs", ".", "batters", "[", "1", "]", "end", "else", "puts", "\"No da...
Returns an array of either home or away batters for this game home_or_away must be a string with value 'home' or 'away' The values in the returned array are BattingAppearance instances
[ "Returns", "an", "array", "of", "either", "home", "or", "away", "batters", "for", "this", "game", "home_or_away", "must", "be", "a", "string", "with", "value", "home", "or", "away", "The", "values", "in", "the", "returned", "array", "are", "BattingAppearance...
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/game.rb#L355-L366
22,673
timothyf/gameday_api
lib/gameday_api/game.rb
GamedayApi.Game.get_winner
def get_winner ls = get_boxscore.linescore if ls.home_team_runs > ls.away_team_runs return home_team_abbrev else return visit_team_abbrev end end
ruby
def get_winner ls = get_boxscore.linescore if ls.home_team_runs > ls.away_team_runs return home_team_abbrev else return visit_team_abbrev end end
[ "def", "get_winner", "ls", "=", "get_boxscore", ".", "linescore", "if", "ls", ".", "home_team_runs", ">", "ls", ".", "away_team_runs", "return", "home_team_abbrev", "else", "return", "visit_team_abbrev", "end", "end" ]
Returns the team abreviation of the winning team
[ "Returns", "the", "team", "abreviation", "of", "the", "winning", "team" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/game.rb#L390-L397
22,674
timothyf/gameday_api
lib/gameday_api/game.rb
GamedayApi.Game.get_innings
def get_innings if @innings.length == 0 inn_count = get_num_innings (1..get_num_innings).each do |inn| inning = Inning.new inning.load_from_id(@gid, inn) @innings << inning end end @innings end
ruby
def get_innings if @innings.length == 0 inn_count = get_num_innings (1..get_num_innings).each do |inn| inning = Inning.new inning.load_from_id(@gid, inn) @innings << inning end end @innings end
[ "def", "get_innings", "if", "@innings", ".", "length", "==", "0", "inn_count", "=", "get_num_innings", "(", "1", "..", "get_num_innings", ")", ".", "each", "do", "|", "inn", "|", "inning", "=", "Inning", ".", "new", "inning", ".", "load_from_id", "(", "@...
Returns an array of Inning objects that represent each inning of the game
[ "Returns", "an", "array", "of", "Inning", "objects", "that", "represent", "each", "inning", "of", "the", "game" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/game.rb#L430-L440
22,675
timothyf/gameday_api
lib/gameday_api/game.rb
GamedayApi.Game.get_atbats
def get_atbats atbats = [] innings = get_innings innings.each do |inning| inning.top_atbats.each do |atbat| atbats << atbat end inning.bottom_atbats.each do |atbat| atbats << atbat end end atbats end
ruby
def get_atbats atbats = [] innings = get_innings innings.each do |inning| inning.top_atbats.each do |atbat| atbats << atbat end inning.bottom_atbats.each do |atbat| atbats << atbat end end atbats end
[ "def", "get_atbats", "atbats", "=", "[", "]", "innings", "=", "get_innings", "innings", ".", "each", "do", "|", "inning", "|", "inning", ".", "top_atbats", ".", "each", "do", "|", "atbat", "|", "atbats", "<<", "atbat", "end", "inning", ".", "bottom_atbat...
Returns an array of AtBat objects that represent each atbat of the game
[ "Returns", "an", "array", "of", "AtBat", "objects", "that", "represent", "each", "atbat", "of", "the", "game" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/game.rb#L444-L456
22,676
timothyf/gameday_api
lib/gameday_api/line_score.rb
GamedayApi.LineScore.init
def init(element) @xml_doc = element self.away_team_runs = element.attributes["away_team_runs"] self.away_team_hits = element.attributes["away_team_hits"] self.away_team_errors = element.attributes["away_team_errors"] self.home_team_runs = element.attributes["home_team_runs"] ...
ruby
def init(element) @xml_doc = element self.away_team_runs = element.attributes["away_team_runs"] self.away_team_hits = element.attributes["away_team_hits"] self.away_team_errors = element.attributes["away_team_errors"] self.home_team_runs = element.attributes["home_team_runs"] ...
[ "def", "init", "(", "element", ")", "@xml_doc", "=", "element", "self", ".", "away_team_runs", "=", "element", ".", "attributes", "[", "\"away_team_runs\"", "]", "self", ".", "away_team_hits", "=", "element", ".", "attributes", "[", "\"away_team_hits\"", "]", ...
Initialize this instance from an XML element containing linescore data.
[ "Initialize", "this", "instance", "from", "an", "XML", "element", "containing", "linescore", "data", "." ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/line_score.rb#L11-L23
22,677
timothyf/gameday_api
lib/gameday_api/batting_appearance.rb
GamedayApi.BattingAppearance.get_player
def get_player if !self.player # retrieve player object player = Player.new player.init() self.player = player end self.player end
ruby
def get_player if !self.player # retrieve player object player = Player.new player.init() self.player = player end self.player end
[ "def", "get_player", "if", "!", "self", ".", "player", "# retrieve player object\r", "player", "=", "Player", ".", "new", "player", ".", "init", "(", ")", "self", ".", "player", "=", "player", "end", "self", ".", "player", "end" ]
Looks up the player record using the players.xml file for the player in this appearance
[ "Looks", "up", "the", "player", "record", "using", "the", "players", ".", "xml", "file", "for", "the", "player", "in", "this", "appearance" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/batting_appearance.rb#L42-L50
22,678
timothyf/gameday_api
lib/gameday_api/inning.rb
GamedayApi.Inning.load_from_id
def load_from_id(gid, inning) @top_atbats = [] @bottom_atbats = [] @gid = gid begin @xml_data = GamedayFetcher.fetch_inningx(gid, inning) @xml_doc = REXML::Document.new(@xml_data) if @xml_doc.root @num = @xml_doc.root.attributes["num"] @away_t...
ruby
def load_from_id(gid, inning) @top_atbats = [] @bottom_atbats = [] @gid = gid begin @xml_data = GamedayFetcher.fetch_inningx(gid, inning) @xml_doc = REXML::Document.new(@xml_data) if @xml_doc.root @num = @xml_doc.root.attributes["num"] @away_t...
[ "def", "load_from_id", "(", "gid", ",", "inning", ")", "@top_atbats", "=", "[", "]", "@bottom_atbats", "=", "[", "]", "@gid", "=", "gid", "begin", "@xml_data", "=", "GamedayFetcher", ".", "fetch_inningx", "(", "gid", ",", "inning", ")", "@xml_doc", "=", ...
loads an Inning object given a game id and an inning number
[ "loads", "an", "Inning", "object", "given", "a", "game", "id", "and", "an", "inning", "number" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/inning.rb#L13-L30
22,679
timothyf/gameday_api
lib/gameday_api/roster.rb
GamedayApi.Roster.init
def init(element, gid) self.gid = gid self.team_name = element.attributes['name'] self.id = element.attributes['id'] self.type = element.attributes['type'] self.players = [] self.coaches = [] self.set_players(element) self.set_coaches(element) end
ruby
def init(element, gid) self.gid = gid self.team_name = element.attributes['name'] self.id = element.attributes['id'] self.type = element.attributes['type'] self.players = [] self.coaches = [] self.set_players(element) self.set_coaches(element) end
[ "def", "init", "(", "element", ",", "gid", ")", "self", ".", "gid", "=", "gid", "self", ".", "team_name", "=", "element", ".", "attributes", "[", "'name'", "]", "self", ".", "id", "=", "element", ".", "attributes", "[", "'id'", "]", "self", ".", "t...
type = home or away
[ "type", "=", "home", "or", "away" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/roster.rb#L13-L22
22,680
mcordell/grape_devise_token_auth
lib/grape_devise_token_auth/devise_interface.rb
GrapeDeviseTokenAuth.DeviseInterface.set_user_in_warden
def set_user_in_warden(scope, resource) scope = Devise::Mapping.find_scope!(scope) warden.set_user(resource, scope: scope, store: false) end
ruby
def set_user_in_warden(scope, resource) scope = Devise::Mapping.find_scope!(scope) warden.set_user(resource, scope: scope, store: false) end
[ "def", "set_user_in_warden", "(", "scope", ",", "resource", ")", "scope", "=", "Devise", "::", "Mapping", ".", "find_scope!", "(", "scope", ")", "warden", ".", "set_user", "(", "resource", ",", "scope", ":", "scope", ",", "store", ":", "false", ")", "end...
extracted and simplified from Devise
[ "extracted", "and", "simplified", "from", "Devise" ]
c5b1ead8dbad1dc9fa2a2e7c9346f167e1d9fb1f
https://github.com/mcordell/grape_devise_token_auth/blob/c5b1ead8dbad1dc9fa2a2e7c9346f167e1d9fb1f/lib/grape_devise_token_auth/devise_interface.rb#L9-L12
22,681
timothyf/gameday_api
lib/gameday_api/db_importer.rb
GamedayApi.DbImporter.import_team_for_month
def import_team_for_month(team_abbrev, year, month) start_date = Date.new(year.to_i, month.to_i) # first day of month end_date = (start_date >> 1)-1 # last day of month ((start_date)..(end_date)).each do |dt| puts year.to_s + '/' + month.to_s + '/' + dt.day team = Team.new('det')...
ruby
def import_team_for_month(team_abbrev, year, month) start_date = Date.new(year.to_i, month.to_i) # first day of month end_date = (start_date >> 1)-1 # last day of month ((start_date)..(end_date)).each do |dt| puts year.to_s + '/' + month.to_s + '/' + dt.day team = Team.new('det')...
[ "def", "import_team_for_month", "(", "team_abbrev", ",", "year", ",", "month", ")", "start_date", "=", "Date", ".", "new", "(", "year", ".", "to_i", ",", "month", ".", "to_i", ")", "# first day of month\r", "end_date", "=", "(", "start_date", ">>", "1", ")...
player team game atbat pitch pitch type game type umpire
[ "player", "team", "game", "atbat", "pitch", "pitch", "type", "game", "type", "umpire" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/db_importer.rb#L25-L36
22,682
puppetlabs/beaker-docker
lib/beaker/hypervisor/docker.rb
Beaker.Docker.install_ssh_components
def install_ssh_components(container, host) case host['platform'] when /ubuntu/, /debian/ container.exec(%w(apt-get update)) container.exec(%w(apt-get install -y openssh-server openssh-client)) when /cumulus/ container.exec(%w(apt-get update)) container.exec(%w(apt-get ...
ruby
def install_ssh_components(container, host) case host['platform'] when /ubuntu/, /debian/ container.exec(%w(apt-get update)) container.exec(%w(apt-get install -y openssh-server openssh-client)) when /cumulus/ container.exec(%w(apt-get update)) container.exec(%w(apt-get ...
[ "def", "install_ssh_components", "(", "container", ",", "host", ")", "case", "host", "[", "'platform'", "]", "when", "/", "/", ",", "/", "/", "container", ".", "exec", "(", "%w(", "apt-get", "update", ")", ")", "container", ".", "exec", "(", "%w(", "ap...
This sideloads sshd after a container starts
[ "This", "sideloads", "sshd", "after", "a", "container", "starts" ]
d102f4af3af7d2231a5f43fbeaa57379cdcf825b
https://github.com/puppetlabs/beaker-docker/blob/d102f4af3af7d2231a5f43fbeaa57379cdcf825b/lib/beaker/hypervisor/docker.rb#L221-L262
22,683
puppetlabs/beaker-docker
lib/beaker/hypervisor/docker.rb
Beaker.Docker.fix_ssh
def fix_ssh(container, host=nil) @logger.debug("Fixing ssh on container #{container.id}") container.exec(['sed','-ri', 's/^#?PermitRootLogin .*/PermitRootLogin yes/', '/etc/ssh/sshd_config']) container.exec(['sed','-ri', 's/^#?PasswordA...
ruby
def fix_ssh(container, host=nil) @logger.debug("Fixing ssh on container #{container.id}") container.exec(['sed','-ri', 's/^#?PermitRootLogin .*/PermitRootLogin yes/', '/etc/ssh/sshd_config']) container.exec(['sed','-ri', 's/^#?PasswordA...
[ "def", "fix_ssh", "(", "container", ",", "host", "=", "nil", ")", "@logger", ".", "debug", "(", "\"Fixing ssh on container #{container.id}\"", ")", "container", ".", "exec", "(", "[", "'sed'", ",", "'-ri'", ",", "'s/^#?PermitRootLogin .*/PermitRootLogin yes/'", ",",...
a puppet run may have changed the ssh config which would keep us out of the container. This is a best effort to fix it. Optionally pass in a host object to to determine which ssh restart command we should try.
[ "a", "puppet", "run", "may", "have", "changed", "the", "ssh", "config", "which", "would", "keep", "us", "out", "of", "the", "container", ".", "This", "is", "a", "best", "effort", "to", "fix", "it", ".", "Optionally", "pass", "in", "a", "host", "object"...
d102f4af3af7d2231a5f43fbeaa57379cdcf825b
https://github.com/puppetlabs/beaker-docker/blob/d102f4af3af7d2231a5f43fbeaa57379cdcf825b/lib/beaker/hypervisor/docker.rb#L436-L460
22,684
puppetlabs/beaker-docker
lib/beaker/hypervisor/docker.rb
Beaker.Docker.find_container
def find_container(host) id = host['docker_container_id'] name = host['docker_container_name'] return unless id || name containers = ::Docker::Container.all if id @logger.debug("Looking for an existing container with ID #{id}") container = containers.select { |c| c.id == ...
ruby
def find_container(host) id = host['docker_container_id'] name = host['docker_container_name'] return unless id || name containers = ::Docker::Container.all if id @logger.debug("Looking for an existing container with ID #{id}") container = containers.select { |c| c.id == ...
[ "def", "find_container", "(", "host", ")", "id", "=", "host", "[", "'docker_container_id'", "]", "name", "=", "host", "[", "'docker_container_name'", "]", "return", "unless", "id", "||", "name", "containers", "=", "::", "Docker", "::", "Container", ".", "all...
return the existing container if we're not provisioning and docker_container_name is set
[ "return", "the", "existing", "container", "if", "we", "re", "not", "provisioning", "and", "docker_container_name", "is", "set" ]
d102f4af3af7d2231a5f43fbeaa57379cdcf825b
https://github.com/puppetlabs/beaker-docker/blob/d102f4af3af7d2231a5f43fbeaa57379cdcf825b/lib/beaker/hypervisor/docker.rb#L465-L486
22,685
timothyf/gameday_api
lib/gameday_api/players.rb
GamedayApi.Players.load_from_id
def load_from_id(gid) @gid = gid @rosters = [] @umpires = {} @xml_data = GamedayFetcher.fetch_players(gid) @xml_doc = REXML::Document.new(@xml_data) if @xml_doc.root self.set_rosters self.set_umpires end end
ruby
def load_from_id(gid) @gid = gid @rosters = [] @umpires = {} @xml_data = GamedayFetcher.fetch_players(gid) @xml_doc = REXML::Document.new(@xml_data) if @xml_doc.root self.set_rosters self.set_umpires end end
[ "def", "load_from_id", "(", "gid", ")", "@gid", "=", "gid", "@rosters", "=", "[", "]", "@umpires", "=", "{", "}", "@xml_data", "=", "GamedayFetcher", ".", "fetch_players", "(", "gid", ")", "@xml_doc", "=", "REXML", "::", "Document", ".", "new", "(", "@...
Loads the players XML from the MLB gameday server and parses it using REXML
[ "Loads", "the", "players", "XML", "from", "the", "MLB", "gameday", "server", "and", "parses", "it", "using", "REXML" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/players.rb#L12-L22
22,686
timothyf/gameday_api
lib/gameday_api/pitchfx_db_manager.rb
GamedayApi.PitchfxDbManager.update_rosters
def update_rosters(game, away_id, home_id) game_id = find_or_create_game(game, nil, nil) gameday_info = GamedayUtil.parse_gameday_id('gid_' + game.gid) active_date = "#{gameday_info['year']}/#{gameday_info['month']}/#{gameday_info['day']}" away_res = @db.query("select...
ruby
def update_rosters(game, away_id, home_id) game_id = find_or_create_game(game, nil, nil) gameday_info = GamedayUtil.parse_gameday_id('gid_' + game.gid) active_date = "#{gameday_info['year']}/#{gameday_info['month']}/#{gameday_info['day']}" away_res = @db.query("select...
[ "def", "update_rosters", "(", "game", ",", "away_id", ",", "home_id", ")", "game_id", "=", "find_or_create_game", "(", "game", ",", "nil", ",", "nil", ")", "gameday_info", "=", "GamedayUtil", ".", "parse_gameday_id", "(", "'gid_'", "+", "game", ".", "gid", ...
Used to set game_id and home_or_away flag
[ "Used", "to", "set", "game_id", "and", "home_or_away", "flag" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/pitchfx_db_manager.rb#L460-L488
22,687
timothyf/gameday_api
lib/gameday_api/pitchfx_db_manager.rb
GamedayApi.PitchfxDbManager.update_umpire_ids_for_games
def update_umpire_ids_for_games ump_id_hp = nil ump_id_1b = nil ump_id_2b = nil ump_id_3b = nil res = @db.query("select id, umpire_hp_id, umpire_1b_id, umpire_2b_id, umpire_3b_id from games") res.each do |row| # each game game_id = row[0] umpir...
ruby
def update_umpire_ids_for_games ump_id_hp = nil ump_id_1b = nil ump_id_2b = nil ump_id_3b = nil res = @db.query("select id, umpire_hp_id, umpire_1b_id, umpire_2b_id, umpire_3b_id from games") res.each do |row| # each game game_id = row[0] umpir...
[ "def", "update_umpire_ids_for_games", "ump_id_hp", "=", "nil", "ump_id_1b", "=", "nil", "ump_id_2b", "=", "nil", "ump_id_3b", "=", "nil", "res", "=", "@db", ".", "query", "(", "\"select id, umpire_hp_id, umpire_1b_id, umpire_2b_id, umpire_3b_id from games\"", ")", "res", ...
Update the game records to point to the first instance of the specific umpires originally new umpire records were being inserted for every game, which is what caused this problem
[ "Update", "the", "game", "records", "to", "point", "to", "the", "first", "instance", "of", "the", "specific", "umpires", "originally", "new", "umpire", "records", "were", "being", "inserted", "for", "every", "game", "which", "is", "what", "caused", "this", "...
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/pitchfx_db_manager.rb#L778-L801
22,688
timothyf/gameday_api
lib/gameday_api/event_log.rb
GamedayApi.EventLog.load_from_id
def load_from_id(gid) @gid = gid @xml_data = GamedayFetcher.fetch_eventlog(gid) @xml_doc = REXML::Document.new(@xml_data) if @xml_doc.root set_teams set_events end end
ruby
def load_from_id(gid) @gid = gid @xml_data = GamedayFetcher.fetch_eventlog(gid) @xml_doc = REXML::Document.new(@xml_data) if @xml_doc.root set_teams set_events end end
[ "def", "load_from_id", "(", "gid", ")", "@gid", "=", "gid", "@xml_data", "=", "GamedayFetcher", ".", "fetch_eventlog", "(", "gid", ")", "@xml_doc", "=", "REXML", "::", "Document", ".", "new", "(", "@xml_data", ")", "if", "@xml_doc", ".", "root", "set_teams...
Loads the eventLog XML from the MLB gameday server and parses it using REXML
[ "Loads", "the", "eventLog", "XML", "from", "the", "MLB", "gameday", "server", "and", "parses", "it", "using", "REXML" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/event_log.rb#L15-L23
22,689
timothyf/gameday_api
lib/gameday_api/event_log.rb
GamedayApi.EventLog.set_teams
def set_teams @xml_doc.elements.each("game/team[@home_team='false']") do |element| @away_team = element.attributes["name"] end @xml_doc.elements.each("game/team[@home_team='true']") do |element| @home_team = element.attributes["name"] end end
ruby
def set_teams @xml_doc.elements.each("game/team[@home_team='false']") do |element| @away_team = element.attributes["name"] end @xml_doc.elements.each("game/team[@home_team='true']") do |element| @home_team = element.attributes["name"] end end
[ "def", "set_teams", "@xml_doc", ".", "elements", ".", "each", "(", "\"game/team[@home_team='false']\"", ")", "do", "|", "element", "|", "@away_team", "=", "element", ".", "attributes", "[", "\"name\"", "]", "end", "@xml_doc", ".", "elements", ".", "each", "(",...
Sets the team names for the teams involved in this game
[ "Sets", "the", "team", "names", "for", "the", "teams", "involved", "in", "this", "game" ]
2cb629398221f94ffadcaee35fe9740ee30577d4
https://github.com/timothyf/gameday_api/blob/2cb629398221f94ffadcaee35fe9740ee30577d4/lib/gameday_api/event_log.rb#L27-L34
22,690
chriskite/jimson
lib/jimson/server.rb
Jimson.Server.call
def call(env) req = Rack::Request.new(env) resp = Rack::Response.new return resp.finish if !req.post? resp.write process(req.body.read) resp.finish end
ruby
def call(env) req = Rack::Request.new(env) resp = Rack::Response.new return resp.finish if !req.post? resp.write process(req.body.read) resp.finish end
[ "def", "call", "(", "env", ")", "req", "=", "Rack", "::", "Request", ".", "new", "(", "env", ")", "resp", "=", "Rack", "::", "Response", ".", "new", "return", "resp", ".", "finish", "if", "!", "req", ".", "post?", "resp", ".", "write", "process", ...
Entry point for Rack
[ "Entry", "point", "for", "Rack" ]
d921a29857384997509e477e655d152377a4dfcc
https://github.com/chriskite/jimson/blob/d921a29857384997509e477e655d152377a4dfcc/lib/jimson/server.rb#L83-L89
22,691
logdna/ruby
lib/logdna/client.rb
Logdna.Client.buffer
def buffer(msg, opts) buffer_size = write_to_buffer(msg, opts) unless buffer_size.nil? process_buffer(buffer_size) end end
ruby
def buffer(msg, opts) buffer_size = write_to_buffer(msg, opts) unless buffer_size.nil? process_buffer(buffer_size) end end
[ "def", "buffer", "(", "msg", ",", "opts", ")", "buffer_size", "=", "write_to_buffer", "(", "msg", ",", "opts", ")", "unless", "buffer_size", ".", "nil?", "process_buffer", "(", "buffer_size", ")", "end", "end" ]
this should always be running synchronously within this thread
[ "this", "should", "always", "be", "running", "synchronously", "within", "this", "thread" ]
8655d45d58f1d4fbf01e12e83bd9b37e8afc8614
https://github.com/logdna/ruby/blob/8655d45d58f1d4fbf01e12e83bd9b37e8afc8614/lib/logdna/client.rb#L86-L91
22,692
logdna/ruby
lib/logdna/client.rb
Logdna.Client.flush
def flush() if defined? @@request and !@@request.nil? request_messages = [] @lock.synchronize do request_messages = @messages @buffer.truncate(0) @messages = [] end return if request_messages.empty? real = { e: 'ls', ls: re...
ruby
def flush() if defined? @@request and !@@request.nil? request_messages = [] @lock.synchronize do request_messages = @messages @buffer.truncate(0) @messages = [] end return if request_messages.empty? real = { e: 'ls', ls: re...
[ "def", "flush", "(", ")", "if", "defined?", "@@request", "and", "!", "@@request", ".", "nil?", "request_messages", "=", "[", "]", "@lock", ".", "synchronize", "do", "request_messages", "=", "@messages", "@buffer", ".", "truncate", "(", "0", ")", "@messages",...
this should be running synchronously if @buffer_over_limit i.e. called from self.buffer else asynchronously through @task
[ "this", "should", "be", "running", "synchronously", "if" ]
8655d45d58f1d4fbf01e12e83bd9b37e8afc8614
https://github.com/logdna/ruby/blob/8655d45d58f1d4fbf01e12e83bd9b37e8afc8614/lib/logdna/client.rb#L126-L153
22,693
pat/riddle
lib/riddle/client.rb
Riddle.Client.run
def run response = Response.new request(:search, @queue) results = @queue.collect do result = { :matches => [], :fields => [], :attributes => {}, :attribute_names => [], :words => {} } result[:status]...
ruby
def run response = Response.new request(:search, @queue) results = @queue.collect do result = { :matches => [], :fields => [], :attributes => {}, :attribute_names => [], :words => {} } result[:status]...
[ "def", "run", "response", "=", "Response", ".", "new", "request", "(", ":search", ",", "@queue", ")", "results", "=", "@queue", ".", "collect", "do", "result", "=", "{", ":matches", "=>", "[", "]", ",", ":fields", "=>", "[", "]", ",", ":attributes", ...
Run all the queries currently in the queue. This will return an array of results hashes.
[ "Run", "all", "the", "queries", "currently", "in", "the", "queue", ".", "This", "will", "return", "an", "array", "of", "results", "hashes", "." ]
4cd51cb37cc2c1000c9c1e873cef5109d291899e
https://github.com/pat/riddle/blob/4cd51cb37cc2c1000c9c1e873cef5109d291899e/lib/riddle/client.rb#L230-L304
22,694
pat/riddle
lib/riddle/client.rb
Riddle.Client.query
def query(search, index = '*', comments = '') @queue.clear @queue << query_message(search, index, comments) self.run.first end
ruby
def query(search, index = '*', comments = '') @queue.clear @queue << query_message(search, index, comments) self.run.first end
[ "def", "query", "(", "search", ",", "index", "=", "'*'", ",", "comments", "=", "''", ")", "@queue", ".", "clear", "@queue", "<<", "query_message", "(", "search", ",", "index", ",", "comments", ")", "self", ".", "run", ".", "first", "end" ]
Query the Sphinx daemon - defaulting to all indices, but you can specify a specific one if you wish. The search parameter should be a string following Sphinx's expectations. The object returned from this method is a hash with the following keys: * :matches * :fields * :attributes * :attribute_names * :words ...
[ "Query", "the", "Sphinx", "daemon", "-", "defaulting", "to", "all", "indices", "but", "you", "can", "specify", "a", "specific", "one", "if", "you", "wish", ".", "The", "search", "parameter", "should", "be", "a", "string", "following", "Sphinx", "s", "expec...
4cd51cb37cc2c1000c9c1e873cef5109d291899e
https://github.com/pat/riddle/blob/4cd51cb37cc2c1000c9c1e873cef5109d291899e/lib/riddle/client.rb#L347-L351
22,695
pat/riddle
lib/riddle/client.rb
Riddle.Client.update
def update(index, attributes, values_by_doc) response = Response.new request( :update, update_message(index, attributes, values_by_doc) ) response.next_int end
ruby
def update(index, attributes, values_by_doc) response = Response.new request( :update, update_message(index, attributes, values_by_doc) ) response.next_int end
[ "def", "update", "(", "index", ",", "attributes", ",", "values_by_doc", ")", "response", "=", "Response", ".", "new", "request", "(", ":update", ",", "update_message", "(", "index", ",", "attributes", ",", "values_by_doc", ")", ")", "response", ".", "next_in...
Update attributes - first parameter is the relevant index, second is an array of attributes to be updated, and the third is a hash, where the keys are the document ids, and the values are arrays with the attribute values - in the same order as the second parameter. Example: client.update('people', ['birthday']...
[ "Update", "attributes", "-", "first", "parameter", "is", "the", "relevant", "index", "second", "is", "an", "array", "of", "attributes", "to", "be", "updated", "and", "the", "third", "is", "a", "hash", "where", "the", "keys", "are", "the", "document", "ids"...
4cd51cb37cc2c1000c9c1e873cef5109d291899e
https://github.com/pat/riddle/blob/4cd51cb37cc2c1000c9c1e873cef5109d291899e/lib/riddle/client.rb#L433-L440
22,696
pat/riddle
lib/riddle/client.rb
Riddle.Client.query_message
def query_message(search, index, comments = '') message = Message.new # Mode, Limits message.append_ints @offset, @limit, MatchModes[@match_mode] # Ranking message.append_int RankModes[@rank_mode] message.append_string @rank_expr if @rank_mode == :expr # Sort Mode mess...
ruby
def query_message(search, index, comments = '') message = Message.new # Mode, Limits message.append_ints @offset, @limit, MatchModes[@match_mode] # Ranking message.append_int RankModes[@rank_mode] message.append_string @rank_expr if @rank_mode == :expr # Sort Mode mess...
[ "def", "query_message", "(", "search", ",", "index", ",", "comments", "=", "''", ")", "message", "=", "Message", ".", "new", "# Mode, Limits", "message", ".", "append_ints", "@offset", ",", "@limit", ",", "MatchModes", "[", "@match_mode", "]", "# Ranking", "...
Generation of the message to send to Sphinx for a search.
[ "Generation", "of", "the", "message", "to", "send", "to", "Sphinx", "for", "a", "search", "." ]
4cd51cb37cc2c1000c9c1e873cef5109d291899e
https://github.com/pat/riddle/blob/4cd51cb37cc2c1000c9c1e873cef5109d291899e/lib/riddle/client.rb#L695-L789
22,697
pat/riddle
lib/riddle/client.rb
Riddle.Client.excerpts_message
def excerpts_message(options) message = Message.new message.append [0, excerpt_flags(options)].pack('N2') # 0 = mode message.append_string options[:index] message.append_string options[:words] # options message.append_string options[:before_match] message.append_string option...
ruby
def excerpts_message(options) message = Message.new message.append [0, excerpt_flags(options)].pack('N2') # 0 = mode message.append_string options[:index] message.append_string options[:words] # options message.append_string options[:before_match] message.append_string option...
[ "def", "excerpts_message", "(", "options", ")", "message", "=", "Message", ".", "new", "message", ".", "append", "[", "0", ",", "excerpt_flags", "(", "options", ")", "]", ".", "pack", "(", "'N2'", ")", "# 0 = mode", "message", ".", "append_string", "option...
Generation of the message to send to Sphinx for an excerpts request.
[ "Generation", "of", "the", "message", "to", "send", "to", "Sphinx", "for", "an", "excerpts", "request", "." ]
4cd51cb37cc2c1000c9c1e873cef5109d291899e
https://github.com/pat/riddle/blob/4cd51cb37cc2c1000c9c1e873cef5109d291899e/lib/riddle/client.rb#L792-L808
22,698
pat/riddle
lib/riddle/client.rb
Riddle.Client.update_message
def update_message(index, attributes, values_by_doc) message = Message.new message.append_string index message.append_array attributes message.append_int values_by_doc.length values_by_doc.each do |key,values| message.append_64bit_int key # document ID message.append_ints...
ruby
def update_message(index, attributes, values_by_doc) message = Message.new message.append_string index message.append_array attributes message.append_int values_by_doc.length values_by_doc.each do |key,values| message.append_64bit_int key # document ID message.append_ints...
[ "def", "update_message", "(", "index", ",", "attributes", ",", "values_by_doc", ")", "message", "=", "Message", ".", "new", "message", ".", "append_string", "index", "message", ".", "append_array", "attributes", "message", ".", "append_int", "values_by_doc", ".", ...
Generation of the message to send to Sphinx to update attributes of a document.
[ "Generation", "of", "the", "message", "to", "send", "to", "Sphinx", "to", "update", "attributes", "of", "a", "document", "." ]
4cd51cb37cc2c1000c9c1e873cef5109d291899e
https://github.com/pat/riddle/blob/4cd51cb37cc2c1000c9c1e873cef5109d291899e/lib/riddle/client.rb#L812-L825
22,699
pat/riddle
lib/riddle/client.rb
Riddle.Client.keywords_message
def keywords_message(query, index, return_hits) message = Message.new message.append_string query message.append_string index message.append_int return_hits ? 1 : 0 message.to_s end
ruby
def keywords_message(query, index, return_hits) message = Message.new message.append_string query message.append_string index message.append_int return_hits ? 1 : 0 message.to_s end
[ "def", "keywords_message", "(", "query", ",", "index", ",", "return_hits", ")", "message", "=", "Message", ".", "new", "message", ".", "append_string", "query", "message", ".", "append_string", "index", "message", ".", "append_int", "return_hits", "?", "1", ":...
Generates the simple message to send to the daemon for a keywords request.
[ "Generates", "the", "simple", "message", "to", "send", "to", "the", "daemon", "for", "a", "keywords", "request", "." ]
4cd51cb37cc2c1000c9c1e873cef5109d291899e
https://github.com/pat/riddle/blob/4cd51cb37cc2c1000c9c1e873cef5109d291899e/lib/riddle/client.rb#L828-L836