hexsha
stringlengths 40
40
| size
int64 2
1.01M
| content
stringlengths 2
1.01M
| avg_line_length
float64 1.5
100
| max_line_length
int64 2
1k
| alphanum_fraction
float64 0.25
1
|
---|---|---|---|---|---|
aba43b599afc4e0ea6dd713822acd148dc3a94bd | 1,142 | #
# Cookbook Name:: esri-tomcat
# Recipe:: openjdk
#
# Copyright 2021 Esri
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
remote_file "download jdk #{node['java']['version']} tarball" do
source node['java']['tarball_uri']
path node['java']['tarball_path']
not_if { ::File.exist?(node['java']['tarball_path']) }
end
execute 'extract jdk tarball' do
command "tar -xvf #{node['java']['tarball_path']} -C #{node['java']['install_path']}"
action :run
end
execute 'update java alternatives' do
command "update-alternatives --install /usr/bin/java java #{node['java']['install_path']}/jdk-#{node['java']['version']}/bin/java 10"
end
| 33.588235 | 135 | 0.718039 |
39cae463d5c51c7cc12338e3ef651b8fe843ded9 | 866 | class SchoolVacancyPresenter < BasePresenter
include DateHelper
include ActionView::Helpers::UrlHelper
def page_views
model.total_pageviews || 0
end
# rubocop:disable Naming/AccessorMethodName
def get_more_info_clicks
model.total_get_more_info_clicks || 0
end
# rubocop:enable Naming/AccessorMethodName
def publish_on
format_date(model.publish_on)
end
def created_at
format_date(model.created_at)
end
def expires_on
format_date(model.expires_on)
end
def preview_path
url_helpers.school_job_path(model.id)
end
def edit_path
url_helpers.edit_school_job_path(model.id)
end
def copy_path
url_helpers.new_school_job_copy_path(model.id)
end
def delete_path
url_helpers.school_job_path(id: model.id)
end
private
def url_helpers
Rails.application.routes.url_helpers
end
end | 18.041667 | 50 | 0.76097 |
1dd3c5c3204c6f666b77c201b44ace36bb004bdd | 2,258 | # Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
require 'spec_helper'
module AWS
class DynamoDB
describe Client do
it 'returns a V20111205 client by default' do
Client.new.should be_a(Client::V20111205)
end
it 'accpets an :api_version of 2011-12-05' do
client = Client.new(:api_version => '2011-12-05')
client.should be_a(Client::V20111205)
end
it 'accpets an :api_version of 2012-08-10' do
client = Client.new(:api_version => '2012-08-10')
client.should be_a(Client::V20120810)
end
it 'suports the deprecated ClientV2' do
client = ClientV2.new
client.should be_a(Client::V20120810)
end
it 'can be constructed from the subclass clients' do
Client::V20111205.new.should be_a(Client::V20111205)
Client::V20120810.new.should be_a(Client::V20120810)
end
context 'with default versions' do
def set_default(api_version)
AWS.config.stub(:dynamo_db).and_return(:api_version => api_version)
end
it 'returns the configured default' do
Client.new.should be_a(Client::V20111205)
set_default('2012-08-10')
Client.new.should be_a(Client::V20120810)
end
it 'can construct specific clients using their versioned class' do
set_default('2000-01-02')
Client::V20111205.new.should be_a(Client::V20111205)
Client::V20120810.new.should be_a(Client::V20120810)
end
it 'uses :api_version from new over AWS.config' do
set_default('2011-12-05')
Client.new(:api_version => '2012-08-10').should be_a(Client::V20120810)
end
end
end
end
end
| 30.931507 | 81 | 0.662533 |
d57c598b5424127b05fcd810c4423f2883fc17fb | 24,872 | # -*- coding: binary -*-
module Msf
module Serializer
# This class formats information in a plain-text format that
# is meant to be displayed on a console or some other non-GUI
# medium.
class ReadableText
#Default number of characters to wrap at.
DefaultColumnWrap = 70
#Default number of characters to indent.
DefaultIndent = 2
# Returns a formatted string that contains information about
# the supplied module instance.
#
# @param mod [Msf::Module] the module to dump information for.
# @param indent [String] the indentation to use.
# @return [String] formatted text output of the dump.
def self.dump_module(mod, indent = " ")
case mod.type
when Msf::MODULE_PAYLOAD
return dump_payload_module(mod, indent)
when Msf::MODULE_NOP
return dump_basic_module(mod, indent)
when Msf::MODULE_ENCODER
return dump_basic_module(mod, indent)
when Msf::MODULE_EXPLOIT
return dump_exploit_module(mod, indent)
when Msf::MODULE_AUX
return dump_auxiliary_module(mod, indent)
when Msf::MODULE_POST
return dump_post_module(mod, indent)
else
return dump_generic_module(mod, indent)
end
end
# Dumps an exploit's targets.
#
# @param mod [Msf::Exploit] the exploit module to dump targets
# for.
# @param indent [String] the indentation to use (only the length
# matters).
# @param h [String] the string to display as the table heading.
# @return [String] the string form of the table.
def self.dump_exploit_targets(mod, indent = '', h = nil)
tbl = Rex::Text::Table.new(
'Indent' => indent.length,
'Header' => h,
'Columns' =>
[
'Id',
'Name',
])
mod.targets.each_with_index { |target, idx|
tbl << [ idx.to_s, target.name || 'All' ]
}
tbl.to_s + "\n"
end
# Dumps the exploit's selected target
#
# @param mod [Msf::Exploit] the exploit module.
# @param indent [String] the indentation to use (only the length
# matters)
# @param h [String] the string to display as the table heading.
# @return [String] the string form of the table.
def self.dump_exploit_target(mod, indent = '', h = nil)
tbl = Rex::Text::Table.new(
'Indent' => indent.length,
'Header' => h,
'Columns' =>
[
'Id',
'Name',
])
tbl << [ mod.target_index, mod.target.name || 'All' ]
tbl.to_s + "\n"
end
# Dumps a module's actions
#
# @param mod [Msf::Module] the module.
# @param indent [String] the indentation to use (only the length
# matters)
# @param h [String] the string to display as the table heading.
# @return [String] the string form of the table.
def self.dump_module_actions(mod, indent = '', h = nil)
tbl = Rex::Text::Table.new(
'Indent' => indent.length,
'Header' => h,
'Columns' =>
[
'Name',
'Description'
])
mod.actions.each_with_index { |target, idx|
tbl << [ target.name || 'All' , target.description || '' ]
}
tbl.to_s + "\n"
end
# Dumps the module's selected action
#
# @param mod [Msf::Module] the module.
# @param indent [String] the indentation to use (only the length
# matters)
# @param h [String] the string to display as the table heading.
# @return [String] the string form of the table.
def self.dump_module_action(mod, indent = '', h = nil)
tbl = Rex::Text::Table.new(
'Indent' => indent.length,
'Header' => h,
'Columns' =>
[
'Name',
'Description',
])
tbl << [ mod.action.name || 'All', mod.action.description || '' ]
tbl.to_s + "\n"
end
# Dumps the table of payloads that are compatible with the supplied
# exploit.
#
# @param exploit [Msf::Exploit] the exploit module.
# @param indent [String] the indentation to use (only the length
# matters)
# @param h [String] the string to display as the table heading.
# @return [String] the string form of the table.
def self.dump_compatible_payloads(exploit, indent = '', h = nil)
tbl = Rex::Text::Table.new(
'Indent' => indent.length,
'Header' => h,
'Columns' =>
[
'Name',
'Description',
])
exploit.compatible_payloads.each { |entry|
tbl << [ entry[0], entry[1].new.description ]
}
tbl.to_s + "\n"
end
# Dumps information about an exploit module.
#
# @param mod [Msf::Exploit] the exploit module.
# @param indent [String] the indentation to use.
# @return [String] the string form of the information.
def self.dump_exploit_module(mod, indent = '')
output = "\n"
output << " Name: #{mod.name}\n"
output << " Module: #{mod.fullname}\n"
output << " Platform: #{mod.platform_to_s}\n"
output << " Arch: #{mod.arch_to_s}\n"
output << " Privileged: " + (mod.privileged? ? "Yes" : "No") + "\n"
output << " License: #{mod.license}\n"
output << " Rank: #{mod.rank_to_s.capitalize}\n"
output << " Disclosed: #{mod.disclosure_date}\n" if mod.disclosure_date
output << "\n"
# Authors
output << "Provided by:\n"
mod.each_author { |author|
output << indent + author.to_s + "\n"
}
output << "\n"
# Targets
output << "Available targets:\n"
output << dump_exploit_targets(mod, indent)
# Options
if (mod.options.has_options?)
output << "Basic options:\n"
output << dump_options(mod, indent)
output << "\n"
end
# Payload information
if (mod.payload_info.length)
output << "Payload information:\n"
if (mod.payload_space)
output << indent + "Space: " + mod.payload_space.to_s + "\n"
end
if (mod.payload_badchars)
output << indent + "Avoid: " + mod.payload_badchars.length.to_s + " characters\n"
end
output << "\n"
end
# Description
output << "Description:\n"
output << word_wrap(Rex::Text.compress(mod.description))
output << "\n"
# References
output << dump_references(mod, indent)
return output
end
# Dumps information about an auxiliary module.
#
# @param mod [Msf::Auxiliary] the auxiliary module.
# @param indent [String] the indentation to use.
# @return [String] the string form of the information.
def self.dump_auxiliary_module(mod, indent = '')
output = "\n"
output << " Name: #{mod.name}\n"
output << " Module: #{mod.fullname}\n"
output << " License: #{mod.license}\n"
output << " Rank: #{mod.rank_to_s.capitalize}\n"
output << " Disclosed: #{mod.disclosure_date}\n" if mod.disclosure_date
output << "\n"
# Authors
output << "Provided by:\n"
mod.each_author { |author|
output << indent + author.to_s + "\n"
}
output << "\n"
# Actions
if mod.action
output << "Available actions:\n"
output << dump_module_actions(mod, indent)
end
# Options
if (mod.options.has_options?)
output << "Basic options:\n"
output << dump_options(mod, indent)
output << "\n"
end
# Description
output << "Description:\n"
output << word_wrap(Rex::Text.compress(mod.description))
output << "\n"
# References
output << dump_references(mod, indent)
return output
end
# Dumps information about a post module.
#
# @param mod [Msf::Post] the post module.
# @param indent [String] the indentation to use.
# @return [String] the string form of the information.
def self.dump_post_module(mod, indent = '')
output = "\n"
output << " Name: #{mod.name}\n"
output << " Module: #{mod.fullname}\n"
output << " Platform: #{mod.platform_to_s}\n"
output << " Arch: #{mod.arch_to_s}\n"
output << " Rank: #{mod.rank_to_s.capitalize}\n"
output << " Disclosed: #{mod.disclosure_date}\n" if mod.disclosure_date
output << "\n"
# Authors
output << "Provided by:\n"
mod.each_author.each do |author|
output << indent + author.to_s + "\n"
end
output << "\n"
# Compatible session types
if mod.session_types
output << "Compatible session types:\n"
mod.session_types.sort.each do |type|
output << indent + type.capitalize + "\n"
end
output << "\n"
end
# Actions
if mod.action
output << "Available actions:\n"
output << dump_module_actions(mod, indent)
end
# Options
if (mod.options.has_options?)
output << "Basic options:\n"
output << dump_options(mod, indent)
output << "\n"
end
# Description
output << "Description:\n"
output << word_wrap(Rex::Text.compress(mod.description))
output << "\n"
# References
output << dump_references(mod, indent)
return output
end
# Dumps information about a payload module.
#
# @param mod [Msf::Payload] the payload module.
# @param indent [String] the indentation to use.
# @return [String] the string form of the information.
def self.dump_payload_module(mod, indent = '')
# General
output = "\n"
output << " Name: #{mod.name}\n"
output << " Module: #{mod.fullname}\n"
output << " Platform: #{mod.platform_to_s}\n"
output << " Arch: #{mod.arch_to_s}\n"
output << "Needs Admin: " + (mod.privileged? ? "Yes" : "No") + "\n"
output << " Total size: #{mod.size}\n"
output << " Rank: #{mod.rank_to_s.capitalize}\n"
output << "\n"
# Authors
output << "Provided by:\n"
mod.each_author { |author|
output << indent + author.to_s + "\n"
}
output << "\n"
# Options
if (mod.options.has_options?)
output << "Basic options:\n"
output << dump_options(mod)
output << "\n"
end
# Description
output << "Description:\n"
output << word_wrap(Rex::Text.compress(mod.description))
output << "\n\n"
return output
end
# Dumps information about a module, just the basics.
#
# @param mod [Msf::Module] the module.
# @param indent [String] the indentation to use.
# @return [String] the string form of the information.
def self.dump_basic_module(mod, indent = '')
# General
output = "\n"
output << " Name: #{mod.name}\n"
output << " Module: #{mod.fullname}\n"
output << " Platform: #{mod.platform_to_s}\n"
output << " Arch: #{mod.arch_to_s}\n"
output << " Rank: #{mod.rank_to_s.capitalize}\n"
output << "\n"
# Authors
output << "Provided by:\n"
mod.each_author { |author|
output << indent + author.to_s + "\n"
}
output << "\n"
# Description
output << "Description:\n"
output << word_wrap(Rex::Text.compress(mod.description))
output << "\n"
output << dump_references(mod, indent)
output << "\n"
return output
end
#No current use
def self.dump_generic_module(mod, indent = '')
end
# Dumps the list of options associated with the
# supplied module.
#
# @param mod [Msf::Module] the module.
# @param indent [String] the indentation to use.
# @param missing [Boolean] dump only empty required options.
# @return [String] the string form of the information.
def self.dump_options(mod, indent = '', missing = false)
tbl = Rex::Text::Table.new(
'Indent' => indent.length,
'Columns' =>
[
'Name',
'Current Setting',
'Required',
'Description'
])
mod.options.sorted.each do |name, opt|
val = mod.datastore[name].nil? ? opt.default : mod.datastore[name]
next if (opt.advanced?)
next if (opt.evasion?)
next if (missing && opt.valid?(val))
desc = opt.desc.dup
# Hint at RPORT proto by regexing mixins
if name == 'RPORT' && opt.kind_of?(Msf::OptPort)
mod.class.included_modules.each do |m|
case m.name
when /tcp/i, /HttpClient$/
desc << ' (TCP)'
break
when /udp/i
desc << ' (UDP)'
break
end
end
end
tbl << [ name, opt.display_value(val), opt.required? ? "yes" : "no", desc ]
end
return tbl.to_s
end
# Dumps the advanced options associated with the supplied module.
#
# @param mod [Msf::Module] the module.
# @param indent [String] the indentation to use.
# @return [String] the string form of the information.
def self.dump_advanced_options(mod, indent = '')
tbl = Rex::Text::Table.new(
'Indent' => indent.length,
'Columns' =>
[
'Name',
'Current Setting',
'Required',
'Description'
])
mod.options.sorted.each do |name, opt|
next unless opt.advanced?
val = mod.datastore[name].nil? ? opt.default : mod.datastore[name]
tbl << [ name, opt.display_value(val), opt.required? ? "yes" : "no", opt.desc ]
end
return tbl.to_s
end
# Dumps the evasion options associated with the supplied module.
#
# @param mod [Msf::Module] the module.
# @param indent [String] the indentation to use.
# @return [String] the string form of the information.
def self.dump_evasion_options(mod, indent = '')
tbl = Rex::Text::Table.new(
'Indent' => indent.length,
'Columns' =>
[
'Name',
'Current Setting',
'Required',
'Description'
])
mod.options.sorted.each do |name, opt|
next unless opt.evasion?
val = mod.datastore[name].nil? ? opt.default : mod.datastore[name]
tbl << [ name, opt.display_value(val), opt.required? ? "yes" : "no", opt.desc ]
end
return tbl.to_s
end
# Dumps the references associated with the supplied module.
#
# @param mod [Msf::Module] the module.
# @param indent [String] the indentation to use.
# @return [String] the string form of the information.
def self.dump_references(mod, indent = '')
output = ''
if (mod.respond_to?(:references) && mod.references && mod.references.length > 0)
output << "References:\n"
cve_collection = mod.references.select { |r| r.ctx_id.match(/^cve$/i) }
if cve_collection.empty?
output << "#{indent}CVE: Not available\n"
end
mod.references.each { |ref|
case ref.ctx_id
when 'CVE', 'cve'
if !cve_collection.empty? && ref.ctx_val.blank?
output << "#{indent}CVE: Not available\n"
else
output << indent + ref.to_s + "\n"
end
else
output << indent + ref.to_s + "\n"
end
}
output << "\n"
end
output
end
# Dumps the contents of a datastore.
#
# @param name [String] displayed as the table header.
# @param ds [Msf::DataStore] the DataStore to dump.
# @param indent [Integer] the indentation size.
# @param col [Integer] the column width.
# @return [String] the formatted DataStore contents.
def self.dump_datastore(name, ds, indent = DefaultIndent, col = DefaultColumnWrap)
tbl = Rex::Text::Table.new(
'Indent' => indent,
'Header' => name,
'Columns' =>
[
'Name',
'Value'
])
ds.keys.sort.each { |k|
tbl << [ k, (ds[k] != nil) ? ds[k].to_s : '' ]
}
return ds.length > 0 ? tbl.to_s : "#{tbl.header_to_s}No entries in data store.\n"
end
# Dumps the list of sessions.
#
# @param framework [Msf::Framework] the framework to dump.
# @param opts [Hash] the options to dump with.
# @option opts :verbose [Boolean] gives more information if set to
# true.
# @option opts :indent [Integer] set the indentation amount.
# @return [String] the formatted list of sessions.
def self.dump_sessions(framework, opts={})
output = ""
verbose = opts[:verbose] || false
show_active = opts[:show_active] || false
show_inactive = opts[:show_inactive] || false
# if show_active and show_inactive are false the caller didn't
# specify either flag; default to displaying active sessions
show_active = true if !(show_active || show_inactive)
show_extended = opts[:show_extended] || false
indent = opts[:indent] || DefaultIndent
return dump_sessions_verbose(framework, opts) if verbose
if show_active
columns = []
columns << 'Id'
columns << 'Name'
columns << 'Type'
columns << 'Checkin?' if show_extended
columns << 'Enc?' if show_extended
columns << 'Local URI' if show_extended
columns << 'Information'
columns << 'Connection'
tbl = Rex::Text::Table.new(
'Header' => "Active sessions",
'Columns' => columns,
'Indent' => indent)
framework.sessions.each_sorted { |k|
session = framework.sessions[k]
row = create_msf_session_row(session, show_extended)
tbl << row
}
output << (tbl.rows.count > 0 ? tbl.to_s : "#{tbl.header_to_s}No active sessions.\n")
end
if show_inactive
output << "\n" if show_active
columns = []
columns << 'Closed'
columns << 'Opened'
columns << 'Reason Closed'
columns << 'Type'
columns << 'Address'
tbl = Rex::Text::Table.new(
'Header' => "Inactive sessions",
'Columns' => columns,
'Indent' => indent,
'SortIndex' => 1)
framework.db.sessions.each do |session|
unless session.closed_at.nil?
row = create_mdm_session_row(session, show_extended)
tbl << row
end
end
output << (tbl.rows.count > 0 ? tbl.to_s : "#{tbl.header_to_s}No inactive sessions.\n")
end
# return formatted listing of sessions
output
end
# Creates a table row that represents the specified session.
#
# @param session [Msf::Session] session used to create a table row.
# @param show_extended [Boolean] Indicates if extended information will be included in the row.
# @return [Array] table row of session data.
def self.create_msf_session_row(session, show_extended)
row = []
row << session.sid.to_s
row << session.sname.to_s
row << session.type.to_s
if session.respond_to?(:session_type)
row[-1] << " #{session.session_type}"
elsif session.respond_to?(:platform)
row[-1] << " #{session.platform}"
end
if show_extended
if session.respond_to?(:last_checkin) && session.last_checkin
row << "#{(Time.now.to_i - session.last_checkin.to_i)}s ago"
else
row << '?'
end
if session.respond_to?(:tlv_enc_key) && session.tlv_enc_key && session.tlv_enc_key[:key]
row << 'Y'
else
row << 'N'
end
if session.exploit_datastore && session.exploit_datastore.has_key?('LURI') && !session.exploit_datastore['LURI'].empty?
row << "(#{exploit_datastore['LURI']})"
else
row << '?'
end
end
sinfo = session.info.to_s
# Arbitrarily cut info at 80 columns
if sinfo.length > 80
sinfo = "#{sinfo[0,77]}..."
end
row << sinfo
row << "#{session.tunnel_to_s} (#{session.session_host})"
# return complete row
row
end
# Creates a table row that represents the specified session.
#
# @param session [Mdm::Session] session used to create a table row.
# @param show_extended [Boolean] Indicates if extended information will be included in the row.
# @return [Array] table row of session data.
def self.create_mdm_session_row(session, show_extended)
row = []
row << session.closed_at.to_s
row << session.opened_at.to_s
row << session.close_reason
row << session.stype
if session.respond_to?(:platform) && !session.platform.nil?
row[-1] << " #{session.platform}"
end
row << (!session.host.nil? ? session.host.address : nil)
# return complete row
row
end
# Dumps the list of active sessions in verbose mode
#
# @param framework [Msf::Framework] the framework to dump.
# @param opts [Hash] the options to dump with.
# @return [String] the formatted list of sessions.
def self.dump_sessions_verbose(framework, opts={})
out = "Active sessions\n" +
"===============\n\n"
if framework.sessions.length == 0
out << "No active sessions.\n"
return out
end
framework.sessions.each_sorted do |k|
session = framework.sessions[k]
sess_info = session.info.to_s
sess_id = session.sid.to_s
sess_name = session.sname.to_s
sess_tunnel = session.tunnel_to_s + " (#{session.session_host})"
sess_via = session.via_exploit.to_s
sess_type = session.type.to_s
sess_uuid = session.payload_uuid.to_s
sess_luri = session.exploit_datastore['LURI'] || "" if session.exploit_datastore
sess_enc = false
if session.respond_to?(:tlv_enc_key) && session.tlv_enc_key && session.tlv_enc_key[:key]
sess_enc = true
end
sess_checkin = "<none>"
sess_registration = "No"
if session.respond_to?(:platform)
sess_type << " " + session.platform
end
if session.respond_to?(:last_checkin) && session.last_checkin
sess_checkin = "#{(Time.now.to_i - session.last_checkin.to_i)}s ago @ #{session.last_checkin.to_s}"
end
if !session.payload_uuid.nil? && session.payload_uuid.registered
sess_registration = "Yes"
if session.payload_uuid.name
sess_registration << " - Name=\"#{session.payload_uuid.name}\""
end
end
out << " Session ID: #{sess_id}\n"
out << " Name: #{sess_name}\n"
out << " Type: #{sess_type}\n"
out << " Info: #{sess_info}\n"
out << " Tunnel: #{sess_tunnel}\n"
out << " Via: #{sess_via}\n"
out << " Encrypted: #{sess_enc}\n"
out << " UUID: #{sess_uuid}\n"
out << " CheckIn: #{sess_checkin}\n"
out << " Registered: #{sess_registration}\n"
unless (sess_luri || '').empty?
out << " LURI: #{sess_luri}\n"
end
out << "\n"
end
out << "\n"
return out
end
# Dumps the list of running jobs.
#
# @param framework [Msf::Framework] the framework.
# @param verbose [Boolean] if true, also prints the payload, LPORT, URIPATH
# and start time, if they exist, for each job.
# @param indent [Integer] the indentation amount.
# @param col [Integer] the column wrap width.
# @return [String] the formatted list of running jobs.
def self.dump_jobs(framework, verbose = false, indent = DefaultIndent, col = DefaultColumnWrap)
columns = [ 'Id', 'Name', "Payload", "Payload opts" ]
if (verbose)
columns += [ "URIPATH", "Start Time", "Handler opts" ]
end
tbl = Rex::Text::Table.new(
'Indent' => indent,
'Header' => "Jobs",
'Columns' => columns
)
# jobs are stored as a hash with the keys being a numeric String job_id.
framework.jobs.keys.sort_by(&:to_i).each do |job_id|
# Job context is stored as an Array with the 0th element being
# the running module. If that module is an exploit, ctx will also
# contain its payload.
exploit_mod, _payload_mod = framework.jobs[job_id].ctx
row = []
row[0] = job_id
row[1] = framework.jobs[job_id].name
pinst = exploit_mod.respond_to?(:payload_instance) ? exploit_mod.payload_instance : nil
payload_uri = ''
if pinst.nil?
row[2] = ""
row[3] = ""
else
row[2] = pinst.refname
row[3] = ""
if pinst.respond_to?(:payload_uri)
payload_uri = pinst.payload_uri.strip
row[3] << payload_uri
end
if pinst.respond_to?(:luri)
row[3] << pinst.luri
end
end
if verbose
uripath = exploit_mod.get_resource if exploit_mod.respond_to?(:get_resource)
uripath ||= exploit_mod.datastore['URIPATH']
row[4] = uripath
row[5] = framework.jobs[job_id].start_time
row[6] = ''
if pinst.respond_to?(:listener_uri)
listener_uri = pinst.listener_uri.strip
row[6] = listener_uri unless listener_uri == payload_uri
end
end
tbl << row
end
return framework.jobs.keys.length > 0 ? tbl.to_s : "#{tbl.header_to_s}No active jobs.\n"
end
# Jacked from Ernest Ellingson <erne [at] powernav.com>, modified
# a bit to add indention
#
# @param str [String] the string to wrap.
# @param indent [Integer] the indentation amount.
# @param col [Integer] the column wrap width.
# @return [String] the wrapped string.
def self.word_wrap(str, indent = DefaultIndent, col = DefaultColumnWrap)
return Rex::Text.wordwrap(str, indent, col)
end
end
end end
| 29.399527 | 125 | 0.598102 |
871d9a6e405c169b58d4b6f525718b387b345714 | 1,832 | # encoding: UTF-8
module Sources
class Site
attr_reader :url, :strategy
delegate :get, :get_size, :referer_url, :site_name, :artist_name, :profile_url, :image_url, :tags, :artist_record, :unique_id, :page_count, :file_url, :ugoira_frame_data, :image_urls, :to => :strategy
def self.strategies
[Strategies::Pixiv, Strategies::NicoSeiga, Strategies::DeviantArt, Strategies::Nijie, Strategies::Twitter]
end
def initialize(url)
@url = url
Site.strategies.each do |strategy|
if strategy.url_match?(url)
@strategy = strategy.new(url)
break
end
end
end
def normalized_for_artist_finder?
available? && strategy.normalized_for_artist_finder?
end
def normalize_for_artist_finder!
if available? && strategy.normalizable_for_artist_finder?
strategy.normalize_for_artist_finder!
else
url
end
rescue
url
end
def translated_tags
untranslated_tags = tags
untranslated_tags = untranslated_tags.map(&:first)
untranslated_tags = untranslated_tags.map do |tag|
if tag =~ /\A(\S+?)_?\d+users入り\Z/
$1
else
tag
end
end
WikiPage.other_names_match(untranslated_tags).map{|wiki_page| [wiki_page.title, wiki_page.category_name]}
end
def to_json
return {
:artist_name => artist_name,
:profile_url => profile_url,
:image_url => image_url,
:tags => tags,
:translated_tags => translated_tags,
:danbooru_name => artist_record.try(:first).try(:name),
:danbooru_id => artist_record.try(:first).try(:id),
:unique_id => unique_id,
:page_count => page_count
}.to_json
end
def available?
strategy.present?
end
end
end
| 26.550725 | 204 | 0.633734 |
1869d3fd0bf783eab7be71bb7ca2a7f9fa0d2439 | 566 | require File.join(File.dirname(__FILE__), 'shared')
module BcmsSupport
module Cucumber
include BcmsSupport::Shared
def login_as(user)
@current_user = User.current = user
cookies[:fake_user_id] = @current_user.id
end
end
end
if defined? ApplicationController
class ApplicationController < ActionController::Base
prepend_before_filter :fake_current_user
def fake_current_user
session[:user_id] = cookies[:fake_user_id] if cookies[:fake_user_id]
end
end
end
World(BcmsSupport::Cucumber) if defined? Cucumber | 24.608696 | 74 | 0.736749 |
e88827eedfc2cc7e7db2e2cadda195ff6e915bd7 | 22,572 | # encoding: utf-8
require 'tmpdir'
require 'stringio'
require 'zip/zipfilesystem'
# Base class for all other types of spreadsheets
class Roo::Base
include Enumerable
TEMP_PREFIX = "oo_"
attr_reader :default_sheet, :headers
# sets the line with attribute names (default: 1)
attr_accessor :header_line
protected
def self.split_coordinate(str)
letter,number = Roo::Base.split_coord(str)
x = letter_to_number(letter)
y = number
return y, x
end
def self.split_coord(s)
if s =~ /([a-zA-Z]+)([0-9]+)/
letter = $1
number = $2.to_i
else
raise ArgumentError
end
return letter, number
end
public
def initialize(filename, options={}, file_warning=:error, tmpdir=nil)
@filename = filename
@options = options
@cell = {}
@cell_type = {}
@cells_read = {}
@first_row = {}
@last_row = {}
@first_column = {}
@last_column = {}
@header_line = 1
@default_sheet = self.sheets.first
@header_line = 1
end
# sets the working sheet in the document
# 'sheet' can be a number (1 = first sheet) or the name of a sheet.
def default_sheet=(sheet)
validate_sheet!(sheet)
@default_sheet = sheet
@first_row[sheet] = @last_row[sheet] = @first_column[sheet] = @last_column[sheet] = nil
@cells_read[sheet] = false
end
# first non-empty column as a letter
def first_column_as_letter(sheet=nil)
Roo::Base.number_to_letter(first_column(sheet))
end
# last non-empty column as a letter
def last_column_as_letter(sheet=nil)
Roo::Base.number_to_letter(last_column(sheet))
end
# returns the number of the first non-empty row
def first_row(sheet=nil)
sheet ||= @default_sheet
read_cells(sheet)
if @first_row[sheet]
return @first_row[sheet]
end
impossible_value = 999_999 # more than a spreadsheet can hold
result = impossible_value
@cell[sheet].each_pair {|key,value|
y = key.first.to_i # _to_string(key).split(',')
result = [result, y].min if value
} if @cell[sheet]
result = nil if result == impossible_value
@first_row[sheet] = result
result
end
# returns the number of the last non-empty row
def last_row(sheet=nil)
sheet ||= @default_sheet
read_cells(sheet)
if @last_row[sheet]
return @last_row[sheet]
end
impossible_value = 0
result = impossible_value
@cell[sheet].each_pair {|key,value|
y = key.first.to_i # _to_string(key).split(',')
result = [result, y].max if value
} if @cell[sheet]
result = nil if result == impossible_value
@last_row[sheet] = result
result
end
# returns the number of the first non-empty column
def first_column(sheet=nil)
sheet ||= @default_sheet
read_cells(sheet)
if @first_column[sheet]
return @first_column[sheet]
end
impossible_value = 999_999 # more than a spreadsheet can hold
result = impossible_value
@cell[sheet].each_pair {|key,value|
x = key.last.to_i # _to_string(key).split(',')
result = [result, x].min if value
} if @cell[sheet]
result = nil if result == impossible_value
@first_column[sheet] = result
result
end
# returns the number of the last non-empty column
def last_column(sheet=nil)
sheet ||= @default_sheet
read_cells(sheet)
if @last_column[sheet]
return @last_column[sheet]
end
impossible_value = 0
result = impossible_value
@cell[sheet].each_pair {|key,value|
x = key.last.to_i # _to_string(key).split(',')
result = [result, x].max if value
} if @cell[sheet]
result = nil if result == impossible_value
@last_column[sheet] = result
result
end
# returns a rectangular area (default: all cells) as yaml-output
# you can add additional attributes with the prefix parameter like:
# oo.to_yaml({"file"=>"flightdata_2007-06-26", "sheet" => "1"})
def to_yaml(prefix={}, from_row=nil, from_column=nil, to_row=nil, to_column=nil,sheet=nil)
sheet ||= @default_sheet
result = "--- \n"
return '' unless first_row # empty result if there is no first_row in a sheet
(from_row||first_row(sheet)).upto(to_row||last_row(sheet)) do |row|
(from_column||first_column(sheet)).upto(to_column||last_column(sheet)) do |col|
unless empty?(row,col,sheet)
result << "cell_#{row}_#{col}: \n"
prefix.each {|k,v|
result << " #{k}: #{v} \n"
}
result << " row: #{row} \n"
result << " col: #{col} \n"
result << " celltype: #{self.celltype(row,col,sheet)} \n"
if self.celltype(row,col,sheet) == :time
result << " value: #{Roo::Base.integer_to_timestring( self.cell(row,col,sheet))} \n"
else
result << " value: #{self.cell(row,col,sheet)} \n"
end
end
end
end
result
end
# write the current spreadsheet to stdout or into a file
def to_csv(filename=nil,sheet=nil)
sheet ||= @default_sheet
if filename
File.open(filename,"w") do |file|
write_csv_content(file,sheet)
end
return true
else
sio = StringIO.new
write_csv_content(sio,sheet)
sio.rewind
return sio.read
end
end
# returns a matrix object from the whole sheet or a rectangular area of a sheet
def to_matrix(from_row=nil, from_column=nil, to_row=nil, to_column=nil,sheet=nil)
require 'matrix'
sheet ||= @default_sheet
return Matrix.empty unless first_row
Matrix.rows((from_row||first_row(sheet)).upto(to_row||last_row(sheet)).map do |row|
(from_column||first_column(sheet)).upto(to_column||last_column(sheet)).map do |col|
cell(row,col)
end
end)
end
# find a row either by row number or a condition
# Caution: this works only within the default sheet -> set default_sheet before you call this method
# (experimental. see examples in the test_roo.rb file)
def find(*args) # :nodoc
options = (args.last.is_a?(Hash) ? args.pop : {})
result_array = options[:array]
header_for = Hash[1.upto(last_column).map do |col|
[col, cell(@header_line,col)]
end]
#-- id
if args[0].class == Fixnum
rownum = args[0]
if @header_line
[Hash[1.upto(self.row().size).map {|j|
[header_for.fetch(j), cell(rownum,j)]
}]]
else
self.row(rownum).size.times.map {|j|
cell(rownum,j + 1)
}
end
#-- :all
elsif args[0] == :all
rows = first_row.upto(last_row)
# are all conditions met?
if (conditions = options[:conditions]) && !conditions.empty?
column_with = header_for.invert
rows = rows.select do |i|
conditions.all? { |key,val| cell(i,column_with[key]) == val }
end
end
rows.map do |i|
if result_array
self.row(i)
else
Hash[1.upto(self.row(i).size).map do |j|
[header_for.fetch(j), cell(i,j)]
end]
end
end
end
end
# returns all values in this row as an array
# row numbers are 1,2,3,... like in the spreadsheet
def row(rownumber,sheet=nil)
sheet ||= @default_sheet
read_cells(sheet)
first_column(sheet).upto(last_column(sheet)).map do |col|
cell(rownumber,col,sheet)
end
end
# returns all values in this column as an array
# column numbers are 1,2,3,... like in the spreadsheet
def column(columnnumber,sheet=nil)
if columnnumber.class == String
columnnumber = Roo::Excel.letter_to_number(columnnumber)
end
sheet ||= @default_sheet
read_cells(sheet)
first_row(sheet).upto(last_row(sheet)).map do |row|
cell(row,columnnumber,sheet)
end
end
# set a cell to a certain value
# (this will not be saved back to the spreadsheet file!)
def set(row,col,value,sheet=nil) #:nodoc:
sheet ||= @default_sheet
read_cells(sheet)
row, col = normalize(row,col)
cell_type = case value
when Fixnum then :float
when String, Float then :string
else
raise ArgumentError, "Type for #{value} not set"
end
set_value(row,col,value,sheet)
set_type(row,col,cell_type,sheet)
end
# reopens and read a spreadsheet document
def reload
ds = @default_sheet
reinitialize
self.default_sheet = ds
end
# true if cell is empty
def empty?(row, col, sheet=nil)
sheet ||= @default_sheet
read_cells(sheet)
row,col = normalize(row,col)
contents = cell(row, col, sheet)
!contents || (celltype(row, col, sheet) == :string && contents.empty?) \
|| (row < first_row(sheet) || row > last_row(sheet) || col < first_column(sheet) || col > last_column(sheet))
end
# returns information of the spreadsheet document and all sheets within
# this document.
def info
result = "File: #{File.basename(@filename)}\n"+
"Number of sheets: #{sheets.size}\n"+
"Sheets: #{sheets.join(', ')}\n"
n = 1
sheets.each {|sheet|
self.default_sheet = sheet
result << "Sheet " + n.to_s + ":\n"
unless first_row
result << " - empty -"
else
result << " First row: #{first_row}\n"
result << " Last row: #{last_row}\n"
result << " First column: #{Roo::Base.number_to_letter(first_column)}\n"
result << " Last column: #{Roo::Base.number_to_letter(last_column)}"
end
result << "\n" if sheet != sheets.last
n += 1
}
result
end
# returns an XML representation of all sheets of a spreadsheet file
def to_xml
Nokogiri::XML::Builder.new do |xml|
xml.spreadsheet {
self.sheets.each do |sheet|
self.default_sheet = sheet
xml.sheet(:name => sheet) { |x|
if first_row and last_row and first_column and last_column
# sonst gibt es Fehler bei leeren Blaettern
first_row.upto(last_row) do |row|
first_column.upto(last_column) do |col|
unless empty?(row,col)
x.cell(cell(row,col),
:row =>row,
:column => col,
:type => celltype(row,col))
end
end
end
end
}
end
}
end.to_xml
end
# when a method like spreadsheet.a42 is called
# convert it to a call of spreadsheet.cell('a',42)
def method_missing(m, *args)
# #aa42 => #cell('aa',42)
# #aa42('Sheet1') => #cell('aa',42,'Sheet1')
if m =~ /^([a-z]+)(\d)$/
col = Roo::Base.letter_to_number($1)
row = $2.to_i
if args.empty?
cell(row,col)
else
cell(row,col,args.first)
end
else
super
end
end
=begin
#TODO: hier entfernen
# returns each formula in the selected sheet as an array of elements
# [row, col, formula]
def formulas(sheet=nil)
theformulas = Array.new
sheet ||= @default_sheet
read_cells(sheet)
return theformulas unless first_row(sheet) # if there is no first row then
# there can't be formulas
first_row(sheet).upto(last_row(sheet)) {|row|
first_column(sheet).upto(last_column(sheet)) {|col|
if formula?(row,col,sheet)
theformulas << [row, col, formula(row,col,sheet)]
end
}
}
theformulas
end
=end
# FestivalBobcats fork changes begin here
# access different worksheets by calling spreadsheet.sheet(1)
# or spreadsheet.sheet('SHEETNAME')
def sheet(index,name=false)
@default_sheet = String === index ? index : self.sheets[index]
name ? [@default_sheet,self] : self
end
# iterate through all worksheets of a document
def each_with_pagename
self.sheets.each do |s|
yield sheet(s,true)
end
end
# by passing in headers as options, this method returns
# specific columns from your header assignment
# for example:
# xls.sheet('New Prices').parse(:upc => 'UPC', :price => 'Price') would return:
# [{:upc => 123456789012, :price => 35.42},..]
# the queries are matched with regex, so regex options can be passed in
# such as :price => '^(Cost|Price)'
# case insensitive by default
# by using the :header_search option, you can query for headers
# and return a hash of every row with the keys set to the header result
# for example:
# xls.sheet('New Prices').parse(:header_search => ['UPC*SKU','^Price*\sCost\s'])
# that example searches for a column titled either UPC or SKU and another
# column titled either Price or Cost (regex characters allowed)
# * is the wildcard character
# you can also pass in a :clean => true option to strip the sheet of
# odd unicode characters and white spaces around columns
def each(options={})
if options.empty?
1.upto(last_row) do |line|
yield row(line)
end
else
if options[:clean]
options.delete(:clean)
@cleaned ||= {}
@cleaned[@default_sheet] || clean_sheet(@default_sheet)
end
if options[:header_search]
@headers = nil
@header_line = row_with(options[:header_search])
elsif [:first_row,true].include?(options[:headers])
@headers = []
row(first_row).each_with_index {|x,i| @headers << [x,i + 1]}
else
set_headers(options)
end
headers = @headers ||
Hash[(first_column..last_column).map do |col|
[cell(@header_line,col), col]
end]
@header_line.upto(last_row) do |line|
yield(Hash[headers.map {|k,v| [k,cell(line,v)]}])
end
end
end
def parse(options={})
ary = []
if block_given?
each(options) {|row| ary << yield(row)}
else
each(options) {|row| ary << row}
end
ary
end
def row_with(query,return_headers=false)
query.map! {|x| Array(x.split('*'))}
line_no = 0
each do |row|
line_no += 1
# makes sure headers is the first part of wildcard search for priority
# ex. if UPC and SKU exist for UPC*SKU search, UPC takes the cake
headers = query.map do |q|
q.map {|i| row.grep(/#{i}/i)[0]}.compact[0]
end.compact
if headers.length == query.length
@header_line = line_no
return return_headers ? headers : line_no
elsif line_no > 100
raise "Couldn't find header row."
end
end
end
# this method lets you find the worksheet with the most data
def longest_sheet
sheet(@workbook.worksheets.inject {|m,o|
o.row_count > m.row_count ? o : m
}.name)
end
protected
def file_type_check(filename, ext, name, warning_level, packed=nil)
new_expression = {
'.ods' => 'Roo::OpenOffice.new',
'.xls' => 'Roo::Excel.new',
'.xlsx' => 'Roo::Excelx.new',
'.csv' => 'Roo::CSV.new',
'.xml' => 'Roo::Excel2003XML.new',
}
if packed == :zip
# lalala.ods.zip => lalala.ods
# hier wird KEIN unzip gemacht, sondern nur der Name der Datei
# getestet, falls es eine gepackte Datei ist.
filename = File.basename(filename,File.extname(filename))
end
case ext
when '.ods', '.xls', '.xlsx', '.csv', '.xml'
correct_class = "use #{new_expression[ext]} to handle #{ext} spreadsheet files. This has #{File.extname(filename).downcase}"
else
raise "unknown file type: #{ext}"
end
if uri?(filename) && qs_begin = filename.rindex('?')
filename = filename[0..qs_begin-1]
end
if File.extname(filename).downcase != ext
case warning_level
when :error
warn correct_class
raise TypeError, "#{filename} is not #{name} file"
when :warning
warn "are you sure, this is #{name} spreadsheet file?"
warn correct_class
when :ignore
# ignore
else
raise "#{warning_level} illegal state of file_warning"
end
end
end
# konvertiert einen Key in der Form "12,45" (=row,column) in
# ein Array mit numerischen Werten ([12,45])
# Diese Methode ist eine temp. Loesung, um zu erforschen, ob der
# Zugriff mit numerischen Keys schneller ist.
def key_to_num(str)
r,c = str.split(',')
[r.to_i,c.to_i]
end
# see: key_to_num
def key_to_string(arr)
"#{arr[0]},#{arr[1]}"
end
private
def reinitialize
initialize(@filename)
end
def make_tmpdir(tmp_root = nil)
Dir.mktmpdir(TEMP_PREFIX, tmp_root || ENV['ROO_TMP']) do |tmpdir|
yield tmpdir
end
end
def clean_sheet(sheet)
read_cells(sheet)
@cell[sheet].each_pair do |coord,value|
if String === value
@cell[sheet][coord] = sanitize_value(value)
end
end
@cleaned[sheet] = true
end
def sanitize_value(v)
v.strip.unpack('U*').select {|b| b < 127}.pack('U*')
end
def set_headers(hash={})
# try to find header row with all values or give an error
# then create new hash by indexing strings and keeping integers for header array
@headers = row_with(hash.values,true)
@headers = Hash[hash.keys.zip(@headers.map {|x| header_index(x)})]
end
def header_index(query)
row(@header_line).index(query) + first_column
end
def set_value(row,col,value,sheet=nil)
sheet ||= @default_sheet
@cell[sheet][[row,col]] = value
end
def set_type(row,col,type,sheet=nil)
sheet ||= @default_sheet
@cell_type[sheet][[row,col]] = type
end
# converts cell coordinate to numeric values of row,col
def normalize(row,col)
if row.class == String
if col.class == Fixnum
# ('A',1):
# ('B', 5) -> (5, 2)
row, col = col, row
else
raise ArgumentError
end
end
if col.class == String
col = Roo::Base.letter_to_number(col)
end
return row,col
end
def uri?(filename)
filename.start_with?("http://", "https://")
end
def open_from_uri(uri, tmpdir)
require 'open-uri'
response = ''
begin
open(uri, "User-Agent" => "Ruby/#{RUBY_VERSION}") { |net|
response = net.read
tempfilename = File.join(tmpdir, File.basename(uri))
File.open(tempfilename,"wb") do |file|
file.write(response)
end
}
rescue OpenURI::HTTPError
raise "could not open #{uri}"
end
File.join(tmpdir, File.basename(uri))
end
def open_from_stream(stream, tmpdir)
tempfilename = File.join(tmpdir, "spreadsheet")
File.open(tempfilename,"wb") do |file|
file.write(stream[7..-1])
end
File.join(tmpdir, "spreadsheet")
end
LETTERS = %w{A B C D E F G H I J K L M N O P Q R S T U V W X Y Z}
# convert a number to something like 'AB' (1 => 'A', 2 => 'B', ...)
def self.number_to_letter(n)
letters=""
if n > 26
while n % 26 == 0 && n != 0
letters << 'Z'
n = (n - 26) / 26
end
while n > 0
num = n%26
letters = LETTERS[num-1] + letters
n = (n / 26)
end
else
letters = LETTERS[n-1]
end
letters
end
# convert letters like 'AB' to a number ('A' => 1, 'B' => 2, ...)
def self.letter_to_number(letters)
result = 0
while letters && letters.length > 0
character = letters[0,1].upcase
num = LETTERS.index(character)
raise ArgumentError, "invalid column character '#{letters[0,1]}'" if num == nil
num += 1
result = result * 26 + num
letters = letters[1..-1]
end
result
end
def unzip(filename, tmpdir)
Zip::ZipFile.open(filename) do |zip|
process_zipfile_packed(zip, tmpdir)
end
end
# check if default_sheet was set and exists in sheets-array
def validate_sheet!(sheet)
case sheet
when nil
raise ArgumentError, "Error: sheet 'nil' not valid"
when Fixnum
self.sheets.fetch(sheet-1) do
raise RangeError, "sheet index #{sheet} not found"
end
when String
if !sheets.include? sheet
raise RangeError, "sheet '#{sheet}' not found"
end
else
raise TypeError, "not a valid sheet type: #{sheet.inspect}"
end
end
def process_zipfile_packed(zip, tmpdir, path='')
if zip.file.file? path
# extract and return filename
File.open(File.join(tmpdir, path),"wb") do |file|
file.write(zip.read(path))
end
File.join(tmpdir, path)
else
ret=nil
path += '/' unless path.empty?
zip.dir.foreach(path) do |filename|
ret = process_zipfile_packed(zip, tmpdir, path + filename)
end
ret
end
end
# Write all cells to the csv file. File can be a filename or nil. If the this
# parameter is nil the output goes to STDOUT
def write_csv_content(file=nil,sheet=nil)
file ||= STDOUT
if first_row(sheet) # sheet is not empty
1.upto(last_row(sheet)) do |row|
1.upto(last_column(sheet)) do |col|
file.print(",") if col > 1
file.print cell_to_csv(row,col,sheet)
end
file.print("\n")
end # sheet not empty
end
end
# The content of a cell in the csv output
def cell_to_csv(row, col, sheet)
if empty?(row,col,sheet)
''
else
onecell = cell(row,col,sheet)
case celltype(row,col,sheet)
when :string
unless onecell.empty?
%{"#{onecell.gsub(/"/,'""')}"}
end
when :float, :percentage
if onecell == onecell.to_i
onecell.to_i.to_s
else
onecell.to_s
end
when :formula
case onecell
when String
unless onecell.empty?
%{"#{onecell.gsub(/"/,'""')}"}
end
when Float
if onecell == onecell.to_i
onecell.to_i.to_s
else
onecell.to_s
end
when DateTime
onecell.to_s
else
raise "unhandled onecell-class #{onecell.class}"
end
when :date, :datetime
onecell.to_s
when :time
Roo::Base.integer_to_timestring(onecell)
else
raise "unhandled celltype #{celltype(row,col,sheet)}"
end || ""
end
end
# converts an integer value to a time string like '02:05:06'
def self.integer_to_timestring(content)
h = (content/3600.0).floor
content = content - h*3600
m = (content/60.0).floor
content = content - m*60
s = content
sprintf("%02d:%02d:%02d",h,m,s)
end
end
| 27.97026 | 130 | 0.602383 |
2637d374d462c2a219b2ccc72fd160fdffef74d7 | 330 | require 'test_helper'
class StaticPagesControllerTest < ActionController::TestCase
test "should get about" do
get :about
assert_response :success
end
test "should get contact" do
get :contact
assert_response :success
end
test "should get home" do
get :home
assert_response :success
end
end
| 16.5 | 60 | 0.715152 |
e89af3133a9cb47089d4aeb93eda91a277db4194 | 1,638 | require 'time'
import 'org.apache.hadoop.hbase.client.HTable'
import 'org.apache.hadoop.hbase.client.Put'
import 'javax.xml.stream.XMLStreamConstants'
def jbytes( *args )
args.map { |arg| arg.to_s.to_java_bytes }
end
factory = javax.xml.stream.XMLInputFactory.newInstance
reader = factory.createXMLStreamReader(java.lang.System.in)
document = nil
buffer = nil
count = 0
table = HTable.new( @hbase.configuration, 'wiki' )
table.setAutoFlush( false )
while reader.has_next
type = reader.next
if type == XMLStreamConstants::START_ELEMENT
case reader.local_name
when 'page' then document = {}
when /title|timestamp|username|comment|text/ then buffer = []
end
elsif type == XMLStreamConstants::CHARACTERS
buffer << reader.text unless buffer.nil?
elsif type == XMLStreamConstants::END_ELEMENT
case reader.local_name
when /title|timestamp|username|comment|text/
document[reader.local_name] = buffer.join
when 'revision'
key = document['title'].to_java_bytes
ts = ( Time.parse document['timestamp'] ).to_i
p = Put.new( key, ts )
p.add( *jbytes( "text", "", document['text'] ) )
p.add( *jbytes( "revision", "author", document['username'] ) )
p.add( *jbytes( "revision", "comment", document['comment'] ) )
table.put( p )
count += 1
table.flushCommits() if count % 10 == 0
if count % 500 == 0
puts "#{count} records inserted (#{document['title']})"
end
end
end
end
table.flushCommits()
exit | 34.125 | 74 | 0.622711 |
03748768b1cc0f774fe997deda64cf4ac5c48684 | 889 | {
matrix_id: '1604',
name: 'conf6_0-8x8-80',
group: 'QCD',
description: 'Quantum chromodynamics conf6.0-00l8x8-8000',
author: 'B. Medeke',
editor: 'R. Boisvert, R. Pozo, K. Remington, B. Miller, R. Lipman, R. Barrett, J. Dongarra',
date: '1999',
kind: 'theoretical/quantum chemistry problem',
problem_2D_or_3D: '0',
num_rows: '49152',
num_cols: '49152',
nonzeros: '1916928',
num_explicit_zeros: '0',
num_strongly_connected_components: '1',
num_dmperm_blocks: '2',
structural_full_rank: 'true',
structural_rank: '49152',
pattern_symmetry: '0.923',
numeric_symmetry: '0.462',
rb_type: 'complex',
structure: 'unsymmetric',
cholesky_candidate: 'no',
positive_definite: 'no',
image_files: 'conf6_0-8x8-80.png,conf6_0-8x8-80_dmperm.png,conf6_0-8x8-80_APlusAT_graph.gif,conf6_0-8x8-80_graph.gif,',
}
| 32.925926 | 123 | 0.662542 |
91687a188166ff88b762930b3fdc8f3ef91b176c | 1,474 | # require 'monkeyshines/utils/factory_module'
module Edamame
module Store
class Base
# The actual backing store; should respond to #set and #get methods
attr_accessor :db
def initialize options
end
#
# Executes block once for each element in the whole DB, in whatever order
# the DB thinks you should see it.
#
# Your block will see |key, val|
#
# key_store.each do |key, val|
# # ... stuff ...
# end
#
def each &block
db.iterinit
loop do
key = db.iternext or break
val = db[key]
yield key, val
end
end
def each_as klass, &block
self.each do |key, hsh|
yield [key, klass.from_hash(hsh)]
end
end
# Delegate to store
def set(key, val)
return unless val
db.put key, val.to_hash.compact
end
def save obj
return unless obj
db.put obj.key, obj.to_hash.compact
end
def get(key) db[key] end
def [](key) get(key) end
def put(key, val) db.put key, val end
def close() db.close end
def size() db.size end
def delete(key) db.delete(key) end
#
# Load from standard command-line options
#
# obvs only works when there's just one store
#
def self.create type, options
end
end
end
end
| 23.396825 | 79 | 0.531886 |
08e9070da07b7bcb762278c0bbd2da1938ff8e99 | 601 | class SonarCompletion < Formula
desc "Bash completion for Sonar"
homepage "https://github.com/a1dutch/sonarqube-bash-completion"
url "https://github.com/a1dutch/sonarqube-bash-completion/archive/1.1.tar.gz"
sha256 "506a592b166cff88786ae9e6215f922b8ed3617c65a4a88169211a80ef1c6b66"
license "Apache-2.0"
head "https://github.com/a1dutch/sonarqube-bash-completion.git", branch: "master"
def install
bash_completion.install "etc/bash_completion.d/sonar"
end
test do
assert_match "-F _sonar",
shell_output("source #{bash_completion}/sonar && complete -p sonar")
end
end
| 33.388889 | 83 | 0.758735 |
62abf24e99a4f0201abe779187937e0b31f58e7c | 132 | class JwtBlacklist < ApplicationRecord
include Devise::JWT::RevocationStrategies::Blacklist
self.table_name = 'jwt_blacklist'
end | 26.4 | 53 | 0.825758 |
ff1905859f8154c51e9b1445920f52f8ec0e00a1 | 799 | # frozen_string_literal: true
module Yoti
module Sandbox
module DocScan
module Request
class LivenessCheck < Check
#
# @param [CheckResult] result
# @param [String] liveness_type
#
def initialize(result, liveness_type)
raise(TypeError, "#{self.class} cannot be instantiated") if instance_of?(LivenessCheck)
super(result)
Validation.assert_is_a(String, liveness_type, 'liveness_type')
@liveness_type = liveness_type
end
def to_json(*_args)
as_json.to_json
end
def as_json(*_args)
super.merge(
liveness_type: @liveness_type
).compact
end
end
end
end
end
end
| 22.828571 | 99 | 0.556946 |
f7699f4e422fe055b900b61232903da4cc21559a | 140 | # Be sure to restart your server when you modify this file.
Rails.application.config.session_store :cookie_store, key: '_refugees_session'
| 35 | 78 | 0.807143 |
8777d059167607495284e263ad93f66598386001 | 1,368 | module Fastlane
module Actions
class GetVersionNumberFromGitBranchAction < Action
def self.run(params)
if Helper.test?
branch = 'releases/release-1.3.5'
else
branch = Actions.git_branch
end
pattern = params[:pattern].dup
pattern["#"] = "(.*)"
match = Regexp.new(pattern).match(branch)
UI.user_error!("Cannot find version number in git branch '#{branch}' by pattern '#{params[:pattern]}'") unless match
match[1]
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Extract version number from git branch name"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :pattern,
env_name: "FL_VERSION_NUMBER_FROM_GIT_BRANCH_PATTERN",
description: "Pattern for branch name, should contain # character in place of version number",
default_value: 'release-#',
is_string: true)
]
end
def self.authors
["SiarheiFedartsou"]
end
def self.is_supported?(platform)
%i[ios mac android].include? platform
end
end
end
end
| 29.106383 | 124 | 0.516813 |
6a80b8f6057c3485b4490e01317097aa418d91c1 | 186 | # frozen_string_literal: true
desc 'Ensure PR changes are fully covered by tests'
task :undercover do |_t|
ret =
system('undercover --compare origin/main')
raise unless ret
end
| 20.666667 | 51 | 0.736559 |
1dea33a05ec8a193a9839515d8e225306be0ae04 | 1,729 | class Glew < Formula
desc "OpenGL Extension Wrangler Library"
homepage "http://glew.sourceforge.net/"
url "https://downloads.sourceforge.net/project/glew/glew/1.13.0/glew-1.13.0.tgz"
mirror "https://mirrors.kernel.org/debian/pool/main/g/glew/glew_1.13.0.orig.tar.gz"
sha256 "aa25dc48ed84b0b64b8d41cdd42c8f40f149c37fa2ffa39cd97f42c78d128bc7"
head "https://github.com/nigels-com/glew.git"
bottle do
cellar :any
sha256 "a0d99f5538ffc0a182f227934753b0129b5b6cdfdc790cf7ef208fb4d8b00845" => :el_capitan
sha256 "351ff9dbee1b1307720a2e3ad8e86c28975b3bc2614cfbc7ae45492cb3810062" => :yosemite
sha256 "a8d8c2095176c09b10667627de9861b0e35d310bcd860922a2be4037a3e6418c" => :mavericks
end
option :universal
def install
# Makefile directory race condition on lion
ENV.deparallelize
if build.universal?
ENV.universal_binary
# Do not strip resulting binaries; https://sourceforge.net/p/glew/bugs/259/
ENV["STRIP"] = ""
end
inreplace "glew.pc.in", "Requires: @requireslib@", ""
system "make", "GLEW_PREFIX=#{prefix}", "GLEW_DEST=#{prefix}", "all"
system "make", "GLEW_PREFIX=#{prefix}", "GLEW_DEST=#{prefix}", "install.all"
doc.install Dir["doc/*"]
end
test do
(testpath/"test.c").write <<-EOS.undent
#include <GL/glew.h>
#include <GLUT/glut.h>
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutCreateWindow("GLEW Test");
GLenum err = glewInit();
if (GLEW_OK != err) {
return 1;
}
return 0;
}
EOS
system ENV.cc, "-framework", "OpenGL", "-framework", "GLUT",
"-lglew", testpath/"test.c", "-o", "test"
system "./test"
end
end
| 30.875 | 92 | 0.663968 |
abaf9f515ad6c36b68f26ecf4a7948ff963f98cd | 373 | class Address < ApplicationRecord
has_and_belongs_to_many :device
before_validation :ensure_has_slug
def to_s
"0x%02x" % address
end
def to_slug(string)
string.parameterize.truncate(80, omission: '')
end
def to_param
slug
end
private
def ensure_has_slug
if slug.nil? || slug.empty?
self.slug = to_slug(to_s())
end
end
end
| 14.92 | 50 | 0.686327 |
87d8a48ea5cc9b3bc945087a60242529545f6ec8 | 267 | require 'spec_helper'
module BlockCypherClient
module Bitcoin
RSpec.describe BaseResponse do
it "inherits from BlockCypherClient::BaseResponse" do
expect(described_class < BlockCypherClient::BaseResponse).to be true
end
end
end
end
| 19.071429 | 76 | 0.734082 |
6a0340b96602adbf8805d6704621440a06c872cf | 2,668 | #
# Cookbook:: filesystem
# Provider:: filebacked
#
# Copyright:: 2013-2017, Alex Trull
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
use_inline_resources
action :create do
file = @new_resource.name
size = @new_resource.size
sparse = @new_resource.sparse
device = @new_resource.device
# Idempotent behaviour:
# Case 1) File found, Loopback found => return loopback.
# Case 2) File found, Loopback missing => create loopback, return loopback.
# Case 3) File missing, Loopback missing => create file and loopback, return loopback.
create_loopback = "losetup #{device} #{file}"
get_loopback_cmd = "losetup -a | grep #{file} | grep #{device}"
loopback = Mixlib::ShellOut.new(get_loopback_cmd).run_command.stdout.gsub(/: \[.*/, '').strip
if ::File.exist?(file) && device == loopback
# Case 1)
# File and Loopback found - nothing to do.
log "Device #{loopback} already exists for #{file}"
elsif ::File.exist?(file) && device != loopback
# Case 2)
# File but no loopback - so we make a loopback
log "Creating #{device} for #{file}"
execute create_loopback do
only_if "ls #{file} >/dev/null"
end
elsif !size.nil?
# Case 3)
# If we have a size, we can create the file..
# We make sure a directory exists for the file to live in.
directory ::File.dirname(file) do
recursive true
end
# We pick the file creation method
file_creation_cmd = if sparse
# We default to speedy file creation.
"dd bs=1M count=0 seek=#{size} of=\"#{file}\""
else
# If not sparse we use zeros - this takes much longer.
"dd bs=1M count=#{size} if=/dev/zero of=\"#{file}\""
end
log "Creating #{file}"
# We create the file
execute file_creation_cmd do
not_if "ls #{file} >/dev/null"
end
# If the file was created, we make a loopback device for the file and return the loopback result.
log "Creating #{device} for #{file}"
execute create_loopback do
only_if "ls #{file} >/dev/null"
end
end
end
| 31.023256 | 101 | 0.643553 |
ac9b4a460af6d7a43058f18c79fa6e6bce8d35af | 1,657 | # frozen_string_literal: true
require 'solidus_starter_frontend_helper'
RSpec.describe 'orders', type: :system do
let(:order) { Spree::TestingSupport::OrderWalkthrough.up_to(:complete) }
let(:user) { create(:user) }
before do
order.update_attribute(:user_id, user.id)
allow_any_instance_of(Spree::OrdersController).to receive_messages(try_spree_current_user: user)
end
it "can visit an order" do
# Regression test for current_user call on orders/show
visit spree.order_path(order)
end
it "should display line item price" do
# Regression test for https://github.com/spree/spree/issues/2772
line_item = order.line_items.first
line_item.target_shipment = create(:shipment)
line_item.price = 19.00
line_item.save!
visit spree.order_path(order)
# Tests view spree/shared/_order_details
within '.order-item__price-single' do
expect(page).to have_content "19.00"
end
end
it "should have credit card info if paid with credit card" do
create(:payment, order: order)
visit spree.order_path(order)
within '.payment-info' do
expect(page).to have_content "Ending in 1111"
end
end
it "should have payment method name visible if not paid with credit card" do
create(:check_payment, order: order)
visit spree.order_path(order)
within '.payment-info' do
expect(page).to have_content "Check"
end
end
it "should return the correct title when displaying a completed order" do
visit spree.order_path(order)
within '#order_summary' do
expect(page).to have_content("#{I18n.t('spree.order')} #{order.number}")
end
end
end
| 28.568966 | 100 | 0.713941 |
284fa13aabc30911b49c0b30151b78f50288c5d8 | 1,326 | require 'rails_helper'
RSpec.describe CoUsersController, type: :controller do
let!(:user) { create :user }
let(:account) { create :account }
let(:rule) { create(:rule, spending_limit: 0.0)}
let!(:usr_acc) { create(:account_user,
user_id: user.id,
account_id: account.id,
rule_id: rule.id,
role_id: 2) }
let!(:limit) { create(:limit, account_user_id: usr_acc.id, reminder: rule.spending_limit) }
before { sign_in user }
describe 'GET show' do
it 'has a 200 status code' do
get :show, params: { account_id: account.id, id: user.id }
expect(response).to have_http_status :ok
end
it 'render index template' do
get :show, params: { account_id: account.id, id: user.id }
expect(response).to render_template :show
end
end
describe 'PATCH update' do
it 'has a 302 status code' do
patch :update, params: { account_id: account.hash_id, id: user.id, account_rule: { spending_limit: 20} }
expect(response).to have_http_status :found
end
it 'render index template' do
patch :update, params: { account_id: account.id, id: user.id, account_rule: { spending_limit: 20} }
expect(response).to redirect_to :account_co_user
end
end
end
| 34 | 110 | 0.625189 |
2838ca4307c7db5746aa09da2f133054732afe6b | 5,056 | users_list = [
["Bob", "[email protected]", "23reu"],
["Hongki","[email protected]", "rhagfsdr"],
["Jessice","[email protected]","dsfg"],
["Amber","[email protected]","fsdg"],
["Roger","[email protected]","fdsg"],
["Jaebum","[email protected]","rgsafsrg"],
["Alex","[email protected]","fsgs"],
["Jamal","[email protected]","dfg"],
["Dpr","[email protected]" "rwgdar"],
["Nelson","[email protected]","rgfs"],
["Matt","[email protected]","gfsg"],
["Leon","[email protected]","jiyongie"],
["G-dragon","[email protected]", "rwgrasdg"],
["Paul","[email protected]","jiyongie"],
["Janice","[email protected]","rtgfs"],
["Will","[email protected]","ban"],
["Dai","[email protected]","egrf"],
["Soohyun", "[email protected]", "regag"]
]
@all_users = []
users_list.each do |name, email, password|
@all_users << User.create(name: name, email: email, password: password)
end
groups_list = [
["Parents Forum", "We give each other advice on issues that we might be having with our children"],
["Coders-Around the World","We help each other strengthen our coding abilities"],
["We Hate Cats","I guess its not that we hate it... we are just allergic and would rather stay away. Share your feline horror stories. We all know that they are really out to get us.... one day they will take over the world if we aren't careful"],
["Weeb Life","Are you about that weeb life? Need some cosplay ideas? Maybe you are stuck on how to make something pratical for wearing... WE ARE HERE TO HELP!"],
["We Aren't Crazy...","The goverment is hiding secrets!!! From UFO's to the Bermuda triangle.. they have their dirty fingers in EVERYTHING!!! Join us in the fight against the unknown. You will have to provide your own tin-foil hat. No lizard people allowed! "],
["Foodies","We are dedicated to sharing recipes, the go to food spots, and advice to improve your instagram foodies photos!"],
["Memes","Do you know dey way?"]
]
@all_groups = []
groups_list.each do |name, bio|
@all_groups << Group.create(name: name, bio: bio)
end
@all_users.each do |user|
@group = @all_groups[rand 7]
user.group = @group
user.save
end
users_post = ["I love this group!",
"Have you heard what is going on with the virus?",
"I wish I could meet up with you all in person.",
"I am new to the group. I can't wait to get to know you all!",
"What's the weather like in your area guys?",
"I have no idea what to put to be honest so... supp guys?",
"I really could go for a sandwich right about now!",
"Weather has been CRAZY these last few days.",
"I think I might be in the wrong group.... but I guess I will stay.",
"Is anyone working on anything big they would like to share?",
"Hey guys, my numnber is 1-800-573-5793",
"Do you guys think there is life on Mars?... off topic but... yea?",
"Lets-meet would be cooler if it was a blue background",
"HEY!",
"Wassup!",
"What's good?",
"I am really running out of things to talk about with you guys.",
"I am thinking about leaving this group.. you guys are cool just... its me... not you.",
"I really want some ice cream right meow",
"What's your guys favorite movie?",
"Its kinda crazy how we are never on the same topic... why dont you guys ever reply to each other... you guys suckkk XD",
"My favorite color is red... whats yours?",
"I am currently attending school at Flatiron so.. I might get busy and not have a lot of time to be active here soon",
"Dude have you see the photos of people buying all the tp? What is up with that?!",
"There were tornadoes here last night... I just thought you should know.",
"Lets take a trip to Hawaii",
"I don't know about you guys but the new sonic movie was LITTT",
"This groups sucks... you guys suck..",
"TROLLOLOLOLOLOLOLOLOLOLOLOLOLOL",
"Dope... I am in a group now!",
"SUHHHHHHHH UP I am new here... what it do lol",
"Anyone free for a video cam chat.. having a hard day and would love a pick me up",
"I really don't know who to talk to about this but... there's this weird mole on my back and... its ugly man",
"Do any of you watch Westworld? Show is legit the best!",
"Have you seen devs? Its pretty cool man!",
"I wish I could take a break and just go on a vacay man",
"I hear that Trump is going to get impeached... whatcha think about that?",
"Drugs are bad.... mmmmmmkkkkaaayyy",
"Theres no I in team... but you can make a me... JUST SAYING",
"What's the weirdest thing you guys have ever done?",
"Do you guys wanna meet up in RL?",
"ASL?"
]
@all_post = []
users_post.each do |content|
@all_post << Post.create(content: content)
end
def rand_in_range(from, to)
rand * (to - from) + from
end
def rand_time(from, to=Time.now)
Time.at(rand_in_range(from.to_f, to.to_f))
end
@all_post.each do |post|
@user = @all_users[rand 20]
post.user = @user
post.published = rand_time((rand 20).days.ago)
post.save
end | 48.152381 | 265 | 0.661986 |
01381cb9e7bfc5d787520ebd7c9ae0ff437308ae | 1,599 | # Description : This plugin checks code blocks created using `or```
# in their markdown state for special characters that can cause problem in terminal.
# Authour : Reza R <[email protected]>
#####
Jekyll::Hooks.register :pages, :pre_render do |post|
# do nothing if url indicates legal folder
if !post.path.match(/\/legal\//)
occurrences = []
# Check post content and extract code blocks
post.content.scan(/(?:[`]{3}|(?<!`)[`](?!`))(.*?)(?:[`]{3}|(?<!`)[`](?!`))/m){ |match|
# Check all matched cases
match.each do |block|
# convert each character to an array of Decimal numbers
# and iterate each character.
block.codepoints.each_with_index do |b_chr, idx|
# \n (9) and \t (10) are exceptions for this block
if ( b_chr < 32 && ![9,10].include?(b_chr) ) || b_chr > 126
occurrences.append({'code' => block, 'idx' => idx})
end
end
end
}
# were there any special characters?
if occurrences.length > 0
occurrences.each do |sentence|
# printing line to user
print(sentence['code'][sentence['idx']-10..sentence['idx']+10].strip)
# printing position of the character
print("\n"+" "*10 + "^~~~~~~~~~~~\n")
end
# Stop compiling
raise "\n Unexpected character in codeblock detected: #{post.path}"
end
end
end
| 44.416667 | 94 | 0.52783 |
1afe2b46a4602309c4c8d7c75a2c1686ed3dc661 | 261,455 | # WARNING ABOUT GENERATED CODE
#
# This file is generated. See the contributing guide for more information:
# https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
#
# WARNING ABOUT GENERATED CODE
require 'seahorse/client/plugins/content_length.rb'
require 'aws-sdk-core/plugins/credentials_configuration.rb'
require 'aws-sdk-core/plugins/logging.rb'
require 'aws-sdk-core/plugins/param_converter.rb'
require 'aws-sdk-core/plugins/param_validator.rb'
require 'aws-sdk-core/plugins/user_agent.rb'
require 'aws-sdk-core/plugins/helpful_socket_errors.rb'
require 'aws-sdk-core/plugins/retry_errors.rb'
require 'aws-sdk-core/plugins/global_configuration.rb'
require 'aws-sdk-core/plugins/regional_endpoint.rb'
require 'aws-sdk-core/plugins/endpoint_discovery.rb'
require 'aws-sdk-core/plugins/endpoint_pattern.rb'
require 'aws-sdk-core/plugins/response_paging.rb'
require 'aws-sdk-core/plugins/stub_responses.rb'
require 'aws-sdk-core/plugins/idempotency_token.rb'
require 'aws-sdk-core/plugins/jsonvalue_converter.rb'
require 'aws-sdk-core/plugins/client_metrics_plugin.rb'
require 'aws-sdk-core/plugins/client_metrics_send_plugin.rb'
require 'aws-sdk-core/plugins/transfer_encoding.rb'
require 'aws-sdk-core/plugins/signature_v4.rb'
require 'aws-sdk-core/plugins/protocols/json_rpc.rb'
Aws::Plugins::GlobalConfiguration.add_identifier(:devicefarm)
module Aws::DeviceFarm
class Client < Seahorse::Client::Base
include Aws::ClientStubs
@identifier = :devicefarm
set_api(ClientApi::API)
add_plugin(Seahorse::Client::Plugins::ContentLength)
add_plugin(Aws::Plugins::CredentialsConfiguration)
add_plugin(Aws::Plugins::Logging)
add_plugin(Aws::Plugins::ParamConverter)
add_plugin(Aws::Plugins::ParamValidator)
add_plugin(Aws::Plugins::UserAgent)
add_plugin(Aws::Plugins::HelpfulSocketErrors)
add_plugin(Aws::Plugins::RetryErrors)
add_plugin(Aws::Plugins::GlobalConfiguration)
add_plugin(Aws::Plugins::RegionalEndpoint)
add_plugin(Aws::Plugins::EndpointDiscovery)
add_plugin(Aws::Plugins::EndpointPattern)
add_plugin(Aws::Plugins::ResponsePaging)
add_plugin(Aws::Plugins::StubResponses)
add_plugin(Aws::Plugins::IdempotencyToken)
add_plugin(Aws::Plugins::JsonvalueConverter)
add_plugin(Aws::Plugins::ClientMetricsPlugin)
add_plugin(Aws::Plugins::ClientMetricsSendPlugin)
add_plugin(Aws::Plugins::TransferEncoding)
add_plugin(Aws::Plugins::SignatureV4)
add_plugin(Aws::Plugins::Protocols::JsonRpc)
# @overload initialize(options)
# @param [Hash] options
# @option options [required, Aws::CredentialProvider] :credentials
# Your AWS credentials. This can be an instance of any one of the
# following classes:
#
# * `Aws::Credentials` - Used for configuring static, non-refreshing
# credentials.
#
# * `Aws::InstanceProfileCredentials` - Used for loading credentials
# from an EC2 IMDS on an EC2 instance.
#
# * `Aws::SharedCredentials` - Used for loading credentials from a
# shared file, such as `~/.aws/config`.
#
# * `Aws::AssumeRoleCredentials` - Used when you need to assume a role.
#
# When `:credentials` are not configured directly, the following
# locations will be searched for credentials:
#
# * `Aws.config[:credentials]`
# * The `:access_key_id`, `:secret_access_key`, and `:session_token` options.
# * ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']
# * `~/.aws/credentials`
# * `~/.aws/config`
# * EC2 IMDS instance profile - When used by default, the timeouts are
# very aggressive. Construct and pass an instance of
# `Aws::InstanceProfileCredentails` to enable retries and extended
# timeouts.
#
# @option options [required, String] :region
# The AWS region to connect to. The configured `:region` is
# used to determine the service `:endpoint`. When not passed,
# a default `:region` is search for in the following locations:
#
# * `Aws.config[:region]`
# * `ENV['AWS_REGION']`
# * `ENV['AMAZON_REGION']`
# * `ENV['AWS_DEFAULT_REGION']`
# * `~/.aws/credentials`
# * `~/.aws/config`
#
# @option options [String] :access_key_id
#
# @option options [Boolean] :active_endpoint_cache (false)
# When set to `true`, a thread polling for endpoints will be running in
# the background every 60 secs (default). Defaults to `false`.
#
# @option options [Boolean] :client_side_monitoring (false)
# When `true`, client-side metrics will be collected for all API requests from
# this client.
#
# @option options [String] :client_side_monitoring_client_id ("")
# Allows you to provide an identifier for this client which will be attached to
# all generated client side metrics. Defaults to an empty string.
#
# @option options [String] :client_side_monitoring_host ("127.0.0.1")
# Allows you to specify the DNS hostname or IPv4 or IPv6 address that the client
# side monitoring agent is running on, where client metrics will be published via UDP.
#
# @option options [Integer] :client_side_monitoring_port (31000)
# Required for publishing client metrics. The port that the client side monitoring
# agent is running on, where client metrics will be published via UDP.
#
# @option options [Aws::ClientSideMonitoring::Publisher] :client_side_monitoring_publisher (Aws::ClientSideMonitoring::Publisher)
# Allows you to provide a custom client-side monitoring publisher class. By default,
# will use the Client Side Monitoring Agent Publisher.
#
# @option options [Boolean] :convert_params (true)
# When `true`, an attempt is made to coerce request parameters into
# the required types.
#
# @option options [Boolean] :disable_host_prefix_injection (false)
# Set to true to disable SDK automatically adding host prefix
# to default service endpoint when available.
#
# @option options [String] :endpoint
# The client endpoint is normally constructed from the `:region`
# option. You should only configure an `:endpoint` when connecting
# to test endpoints. This should be avalid HTTP(S) URI.
#
# @option options [Integer] :endpoint_cache_max_entries (1000)
# Used for the maximum size limit of the LRU cache storing endpoints data
# for endpoint discovery enabled operations. Defaults to 1000.
#
# @option options [Integer] :endpoint_cache_max_threads (10)
# Used for the maximum threads in use for polling endpoints to be cached, defaults to 10.
#
# @option options [Integer] :endpoint_cache_poll_interval (60)
# When :endpoint_discovery and :active_endpoint_cache is enabled,
# Use this option to config the time interval in seconds for making
# requests fetching endpoints information. Defaults to 60 sec.
#
# @option options [Boolean] :endpoint_discovery (false)
# When set to `true`, endpoint discovery will be enabled for operations when available. Defaults to `false`.
#
# @option options [Aws::Log::Formatter] :log_formatter (Aws::Log::Formatter.default)
# The log formatter.
#
# @option options [Symbol] :log_level (:info)
# The log level to send messages to the `:logger` at.
#
# @option options [Logger] :logger
# The Logger instance to send log messages to. If this option
# is not set, logging will be disabled.
#
# @option options [String] :profile ("default")
# Used when loading credentials from the shared credentials file
# at HOME/.aws/credentials. When not specified, 'default' is used.
#
# @option options [Float] :retry_base_delay (0.3)
# The base delay in seconds used by the default backoff function.
#
# @option options [Symbol] :retry_jitter (:none)
# A delay randomiser function used by the default backoff function. Some predefined functions can be referenced by name - :none, :equal, :full, otherwise a Proc that takes and returns a number.
#
# @see https://www.awsarchitectureblog.com/2015/03/backoff.html
#
# @option options [Integer] :retry_limit (3)
# The maximum number of times to retry failed requests. Only
# ~ 500 level server errors and certain ~ 400 level client errors
# are retried. Generally, these are throttling errors, data
# checksum errors, networking errors, timeout errors and auth
# errors from expired credentials.
#
# @option options [Integer] :retry_max_delay (0)
# The maximum number of seconds to delay between retries (0 for no limit) used by the default backoff function.
#
# @option options [String] :secret_access_key
#
# @option options [String] :session_token
#
# @option options [Boolean] :simple_json (false)
# Disables request parameter conversion, validation, and formatting.
# Also disable response data type conversions. This option is useful
# when you want to ensure the highest level of performance by
# avoiding overhead of walking request parameters and response data
# structures.
#
# When `:simple_json` is enabled, the request parameters hash must
# be formatted exactly as the DynamoDB API expects.
#
# @option options [Boolean] :stub_responses (false)
# Causes the client to return stubbed responses. By default
# fake responses are generated and returned. You can specify
# the response data to return or errors to raise by calling
# {ClientStubs#stub_responses}. See {ClientStubs} for more information.
#
# ** Please note ** When response stubbing is enabled, no HTTP
# requests are made, and retries are disabled.
#
# @option options [Boolean] :validate_params (true)
# When `true`, request parameters are validated before
# sending the request.
#
# @option options [URI::HTTP,String] :http_proxy A proxy to send
# requests through. Formatted like 'http://proxy.com:123'.
#
# @option options [Float] :http_open_timeout (15) The number of
# seconds to wait when opening a HTTP session before rasing a
# `Timeout::Error`.
#
# @option options [Integer] :http_read_timeout (60) The default
# number of seconds to wait for response data. This value can
# safely be set
# per-request on the session yeidled by {#session_for}.
#
# @option options [Float] :http_idle_timeout (5) The number of
# seconds a connection is allowed to sit idble before it is
# considered stale. Stale connections are closed and removed
# from the pool before making a request.
#
# @option options [Float] :http_continue_timeout (1) The number of
# seconds to wait for a 100-continue response before sending the
# request body. This option has no effect unless the request has
# "Expect" header set to "100-continue". Defaults to `nil` which
# disables this behaviour. This value can safely be set per
# request on the session yeidled by {#session_for}.
#
# @option options [Boolean] :http_wire_trace (false) When `true`,
# HTTP debug output will be sent to the `:logger`.
#
# @option options [Boolean] :ssl_verify_peer (true) When `true`,
# SSL peer certificates are verified when establishing a
# connection.
#
# @option options [String] :ssl_ca_bundle Full path to the SSL
# certificate authority bundle file that should be used when
# verifying peer certificates. If you do not pass
# `:ssl_ca_bundle` or `:ssl_ca_directory` the the system default
# will be used if available.
#
# @option options [String] :ssl_ca_directory Full path of the
# directory that contains the unbundled SSL certificate
# authority files for verifying peer certificates. If you do
# not pass `:ssl_ca_bundle` or `:ssl_ca_directory` the the
# system default will be used if available.
#
def initialize(*args)
super
end
# @!group API Operations
# Creates a device pool.
#
# @option params [required, String] :project_arn
# The ARN of the project for the device pool.
#
# @option params [required, String] :name
# The device pool's name.
#
# @option params [String] :description
# The device pool's description.
#
# @option params [required, Array<Types::Rule>] :rules
# The device pool's rules.
#
# @option params [Integer] :max_devices
# The number of devices that Device Farm can add to your device pool.
# Device Farm adds devices that are available and that meet the criteria
# that you assign for the `rules` parameter. Depending on how many
# devices meet these constraints, your device pool might contain fewer
# devices than the value for this parameter.
#
# By specifying the maximum number of devices, you can control the costs
# that you incur by running tests.
#
# @return [Types::CreateDevicePoolResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::CreateDevicePoolResult#device_pool #device_pool} => Types::DevicePool
#
#
# @example Example: To create a new device pool
#
# # The following example creates a new device pool named MyDevicePool inside an existing project.
#
# resp = client.create_device_pool({
# name: "MyDevicePool", # A device pool contains related devices, such as devices that run only on Android or that run only on iOS.
# description: "My Android devices",
# project_arn: "arn:aws:devicefarm:us-west-2:123456789101:project:EXAMPLE-GUID-123-456", # You can get the project ARN by using the list-projects CLI command.
# rules: [
# ],
# })
#
# resp.to_h outputs the following:
# {
# device_pool: {
# },
# }
#
# @example Request syntax with placeholder values
#
# resp = client.create_device_pool({
# project_arn: "AmazonResourceName", # required
# name: "Name", # required
# description: "Message",
# rules: [ # required
# {
# attribute: "ARN", # accepts ARN, PLATFORM, FORM_FACTOR, MANUFACTURER, REMOTE_ACCESS_ENABLED, REMOTE_DEBUG_ENABLED, APPIUM_VERSION, INSTANCE_ARN, INSTANCE_LABELS, FLEET_TYPE, OS_VERSION, MODEL, AVAILABILITY
# operator: "EQUALS", # accepts EQUALS, LESS_THAN, LESS_THAN_OR_EQUALS, GREATER_THAN, GREATER_THAN_OR_EQUALS, IN, NOT_IN, CONTAINS
# value: "String",
# },
# ],
# max_devices: 1,
# })
#
# @example Response structure
#
# resp.device_pool.arn #=> String
# resp.device_pool.name #=> String
# resp.device_pool.description #=> String
# resp.device_pool.type #=> String, one of "CURATED", "PRIVATE"
# resp.device_pool.rules #=> Array
# resp.device_pool.rules[0].attribute #=> String, one of "ARN", "PLATFORM", "FORM_FACTOR", "MANUFACTURER", "REMOTE_ACCESS_ENABLED", "REMOTE_DEBUG_ENABLED", "APPIUM_VERSION", "INSTANCE_ARN", "INSTANCE_LABELS", "FLEET_TYPE", "OS_VERSION", "MODEL", "AVAILABILITY"
# resp.device_pool.rules[0].operator #=> String, one of "EQUALS", "LESS_THAN", "LESS_THAN_OR_EQUALS", "GREATER_THAN", "GREATER_THAN_OR_EQUALS", "IN", "NOT_IN", "CONTAINS"
# resp.device_pool.rules[0].value #=> String
# resp.device_pool.max_devices #=> Integer
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/CreateDevicePool AWS API Documentation
#
# @overload create_device_pool(params = {})
# @param [Hash] params ({})
def create_device_pool(params = {}, options = {})
req = build_request(:create_device_pool, params)
req.send_request(options)
end
# Creates a profile that can be applied to one or more private fleet
# device instances.
#
# @option params [required, String] :name
# The name of your instance profile.
#
# @option params [String] :description
# The description of your instance profile.
#
# @option params [Boolean] :package_cleanup
# When set to `true`, Device Farm will remove app packages after a test
# run. The default value is `false` for private devices.
#
# @option params [Array<String>] :exclude_app_packages_from_cleanup
# An array of strings specifying the list of app packages that should
# not be cleaned up from the device after a test run is over.
#
# The list of packages is only considered if you set `packageCleanup` to
# `true`.
#
# @option params [Boolean] :reboot_after_use
# When set to `true`, Device Farm will reboot the instance after a test
# run. The default value is `true`.
#
# @return [Types::CreateInstanceProfileResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::CreateInstanceProfileResult#instance_profile #instance_profile} => Types::InstanceProfile
#
# @example Request syntax with placeholder values
#
# resp = client.create_instance_profile({
# name: "Name", # required
# description: "Message",
# package_cleanup: false,
# exclude_app_packages_from_cleanup: ["String"],
# reboot_after_use: false,
# })
#
# @example Response structure
#
# resp.instance_profile.arn #=> String
# resp.instance_profile.package_cleanup #=> Boolean
# resp.instance_profile.exclude_app_packages_from_cleanup #=> Array
# resp.instance_profile.exclude_app_packages_from_cleanup[0] #=> String
# resp.instance_profile.reboot_after_use #=> Boolean
# resp.instance_profile.name #=> String
# resp.instance_profile.description #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/CreateInstanceProfile AWS API Documentation
#
# @overload create_instance_profile(params = {})
# @param [Hash] params ({})
def create_instance_profile(params = {}, options = {})
req = build_request(:create_instance_profile, params)
req.send_request(options)
end
# Creates a network profile.
#
# @option params [required, String] :project_arn
# The Amazon Resource Name (ARN) of the project for which you want to
# create a network profile.
#
# @option params [required, String] :name
# The name you wish to specify for the new network profile.
#
# @option params [String] :description
# The description of the network profile.
#
# @option params [String] :type
# The type of network profile you wish to create. Valid values are
# listed below.
#
# @option params [Integer] :uplink_bandwidth_bits
# The data throughput rate in bits per second, as an integer from 0 to
# 104857600.
#
# @option params [Integer] :downlink_bandwidth_bits
# The data throughput rate in bits per second, as an integer from 0 to
# 104857600.
#
# @option params [Integer] :uplink_delay_ms
# Delay time for all packets to destination in milliseconds as an
# integer from 0 to 2000.
#
# @option params [Integer] :downlink_delay_ms
# Delay time for all packets to destination in milliseconds as an
# integer from 0 to 2000.
#
# @option params [Integer] :uplink_jitter_ms
# Time variation in the delay of received packets in milliseconds as an
# integer from 0 to 2000.
#
# @option params [Integer] :downlink_jitter_ms
# Time variation in the delay of received packets in milliseconds as an
# integer from 0 to 2000.
#
# @option params [Integer] :uplink_loss_percent
# Proportion of transmitted packets that fail to arrive from 0 to 100
# percent.
#
# @option params [Integer] :downlink_loss_percent
# Proportion of received packets that fail to arrive from 0 to 100
# percent.
#
# @return [Types::CreateNetworkProfileResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::CreateNetworkProfileResult#network_profile #network_profile} => Types::NetworkProfile
#
# @example Request syntax with placeholder values
#
# resp = client.create_network_profile({
# project_arn: "AmazonResourceName", # required
# name: "Name", # required
# description: "Message",
# type: "CURATED", # accepts CURATED, PRIVATE
# uplink_bandwidth_bits: 1,
# downlink_bandwidth_bits: 1,
# uplink_delay_ms: 1,
# downlink_delay_ms: 1,
# uplink_jitter_ms: 1,
# downlink_jitter_ms: 1,
# uplink_loss_percent: 1,
# downlink_loss_percent: 1,
# })
#
# @example Response structure
#
# resp.network_profile.arn #=> String
# resp.network_profile.name #=> String
# resp.network_profile.description #=> String
# resp.network_profile.type #=> String, one of "CURATED", "PRIVATE"
# resp.network_profile.uplink_bandwidth_bits #=> Integer
# resp.network_profile.downlink_bandwidth_bits #=> Integer
# resp.network_profile.uplink_delay_ms #=> Integer
# resp.network_profile.downlink_delay_ms #=> Integer
# resp.network_profile.uplink_jitter_ms #=> Integer
# resp.network_profile.downlink_jitter_ms #=> Integer
# resp.network_profile.uplink_loss_percent #=> Integer
# resp.network_profile.downlink_loss_percent #=> Integer
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/CreateNetworkProfile AWS API Documentation
#
# @overload create_network_profile(params = {})
# @param [Hash] params ({})
def create_network_profile(params = {}, options = {})
req = build_request(:create_network_profile, params)
req.send_request(options)
end
# Creates a new project.
#
# @option params [required, String] :name
# The project's name.
#
# @option params [Integer] :default_job_timeout_minutes
# Sets the execution timeout value (in minutes) for a project. All test
# runs in this project will use the specified execution timeout value
# unless overridden when scheduling a run.
#
# @return [Types::CreateProjectResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::CreateProjectResult#project #project} => Types::Project
#
#
# @example Example: To create a new project
#
# # The following example creates a new project named MyProject.
#
# resp = client.create_project({
# name: "MyProject", # A project in Device Farm is a workspace that contains test runs. A run is a test of a single app against one or more devices.
# })
#
# resp.to_h outputs the following:
# {
# project: {
# name: "MyProject",
# arn: "arn:aws:devicefarm:us-west-2:123456789101:project:5e01a8c7-c861-4c0a-b1d5-12345EXAMPLE",
# created: Time.parse("1472660939.152"),
# },
# }
#
# @example Request syntax with placeholder values
#
# resp = client.create_project({
# name: "Name", # required
# default_job_timeout_minutes: 1,
# })
#
# @example Response structure
#
# resp.project.arn #=> String
# resp.project.name #=> String
# resp.project.default_job_timeout_minutes #=> Integer
# resp.project.created #=> Time
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/CreateProject AWS API Documentation
#
# @overload create_project(params = {})
# @param [Hash] params ({})
def create_project(params = {}, options = {})
req = build_request(:create_project, params)
req.send_request(options)
end
# Specifies and starts a remote access session.
#
# @option params [required, String] :project_arn
# The Amazon Resource Name (ARN) of the project for which you want to
# create a remote access session.
#
# @option params [required, String] :device_arn
# The Amazon Resource Name (ARN) of the device for which you want to
# create a remote access session.
#
# @option params [String] :instance_arn
# The Amazon Resource Name (ARN) of the device instance for which you
# want to create a remote access session.
#
# @option params [String] :ssh_public_key
# *Ignored.* The public key of the `ssh` key pair you want to use for
# connecting to remote devices in your remote debugging session. This is
# only required if `remoteDebugEnabled` is set to `true`.
#
# *Remote debugging is [no longer supported][1].*
#
#
#
# [1]: https://docs.aws.amazon.com/devicefarm/latest/developerguide/history.html
#
# @option params [Boolean] :remote_debug_enabled
# Set to `true` if you want to access devices remotely for debugging in
# your remote access session.
#
# *Remote debugging is [no longer supported][1].*
#
#
#
# [1]: https://docs.aws.amazon.com/devicefarm/latest/developerguide/history.html
#
# @option params [Boolean] :remote_record_enabled
# Set to `true` to enable remote recording for the remote access
# session.
#
# @option params [String] :remote_record_app_arn
# The Amazon Resource Name (ARN) for the app to be recorded in the
# remote access session.
#
# @option params [String] :name
# The name of the remote access session that you wish to create.
#
# @option params [String] :client_id
# Unique identifier for the client. If you want access to multiple
# devices on the same client, you should pass the same `clientId` value
# in each call to `CreateRemoteAccessSession`. This is required only if
# `remoteDebugEnabled` is set to `true`.
#
# *Remote debugging is [no longer supported][1].*
#
#
#
# [1]: https://docs.aws.amazon.com/devicefarm/latest/developerguide/history.html
#
# @option params [Types::CreateRemoteAccessSessionConfiguration] :configuration
# The configuration information for the remote access session request.
#
# @option params [String] :interaction_mode
# The interaction mode of the remote access session. Valid values are:
#
# * INTERACTIVE: You can interact with the iOS device by viewing,
# touching, and rotating the screen. You **cannot** run XCUITest
# framework-based tests in this mode.
#
# * NO\_VIDEO: You are connected to the device but cannot interact with
# it or view the screen. This mode has the fastest test execution
# speed. You **can** run XCUITest framework-based tests in this mode.
#
# * VIDEO\_ONLY: You can view the screen but cannot touch or rotate it.
# You **can** run XCUITest framework-based tests and watch the screen
# in this mode.
#
# @option params [Boolean] :skip_app_resign
# When set to `true`, for private devices, Device Farm will not sign
# your app again. For public devices, Device Farm always signs your apps
# again and this parameter has no effect.
#
# For more information about how Device Farm re-signs your app(s), see
# [Do you modify my app?][1] in the *AWS Device Farm FAQs*.
#
#
#
# [1]: https://aws.amazon.com/device-farm/faq/
#
# @return [Types::CreateRemoteAccessSessionResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::CreateRemoteAccessSessionResult#remote_access_session #remote_access_session} => Types::RemoteAccessSession
#
#
# @example Example: To create a remote access session
#
# # The following example creates a remote access session named MySession.
#
# resp = client.create_remote_access_session({
# name: "MySession",
# configuration: {
# billing_method: "METERED",
# },
# device_arn: "arn:aws:devicefarm:us-west-2::device:123EXAMPLE", # You can get the device ARN by using the list-devices CLI command.
# project_arn: "arn:aws:devicefarm:us-west-2:123456789101:project:EXAMPLE-GUID-123-456", # You can get the project ARN by using the list-projects CLI command.
# })
#
# resp.to_h outputs the following:
# {
# remote_access_session: {
# },
# }
#
# @example Request syntax with placeholder values
#
# resp = client.create_remote_access_session({
# project_arn: "AmazonResourceName", # required
# device_arn: "AmazonResourceName", # required
# instance_arn: "AmazonResourceName",
# ssh_public_key: "SshPublicKey",
# remote_debug_enabled: false,
# remote_record_enabled: false,
# remote_record_app_arn: "AmazonResourceName",
# name: "Name",
# client_id: "ClientId",
# configuration: {
# billing_method: "METERED", # accepts METERED, UNMETERED
# vpce_configuration_arns: ["AmazonResourceName"],
# },
# interaction_mode: "INTERACTIVE", # accepts INTERACTIVE, NO_VIDEO, VIDEO_ONLY
# skip_app_resign: false,
# })
#
# @example Response structure
#
# resp.remote_access_session.arn #=> String
# resp.remote_access_session.name #=> String
# resp.remote_access_session.created #=> Time
# resp.remote_access_session.status #=> String, one of "PENDING", "PENDING_CONCURRENCY", "PENDING_DEVICE", "PROCESSING", "SCHEDULING", "PREPARING", "RUNNING", "COMPLETED", "STOPPING"
# resp.remote_access_session.result #=> String, one of "PENDING", "PASSED", "WARNED", "FAILED", "SKIPPED", "ERRORED", "STOPPED"
# resp.remote_access_session.message #=> String
# resp.remote_access_session.started #=> Time
# resp.remote_access_session.stopped #=> Time
# resp.remote_access_session.device.arn #=> String
# resp.remote_access_session.device.name #=> String
# resp.remote_access_session.device.manufacturer #=> String
# resp.remote_access_session.device.model #=> String
# resp.remote_access_session.device.model_id #=> String
# resp.remote_access_session.device.form_factor #=> String, one of "PHONE", "TABLET"
# resp.remote_access_session.device.platform #=> String, one of "ANDROID", "IOS"
# resp.remote_access_session.device.os #=> String
# resp.remote_access_session.device.cpu.frequency #=> String
# resp.remote_access_session.device.cpu.architecture #=> String
# resp.remote_access_session.device.cpu.clock #=> Float
# resp.remote_access_session.device.resolution.width #=> Integer
# resp.remote_access_session.device.resolution.height #=> Integer
# resp.remote_access_session.device.heap_size #=> Integer
# resp.remote_access_session.device.memory #=> Integer
# resp.remote_access_session.device.image #=> String
# resp.remote_access_session.device.carrier #=> String
# resp.remote_access_session.device.radio #=> String
# resp.remote_access_session.device.remote_access_enabled #=> Boolean
# resp.remote_access_session.device.remote_debug_enabled #=> Boolean
# resp.remote_access_session.device.fleet_type #=> String
# resp.remote_access_session.device.fleet_name #=> String
# resp.remote_access_session.device.instances #=> Array
# resp.remote_access_session.device.instances[0].arn #=> String
# resp.remote_access_session.device.instances[0].device_arn #=> String
# resp.remote_access_session.device.instances[0].labels #=> Array
# resp.remote_access_session.device.instances[0].labels[0] #=> String
# resp.remote_access_session.device.instances[0].status #=> String, one of "IN_USE", "PREPARING", "AVAILABLE", "NOT_AVAILABLE"
# resp.remote_access_session.device.instances[0].udid #=> String
# resp.remote_access_session.device.instances[0].instance_profile.arn #=> String
# resp.remote_access_session.device.instances[0].instance_profile.package_cleanup #=> Boolean
# resp.remote_access_session.device.instances[0].instance_profile.exclude_app_packages_from_cleanup #=> Array
# resp.remote_access_session.device.instances[0].instance_profile.exclude_app_packages_from_cleanup[0] #=> String
# resp.remote_access_session.device.instances[0].instance_profile.reboot_after_use #=> Boolean
# resp.remote_access_session.device.instances[0].instance_profile.name #=> String
# resp.remote_access_session.device.instances[0].instance_profile.description #=> String
# resp.remote_access_session.device.availability #=> String, one of "TEMPORARY_NOT_AVAILABLE", "BUSY", "AVAILABLE", "HIGHLY_AVAILABLE"
# resp.remote_access_session.instance_arn #=> String
# resp.remote_access_session.remote_debug_enabled #=> Boolean
# resp.remote_access_session.remote_record_enabled #=> Boolean
# resp.remote_access_session.remote_record_app_arn #=> String
# resp.remote_access_session.host_address #=> String
# resp.remote_access_session.client_id #=> String
# resp.remote_access_session.billing_method #=> String, one of "METERED", "UNMETERED"
# resp.remote_access_session.device_minutes.total #=> Float
# resp.remote_access_session.device_minutes.metered #=> Float
# resp.remote_access_session.device_minutes.unmetered #=> Float
# resp.remote_access_session.endpoint #=> String
# resp.remote_access_session.device_udid #=> String
# resp.remote_access_session.interaction_mode #=> String, one of "INTERACTIVE", "NO_VIDEO", "VIDEO_ONLY"
# resp.remote_access_session.skip_app_resign #=> Boolean
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/CreateRemoteAccessSession AWS API Documentation
#
# @overload create_remote_access_session(params = {})
# @param [Hash] params ({})
def create_remote_access_session(params = {}, options = {})
req = build_request(:create_remote_access_session, params)
req.send_request(options)
end
# Uploads an app or test scripts.
#
# @option params [required, String] :project_arn
# The ARN of the project for the upload.
#
# @option params [required, String] :name
# The upload's file name. The name should not contain the '/'
# character. If uploading an iOS app, the file name needs to end with
# the `.ipa` extension. If uploading an Android app, the file name needs
# to end with the `.apk` extension. For all others, the file name must
# end with the `.zip` file extension.
#
# @option params [required, String] :type
# The upload's upload type.
#
# Must be one of the following values:
#
# * ANDROID\_APP: An Android upload.
#
# * IOS\_APP: An iOS upload.
#
# * WEB\_APP: A web application upload.
#
# * EXTERNAL\_DATA: An external data upload.
#
# * APPIUM\_JAVA\_JUNIT\_TEST\_PACKAGE: An Appium Java JUnit test
# package upload.
#
# * APPIUM\_JAVA\_TESTNG\_TEST\_PACKAGE: An Appium Java TestNG test
# package upload.
#
# * APPIUM\_PYTHON\_TEST\_PACKAGE: An Appium Python test package upload.
#
# * APPIUM\_NODE\_TEST\_PACKAGE: An Appium Node.js test package upload.
#
# * APPIUM\_RUBY\_TEST\_PACKAGE: An Appium Ruby test package upload.
#
# * APPIUM\_WEB\_JAVA\_JUNIT\_TEST\_PACKAGE: An Appium Java JUnit test
# package upload for a web app.
#
# * APPIUM\_WEB\_JAVA\_TESTNG\_TEST\_PACKAGE: An Appium Java TestNG test
# package upload for a web app.
#
# * APPIUM\_WEB\_PYTHON\_TEST\_PACKAGE: An Appium Python test package
# upload for a web app.
#
# * APPIUM\_WEB\_NODE\_TEST\_PACKAGE: An Appium Node.js test package
# upload for a web app.
#
# * APPIUM\_WEB\_RUBY\_TEST\_PACKAGE: An Appium Ruby test package upload
# for a web app.
#
# * CALABASH\_TEST\_PACKAGE: A Calabash test package upload.
#
# * INSTRUMENTATION\_TEST\_PACKAGE: An instrumentation upload.
#
# * UIAUTOMATION\_TEST\_PACKAGE: A uiautomation test package upload.
#
# * UIAUTOMATOR\_TEST\_PACKAGE: A uiautomator test package upload.
#
# * XCTEST\_TEST\_PACKAGE: An Xcode test package upload.
#
# * XCTEST\_UI\_TEST\_PACKAGE: An Xcode UI test package upload.
#
# * APPIUM\_JAVA\_JUNIT\_TEST\_SPEC: An Appium Java JUnit test spec
# upload.
#
# * APPIUM\_JAVA\_TESTNG\_TEST\_SPEC: An Appium Java TestNG test spec
# upload.
#
# * APPIUM\_PYTHON\_TEST\_SPEC: An Appium Python test spec upload.
#
# * APPIUM\_NODE\_TEST\_SPEC: An Appium Node.js test spec upload.
#
# * APPIUM\_RUBY\_TEST\_SPEC: An Appium Ruby test spec upload.
#
# * APPIUM\_WEB\_JAVA\_JUNIT\_TEST\_SPEC: An Appium Java JUnit test spec
# upload for a web app.
#
# * APPIUM\_WEB\_JAVA\_TESTNG\_TEST\_SPEC: An Appium Java TestNG test
# spec upload for a web app.
#
# * APPIUM\_WEB\_PYTHON\_TEST\_SPEC: An Appium Python test spec upload
# for a web app.
#
# * APPIUM\_WEB\_NODE\_TEST\_SPEC: An Appium Node.js test spec upload
# for a web app.
#
# * APPIUM\_WEB\_RUBY\_TEST\_SPEC: An Appium Ruby test spec upload for a
# web app.
#
# * INSTRUMENTATION\_TEST\_SPEC: An instrumentation test spec upload.
#
# * XCTEST\_UI\_TEST\_SPEC: An Xcode UI test spec upload.
#
# **Note** If you call `CreateUpload` with `WEB_APP` specified, AWS
# Device Farm throws an `ArgumentException` error.
#
# @option params [String] :content_type
# The upload's content type (for example,
# "application/octet-stream").
#
# @return [Types::CreateUploadResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::CreateUploadResult#upload #upload} => Types::Upload
#
#
# @example Example: To create a new test package upload
#
# # The following example creates a new Appium Python test package upload inside an existing project.
#
# resp = client.create_upload({
# name: "MyAppiumPythonUpload",
# type: "APPIUM_PYTHON_TEST_PACKAGE",
# project_arn: "arn:aws:devicefarm:us-west-2:123456789101:project:EXAMPLE-GUID-123-456", # You can get the project ARN by using the list-projects CLI command.
# })
#
# resp.to_h outputs the following:
# {
# upload: {
# name: "MyAppiumPythonUpload",
# type: "APPIUM_PYTHON_TEST_PACKAGE",
# arn: "arn:aws:devicefarm:us-west-2:123456789101:upload:5e01a8c7-c861-4c0a-b1d5-5ec6e6c6dd23/b5340a65-3da7-4da6-a26e-12345EXAMPLE",
# created: Time.parse("1472661404.186"),
# status: "INITIALIZED",
# url: "https://prod-us-west-2-uploads.s3-us-west-2.amazonaws.com/arn%3Aaws%3Adevicefarm%3Aus-west-2%3A123456789101%3Aproject%3A5e01a8c7-c861-4c0a-b1d5-12345EXAMPLE/uploads/arn%3Aaws%3Adevicefarm%3Aus-west-2%3A123456789101%3Aupload%3A5e01a8c7-c861-4c0a-b1d5-5ec6e6c6dd23/b5340a65-3da7-4da6-a26e-12345EXAMPLE/MyAppiumPythonUpload?AWSAccessKeyId=1234567891011EXAMPLE&Expires=1472747804&Signature=1234567891011EXAMPLE",
# },
# }
#
# @example Request syntax with placeholder values
#
# resp = client.create_upload({
# project_arn: "AmazonResourceName", # required
# name: "Name", # required
# type: "ANDROID_APP", # required, accepts ANDROID_APP, IOS_APP, WEB_APP, EXTERNAL_DATA, APPIUM_JAVA_JUNIT_TEST_PACKAGE, APPIUM_JAVA_TESTNG_TEST_PACKAGE, APPIUM_PYTHON_TEST_PACKAGE, APPIUM_NODE_TEST_PACKAGE, APPIUM_RUBY_TEST_PACKAGE, APPIUM_WEB_JAVA_JUNIT_TEST_PACKAGE, APPIUM_WEB_JAVA_TESTNG_TEST_PACKAGE, APPIUM_WEB_PYTHON_TEST_PACKAGE, APPIUM_WEB_NODE_TEST_PACKAGE, APPIUM_WEB_RUBY_TEST_PACKAGE, CALABASH_TEST_PACKAGE, INSTRUMENTATION_TEST_PACKAGE, UIAUTOMATION_TEST_PACKAGE, UIAUTOMATOR_TEST_PACKAGE, XCTEST_TEST_PACKAGE, XCTEST_UI_TEST_PACKAGE, APPIUM_JAVA_JUNIT_TEST_SPEC, APPIUM_JAVA_TESTNG_TEST_SPEC, APPIUM_PYTHON_TEST_SPEC, APPIUM_NODE_TEST_SPEC, APPIUM_RUBY_TEST_SPEC, APPIUM_WEB_JAVA_JUNIT_TEST_SPEC, APPIUM_WEB_JAVA_TESTNG_TEST_SPEC, APPIUM_WEB_PYTHON_TEST_SPEC, APPIUM_WEB_NODE_TEST_SPEC, APPIUM_WEB_RUBY_TEST_SPEC, INSTRUMENTATION_TEST_SPEC, XCTEST_UI_TEST_SPEC
# content_type: "ContentType",
# })
#
# @example Response structure
#
# resp.upload.arn #=> String
# resp.upload.name #=> String
# resp.upload.created #=> Time
# resp.upload.type #=> String, one of "ANDROID_APP", "IOS_APP", "WEB_APP", "EXTERNAL_DATA", "APPIUM_JAVA_JUNIT_TEST_PACKAGE", "APPIUM_JAVA_TESTNG_TEST_PACKAGE", "APPIUM_PYTHON_TEST_PACKAGE", "APPIUM_NODE_TEST_PACKAGE", "APPIUM_RUBY_TEST_PACKAGE", "APPIUM_WEB_JAVA_JUNIT_TEST_PACKAGE", "APPIUM_WEB_JAVA_TESTNG_TEST_PACKAGE", "APPIUM_WEB_PYTHON_TEST_PACKAGE", "APPIUM_WEB_NODE_TEST_PACKAGE", "APPIUM_WEB_RUBY_TEST_PACKAGE", "CALABASH_TEST_PACKAGE", "INSTRUMENTATION_TEST_PACKAGE", "UIAUTOMATION_TEST_PACKAGE", "UIAUTOMATOR_TEST_PACKAGE", "XCTEST_TEST_PACKAGE", "XCTEST_UI_TEST_PACKAGE", "APPIUM_JAVA_JUNIT_TEST_SPEC", "APPIUM_JAVA_TESTNG_TEST_SPEC", "APPIUM_PYTHON_TEST_SPEC", "APPIUM_NODE_TEST_SPEC", "APPIUM_RUBY_TEST_SPEC", "APPIUM_WEB_JAVA_JUNIT_TEST_SPEC", "APPIUM_WEB_JAVA_TESTNG_TEST_SPEC", "APPIUM_WEB_PYTHON_TEST_SPEC", "APPIUM_WEB_NODE_TEST_SPEC", "APPIUM_WEB_RUBY_TEST_SPEC", "INSTRUMENTATION_TEST_SPEC", "XCTEST_UI_TEST_SPEC"
# resp.upload.status #=> String, one of "INITIALIZED", "PROCESSING", "SUCCEEDED", "FAILED"
# resp.upload.url #=> String
# resp.upload.metadata #=> String
# resp.upload.content_type #=> String
# resp.upload.message #=> String
# resp.upload.category #=> String, one of "CURATED", "PRIVATE"
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/CreateUpload AWS API Documentation
#
# @overload create_upload(params = {})
# @param [Hash] params ({})
def create_upload(params = {}, options = {})
req = build_request(:create_upload, params)
req.send_request(options)
end
# Creates a configuration record in Device Farm for your Amazon Virtual
# Private Cloud (VPC) endpoint.
#
# @option params [required, String] :vpce_configuration_name
# The friendly name you give to your VPC endpoint configuration, to
# manage your configurations more easily.
#
# @option params [required, String] :vpce_service_name
# The name of the VPC endpoint service running inside your AWS account
# that you want Device Farm to test.
#
# @option params [required, String] :service_dns_name
# The DNS name of the service running in your VPC that you want Device
# Farm to test.
#
# @option params [String] :vpce_configuration_description
# An optional description, providing more details about your VPC
# endpoint configuration.
#
# @return [Types::CreateVPCEConfigurationResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::CreateVPCEConfigurationResult#vpce_configuration #vpce_configuration} => Types::VPCEConfiguration
#
# @example Request syntax with placeholder values
#
# resp = client.create_vpce_configuration({
# vpce_configuration_name: "VPCEConfigurationName", # required
# vpce_service_name: "VPCEServiceName", # required
# service_dns_name: "ServiceDnsName", # required
# vpce_configuration_description: "VPCEConfigurationDescription",
# })
#
# @example Response structure
#
# resp.vpce_configuration.arn #=> String
# resp.vpce_configuration.vpce_configuration_name #=> String
# resp.vpce_configuration.vpce_service_name #=> String
# resp.vpce_configuration.service_dns_name #=> String
# resp.vpce_configuration.vpce_configuration_description #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/CreateVPCEConfiguration AWS API Documentation
#
# @overload create_vpce_configuration(params = {})
# @param [Hash] params ({})
def create_vpce_configuration(params = {}, options = {})
req = build_request(:create_vpce_configuration, params)
req.send_request(options)
end
# Deletes a device pool given the pool ARN. Does not allow deletion of
# curated pools owned by the system.
#
# @option params [required, String] :arn
# Represents the Amazon Resource Name (ARN) of the Device Farm device
# pool you wish to delete.
#
# @return [Struct] Returns an empty {Seahorse::Client::Response response}.
#
#
# @example Example: To delete a device pool
#
# # The following example deletes a specific device pool.
#
# resp = client.delete_device_pool({
# arn: "arn:aws:devicefarm:us-west-2::devicepool:123-456-EXAMPLE-GUID", # You can get the device pool ARN by using the list-device-pools CLI command.
# })
#
# resp.to_h outputs the following:
# {
# }
#
# @example Request syntax with placeholder values
#
# resp = client.delete_device_pool({
# arn: "AmazonResourceName", # required
# })
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/DeleteDevicePool AWS API Documentation
#
# @overload delete_device_pool(params = {})
# @param [Hash] params ({})
def delete_device_pool(params = {}, options = {})
req = build_request(:delete_device_pool, params)
req.send_request(options)
end
# Deletes a profile that can be applied to one or more private device
# instances.
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) of the instance profile you are
# requesting to delete.
#
# @return [Struct] Returns an empty {Seahorse::Client::Response response}.
#
# @example Request syntax with placeholder values
#
# resp = client.delete_instance_profile({
# arn: "AmazonResourceName", # required
# })
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/DeleteInstanceProfile AWS API Documentation
#
# @overload delete_instance_profile(params = {})
# @param [Hash] params ({})
def delete_instance_profile(params = {}, options = {})
req = build_request(:delete_instance_profile, params)
req.send_request(options)
end
# Deletes a network profile.
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) of the network profile you want to
# delete.
#
# @return [Struct] Returns an empty {Seahorse::Client::Response response}.
#
# @example Request syntax with placeholder values
#
# resp = client.delete_network_profile({
# arn: "AmazonResourceName", # required
# })
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/DeleteNetworkProfile AWS API Documentation
#
# @overload delete_network_profile(params = {})
# @param [Hash] params ({})
def delete_network_profile(params = {}, options = {})
req = build_request(:delete_network_profile, params)
req.send_request(options)
end
# Deletes an AWS Device Farm project, given the project ARN.
#
# **Note** Deleting this resource does not stop an in-progress run.
#
# @option params [required, String] :arn
# Represents the Amazon Resource Name (ARN) of the Device Farm project
# you wish to delete.
#
# @return [Struct] Returns an empty {Seahorse::Client::Response response}.
#
#
# @example Example: To delete a project
#
# # The following example deletes a specific project.
#
# resp = client.delete_project({
# arn: "arn:aws:devicefarm:us-west-2:123456789101:project:EXAMPLE-GUID-123-456", # You can get the project ARN by using the list-projects CLI command.
# })
#
# resp.to_h outputs the following:
# {
# }
#
# @example Request syntax with placeholder values
#
# resp = client.delete_project({
# arn: "AmazonResourceName", # required
# })
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/DeleteProject AWS API Documentation
#
# @overload delete_project(params = {})
# @param [Hash] params ({})
def delete_project(params = {}, options = {})
req = build_request(:delete_project, params)
req.send_request(options)
end
# Deletes a completed remote access session and its results.
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) of the session for which you want to
# delete remote access.
#
# @return [Struct] Returns an empty {Seahorse::Client::Response response}.
#
#
# @example Example: To delete a specific remote access session
#
# # The following example deletes a specific remote access session.
#
# resp = client.delete_remote_access_session({
# arn: "arn:aws:devicefarm:us-west-2:123456789101:session:EXAMPLE-GUID-123-456", # You can get the remote access session ARN by using the list-remote-access-sessions CLI command.
# })
#
# resp.to_h outputs the following:
# {
# }
#
# @example Request syntax with placeholder values
#
# resp = client.delete_remote_access_session({
# arn: "AmazonResourceName", # required
# })
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/DeleteRemoteAccessSession AWS API Documentation
#
# @overload delete_remote_access_session(params = {})
# @param [Hash] params ({})
def delete_remote_access_session(params = {}, options = {})
req = build_request(:delete_remote_access_session, params)
req.send_request(options)
end
# Deletes the run, given the run ARN.
#
# **Note** Deleting this resource does not stop an in-progress run.
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) for the run you wish to delete.
#
# @return [Struct] Returns an empty {Seahorse::Client::Response response}.
#
#
# @example Example: To delete a run
#
# # The following example deletes a specific test run.
#
# resp = client.delete_run({
# arn: "arn:aws:devicefarm:us-west-2:123456789101:run:EXAMPLE-GUID-123-456", # You can get the run ARN by using the list-runs CLI command.
# })
#
# resp.to_h outputs the following:
# {
# }
#
# @example Request syntax with placeholder values
#
# resp = client.delete_run({
# arn: "AmazonResourceName", # required
# })
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/DeleteRun AWS API Documentation
#
# @overload delete_run(params = {})
# @param [Hash] params ({})
def delete_run(params = {}, options = {})
req = build_request(:delete_run, params)
req.send_request(options)
end
# Deletes an upload given the upload ARN.
#
# @option params [required, String] :arn
# Represents the Amazon Resource Name (ARN) of the Device Farm upload
# you wish to delete.
#
# @return [Struct] Returns an empty {Seahorse::Client::Response response}.
#
#
# @example Example: To delete a specific upload
#
# # The following example deletes a specific upload.
#
# resp = client.delete_upload({
# arn: "arn:aws:devicefarm:us-west-2:123456789101:upload:EXAMPLE-GUID-123-456", # You can get the upload ARN by using the list-uploads CLI command.
# })
#
# resp.to_h outputs the following:
# {
# }
#
# @example Request syntax with placeholder values
#
# resp = client.delete_upload({
# arn: "AmazonResourceName", # required
# })
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/DeleteUpload AWS API Documentation
#
# @overload delete_upload(params = {})
# @param [Hash] params ({})
def delete_upload(params = {}, options = {})
req = build_request(:delete_upload, params)
req.send_request(options)
end
# Deletes a configuration for your Amazon Virtual Private Cloud (VPC)
# endpoint.
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) of the VPC endpoint configuration you
# want to delete.
#
# @return [Struct] Returns an empty {Seahorse::Client::Response response}.
#
# @example Request syntax with placeholder values
#
# resp = client.delete_vpce_configuration({
# arn: "AmazonResourceName", # required
# })
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/DeleteVPCEConfiguration AWS API Documentation
#
# @overload delete_vpce_configuration(params = {})
# @param [Hash] params ({})
def delete_vpce_configuration(params = {}, options = {})
req = build_request(:delete_vpce_configuration, params)
req.send_request(options)
end
# Returns the number of unmetered iOS and/or unmetered Android devices
# that have been purchased by the account.
#
# @return [Types::GetAccountSettingsResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::GetAccountSettingsResult#account_settings #account_settings} => Types::AccountSettings
#
#
# @example Example: To get information about account settings
#
# # The following example returns information about your Device Farm account settings.
#
# resp = client.get_account_settings({
# })
#
# resp.to_h outputs the following:
# {
# account_settings: {
# aws_account_number: "123456789101",
# unmetered_devices: {
# "ANDROID" => 1,
# "IOS" => 2,
# },
# },
# }
#
# @example Response structure
#
# resp.account_settings.aws_account_number #=> String
# resp.account_settings.unmetered_devices #=> Hash
# resp.account_settings.unmetered_devices["DevicePlatform"] #=> Integer
# resp.account_settings.unmetered_remote_access_devices #=> Hash
# resp.account_settings.unmetered_remote_access_devices["DevicePlatform"] #=> Integer
# resp.account_settings.max_job_timeout_minutes #=> Integer
# resp.account_settings.trial_minutes.total #=> Float
# resp.account_settings.trial_minutes.remaining #=> Float
# resp.account_settings.max_slots #=> Hash
# resp.account_settings.max_slots["String"] #=> Integer
# resp.account_settings.default_job_timeout_minutes #=> Integer
# resp.account_settings.skip_app_resign #=> Boolean
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/GetAccountSettings AWS API Documentation
#
# @overload get_account_settings(params = {})
# @param [Hash] params ({})
def get_account_settings(params = {}, options = {})
req = build_request(:get_account_settings, params)
req.send_request(options)
end
# Gets information about a unique device type.
#
# @option params [required, String] :arn
# The device type's ARN.
#
# @return [Types::GetDeviceResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::GetDeviceResult#device #device} => Types::Device
#
#
# @example Example: To get information about a device
#
# # The following example returns information about a specific device.
#
# resp = client.get_device({
# arn: "arn:aws:devicefarm:us-west-2::device:123EXAMPLE",
# })
#
# resp.to_h outputs the following:
# {
# device: {
# name: "LG G2 (Sprint)",
# arn: "arn:aws:devicefarm:us-west-2::device:A0E6E6E1059E45918208DF75B2B7EF6C",
# cpu: {
# architecture: "armeabi-v7a",
# clock: 2265.6,
# frequency: "MHz",
# },
# form_factor: "PHONE",
# heap_size: 256000000,
# image: "75B2B7EF6C12345EXAMPLE",
# manufacturer: "LG",
# memory: 16000000000,
# model: "G2 (Sprint)",
# os: "4.2.2",
# platform: "ANDROID",
# resolution: {
# height: 1920,
# width: 1080,
# },
# },
# }
#
# @example Request syntax with placeholder values
#
# resp = client.get_device({
# arn: "AmazonResourceName", # required
# })
#
# @example Response structure
#
# resp.device.arn #=> String
# resp.device.name #=> String
# resp.device.manufacturer #=> String
# resp.device.model #=> String
# resp.device.model_id #=> String
# resp.device.form_factor #=> String, one of "PHONE", "TABLET"
# resp.device.platform #=> String, one of "ANDROID", "IOS"
# resp.device.os #=> String
# resp.device.cpu.frequency #=> String
# resp.device.cpu.architecture #=> String
# resp.device.cpu.clock #=> Float
# resp.device.resolution.width #=> Integer
# resp.device.resolution.height #=> Integer
# resp.device.heap_size #=> Integer
# resp.device.memory #=> Integer
# resp.device.image #=> String
# resp.device.carrier #=> String
# resp.device.radio #=> String
# resp.device.remote_access_enabled #=> Boolean
# resp.device.remote_debug_enabled #=> Boolean
# resp.device.fleet_type #=> String
# resp.device.fleet_name #=> String
# resp.device.instances #=> Array
# resp.device.instances[0].arn #=> String
# resp.device.instances[0].device_arn #=> String
# resp.device.instances[0].labels #=> Array
# resp.device.instances[0].labels[0] #=> String
# resp.device.instances[0].status #=> String, one of "IN_USE", "PREPARING", "AVAILABLE", "NOT_AVAILABLE"
# resp.device.instances[0].udid #=> String
# resp.device.instances[0].instance_profile.arn #=> String
# resp.device.instances[0].instance_profile.package_cleanup #=> Boolean
# resp.device.instances[0].instance_profile.exclude_app_packages_from_cleanup #=> Array
# resp.device.instances[0].instance_profile.exclude_app_packages_from_cleanup[0] #=> String
# resp.device.instances[0].instance_profile.reboot_after_use #=> Boolean
# resp.device.instances[0].instance_profile.name #=> String
# resp.device.instances[0].instance_profile.description #=> String
# resp.device.availability #=> String, one of "TEMPORARY_NOT_AVAILABLE", "BUSY", "AVAILABLE", "HIGHLY_AVAILABLE"
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/GetDevice AWS API Documentation
#
# @overload get_device(params = {})
# @param [Hash] params ({})
def get_device(params = {}, options = {})
req = build_request(:get_device, params)
req.send_request(options)
end
# Returns information about a device instance belonging to a private
# device fleet.
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) of the instance you're requesting
# information about.
#
# @return [Types::GetDeviceInstanceResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::GetDeviceInstanceResult#device_instance #device_instance} => Types::DeviceInstance
#
# @example Request syntax with placeholder values
#
# resp = client.get_device_instance({
# arn: "AmazonResourceName", # required
# })
#
# @example Response structure
#
# resp.device_instance.arn #=> String
# resp.device_instance.device_arn #=> String
# resp.device_instance.labels #=> Array
# resp.device_instance.labels[0] #=> String
# resp.device_instance.status #=> String, one of "IN_USE", "PREPARING", "AVAILABLE", "NOT_AVAILABLE"
# resp.device_instance.udid #=> String
# resp.device_instance.instance_profile.arn #=> String
# resp.device_instance.instance_profile.package_cleanup #=> Boolean
# resp.device_instance.instance_profile.exclude_app_packages_from_cleanup #=> Array
# resp.device_instance.instance_profile.exclude_app_packages_from_cleanup[0] #=> String
# resp.device_instance.instance_profile.reboot_after_use #=> Boolean
# resp.device_instance.instance_profile.name #=> String
# resp.device_instance.instance_profile.description #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/GetDeviceInstance AWS API Documentation
#
# @overload get_device_instance(params = {})
# @param [Hash] params ({})
def get_device_instance(params = {}, options = {})
req = build_request(:get_device_instance, params)
req.send_request(options)
end
# Gets information about a device pool.
#
# @option params [required, String] :arn
# The device pool's ARN.
#
# @return [Types::GetDevicePoolResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::GetDevicePoolResult#device_pool #device_pool} => Types::DevicePool
#
#
# @example Example: To get information about a device pool
#
# # The following example returns information about a specific device pool, given a project ARN.
#
# resp = client.get_device_pool({
# arn: "arn:aws:devicefarm:us-west-2:123456789101:project:EXAMPLE-GUID-123-456", # You can obtain the project ARN by using the list-projects CLI command.
# })
#
# resp.to_h outputs the following:
# {
# device_pool: {
# },
# }
#
# @example Request syntax with placeholder values
#
# resp = client.get_device_pool({
# arn: "AmazonResourceName", # required
# })
#
# @example Response structure
#
# resp.device_pool.arn #=> String
# resp.device_pool.name #=> String
# resp.device_pool.description #=> String
# resp.device_pool.type #=> String, one of "CURATED", "PRIVATE"
# resp.device_pool.rules #=> Array
# resp.device_pool.rules[0].attribute #=> String, one of "ARN", "PLATFORM", "FORM_FACTOR", "MANUFACTURER", "REMOTE_ACCESS_ENABLED", "REMOTE_DEBUG_ENABLED", "APPIUM_VERSION", "INSTANCE_ARN", "INSTANCE_LABELS", "FLEET_TYPE", "OS_VERSION", "MODEL", "AVAILABILITY"
# resp.device_pool.rules[0].operator #=> String, one of "EQUALS", "LESS_THAN", "LESS_THAN_OR_EQUALS", "GREATER_THAN", "GREATER_THAN_OR_EQUALS", "IN", "NOT_IN", "CONTAINS"
# resp.device_pool.rules[0].value #=> String
# resp.device_pool.max_devices #=> Integer
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/GetDevicePool AWS API Documentation
#
# @overload get_device_pool(params = {})
# @param [Hash] params ({})
def get_device_pool(params = {}, options = {})
req = build_request(:get_device_pool, params)
req.send_request(options)
end
# Gets information about compatibility with a device pool.
#
# @option params [required, String] :device_pool_arn
# The device pool's ARN.
#
# @option params [String] :app_arn
# The ARN of the app that is associated with the specified device pool.
#
# @option params [String] :test_type
# The test type for the specified device pool.
#
# Allowed values include the following:
#
# * BUILTIN\_FUZZ: The built-in fuzz type.
#
# * BUILTIN\_EXPLORER: For Android, an app explorer that will traverse
# an Android app, interacting with it and capturing screenshots at the
# same time.
#
# * APPIUM\_JAVA\_JUNIT: The Appium Java JUnit type.
#
# * APPIUM\_JAVA\_TESTNG: The Appium Java TestNG type.
#
# * APPIUM\_PYTHON: The Appium Python type.
#
# * APPIUM\_NODE: The Appium Node.js type.
#
# * APPIUM\_RUBY: The Appium Ruby type.
#
# * APPIUM\_WEB\_JAVA\_JUNIT: The Appium Java JUnit type for web apps.
#
# * APPIUM\_WEB\_JAVA\_TESTNG: The Appium Java TestNG type for web apps.
#
# * APPIUM\_WEB\_PYTHON: The Appium Python type for web apps.
#
# * APPIUM\_WEB\_NODE: The Appium Node.js type for web apps.
#
# * APPIUM\_WEB\_RUBY: The Appium Ruby type for web apps.
#
# * CALABASH: The Calabash type.
#
# * INSTRUMENTATION: The Instrumentation type.
#
# * UIAUTOMATION: The uiautomation type.
#
# * UIAUTOMATOR: The uiautomator type.
#
# * XCTEST: The Xcode test type.
#
# * XCTEST\_UI: The Xcode UI test type.
#
# @option params [Types::ScheduleRunTest] :test
# Information about the uploaded test to be run against the device pool.
#
# @option params [Types::ScheduleRunConfiguration] :configuration
# An object containing information about the settings for a run.
#
# @return [Types::GetDevicePoolCompatibilityResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::GetDevicePoolCompatibilityResult#compatible_devices #compatible_devices} => Array<Types::DevicePoolCompatibilityResult>
# * {Types::GetDevicePoolCompatibilityResult#incompatible_devices #incompatible_devices} => Array<Types::DevicePoolCompatibilityResult>
#
#
# @example Example: To get information about the compatibility of a device pool
#
# # The following example returns information about the compatibility of a specific device pool, given its ARN.
#
# resp = client.get_device_pool_compatibility({
# app_arn: "arn:aws:devicefarm:us-west-2::app:123-456-EXAMPLE-GUID",
# device_pool_arn: "arn:aws:devicefarm:us-west-2::devicepool:123-456-EXAMPLE-GUID", # You can get the device pool ARN by using the list-device-pools CLI command.
# test_type: "APPIUM_PYTHON",
# })
#
# resp.to_h outputs the following:
# {
# compatible_devices: [
# ],
# incompatible_devices: [
# ],
# }
#
# @example Request syntax with placeholder values
#
# resp = client.get_device_pool_compatibility({
# device_pool_arn: "AmazonResourceName", # required
# app_arn: "AmazonResourceName",
# test_type: "BUILTIN_FUZZ", # accepts BUILTIN_FUZZ, BUILTIN_EXPLORER, WEB_PERFORMANCE_PROFILE, APPIUM_JAVA_JUNIT, APPIUM_JAVA_TESTNG, APPIUM_PYTHON, APPIUM_NODE, APPIUM_RUBY, APPIUM_WEB_JAVA_JUNIT, APPIUM_WEB_JAVA_TESTNG, APPIUM_WEB_PYTHON, APPIUM_WEB_NODE, APPIUM_WEB_RUBY, CALABASH, INSTRUMENTATION, UIAUTOMATION, UIAUTOMATOR, XCTEST, XCTEST_UI, REMOTE_ACCESS_RECORD, REMOTE_ACCESS_REPLAY
# test: {
# type: "BUILTIN_FUZZ", # required, accepts BUILTIN_FUZZ, BUILTIN_EXPLORER, WEB_PERFORMANCE_PROFILE, APPIUM_JAVA_JUNIT, APPIUM_JAVA_TESTNG, APPIUM_PYTHON, APPIUM_NODE, APPIUM_RUBY, APPIUM_WEB_JAVA_JUNIT, APPIUM_WEB_JAVA_TESTNG, APPIUM_WEB_PYTHON, APPIUM_WEB_NODE, APPIUM_WEB_RUBY, CALABASH, INSTRUMENTATION, UIAUTOMATION, UIAUTOMATOR, XCTEST, XCTEST_UI, REMOTE_ACCESS_RECORD, REMOTE_ACCESS_REPLAY
# test_package_arn: "AmazonResourceName",
# test_spec_arn: "AmazonResourceName",
# filter: "Filter",
# parameters: {
# "String" => "String",
# },
# },
# configuration: {
# extra_data_package_arn: "AmazonResourceName",
# network_profile_arn: "AmazonResourceName",
# locale: "String",
# location: {
# latitude: 1.0, # required
# longitude: 1.0, # required
# },
# vpce_configuration_arns: ["AmazonResourceName"],
# customer_artifact_paths: {
# ios_paths: ["String"],
# android_paths: ["String"],
# device_host_paths: ["String"],
# },
# radios: {
# wifi: false,
# bluetooth: false,
# nfc: false,
# gps: false,
# },
# auxiliary_apps: ["AmazonResourceName"],
# billing_method: "METERED", # accepts METERED, UNMETERED
# },
# })
#
# @example Response structure
#
# resp.compatible_devices #=> Array
# resp.compatible_devices[0].device.arn #=> String
# resp.compatible_devices[0].device.name #=> String
# resp.compatible_devices[0].device.manufacturer #=> String
# resp.compatible_devices[0].device.model #=> String
# resp.compatible_devices[0].device.model_id #=> String
# resp.compatible_devices[0].device.form_factor #=> String, one of "PHONE", "TABLET"
# resp.compatible_devices[0].device.platform #=> String, one of "ANDROID", "IOS"
# resp.compatible_devices[0].device.os #=> String
# resp.compatible_devices[0].device.cpu.frequency #=> String
# resp.compatible_devices[0].device.cpu.architecture #=> String
# resp.compatible_devices[0].device.cpu.clock #=> Float
# resp.compatible_devices[0].device.resolution.width #=> Integer
# resp.compatible_devices[0].device.resolution.height #=> Integer
# resp.compatible_devices[0].device.heap_size #=> Integer
# resp.compatible_devices[0].device.memory #=> Integer
# resp.compatible_devices[0].device.image #=> String
# resp.compatible_devices[0].device.carrier #=> String
# resp.compatible_devices[0].device.radio #=> String
# resp.compatible_devices[0].device.remote_access_enabled #=> Boolean
# resp.compatible_devices[0].device.remote_debug_enabled #=> Boolean
# resp.compatible_devices[0].device.fleet_type #=> String
# resp.compatible_devices[0].device.fleet_name #=> String
# resp.compatible_devices[0].device.instances #=> Array
# resp.compatible_devices[0].device.instances[0].arn #=> String
# resp.compatible_devices[0].device.instances[0].device_arn #=> String
# resp.compatible_devices[0].device.instances[0].labels #=> Array
# resp.compatible_devices[0].device.instances[0].labels[0] #=> String
# resp.compatible_devices[0].device.instances[0].status #=> String, one of "IN_USE", "PREPARING", "AVAILABLE", "NOT_AVAILABLE"
# resp.compatible_devices[0].device.instances[0].udid #=> String
# resp.compatible_devices[0].device.instances[0].instance_profile.arn #=> String
# resp.compatible_devices[0].device.instances[0].instance_profile.package_cleanup #=> Boolean
# resp.compatible_devices[0].device.instances[0].instance_profile.exclude_app_packages_from_cleanup #=> Array
# resp.compatible_devices[0].device.instances[0].instance_profile.exclude_app_packages_from_cleanup[0] #=> String
# resp.compatible_devices[0].device.instances[0].instance_profile.reboot_after_use #=> Boolean
# resp.compatible_devices[0].device.instances[0].instance_profile.name #=> String
# resp.compatible_devices[0].device.instances[0].instance_profile.description #=> String
# resp.compatible_devices[0].device.availability #=> String, one of "TEMPORARY_NOT_AVAILABLE", "BUSY", "AVAILABLE", "HIGHLY_AVAILABLE"
# resp.compatible_devices[0].compatible #=> Boolean
# resp.compatible_devices[0].incompatibility_messages #=> Array
# resp.compatible_devices[0].incompatibility_messages[0].message #=> String
# resp.compatible_devices[0].incompatibility_messages[0].type #=> String, one of "ARN", "PLATFORM", "FORM_FACTOR", "MANUFACTURER", "REMOTE_ACCESS_ENABLED", "REMOTE_DEBUG_ENABLED", "APPIUM_VERSION", "INSTANCE_ARN", "INSTANCE_LABELS", "FLEET_TYPE", "OS_VERSION", "MODEL", "AVAILABILITY"
# resp.incompatible_devices #=> Array
# resp.incompatible_devices[0].device.arn #=> String
# resp.incompatible_devices[0].device.name #=> String
# resp.incompatible_devices[0].device.manufacturer #=> String
# resp.incompatible_devices[0].device.model #=> String
# resp.incompatible_devices[0].device.model_id #=> String
# resp.incompatible_devices[0].device.form_factor #=> String, one of "PHONE", "TABLET"
# resp.incompatible_devices[0].device.platform #=> String, one of "ANDROID", "IOS"
# resp.incompatible_devices[0].device.os #=> String
# resp.incompatible_devices[0].device.cpu.frequency #=> String
# resp.incompatible_devices[0].device.cpu.architecture #=> String
# resp.incompatible_devices[0].device.cpu.clock #=> Float
# resp.incompatible_devices[0].device.resolution.width #=> Integer
# resp.incompatible_devices[0].device.resolution.height #=> Integer
# resp.incompatible_devices[0].device.heap_size #=> Integer
# resp.incompatible_devices[0].device.memory #=> Integer
# resp.incompatible_devices[0].device.image #=> String
# resp.incompatible_devices[0].device.carrier #=> String
# resp.incompatible_devices[0].device.radio #=> String
# resp.incompatible_devices[0].device.remote_access_enabled #=> Boolean
# resp.incompatible_devices[0].device.remote_debug_enabled #=> Boolean
# resp.incompatible_devices[0].device.fleet_type #=> String
# resp.incompatible_devices[0].device.fleet_name #=> String
# resp.incompatible_devices[0].device.instances #=> Array
# resp.incompatible_devices[0].device.instances[0].arn #=> String
# resp.incompatible_devices[0].device.instances[0].device_arn #=> String
# resp.incompatible_devices[0].device.instances[0].labels #=> Array
# resp.incompatible_devices[0].device.instances[0].labels[0] #=> String
# resp.incompatible_devices[0].device.instances[0].status #=> String, one of "IN_USE", "PREPARING", "AVAILABLE", "NOT_AVAILABLE"
# resp.incompatible_devices[0].device.instances[0].udid #=> String
# resp.incompatible_devices[0].device.instances[0].instance_profile.arn #=> String
# resp.incompatible_devices[0].device.instances[0].instance_profile.package_cleanup #=> Boolean
# resp.incompatible_devices[0].device.instances[0].instance_profile.exclude_app_packages_from_cleanup #=> Array
# resp.incompatible_devices[0].device.instances[0].instance_profile.exclude_app_packages_from_cleanup[0] #=> String
# resp.incompatible_devices[0].device.instances[0].instance_profile.reboot_after_use #=> Boolean
# resp.incompatible_devices[0].device.instances[0].instance_profile.name #=> String
# resp.incompatible_devices[0].device.instances[0].instance_profile.description #=> String
# resp.incompatible_devices[0].device.availability #=> String, one of "TEMPORARY_NOT_AVAILABLE", "BUSY", "AVAILABLE", "HIGHLY_AVAILABLE"
# resp.incompatible_devices[0].compatible #=> Boolean
# resp.incompatible_devices[0].incompatibility_messages #=> Array
# resp.incompatible_devices[0].incompatibility_messages[0].message #=> String
# resp.incompatible_devices[0].incompatibility_messages[0].type #=> String, one of "ARN", "PLATFORM", "FORM_FACTOR", "MANUFACTURER", "REMOTE_ACCESS_ENABLED", "REMOTE_DEBUG_ENABLED", "APPIUM_VERSION", "INSTANCE_ARN", "INSTANCE_LABELS", "FLEET_TYPE", "OS_VERSION", "MODEL", "AVAILABILITY"
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/GetDevicePoolCompatibility AWS API Documentation
#
# @overload get_device_pool_compatibility(params = {})
# @param [Hash] params ({})
def get_device_pool_compatibility(params = {}, options = {})
req = build_request(:get_device_pool_compatibility, params)
req.send_request(options)
end
# Returns information about the specified instance profile.
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) of your instance profile.
#
# @return [Types::GetInstanceProfileResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::GetInstanceProfileResult#instance_profile #instance_profile} => Types::InstanceProfile
#
# @example Request syntax with placeholder values
#
# resp = client.get_instance_profile({
# arn: "AmazonResourceName", # required
# })
#
# @example Response structure
#
# resp.instance_profile.arn #=> String
# resp.instance_profile.package_cleanup #=> Boolean
# resp.instance_profile.exclude_app_packages_from_cleanup #=> Array
# resp.instance_profile.exclude_app_packages_from_cleanup[0] #=> String
# resp.instance_profile.reboot_after_use #=> Boolean
# resp.instance_profile.name #=> String
# resp.instance_profile.description #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/GetInstanceProfile AWS API Documentation
#
# @overload get_instance_profile(params = {})
# @param [Hash] params ({})
def get_instance_profile(params = {}, options = {})
req = build_request(:get_instance_profile, params)
req.send_request(options)
end
# Gets information about a job.
#
# @option params [required, String] :arn
# The job's ARN.
#
# @return [Types::GetJobResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::GetJobResult#job #job} => Types::Job
#
#
# @example Example: To get information about a job
#
# # The following example returns information about a specific job.
#
# resp = client.get_job({
# arn: "arn:aws:devicefarm:us-west-2::job:123-456-EXAMPLE-GUID", # You can get the job ARN by using the list-jobs CLI command.
# })
#
# resp.to_h outputs the following:
# {
# job: {
# },
# }
#
# @example Request syntax with placeholder values
#
# resp = client.get_job({
# arn: "AmazonResourceName", # required
# })
#
# @example Response structure
#
# resp.job.arn #=> String
# resp.job.name #=> String
# resp.job.type #=> String, one of "BUILTIN_FUZZ", "BUILTIN_EXPLORER", "WEB_PERFORMANCE_PROFILE", "APPIUM_JAVA_JUNIT", "APPIUM_JAVA_TESTNG", "APPIUM_PYTHON", "APPIUM_NODE", "APPIUM_RUBY", "APPIUM_WEB_JAVA_JUNIT", "APPIUM_WEB_JAVA_TESTNG", "APPIUM_WEB_PYTHON", "APPIUM_WEB_NODE", "APPIUM_WEB_RUBY", "CALABASH", "INSTRUMENTATION", "UIAUTOMATION", "UIAUTOMATOR", "XCTEST", "XCTEST_UI", "REMOTE_ACCESS_RECORD", "REMOTE_ACCESS_REPLAY"
# resp.job.created #=> Time
# resp.job.status #=> String, one of "PENDING", "PENDING_CONCURRENCY", "PENDING_DEVICE", "PROCESSING", "SCHEDULING", "PREPARING", "RUNNING", "COMPLETED", "STOPPING"
# resp.job.result #=> String, one of "PENDING", "PASSED", "WARNED", "FAILED", "SKIPPED", "ERRORED", "STOPPED"
# resp.job.started #=> Time
# resp.job.stopped #=> Time
# resp.job.counters.total #=> Integer
# resp.job.counters.passed #=> Integer
# resp.job.counters.failed #=> Integer
# resp.job.counters.warned #=> Integer
# resp.job.counters.errored #=> Integer
# resp.job.counters.stopped #=> Integer
# resp.job.counters.skipped #=> Integer
# resp.job.message #=> String
# resp.job.device.arn #=> String
# resp.job.device.name #=> String
# resp.job.device.manufacturer #=> String
# resp.job.device.model #=> String
# resp.job.device.model_id #=> String
# resp.job.device.form_factor #=> String, one of "PHONE", "TABLET"
# resp.job.device.platform #=> String, one of "ANDROID", "IOS"
# resp.job.device.os #=> String
# resp.job.device.cpu.frequency #=> String
# resp.job.device.cpu.architecture #=> String
# resp.job.device.cpu.clock #=> Float
# resp.job.device.resolution.width #=> Integer
# resp.job.device.resolution.height #=> Integer
# resp.job.device.heap_size #=> Integer
# resp.job.device.memory #=> Integer
# resp.job.device.image #=> String
# resp.job.device.carrier #=> String
# resp.job.device.radio #=> String
# resp.job.device.remote_access_enabled #=> Boolean
# resp.job.device.remote_debug_enabled #=> Boolean
# resp.job.device.fleet_type #=> String
# resp.job.device.fleet_name #=> String
# resp.job.device.instances #=> Array
# resp.job.device.instances[0].arn #=> String
# resp.job.device.instances[0].device_arn #=> String
# resp.job.device.instances[0].labels #=> Array
# resp.job.device.instances[0].labels[0] #=> String
# resp.job.device.instances[0].status #=> String, one of "IN_USE", "PREPARING", "AVAILABLE", "NOT_AVAILABLE"
# resp.job.device.instances[0].udid #=> String
# resp.job.device.instances[0].instance_profile.arn #=> String
# resp.job.device.instances[0].instance_profile.package_cleanup #=> Boolean
# resp.job.device.instances[0].instance_profile.exclude_app_packages_from_cleanup #=> Array
# resp.job.device.instances[0].instance_profile.exclude_app_packages_from_cleanup[0] #=> String
# resp.job.device.instances[0].instance_profile.reboot_after_use #=> Boolean
# resp.job.device.instances[0].instance_profile.name #=> String
# resp.job.device.instances[0].instance_profile.description #=> String
# resp.job.device.availability #=> String, one of "TEMPORARY_NOT_AVAILABLE", "BUSY", "AVAILABLE", "HIGHLY_AVAILABLE"
# resp.job.instance_arn #=> String
# resp.job.device_minutes.total #=> Float
# resp.job.device_minutes.metered #=> Float
# resp.job.device_minutes.unmetered #=> Float
# resp.job.video_endpoint #=> String
# resp.job.video_capture #=> Boolean
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/GetJob AWS API Documentation
#
# @overload get_job(params = {})
# @param [Hash] params ({})
def get_job(params = {}, options = {})
req = build_request(:get_job, params)
req.send_request(options)
end
# Returns information about a network profile.
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) of the network profile you want to
# return information about.
#
# @return [Types::GetNetworkProfileResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::GetNetworkProfileResult#network_profile #network_profile} => Types::NetworkProfile
#
# @example Request syntax with placeholder values
#
# resp = client.get_network_profile({
# arn: "AmazonResourceName", # required
# })
#
# @example Response structure
#
# resp.network_profile.arn #=> String
# resp.network_profile.name #=> String
# resp.network_profile.description #=> String
# resp.network_profile.type #=> String, one of "CURATED", "PRIVATE"
# resp.network_profile.uplink_bandwidth_bits #=> Integer
# resp.network_profile.downlink_bandwidth_bits #=> Integer
# resp.network_profile.uplink_delay_ms #=> Integer
# resp.network_profile.downlink_delay_ms #=> Integer
# resp.network_profile.uplink_jitter_ms #=> Integer
# resp.network_profile.downlink_jitter_ms #=> Integer
# resp.network_profile.uplink_loss_percent #=> Integer
# resp.network_profile.downlink_loss_percent #=> Integer
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/GetNetworkProfile AWS API Documentation
#
# @overload get_network_profile(params = {})
# @param [Hash] params ({})
def get_network_profile(params = {}, options = {})
req = build_request(:get_network_profile, params)
req.send_request(options)
end
# Gets the current status and future status of all offerings purchased
# by an AWS account. The response indicates how many offerings are
# currently available and the offerings that will be available in the
# next period. The API returns a `NotEligible` error if the user is not
# permitted to invoke the operation. Please contact
# [[email protected]](mailto:[email protected])
# if you believe that you should be able to invoke this operation.
#
# @option params [String] :next_token
# An identifier that was returned from the previous call to this
# operation, which can be used to return the next set of items in the
# list.
#
# @return [Types::GetOfferingStatusResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::GetOfferingStatusResult#current #current} => Hash<String,Types::OfferingStatus>
# * {Types::GetOfferingStatusResult#next_period #next_period} => Hash<String,Types::OfferingStatus>
# * {Types::GetOfferingStatusResult#next_token #next_token} => String
#
#
# @example Example: To get status information about device offerings
#
# # The following example returns information about Device Farm offerings available to your account.
#
# resp = client.get_offering_status({
# next_token: "RW5DdDJkMWYwZjM2MzM2VHVpOHJIUXlDUXlhc2QzRGViYnc9SEXAMPLE=", # A dynamically generated value, used for paginating results.
# })
#
# resp.to_h outputs the following:
# {
# current: {
# "D68B3C05-1BA6-4360-BC69-12345EXAMPLE" => {
# offering: {
# type: "RECURRING",
# description: "Android Remote Access Unmetered Device Slot",
# id: "D68B3C05-1BA6-4360-BC69-12345EXAMPLE",
# platform: "ANDROID",
# },
# quantity: 1,
# },
# },
# next_period: {
# "D68B3C05-1BA6-4360-BC69-12345EXAMPLE" => {
# effective_on: Time.parse("1472688000"),
# offering: {
# type: "RECURRING",
# description: "Android Remote Access Unmetered Device Slot",
# id: "D68B3C05-1BA6-4360-BC69-12345EXAMPLE",
# platform: "ANDROID",
# },
# quantity: 1,
# },
# },
# }
#
# @example Request syntax with placeholder values
#
# resp = client.get_offering_status({
# next_token: "PaginationToken",
# })
#
# @example Response structure
#
# resp.current #=> Hash
# resp.current["OfferingIdentifier"].type #=> String, one of "PURCHASE", "RENEW", "SYSTEM"
# resp.current["OfferingIdentifier"].offering.id #=> String
# resp.current["OfferingIdentifier"].offering.description #=> String
# resp.current["OfferingIdentifier"].offering.type #=> String, one of "RECURRING"
# resp.current["OfferingIdentifier"].offering.platform #=> String, one of "ANDROID", "IOS"
# resp.current["OfferingIdentifier"].offering.recurring_charges #=> Array
# resp.current["OfferingIdentifier"].offering.recurring_charges[0].cost.amount #=> Float
# resp.current["OfferingIdentifier"].offering.recurring_charges[0].cost.currency_code #=> String, one of "USD"
# resp.current["OfferingIdentifier"].offering.recurring_charges[0].frequency #=> String, one of "MONTHLY"
# resp.current["OfferingIdentifier"].quantity #=> Integer
# resp.current["OfferingIdentifier"].effective_on #=> Time
# resp.next_period #=> Hash
# resp.next_period["OfferingIdentifier"].type #=> String, one of "PURCHASE", "RENEW", "SYSTEM"
# resp.next_period["OfferingIdentifier"].offering.id #=> String
# resp.next_period["OfferingIdentifier"].offering.description #=> String
# resp.next_period["OfferingIdentifier"].offering.type #=> String, one of "RECURRING"
# resp.next_period["OfferingIdentifier"].offering.platform #=> String, one of "ANDROID", "IOS"
# resp.next_period["OfferingIdentifier"].offering.recurring_charges #=> Array
# resp.next_period["OfferingIdentifier"].offering.recurring_charges[0].cost.amount #=> Float
# resp.next_period["OfferingIdentifier"].offering.recurring_charges[0].cost.currency_code #=> String, one of "USD"
# resp.next_period["OfferingIdentifier"].offering.recurring_charges[0].frequency #=> String, one of "MONTHLY"
# resp.next_period["OfferingIdentifier"].quantity #=> Integer
# resp.next_period["OfferingIdentifier"].effective_on #=> Time
# resp.next_token #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/GetOfferingStatus AWS API Documentation
#
# @overload get_offering_status(params = {})
# @param [Hash] params ({})
def get_offering_status(params = {}, options = {})
req = build_request(:get_offering_status, params)
req.send_request(options)
end
# Gets information about a project.
#
# @option params [required, String] :arn
# The project's ARN.
#
# @return [Types::GetProjectResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::GetProjectResult#project #project} => Types::Project
#
#
# @example Example: To get information about a project
#
# # The following example gets information about a specific project.
#
# resp = client.get_project({
# arn: "arn:aws:devicefarm:us-west-2:123456789101:project:5e01a8c7-c861-4c0a-b1d5-12345EXAMPLE", # You can get the project ARN by using the list-projects CLI command.
# })
#
# resp.to_h outputs the following:
# {
# project: {
# name: "My Project",
# arn: "arn:aws:devicefarm:us-west-2:123456789101:project:5e01a8c7-c861-4c0a-b1d5-12345EXAMPLE",
# created: Time.parse("1472660939.152"),
# },
# }
#
# @example Request syntax with placeholder values
#
# resp = client.get_project({
# arn: "AmazonResourceName", # required
# })
#
# @example Response structure
#
# resp.project.arn #=> String
# resp.project.name #=> String
# resp.project.default_job_timeout_minutes #=> Integer
# resp.project.created #=> Time
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/GetProject AWS API Documentation
#
# @overload get_project(params = {})
# @param [Hash] params ({})
def get_project(params = {}, options = {})
req = build_request(:get_project, params)
req.send_request(options)
end
# Returns a link to a currently running remote access session.
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) of the remote access session about
# which you want to get session information.
#
# @return [Types::GetRemoteAccessSessionResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::GetRemoteAccessSessionResult#remote_access_session #remote_access_session} => Types::RemoteAccessSession
#
#
# @example Example: To get a remote access session
#
# # The following example gets a specific remote access session.
#
# resp = client.get_remote_access_session({
# arn: "arn:aws:devicefarm:us-west-2:123456789101:session:EXAMPLE-GUID-123-456", # You can get the remote access session ARN by using the list-remote-access-sessions CLI command.
# })
#
# resp.to_h outputs the following:
# {
# remote_access_session: {
# },
# }
#
# @example Request syntax with placeholder values
#
# resp = client.get_remote_access_session({
# arn: "AmazonResourceName", # required
# })
#
# @example Response structure
#
# resp.remote_access_session.arn #=> String
# resp.remote_access_session.name #=> String
# resp.remote_access_session.created #=> Time
# resp.remote_access_session.status #=> String, one of "PENDING", "PENDING_CONCURRENCY", "PENDING_DEVICE", "PROCESSING", "SCHEDULING", "PREPARING", "RUNNING", "COMPLETED", "STOPPING"
# resp.remote_access_session.result #=> String, one of "PENDING", "PASSED", "WARNED", "FAILED", "SKIPPED", "ERRORED", "STOPPED"
# resp.remote_access_session.message #=> String
# resp.remote_access_session.started #=> Time
# resp.remote_access_session.stopped #=> Time
# resp.remote_access_session.device.arn #=> String
# resp.remote_access_session.device.name #=> String
# resp.remote_access_session.device.manufacturer #=> String
# resp.remote_access_session.device.model #=> String
# resp.remote_access_session.device.model_id #=> String
# resp.remote_access_session.device.form_factor #=> String, one of "PHONE", "TABLET"
# resp.remote_access_session.device.platform #=> String, one of "ANDROID", "IOS"
# resp.remote_access_session.device.os #=> String
# resp.remote_access_session.device.cpu.frequency #=> String
# resp.remote_access_session.device.cpu.architecture #=> String
# resp.remote_access_session.device.cpu.clock #=> Float
# resp.remote_access_session.device.resolution.width #=> Integer
# resp.remote_access_session.device.resolution.height #=> Integer
# resp.remote_access_session.device.heap_size #=> Integer
# resp.remote_access_session.device.memory #=> Integer
# resp.remote_access_session.device.image #=> String
# resp.remote_access_session.device.carrier #=> String
# resp.remote_access_session.device.radio #=> String
# resp.remote_access_session.device.remote_access_enabled #=> Boolean
# resp.remote_access_session.device.remote_debug_enabled #=> Boolean
# resp.remote_access_session.device.fleet_type #=> String
# resp.remote_access_session.device.fleet_name #=> String
# resp.remote_access_session.device.instances #=> Array
# resp.remote_access_session.device.instances[0].arn #=> String
# resp.remote_access_session.device.instances[0].device_arn #=> String
# resp.remote_access_session.device.instances[0].labels #=> Array
# resp.remote_access_session.device.instances[0].labels[0] #=> String
# resp.remote_access_session.device.instances[0].status #=> String, one of "IN_USE", "PREPARING", "AVAILABLE", "NOT_AVAILABLE"
# resp.remote_access_session.device.instances[0].udid #=> String
# resp.remote_access_session.device.instances[0].instance_profile.arn #=> String
# resp.remote_access_session.device.instances[0].instance_profile.package_cleanup #=> Boolean
# resp.remote_access_session.device.instances[0].instance_profile.exclude_app_packages_from_cleanup #=> Array
# resp.remote_access_session.device.instances[0].instance_profile.exclude_app_packages_from_cleanup[0] #=> String
# resp.remote_access_session.device.instances[0].instance_profile.reboot_after_use #=> Boolean
# resp.remote_access_session.device.instances[0].instance_profile.name #=> String
# resp.remote_access_session.device.instances[0].instance_profile.description #=> String
# resp.remote_access_session.device.availability #=> String, one of "TEMPORARY_NOT_AVAILABLE", "BUSY", "AVAILABLE", "HIGHLY_AVAILABLE"
# resp.remote_access_session.instance_arn #=> String
# resp.remote_access_session.remote_debug_enabled #=> Boolean
# resp.remote_access_session.remote_record_enabled #=> Boolean
# resp.remote_access_session.remote_record_app_arn #=> String
# resp.remote_access_session.host_address #=> String
# resp.remote_access_session.client_id #=> String
# resp.remote_access_session.billing_method #=> String, one of "METERED", "UNMETERED"
# resp.remote_access_session.device_minutes.total #=> Float
# resp.remote_access_session.device_minutes.metered #=> Float
# resp.remote_access_session.device_minutes.unmetered #=> Float
# resp.remote_access_session.endpoint #=> String
# resp.remote_access_session.device_udid #=> String
# resp.remote_access_session.interaction_mode #=> String, one of "INTERACTIVE", "NO_VIDEO", "VIDEO_ONLY"
# resp.remote_access_session.skip_app_resign #=> Boolean
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/GetRemoteAccessSession AWS API Documentation
#
# @overload get_remote_access_session(params = {})
# @param [Hash] params ({})
def get_remote_access_session(params = {}, options = {})
req = build_request(:get_remote_access_session, params)
req.send_request(options)
end
# Gets information about a run.
#
# @option params [required, String] :arn
# The run's ARN.
#
# @return [Types::GetRunResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::GetRunResult#run #run} => Types::Run
#
#
# @example Example: To get information about a test run
#
# # The following example gets information about a specific test run.
#
# resp = client.get_run({
# arn: "arn:aws:devicefarm:us-west-2:123456789101:run:5e01a8c7-c861-4c0a-b1d5-5ec6e6c6dd23/0fcac17b-6122-44d7-ae5a-12345EXAMPLE", # You can get the run ARN by using the list-runs CLI command.
# })
#
# resp.to_h outputs the following:
# {
# run: {
# name: "My Test Run",
# type: "BUILTIN_EXPLORER",
# arn: "arn:aws:devicefarm:us-west-2:123456789101:run:5e01a8c7-c861-4c0a-b1d5-5ec6e6c6dd23/0fcac17b-6122-44d7-ae5a-12345EXAMPLE",
# billing_method: "METERED",
# completed_jobs: 0,
# counters: {
# errored: 0,
# failed: 0,
# passed: 0,
# skipped: 0,
# stopped: 0,
# total: 0,
# warned: 0,
# },
# created: Time.parse("1472667509.852"),
# device_minutes: {
# metered: 0.0,
# total: 0.0,
# unmetered: 0.0,
# },
# platform: "ANDROID",
# result: "PENDING",
# status: "RUNNING",
# total_jobs: 3,
# },
# }
#
# @example Request syntax with placeholder values
#
# resp = client.get_run({
# arn: "AmazonResourceName", # required
# })
#
# @example Response structure
#
# resp.run.arn #=> String
# resp.run.name #=> String
# resp.run.type #=> String, one of "BUILTIN_FUZZ", "BUILTIN_EXPLORER", "WEB_PERFORMANCE_PROFILE", "APPIUM_JAVA_JUNIT", "APPIUM_JAVA_TESTNG", "APPIUM_PYTHON", "APPIUM_NODE", "APPIUM_RUBY", "APPIUM_WEB_JAVA_JUNIT", "APPIUM_WEB_JAVA_TESTNG", "APPIUM_WEB_PYTHON", "APPIUM_WEB_NODE", "APPIUM_WEB_RUBY", "CALABASH", "INSTRUMENTATION", "UIAUTOMATION", "UIAUTOMATOR", "XCTEST", "XCTEST_UI", "REMOTE_ACCESS_RECORD", "REMOTE_ACCESS_REPLAY"
# resp.run.platform #=> String, one of "ANDROID", "IOS"
# resp.run.created #=> Time
# resp.run.status #=> String, one of "PENDING", "PENDING_CONCURRENCY", "PENDING_DEVICE", "PROCESSING", "SCHEDULING", "PREPARING", "RUNNING", "COMPLETED", "STOPPING"
# resp.run.result #=> String, one of "PENDING", "PASSED", "WARNED", "FAILED", "SKIPPED", "ERRORED", "STOPPED"
# resp.run.started #=> Time
# resp.run.stopped #=> Time
# resp.run.counters.total #=> Integer
# resp.run.counters.passed #=> Integer
# resp.run.counters.failed #=> Integer
# resp.run.counters.warned #=> Integer
# resp.run.counters.errored #=> Integer
# resp.run.counters.stopped #=> Integer
# resp.run.counters.skipped #=> Integer
# resp.run.message #=> String
# resp.run.total_jobs #=> Integer
# resp.run.completed_jobs #=> Integer
# resp.run.billing_method #=> String, one of "METERED", "UNMETERED"
# resp.run.device_minutes.total #=> Float
# resp.run.device_minutes.metered #=> Float
# resp.run.device_minutes.unmetered #=> Float
# resp.run.network_profile.arn #=> String
# resp.run.network_profile.name #=> String
# resp.run.network_profile.description #=> String
# resp.run.network_profile.type #=> String, one of "CURATED", "PRIVATE"
# resp.run.network_profile.uplink_bandwidth_bits #=> Integer
# resp.run.network_profile.downlink_bandwidth_bits #=> Integer
# resp.run.network_profile.uplink_delay_ms #=> Integer
# resp.run.network_profile.downlink_delay_ms #=> Integer
# resp.run.network_profile.uplink_jitter_ms #=> Integer
# resp.run.network_profile.downlink_jitter_ms #=> Integer
# resp.run.network_profile.uplink_loss_percent #=> Integer
# resp.run.network_profile.downlink_loss_percent #=> Integer
# resp.run.parsing_result_url #=> String
# resp.run.result_code #=> String, one of "PARSING_FAILED", "VPC_ENDPOINT_SETUP_FAILED"
# resp.run.seed #=> Integer
# resp.run.app_upload #=> String
# resp.run.event_count #=> Integer
# resp.run.job_timeout_minutes #=> Integer
# resp.run.device_pool_arn #=> String
# resp.run.locale #=> String
# resp.run.radios.wifi #=> Boolean
# resp.run.radios.bluetooth #=> Boolean
# resp.run.radios.nfc #=> Boolean
# resp.run.radios.gps #=> Boolean
# resp.run.location.latitude #=> Float
# resp.run.location.longitude #=> Float
# resp.run.customer_artifact_paths.ios_paths #=> Array
# resp.run.customer_artifact_paths.ios_paths[0] #=> String
# resp.run.customer_artifact_paths.android_paths #=> Array
# resp.run.customer_artifact_paths.android_paths[0] #=> String
# resp.run.customer_artifact_paths.device_host_paths #=> Array
# resp.run.customer_artifact_paths.device_host_paths[0] #=> String
# resp.run.web_url #=> String
# resp.run.skip_app_resign #=> Boolean
# resp.run.test_spec_arn #=> String
# resp.run.device_selection_result.filters #=> Array
# resp.run.device_selection_result.filters[0].attribute #=> String, one of "ARN", "PLATFORM", "OS_VERSION", "MODEL", "AVAILABILITY", "FORM_FACTOR", "MANUFACTURER", "REMOTE_ACCESS_ENABLED", "REMOTE_DEBUG_ENABLED", "INSTANCE_ARN", "INSTANCE_LABELS", "FLEET_TYPE"
# resp.run.device_selection_result.filters[0].operator #=> String, one of "EQUALS", "LESS_THAN", "LESS_THAN_OR_EQUALS", "GREATER_THAN", "GREATER_THAN_OR_EQUALS", "IN", "NOT_IN", "CONTAINS"
# resp.run.device_selection_result.filters[0].values #=> Array
# resp.run.device_selection_result.filters[0].values[0] #=> String
# resp.run.device_selection_result.matched_devices_count #=> Integer
# resp.run.device_selection_result.max_devices #=> Integer
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/GetRun AWS API Documentation
#
# @overload get_run(params = {})
# @param [Hash] params ({})
def get_run(params = {}, options = {})
req = build_request(:get_run, params)
req.send_request(options)
end
# Gets information about a suite.
#
# @option params [required, String] :arn
# The suite's ARN.
#
# @return [Types::GetSuiteResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::GetSuiteResult#suite #suite} => Types::Suite
#
#
# @example Example: To get information about a test suite
#
# # The following example gets information about a specific test suite.
#
# resp = client.get_suite({
# arn: "arn:aws:devicefarm:us-west-2:123456789101:suite:EXAMPLE-GUID-123-456", # You can get the suite ARN by using the list-suites CLI command.
# })
#
# resp.to_h outputs the following:
# {
# suite: {
# },
# }
#
# @example Request syntax with placeholder values
#
# resp = client.get_suite({
# arn: "AmazonResourceName", # required
# })
#
# @example Response structure
#
# resp.suite.arn #=> String
# resp.suite.name #=> String
# resp.suite.type #=> String, one of "BUILTIN_FUZZ", "BUILTIN_EXPLORER", "WEB_PERFORMANCE_PROFILE", "APPIUM_JAVA_JUNIT", "APPIUM_JAVA_TESTNG", "APPIUM_PYTHON", "APPIUM_NODE", "APPIUM_RUBY", "APPIUM_WEB_JAVA_JUNIT", "APPIUM_WEB_JAVA_TESTNG", "APPIUM_WEB_PYTHON", "APPIUM_WEB_NODE", "APPIUM_WEB_RUBY", "CALABASH", "INSTRUMENTATION", "UIAUTOMATION", "UIAUTOMATOR", "XCTEST", "XCTEST_UI", "REMOTE_ACCESS_RECORD", "REMOTE_ACCESS_REPLAY"
# resp.suite.created #=> Time
# resp.suite.status #=> String, one of "PENDING", "PENDING_CONCURRENCY", "PENDING_DEVICE", "PROCESSING", "SCHEDULING", "PREPARING", "RUNNING", "COMPLETED", "STOPPING"
# resp.suite.result #=> String, one of "PENDING", "PASSED", "WARNED", "FAILED", "SKIPPED", "ERRORED", "STOPPED"
# resp.suite.started #=> Time
# resp.suite.stopped #=> Time
# resp.suite.counters.total #=> Integer
# resp.suite.counters.passed #=> Integer
# resp.suite.counters.failed #=> Integer
# resp.suite.counters.warned #=> Integer
# resp.suite.counters.errored #=> Integer
# resp.suite.counters.stopped #=> Integer
# resp.suite.counters.skipped #=> Integer
# resp.suite.message #=> String
# resp.suite.device_minutes.total #=> Float
# resp.suite.device_minutes.metered #=> Float
# resp.suite.device_minutes.unmetered #=> Float
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/GetSuite AWS API Documentation
#
# @overload get_suite(params = {})
# @param [Hash] params ({})
def get_suite(params = {}, options = {})
req = build_request(:get_suite, params)
req.send_request(options)
end
# Gets information about a test.
#
# @option params [required, String] :arn
# The test's ARN.
#
# @return [Types::GetTestResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::GetTestResult#test #test} => Types::Test
#
#
# @example Example: To get information about a specific test
#
# # The following example gets information about a specific test.
#
# resp = client.get_test({
# arn: "arn:aws:devicefarm:us-west-2:123456789101:test:EXAMPLE-GUID-123-456", # You can get the test ARN by using the list-tests CLI command.
# })
#
# resp.to_h outputs the following:
# {
# test: {
# },
# }
#
# @example Request syntax with placeholder values
#
# resp = client.get_test({
# arn: "AmazonResourceName", # required
# })
#
# @example Response structure
#
# resp.test.arn #=> String
# resp.test.name #=> String
# resp.test.type #=> String, one of "BUILTIN_FUZZ", "BUILTIN_EXPLORER", "WEB_PERFORMANCE_PROFILE", "APPIUM_JAVA_JUNIT", "APPIUM_JAVA_TESTNG", "APPIUM_PYTHON", "APPIUM_NODE", "APPIUM_RUBY", "APPIUM_WEB_JAVA_JUNIT", "APPIUM_WEB_JAVA_TESTNG", "APPIUM_WEB_PYTHON", "APPIUM_WEB_NODE", "APPIUM_WEB_RUBY", "CALABASH", "INSTRUMENTATION", "UIAUTOMATION", "UIAUTOMATOR", "XCTEST", "XCTEST_UI", "REMOTE_ACCESS_RECORD", "REMOTE_ACCESS_REPLAY"
# resp.test.created #=> Time
# resp.test.status #=> String, one of "PENDING", "PENDING_CONCURRENCY", "PENDING_DEVICE", "PROCESSING", "SCHEDULING", "PREPARING", "RUNNING", "COMPLETED", "STOPPING"
# resp.test.result #=> String, one of "PENDING", "PASSED", "WARNED", "FAILED", "SKIPPED", "ERRORED", "STOPPED"
# resp.test.started #=> Time
# resp.test.stopped #=> Time
# resp.test.counters.total #=> Integer
# resp.test.counters.passed #=> Integer
# resp.test.counters.failed #=> Integer
# resp.test.counters.warned #=> Integer
# resp.test.counters.errored #=> Integer
# resp.test.counters.stopped #=> Integer
# resp.test.counters.skipped #=> Integer
# resp.test.message #=> String
# resp.test.device_minutes.total #=> Float
# resp.test.device_minutes.metered #=> Float
# resp.test.device_minutes.unmetered #=> Float
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/GetTest AWS API Documentation
#
# @overload get_test(params = {})
# @param [Hash] params ({})
def get_test(params = {}, options = {})
req = build_request(:get_test, params)
req.send_request(options)
end
# Gets information about an upload.
#
# @option params [required, String] :arn
# The upload's ARN.
#
# @return [Types::GetUploadResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::GetUploadResult#upload #upload} => Types::Upload
#
#
# @example Example: To get information about a specific upload
#
# # The following example gets information about a specific upload.
#
# resp = client.get_upload({
# arn: "arn:aws:devicefarm:us-west-2:123456789101:upload:EXAMPLE-GUID-123-456", # You can get the test ARN by using the list-uploads CLI command.
# })
#
# resp.to_h outputs the following:
# {
# upload: {
# },
# }
#
# @example Request syntax with placeholder values
#
# resp = client.get_upload({
# arn: "AmazonResourceName", # required
# })
#
# @example Response structure
#
# resp.upload.arn #=> String
# resp.upload.name #=> String
# resp.upload.created #=> Time
# resp.upload.type #=> String, one of "ANDROID_APP", "IOS_APP", "WEB_APP", "EXTERNAL_DATA", "APPIUM_JAVA_JUNIT_TEST_PACKAGE", "APPIUM_JAVA_TESTNG_TEST_PACKAGE", "APPIUM_PYTHON_TEST_PACKAGE", "APPIUM_NODE_TEST_PACKAGE", "APPIUM_RUBY_TEST_PACKAGE", "APPIUM_WEB_JAVA_JUNIT_TEST_PACKAGE", "APPIUM_WEB_JAVA_TESTNG_TEST_PACKAGE", "APPIUM_WEB_PYTHON_TEST_PACKAGE", "APPIUM_WEB_NODE_TEST_PACKAGE", "APPIUM_WEB_RUBY_TEST_PACKAGE", "CALABASH_TEST_PACKAGE", "INSTRUMENTATION_TEST_PACKAGE", "UIAUTOMATION_TEST_PACKAGE", "UIAUTOMATOR_TEST_PACKAGE", "XCTEST_TEST_PACKAGE", "XCTEST_UI_TEST_PACKAGE", "APPIUM_JAVA_JUNIT_TEST_SPEC", "APPIUM_JAVA_TESTNG_TEST_SPEC", "APPIUM_PYTHON_TEST_SPEC", "APPIUM_NODE_TEST_SPEC", "APPIUM_RUBY_TEST_SPEC", "APPIUM_WEB_JAVA_JUNIT_TEST_SPEC", "APPIUM_WEB_JAVA_TESTNG_TEST_SPEC", "APPIUM_WEB_PYTHON_TEST_SPEC", "APPIUM_WEB_NODE_TEST_SPEC", "APPIUM_WEB_RUBY_TEST_SPEC", "INSTRUMENTATION_TEST_SPEC", "XCTEST_UI_TEST_SPEC"
# resp.upload.status #=> String, one of "INITIALIZED", "PROCESSING", "SUCCEEDED", "FAILED"
# resp.upload.url #=> String
# resp.upload.metadata #=> String
# resp.upload.content_type #=> String
# resp.upload.message #=> String
# resp.upload.category #=> String, one of "CURATED", "PRIVATE"
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/GetUpload AWS API Documentation
#
# @overload get_upload(params = {})
# @param [Hash] params ({})
def get_upload(params = {}, options = {})
req = build_request(:get_upload, params)
req.send_request(options)
end
# Returns information about the configuration settings for your Amazon
# Virtual Private Cloud (VPC) endpoint.
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) of the VPC endpoint configuration you
# want to describe.
#
# @return [Types::GetVPCEConfigurationResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::GetVPCEConfigurationResult#vpce_configuration #vpce_configuration} => Types::VPCEConfiguration
#
# @example Request syntax with placeholder values
#
# resp = client.get_vpce_configuration({
# arn: "AmazonResourceName", # required
# })
#
# @example Response structure
#
# resp.vpce_configuration.arn #=> String
# resp.vpce_configuration.vpce_configuration_name #=> String
# resp.vpce_configuration.vpce_service_name #=> String
# resp.vpce_configuration.service_dns_name #=> String
# resp.vpce_configuration.vpce_configuration_description #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/GetVPCEConfiguration AWS API Documentation
#
# @overload get_vpce_configuration(params = {})
# @param [Hash] params ({})
def get_vpce_configuration(params = {}, options = {})
req = build_request(:get_vpce_configuration, params)
req.send_request(options)
end
# Installs an application to the device in a remote access session. For
# Android applications, the file must be in .apk format. For iOS
# applications, the file must be in .ipa format.
#
# @option params [required, String] :remote_access_session_arn
# The Amazon Resource Name (ARN) of the remote access session about
# which you are requesting information.
#
# @option params [required, String] :app_arn
# The Amazon Resource Name (ARN) of the app about which you are
# requesting information.
#
# @return [Types::InstallToRemoteAccessSessionResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::InstallToRemoteAccessSessionResult#app_upload #app_upload} => Types::Upload
#
#
# @example Example: To install to a remote access session
#
# # The following example installs a specific app to a device in a specific remote access session.
#
# resp = client.install_to_remote_access_session({
# app_arn: "arn:aws:devicefarm:us-west-2:123456789101:app:EXAMPLE-GUID-123-456",
# remote_access_session_arn: "arn:aws:devicefarm:us-west-2:123456789101:session:EXAMPLE-GUID-123-456", # You can get the remote access session ARN by using the list-remote-access-sessions CLI command.
# })
#
# resp.to_h outputs the following:
# {
# app_upload: {
# },
# }
#
# @example Request syntax with placeholder values
#
# resp = client.install_to_remote_access_session({
# remote_access_session_arn: "AmazonResourceName", # required
# app_arn: "AmazonResourceName", # required
# })
#
# @example Response structure
#
# resp.app_upload.arn #=> String
# resp.app_upload.name #=> String
# resp.app_upload.created #=> Time
# resp.app_upload.type #=> String, one of "ANDROID_APP", "IOS_APP", "WEB_APP", "EXTERNAL_DATA", "APPIUM_JAVA_JUNIT_TEST_PACKAGE", "APPIUM_JAVA_TESTNG_TEST_PACKAGE", "APPIUM_PYTHON_TEST_PACKAGE", "APPIUM_NODE_TEST_PACKAGE", "APPIUM_RUBY_TEST_PACKAGE", "APPIUM_WEB_JAVA_JUNIT_TEST_PACKAGE", "APPIUM_WEB_JAVA_TESTNG_TEST_PACKAGE", "APPIUM_WEB_PYTHON_TEST_PACKAGE", "APPIUM_WEB_NODE_TEST_PACKAGE", "APPIUM_WEB_RUBY_TEST_PACKAGE", "CALABASH_TEST_PACKAGE", "INSTRUMENTATION_TEST_PACKAGE", "UIAUTOMATION_TEST_PACKAGE", "UIAUTOMATOR_TEST_PACKAGE", "XCTEST_TEST_PACKAGE", "XCTEST_UI_TEST_PACKAGE", "APPIUM_JAVA_JUNIT_TEST_SPEC", "APPIUM_JAVA_TESTNG_TEST_SPEC", "APPIUM_PYTHON_TEST_SPEC", "APPIUM_NODE_TEST_SPEC", "APPIUM_RUBY_TEST_SPEC", "APPIUM_WEB_JAVA_JUNIT_TEST_SPEC", "APPIUM_WEB_JAVA_TESTNG_TEST_SPEC", "APPIUM_WEB_PYTHON_TEST_SPEC", "APPIUM_WEB_NODE_TEST_SPEC", "APPIUM_WEB_RUBY_TEST_SPEC", "INSTRUMENTATION_TEST_SPEC", "XCTEST_UI_TEST_SPEC"
# resp.app_upload.status #=> String, one of "INITIALIZED", "PROCESSING", "SUCCEEDED", "FAILED"
# resp.app_upload.url #=> String
# resp.app_upload.metadata #=> String
# resp.app_upload.content_type #=> String
# resp.app_upload.message #=> String
# resp.app_upload.category #=> String, one of "CURATED", "PRIVATE"
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/InstallToRemoteAccessSession AWS API Documentation
#
# @overload install_to_remote_access_session(params = {})
# @param [Hash] params ({})
def install_to_remote_access_session(params = {}, options = {})
req = build_request(:install_to_remote_access_session, params)
req.send_request(options)
end
# Gets information about artifacts.
#
# @option params [required, String] :arn
# The Run, Job, Suite, or Test ARN.
#
# @option params [required, String] :type
# The artifacts' type.
#
# Allowed values include:
#
# * FILE: The artifacts are files.
#
# * LOG: The artifacts are logs.
#
# * SCREENSHOT: The artifacts are screenshots.
#
# @option params [String] :next_token
# An identifier that was returned from the previous call to this
# operation, which can be used to return the next set of items in the
# list.
#
# @return [Types::ListArtifactsResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::ListArtifactsResult#artifacts #artifacts} => Array<Types::Artifact>
# * {Types::ListArtifactsResult#next_token #next_token} => String
#
#
# @example Example: To list artifacts for a resource
#
# # The following example lists screenshot artifacts for a specific run.
#
# resp = client.list_artifacts({
# type: "SCREENSHOT",
# arn: "arn:aws:devicefarm:us-west-2:123456789101:run:EXAMPLE-GUID-123-456", # Can also be used to list artifacts for a Job, Suite, or Test ARN.
# })
#
# @example Request syntax with placeholder values
#
# resp = client.list_artifacts({
# arn: "AmazonResourceName", # required
# type: "SCREENSHOT", # required, accepts SCREENSHOT, FILE, LOG
# next_token: "PaginationToken",
# })
#
# @example Response structure
#
# resp.artifacts #=> Array
# resp.artifacts[0].arn #=> String
# resp.artifacts[0].name #=> String
# resp.artifacts[0].type #=> String, one of "UNKNOWN", "SCREENSHOT", "DEVICE_LOG", "MESSAGE_LOG", "VIDEO_LOG", "RESULT_LOG", "SERVICE_LOG", "WEBKIT_LOG", "INSTRUMENTATION_OUTPUT", "EXERCISER_MONKEY_OUTPUT", "CALABASH_JSON_OUTPUT", "CALABASH_PRETTY_OUTPUT", "CALABASH_STANDARD_OUTPUT", "CALABASH_JAVA_XML_OUTPUT", "AUTOMATION_OUTPUT", "APPIUM_SERVER_OUTPUT", "APPIUM_JAVA_OUTPUT", "APPIUM_JAVA_XML_OUTPUT", "APPIUM_PYTHON_OUTPUT", "APPIUM_PYTHON_XML_OUTPUT", "EXPLORER_EVENT_LOG", "EXPLORER_SUMMARY_LOG", "APPLICATION_CRASH_REPORT", "XCTEST_LOG", "VIDEO", "CUSTOMER_ARTIFACT", "CUSTOMER_ARTIFACT_LOG", "TESTSPEC_OUTPUT"
# resp.artifacts[0].extension #=> String
# resp.artifacts[0].url #=> String
# resp.next_token #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/ListArtifacts AWS API Documentation
#
# @overload list_artifacts(params = {})
# @param [Hash] params ({})
def list_artifacts(params = {}, options = {})
req = build_request(:list_artifacts, params)
req.send_request(options)
end
# Returns information about the private device instances associated with
# one or more AWS accounts.
#
# @option params [Integer] :max_results
# An integer specifying the maximum number of items you want to return
# in the API response.
#
# @option params [String] :next_token
# An identifier that was returned from the previous call to this
# operation, which can be used to return the next set of items in the
# list.
#
# @return [Types::ListDeviceInstancesResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::ListDeviceInstancesResult#device_instances #device_instances} => Array<Types::DeviceInstance>
# * {Types::ListDeviceInstancesResult#next_token #next_token} => String
#
# @example Request syntax with placeholder values
#
# resp = client.list_device_instances({
# max_results: 1,
# next_token: "PaginationToken",
# })
#
# @example Response structure
#
# resp.device_instances #=> Array
# resp.device_instances[0].arn #=> String
# resp.device_instances[0].device_arn #=> String
# resp.device_instances[0].labels #=> Array
# resp.device_instances[0].labels[0] #=> String
# resp.device_instances[0].status #=> String, one of "IN_USE", "PREPARING", "AVAILABLE", "NOT_AVAILABLE"
# resp.device_instances[0].udid #=> String
# resp.device_instances[0].instance_profile.arn #=> String
# resp.device_instances[0].instance_profile.package_cleanup #=> Boolean
# resp.device_instances[0].instance_profile.exclude_app_packages_from_cleanup #=> Array
# resp.device_instances[0].instance_profile.exclude_app_packages_from_cleanup[0] #=> String
# resp.device_instances[0].instance_profile.reboot_after_use #=> Boolean
# resp.device_instances[0].instance_profile.name #=> String
# resp.device_instances[0].instance_profile.description #=> String
# resp.next_token #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/ListDeviceInstances AWS API Documentation
#
# @overload list_device_instances(params = {})
# @param [Hash] params ({})
def list_device_instances(params = {}, options = {})
req = build_request(:list_device_instances, params)
req.send_request(options)
end
# Gets information about device pools.
#
# @option params [required, String] :arn
# The project ARN.
#
# @option params [String] :type
# The device pools' type.
#
# Allowed values include:
#
# * CURATED: A device pool that is created and managed by AWS Device
# Farm.
#
# * PRIVATE: A device pool that is created and managed by the device
# pool developer.
#
# @option params [String] :next_token
# An identifier that was returned from the previous call to this
# operation, which can be used to return the next set of items in the
# list.
#
# @return [Types::ListDevicePoolsResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::ListDevicePoolsResult#device_pools #device_pools} => Array<Types::DevicePool>
# * {Types::ListDevicePoolsResult#next_token #next_token} => String
#
#
# @example Example: To get information about device pools
#
# # The following example returns information about the private device pools in a specific project.
#
# resp = client.list_device_pools({
# type: "PRIVATE",
# arn: "arn:aws:devicefarm:us-west-2:123456789101:project:EXAMPLE-GUID-123-456", # You can get the project ARN by using the list-projects CLI command.
# })
#
# resp.to_h outputs the following:
# {
# device_pools: [
# {
# name: "Top Devices",
# arn: "arn:aws:devicefarm:us-west-2::devicepool:082d10e5-d7d7-48a5-ba5c-12345EXAMPLE",
# description: "Top devices",
# rules: [
# {
# value: "[\"arn:aws:devicefarm:us-west-2::device:123456789EXAMPLE\",\"arn:aws:devicefarm:us-west-2::device:123456789EXAMPLE\",\"arn:aws:devicefarm:us-west-2::device:123456789EXAMPLE\",\"arn:aws:devicefarm:us-west-2::device:123456789EXAMPLE\",\"arn:aws:devicefarm:us-west-2::device:123456789EXAMPLE\",\"arn:aws:devicefarm:us-west-2::device:123456789EXAMPLE\",\"arn:aws:devicefarm:us-west-2::device:123456789EXAMPLE\",\"arn:aws:devicefarm:us-west-2::device:123456789EXAMPLE\",\"arn:aws:devicefarm:us-west-2::device:123456789EXAMPLE\",\"arn:aws:devicefarm:us-west-2::device:123456789EXAMPLE\"]",
# attribute: "ARN",
# operator: "IN",
# },
# ],
# },
# {
# name: "My Android Device Pool",
# arn: "arn:aws:devicefarm:us-west-2:123456789101:devicepool:5e01a8c7-c861-4c0a-b1d5-5ec6e6c6dd23/bf96e75a-28f6-4e61-b6a7-12345EXAMPLE",
# description: "Samsung Galaxy Android devices",
# rules: [
# {
# value: "[\"arn:aws:devicefarm:us-west-2::device:123456789EXAMPLE\",\"arn:aws:devicefarm:us-west-2::device:123456789EXAMPLE\",\"arn:aws:devicefarm:us-west-2::device:123456789EXAMPLE\"]",
# attribute: "ARN",
# operator: "IN",
# },
# ],
# },
# ],
# }
#
# @example Request syntax with placeholder values
#
# resp = client.list_device_pools({
# arn: "AmazonResourceName", # required
# type: "CURATED", # accepts CURATED, PRIVATE
# next_token: "PaginationToken",
# })
#
# @example Response structure
#
# resp.device_pools #=> Array
# resp.device_pools[0].arn #=> String
# resp.device_pools[0].name #=> String
# resp.device_pools[0].description #=> String
# resp.device_pools[0].type #=> String, one of "CURATED", "PRIVATE"
# resp.device_pools[0].rules #=> Array
# resp.device_pools[0].rules[0].attribute #=> String, one of "ARN", "PLATFORM", "FORM_FACTOR", "MANUFACTURER", "REMOTE_ACCESS_ENABLED", "REMOTE_DEBUG_ENABLED", "APPIUM_VERSION", "INSTANCE_ARN", "INSTANCE_LABELS", "FLEET_TYPE", "OS_VERSION", "MODEL", "AVAILABILITY"
# resp.device_pools[0].rules[0].operator #=> String, one of "EQUALS", "LESS_THAN", "LESS_THAN_OR_EQUALS", "GREATER_THAN", "GREATER_THAN_OR_EQUALS", "IN", "NOT_IN", "CONTAINS"
# resp.device_pools[0].rules[0].value #=> String
# resp.device_pools[0].max_devices #=> Integer
# resp.next_token #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/ListDevicePools AWS API Documentation
#
# @overload list_device_pools(params = {})
# @param [Hash] params ({})
def list_device_pools(params = {}, options = {})
req = build_request(:list_device_pools, params)
req.send_request(options)
end
# Gets information about unique device types.
#
# @option params [String] :arn
# The Amazon Resource Name (ARN) of the project.
#
# @option params [String] :next_token
# An identifier that was returned from the previous call to this
# operation, which can be used to return the next set of items in the
# list.
#
# @option params [Array<Types::DeviceFilter>] :filters
# Used to select a set of devices. A filter is made up of an attribute,
# an operator, and one or more values.
#
# * Attribute: The aspect of a device such as platform or model used as
# the selection criteria in a device filter.
#
# Allowed values include:
#
# * ARN: The Amazon Resource Name (ARN) of the device. For example,
# "arn:aws:devicefarm:us-west-2::device:12345Example".
#
# * PLATFORM: The device platform. Valid values are "ANDROID" or
# "IOS".
#
# * OS\_VERSION: The operating system version. For example,
# "10.3.2".
#
# * MODEL: The device model. For example, "iPad 5th Gen".
#
# * AVAILABILITY: The current availability of the device. Valid values
# are "AVAILABLE", "HIGHLY\_AVAILABLE", "BUSY", or
# "TEMPORARY\_NOT\_AVAILABLE".
#
# * FORM\_FACTOR: The device form factor. Valid values are "PHONE"
# or "TABLET".
#
# * MANUFACTURER: The device manufacturer. For example, "Apple".
#
# * REMOTE\_ACCESS\_ENABLED: Whether the device is enabled for remote
# access. Valid values are "TRUE" or "FALSE".
#
# * REMOTE\_DEBUG\_ENABLED: Whether the device is enabled for remote
# debugging. Valid values are "TRUE" or "FALSE". *This attribute
# will be ignored, as remote debugging is [no longer supported][1].*
#
# * INSTANCE\_ARN: The Amazon Resource Name (ARN) of the device
# instance.
#
# * INSTANCE\_LABELS: The label of the device instance.
#
# * FLEET\_TYPE: The fleet type. Valid values are "PUBLIC" or
# "PRIVATE".
#
# * Operator: The filter operator.
#
# * The EQUALS operator is available for every attribute except
# INSTANCE\_LABELS.
#
# * The CONTAINS operator is available for the INSTANCE\_LABELS and
# MODEL attributes.
#
# * The IN and NOT\_IN operators are available for the ARN,
# OS\_VERSION, MODEL, MANUFACTURER, and INSTANCE\_ARN attributes.
#
# * The LESS\_THAN, GREATER\_THAN, LESS\_THAN\_OR\_EQUALS, and
# GREATER\_THAN\_OR\_EQUALS operators are also available for the
# OS\_VERSION attribute.
#
# * Values: An array of one or more filter values.
#
# * The IN and NOT\_IN operators take a values array that has one or
# more elements.
#
# * The other operators require an array with a single element.
#
# * In a request, the AVAILABILITY attribute takes "AVAILABLE",
# "HIGHLY\_AVAILABLE", "BUSY", or "TEMPORARY\_NOT\_AVAILABLE"
# as values.
#
#
#
# [1]: https://docs.aws.amazon.com/devicefarm/latest/developerguide/history.html
#
# @return [Types::ListDevicesResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::ListDevicesResult#devices #devices} => Array<Types::Device>
# * {Types::ListDevicesResult#next_token #next_token} => String
#
#
# @example Example: To get information about devices
#
# # The following example returns information about the available devices in a specific project.
#
# resp = client.list_devices({
# arn: "arn:aws:devicefarm:us-west-2:123456789101:project:EXAMPLE-GUID-123-456", # You can get the project ARN by using the list-projects CLI command.
# })
#
# resp.to_h outputs the following:
# {
# }
#
# @example Request syntax with placeholder values
#
# resp = client.list_devices({
# arn: "AmazonResourceName",
# next_token: "PaginationToken",
# filters: [
# {
# attribute: "ARN", # accepts ARN, PLATFORM, OS_VERSION, MODEL, AVAILABILITY, FORM_FACTOR, MANUFACTURER, REMOTE_ACCESS_ENABLED, REMOTE_DEBUG_ENABLED, INSTANCE_ARN, INSTANCE_LABELS, FLEET_TYPE
# operator: "EQUALS", # accepts EQUALS, LESS_THAN, LESS_THAN_OR_EQUALS, GREATER_THAN, GREATER_THAN_OR_EQUALS, IN, NOT_IN, CONTAINS
# values: ["String"],
# },
# ],
# })
#
# @example Response structure
#
# resp.devices #=> Array
# resp.devices[0].arn #=> String
# resp.devices[0].name #=> String
# resp.devices[0].manufacturer #=> String
# resp.devices[0].model #=> String
# resp.devices[0].model_id #=> String
# resp.devices[0].form_factor #=> String, one of "PHONE", "TABLET"
# resp.devices[0].platform #=> String, one of "ANDROID", "IOS"
# resp.devices[0].os #=> String
# resp.devices[0].cpu.frequency #=> String
# resp.devices[0].cpu.architecture #=> String
# resp.devices[0].cpu.clock #=> Float
# resp.devices[0].resolution.width #=> Integer
# resp.devices[0].resolution.height #=> Integer
# resp.devices[0].heap_size #=> Integer
# resp.devices[0].memory #=> Integer
# resp.devices[0].image #=> String
# resp.devices[0].carrier #=> String
# resp.devices[0].radio #=> String
# resp.devices[0].remote_access_enabled #=> Boolean
# resp.devices[0].remote_debug_enabled #=> Boolean
# resp.devices[0].fleet_type #=> String
# resp.devices[0].fleet_name #=> String
# resp.devices[0].instances #=> Array
# resp.devices[0].instances[0].arn #=> String
# resp.devices[0].instances[0].device_arn #=> String
# resp.devices[0].instances[0].labels #=> Array
# resp.devices[0].instances[0].labels[0] #=> String
# resp.devices[0].instances[0].status #=> String, one of "IN_USE", "PREPARING", "AVAILABLE", "NOT_AVAILABLE"
# resp.devices[0].instances[0].udid #=> String
# resp.devices[0].instances[0].instance_profile.arn #=> String
# resp.devices[0].instances[0].instance_profile.package_cleanup #=> Boolean
# resp.devices[0].instances[0].instance_profile.exclude_app_packages_from_cleanup #=> Array
# resp.devices[0].instances[0].instance_profile.exclude_app_packages_from_cleanup[0] #=> String
# resp.devices[0].instances[0].instance_profile.reboot_after_use #=> Boolean
# resp.devices[0].instances[0].instance_profile.name #=> String
# resp.devices[0].instances[0].instance_profile.description #=> String
# resp.devices[0].availability #=> String, one of "TEMPORARY_NOT_AVAILABLE", "BUSY", "AVAILABLE", "HIGHLY_AVAILABLE"
# resp.next_token #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/ListDevices AWS API Documentation
#
# @overload list_devices(params = {})
# @param [Hash] params ({})
def list_devices(params = {}, options = {})
req = build_request(:list_devices, params)
req.send_request(options)
end
# Returns information about all the instance profiles in an AWS account.
#
# @option params [Integer] :max_results
# An integer specifying the maximum number of items you want to return
# in the API response.
#
# @option params [String] :next_token
# An identifier that was returned from the previous call to this
# operation, which can be used to return the next set of items in the
# list.
#
# @return [Types::ListInstanceProfilesResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::ListInstanceProfilesResult#instance_profiles #instance_profiles} => Array<Types::InstanceProfile>
# * {Types::ListInstanceProfilesResult#next_token #next_token} => String
#
# @example Request syntax with placeholder values
#
# resp = client.list_instance_profiles({
# max_results: 1,
# next_token: "PaginationToken",
# })
#
# @example Response structure
#
# resp.instance_profiles #=> Array
# resp.instance_profiles[0].arn #=> String
# resp.instance_profiles[0].package_cleanup #=> Boolean
# resp.instance_profiles[0].exclude_app_packages_from_cleanup #=> Array
# resp.instance_profiles[0].exclude_app_packages_from_cleanup[0] #=> String
# resp.instance_profiles[0].reboot_after_use #=> Boolean
# resp.instance_profiles[0].name #=> String
# resp.instance_profiles[0].description #=> String
# resp.next_token #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/ListInstanceProfiles AWS API Documentation
#
# @overload list_instance_profiles(params = {})
# @param [Hash] params ({})
def list_instance_profiles(params = {}, options = {})
req = build_request(:list_instance_profiles, params)
req.send_request(options)
end
# Gets information about jobs for a given test run.
#
# @option params [required, String] :arn
# The run's Amazon Resource Name (ARN).
#
# @option params [String] :next_token
# An identifier that was returned from the previous call to this
# operation, which can be used to return the next set of items in the
# list.
#
# @return [Types::ListJobsResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::ListJobsResult#jobs #jobs} => Array<Types::Job>
# * {Types::ListJobsResult#next_token #next_token} => String
#
#
# @example Example: To get information about jobs
#
# # The following example returns information about jobs in a specific project.
#
# resp = client.list_jobs({
# arn: "arn:aws:devicefarm:us-west-2:123456789101:project:EXAMPLE-GUID-123-456", # You can get the project ARN by using the list-jobs CLI command.
# })
#
# @example Request syntax with placeholder values
#
# resp = client.list_jobs({
# arn: "AmazonResourceName", # required
# next_token: "PaginationToken",
# })
#
# @example Response structure
#
# resp.jobs #=> Array
# resp.jobs[0].arn #=> String
# resp.jobs[0].name #=> String
# resp.jobs[0].type #=> String, one of "BUILTIN_FUZZ", "BUILTIN_EXPLORER", "WEB_PERFORMANCE_PROFILE", "APPIUM_JAVA_JUNIT", "APPIUM_JAVA_TESTNG", "APPIUM_PYTHON", "APPIUM_NODE", "APPIUM_RUBY", "APPIUM_WEB_JAVA_JUNIT", "APPIUM_WEB_JAVA_TESTNG", "APPIUM_WEB_PYTHON", "APPIUM_WEB_NODE", "APPIUM_WEB_RUBY", "CALABASH", "INSTRUMENTATION", "UIAUTOMATION", "UIAUTOMATOR", "XCTEST", "XCTEST_UI", "REMOTE_ACCESS_RECORD", "REMOTE_ACCESS_REPLAY"
# resp.jobs[0].created #=> Time
# resp.jobs[0].status #=> String, one of "PENDING", "PENDING_CONCURRENCY", "PENDING_DEVICE", "PROCESSING", "SCHEDULING", "PREPARING", "RUNNING", "COMPLETED", "STOPPING"
# resp.jobs[0].result #=> String, one of "PENDING", "PASSED", "WARNED", "FAILED", "SKIPPED", "ERRORED", "STOPPED"
# resp.jobs[0].started #=> Time
# resp.jobs[0].stopped #=> Time
# resp.jobs[0].counters.total #=> Integer
# resp.jobs[0].counters.passed #=> Integer
# resp.jobs[0].counters.failed #=> Integer
# resp.jobs[0].counters.warned #=> Integer
# resp.jobs[0].counters.errored #=> Integer
# resp.jobs[0].counters.stopped #=> Integer
# resp.jobs[0].counters.skipped #=> Integer
# resp.jobs[0].message #=> String
# resp.jobs[0].device.arn #=> String
# resp.jobs[0].device.name #=> String
# resp.jobs[0].device.manufacturer #=> String
# resp.jobs[0].device.model #=> String
# resp.jobs[0].device.model_id #=> String
# resp.jobs[0].device.form_factor #=> String, one of "PHONE", "TABLET"
# resp.jobs[0].device.platform #=> String, one of "ANDROID", "IOS"
# resp.jobs[0].device.os #=> String
# resp.jobs[0].device.cpu.frequency #=> String
# resp.jobs[0].device.cpu.architecture #=> String
# resp.jobs[0].device.cpu.clock #=> Float
# resp.jobs[0].device.resolution.width #=> Integer
# resp.jobs[0].device.resolution.height #=> Integer
# resp.jobs[0].device.heap_size #=> Integer
# resp.jobs[0].device.memory #=> Integer
# resp.jobs[0].device.image #=> String
# resp.jobs[0].device.carrier #=> String
# resp.jobs[0].device.radio #=> String
# resp.jobs[0].device.remote_access_enabled #=> Boolean
# resp.jobs[0].device.remote_debug_enabled #=> Boolean
# resp.jobs[0].device.fleet_type #=> String
# resp.jobs[0].device.fleet_name #=> String
# resp.jobs[0].device.instances #=> Array
# resp.jobs[0].device.instances[0].arn #=> String
# resp.jobs[0].device.instances[0].device_arn #=> String
# resp.jobs[0].device.instances[0].labels #=> Array
# resp.jobs[0].device.instances[0].labels[0] #=> String
# resp.jobs[0].device.instances[0].status #=> String, one of "IN_USE", "PREPARING", "AVAILABLE", "NOT_AVAILABLE"
# resp.jobs[0].device.instances[0].udid #=> String
# resp.jobs[0].device.instances[0].instance_profile.arn #=> String
# resp.jobs[0].device.instances[0].instance_profile.package_cleanup #=> Boolean
# resp.jobs[0].device.instances[0].instance_profile.exclude_app_packages_from_cleanup #=> Array
# resp.jobs[0].device.instances[0].instance_profile.exclude_app_packages_from_cleanup[0] #=> String
# resp.jobs[0].device.instances[0].instance_profile.reboot_after_use #=> Boolean
# resp.jobs[0].device.instances[0].instance_profile.name #=> String
# resp.jobs[0].device.instances[0].instance_profile.description #=> String
# resp.jobs[0].device.availability #=> String, one of "TEMPORARY_NOT_AVAILABLE", "BUSY", "AVAILABLE", "HIGHLY_AVAILABLE"
# resp.jobs[0].instance_arn #=> String
# resp.jobs[0].device_minutes.total #=> Float
# resp.jobs[0].device_minutes.metered #=> Float
# resp.jobs[0].device_minutes.unmetered #=> Float
# resp.jobs[0].video_endpoint #=> String
# resp.jobs[0].video_capture #=> Boolean
# resp.next_token #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/ListJobs AWS API Documentation
#
# @overload list_jobs(params = {})
# @param [Hash] params ({})
def list_jobs(params = {}, options = {})
req = build_request(:list_jobs, params)
req.send_request(options)
end
# Returns the list of available network profiles.
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) of the project for which you want to
# list network profiles.
#
# @option params [String] :type
# The type of network profile you wish to return information about.
# Valid values are listed below.
#
# @option params [String] :next_token
# An identifier that was returned from the previous call to this
# operation, which can be used to return the next set of items in the
# list.
#
# @return [Types::ListNetworkProfilesResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::ListNetworkProfilesResult#network_profiles #network_profiles} => Array<Types::NetworkProfile>
# * {Types::ListNetworkProfilesResult#next_token #next_token} => String
#
# @example Request syntax with placeholder values
#
# resp = client.list_network_profiles({
# arn: "AmazonResourceName", # required
# type: "CURATED", # accepts CURATED, PRIVATE
# next_token: "PaginationToken",
# })
#
# @example Response structure
#
# resp.network_profiles #=> Array
# resp.network_profiles[0].arn #=> String
# resp.network_profiles[0].name #=> String
# resp.network_profiles[0].description #=> String
# resp.network_profiles[0].type #=> String, one of "CURATED", "PRIVATE"
# resp.network_profiles[0].uplink_bandwidth_bits #=> Integer
# resp.network_profiles[0].downlink_bandwidth_bits #=> Integer
# resp.network_profiles[0].uplink_delay_ms #=> Integer
# resp.network_profiles[0].downlink_delay_ms #=> Integer
# resp.network_profiles[0].uplink_jitter_ms #=> Integer
# resp.network_profiles[0].downlink_jitter_ms #=> Integer
# resp.network_profiles[0].uplink_loss_percent #=> Integer
# resp.network_profiles[0].downlink_loss_percent #=> Integer
# resp.next_token #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/ListNetworkProfiles AWS API Documentation
#
# @overload list_network_profiles(params = {})
# @param [Hash] params ({})
def list_network_profiles(params = {}, options = {})
req = build_request(:list_network_profiles, params)
req.send_request(options)
end
# Returns a list of offering promotions. Each offering promotion record
# contains the ID and description of the promotion. The API returns a
# `NotEligible` error if the caller is not permitted to invoke the
# operation. Contact
# [[email protected]](mailto:[email protected])
# if you believe that you should be able to invoke this operation.
#
# @option params [String] :next_token
# An identifier that was returned from the previous call to this
# operation, which can be used to return the next set of items in the
# list.
#
# @return [Types::ListOfferingPromotionsResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::ListOfferingPromotionsResult#offering_promotions #offering_promotions} => Array<Types::OfferingPromotion>
# * {Types::ListOfferingPromotionsResult#next_token #next_token} => String
#
# @example Request syntax with placeholder values
#
# resp = client.list_offering_promotions({
# next_token: "PaginationToken",
# })
#
# @example Response structure
#
# resp.offering_promotions #=> Array
# resp.offering_promotions[0].id #=> String
# resp.offering_promotions[0].description #=> String
# resp.next_token #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/ListOfferingPromotions AWS API Documentation
#
# @overload list_offering_promotions(params = {})
# @param [Hash] params ({})
def list_offering_promotions(params = {}, options = {})
req = build_request(:list_offering_promotions, params)
req.send_request(options)
end
# Returns a list of all historical purchases, renewals, and system
# renewal transactions for an AWS account. The list is paginated and
# ordered by a descending timestamp (most recent transactions are
# first). The API returns a `NotEligible` error if the user is not
# permitted to invoke the operation. Please contact
# [[email protected]](mailto:[email protected])
# if you believe that you should be able to invoke this operation.
#
# @option params [String] :next_token
# An identifier that was returned from the previous call to this
# operation, which can be used to return the next set of items in the
# list.
#
# @return [Types::ListOfferingTransactionsResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::ListOfferingTransactionsResult#offering_transactions #offering_transactions} => Array<Types::OfferingTransaction>
# * {Types::ListOfferingTransactionsResult#next_token #next_token} => String
#
#
# @example Example: To get information about device offering transactions
#
# # The following example returns information about Device Farm offering transactions.
#
# resp = client.list_offering_transactions({
# next_token: "RW5DdDJkMWYwZjM2MzM2VHVpOHJIUXlDUXlhc2QzRGViYnc9SEXAMPLE=", # A dynamically generated value, used for paginating results.
# })
#
# resp.to_h outputs the following:
# {
# offering_transactions: [
# {
# cost: {
# amount: 0,
# currency_code: "USD",
# },
# created_on: Time.parse("1470021420"),
# offering_status: {
# type: "RENEW",
# effective_on: Time.parse("1472688000"),
# offering: {
# type: "RECURRING",
# description: "Android Remote Access Unmetered Device Slot",
# id: "D68B3C05-1BA6-4360-BC69-12345EXAMPLE",
# platform: "ANDROID",
# },
# quantity: 0,
# },
# transaction_id: "03728003-d1ea-4851-abd6-12345EXAMPLE",
# },
# {
# cost: {
# amount: 250,
# currency_code: "USD",
# },
# created_on: Time.parse("1470021420"),
# offering_status: {
# type: "PURCHASE",
# effective_on: Time.parse("1470021420"),
# offering: {
# type: "RECURRING",
# description: "Android Remote Access Unmetered Device Slot",
# id: "D68B3C05-1BA6-4360-BC69-12345EXAMPLE",
# platform: "ANDROID",
# },
# quantity: 1,
# },
# transaction_id: "56820b6e-06bd-473a-8ff8-12345EXAMPLE",
# },
# {
# cost: {
# amount: 175,
# currency_code: "USD",
# },
# created_on: Time.parse("1465538520"),
# offering_status: {
# type: "PURCHASE",
# effective_on: Time.parse("1465538520"),
# offering: {
# type: "RECURRING",
# description: "Android Unmetered Device Slot",
# id: "8980F81C-00D7-469D-8EC6-12345EXAMPLE",
# platform: "ANDROID",
# },
# quantity: 1,
# },
# transaction_id: "953ae2c6-d760-4a04-9597-12345EXAMPLE",
# },
# {
# cost: {
# amount: 8.07,
# currency_code: "USD",
# },
# created_on: Time.parse("1459344300"),
# offering_status: {
# type: "PURCHASE",
# effective_on: Time.parse("1459344300"),
# offering: {
# type: "RECURRING",
# description: "iOS Unmetered Device Slot",
# id: "A53D4D73-A6F6-4B82-A0B0-12345EXAMPLE",
# platform: "IOS",
# },
# quantity: 1,
# },
# transaction_id: "2baf9021-ae3e-47f5-ab52-12345EXAMPLE",
# },
# ],
# }
#
# @example Request syntax with placeholder values
#
# resp = client.list_offering_transactions({
# next_token: "PaginationToken",
# })
#
# @example Response structure
#
# resp.offering_transactions #=> Array
# resp.offering_transactions[0].offering_status.type #=> String, one of "PURCHASE", "RENEW", "SYSTEM"
# resp.offering_transactions[0].offering_status.offering.id #=> String
# resp.offering_transactions[0].offering_status.offering.description #=> String
# resp.offering_transactions[0].offering_status.offering.type #=> String, one of "RECURRING"
# resp.offering_transactions[0].offering_status.offering.platform #=> String, one of "ANDROID", "IOS"
# resp.offering_transactions[0].offering_status.offering.recurring_charges #=> Array
# resp.offering_transactions[0].offering_status.offering.recurring_charges[0].cost.amount #=> Float
# resp.offering_transactions[0].offering_status.offering.recurring_charges[0].cost.currency_code #=> String, one of "USD"
# resp.offering_transactions[0].offering_status.offering.recurring_charges[0].frequency #=> String, one of "MONTHLY"
# resp.offering_transactions[0].offering_status.quantity #=> Integer
# resp.offering_transactions[0].offering_status.effective_on #=> Time
# resp.offering_transactions[0].transaction_id #=> String
# resp.offering_transactions[0].offering_promotion_id #=> String
# resp.offering_transactions[0].created_on #=> Time
# resp.offering_transactions[0].cost.amount #=> Float
# resp.offering_transactions[0].cost.currency_code #=> String, one of "USD"
# resp.next_token #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/ListOfferingTransactions AWS API Documentation
#
# @overload list_offering_transactions(params = {})
# @param [Hash] params ({})
def list_offering_transactions(params = {}, options = {})
req = build_request(:list_offering_transactions, params)
req.send_request(options)
end
# Returns a list of products or offerings that the user can manage
# through the API. Each offering record indicates the recurring price
# per unit and the frequency for that offering. The API returns a
# `NotEligible` error if the user is not permitted to invoke the
# operation. Please contact
# [[email protected]](mailto:[email protected])
# if you believe that you should be able to invoke this operation.
#
# @option params [String] :next_token
# An identifier that was returned from the previous call to this
# operation, which can be used to return the next set of items in the
# list.
#
# @return [Types::ListOfferingsResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::ListOfferingsResult#offerings #offerings} => Array<Types::Offering>
# * {Types::ListOfferingsResult#next_token #next_token} => String
#
#
# @example Example: To get information about device offerings
#
# # The following example returns information about available device offerings.
#
# resp = client.list_offerings({
# next_token: "RW5DdDJkMWYwZjM2MzM2VHVpOHJIUXlDUXlhc2QzRGViYnc9SEXAMPLE=", # A dynamically generated value, used for paginating results.
# })
#
# resp.to_h outputs the following:
# {
# offerings: [
# {
# type: "RECURRING",
# description: "iOS Unmetered Device Slot",
# id: "A53D4D73-A6F6-4B82-A0B0-12345EXAMPLE",
# platform: "IOS",
# recurring_charges: [
# {
# cost: {
# amount: 250,
# currency_code: "USD",
# },
# frequency: "MONTHLY",
# },
# ],
# },
# {
# type: "RECURRING",
# description: "Android Unmetered Device Slot",
# id: "8980F81C-00D7-469D-8EC6-12345EXAMPLE",
# platform: "ANDROID",
# recurring_charges: [
# {
# cost: {
# amount: 250,
# currency_code: "USD",
# },
# frequency: "MONTHLY",
# },
# ],
# },
# {
# type: "RECURRING",
# description: "Android Remote Access Unmetered Device Slot",
# id: "D68B3C05-1BA6-4360-BC69-12345EXAMPLE",
# platform: "ANDROID",
# recurring_charges: [
# {
# cost: {
# amount: 250,
# currency_code: "USD",
# },
# frequency: "MONTHLY",
# },
# ],
# },
# {
# type: "RECURRING",
# description: "iOS Remote Access Unmetered Device Slot",
# id: "552B4DAD-A6C9-45C4-94FB-12345EXAMPLE",
# platform: "IOS",
# recurring_charges: [
# {
# cost: {
# amount: 250,
# currency_code: "USD",
# },
# frequency: "MONTHLY",
# },
# ],
# },
# ],
# }
#
# @example Request syntax with placeholder values
#
# resp = client.list_offerings({
# next_token: "PaginationToken",
# })
#
# @example Response structure
#
# resp.offerings #=> Array
# resp.offerings[0].id #=> String
# resp.offerings[0].description #=> String
# resp.offerings[0].type #=> String, one of "RECURRING"
# resp.offerings[0].platform #=> String, one of "ANDROID", "IOS"
# resp.offerings[0].recurring_charges #=> Array
# resp.offerings[0].recurring_charges[0].cost.amount #=> Float
# resp.offerings[0].recurring_charges[0].cost.currency_code #=> String, one of "USD"
# resp.offerings[0].recurring_charges[0].frequency #=> String, one of "MONTHLY"
# resp.next_token #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/ListOfferings AWS API Documentation
#
# @overload list_offerings(params = {})
# @param [Hash] params ({})
def list_offerings(params = {}, options = {})
req = build_request(:list_offerings, params)
req.send_request(options)
end
# Gets information about projects.
#
# @option params [String] :arn
# Optional. If no Amazon Resource Name (ARN) is specified, then AWS
# Device Farm returns a list of all projects for the AWS account. You
# can also specify a project ARN.
#
# @option params [String] :next_token
# An identifier that was returned from the previous call to this
# operation, which can be used to return the next set of items in the
# list.
#
# @return [Types::ListProjectsResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::ListProjectsResult#projects #projects} => Array<Types::Project>
# * {Types::ListProjectsResult#next_token #next_token} => String
#
#
# @example Example: To get information about a Device Farm project
#
# # The following example returns information about the specified project in Device Farm.
#
# resp = client.list_projects({
# arn: "arn:aws:devicefarm:us-west-2:123456789101:project:7ad300ed-8183-41a7-bf94-12345EXAMPLE",
# next_token: "RW5DdDJkMWYwZjM2MzM2VHVpOHJIUXlDUXlhc2QzRGViYnc9SEXAMPLE", # A dynamically generated value, used for paginating results.
# })
#
# resp.to_h outputs the following:
# {
# projects: [
# {
# name: "My Test Project",
# arn: "arn:aws:devicefarm:us-west-2:123456789101:project:7ad300ed-8183-41a7-bf94-12345EXAMPLE",
# created: Time.parse("1453163262.105"),
# },
# {
# name: "Hello World",
# arn: "arn:aws:devicefarm:us-west-2:123456789101:project:d6b087d9-56db-4e44-b9ec-12345EXAMPLE",
# created: Time.parse("1470350112.439"),
# },
# ],
# }
#
# @example Request syntax with placeholder values
#
# resp = client.list_projects({
# arn: "AmazonResourceName",
# next_token: "PaginationToken",
# })
#
# @example Response structure
#
# resp.projects #=> Array
# resp.projects[0].arn #=> String
# resp.projects[0].name #=> String
# resp.projects[0].default_job_timeout_minutes #=> Integer
# resp.projects[0].created #=> Time
# resp.next_token #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/ListProjects AWS API Documentation
#
# @overload list_projects(params = {})
# @param [Hash] params ({})
def list_projects(params = {}, options = {})
req = build_request(:list_projects, params)
req.send_request(options)
end
# Returns a list of all currently running remote access sessions.
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) of the project about which you are
# requesting information.
#
# @option params [String] :next_token
# An identifier that was returned from the previous call to this
# operation, which can be used to return the next set of items in the
# list.
#
# @return [Types::ListRemoteAccessSessionsResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::ListRemoteAccessSessionsResult#remote_access_sessions #remote_access_sessions} => Array<Types::RemoteAccessSession>
# * {Types::ListRemoteAccessSessionsResult#next_token #next_token} => String
#
#
# @example Example: To get information about a remote access session
#
# # The following example returns information about a specific Device Farm remote access session.
#
# resp = client.list_remote_access_sessions({
# arn: "arn:aws:devicefarm:us-west-2:123456789101:session:EXAMPLE-GUID-123-456", # You can get the Amazon Resource Name (ARN) of the session by using the list-sessions CLI command.
# next_token: "RW5DdDJkMWYwZjM2MzM2VHVpOHJIUXlDUXlhc2QzRGViYnc9SEXAMPLE=", # A dynamically generated value, used for paginating results.
# })
#
# resp.to_h outputs the following:
# {
# remote_access_sessions: [
# ],
# }
#
# @example Request syntax with placeholder values
#
# resp = client.list_remote_access_sessions({
# arn: "AmazonResourceName", # required
# next_token: "PaginationToken",
# })
#
# @example Response structure
#
# resp.remote_access_sessions #=> Array
# resp.remote_access_sessions[0].arn #=> String
# resp.remote_access_sessions[0].name #=> String
# resp.remote_access_sessions[0].created #=> Time
# resp.remote_access_sessions[0].status #=> String, one of "PENDING", "PENDING_CONCURRENCY", "PENDING_DEVICE", "PROCESSING", "SCHEDULING", "PREPARING", "RUNNING", "COMPLETED", "STOPPING"
# resp.remote_access_sessions[0].result #=> String, one of "PENDING", "PASSED", "WARNED", "FAILED", "SKIPPED", "ERRORED", "STOPPED"
# resp.remote_access_sessions[0].message #=> String
# resp.remote_access_sessions[0].started #=> Time
# resp.remote_access_sessions[0].stopped #=> Time
# resp.remote_access_sessions[0].device.arn #=> String
# resp.remote_access_sessions[0].device.name #=> String
# resp.remote_access_sessions[0].device.manufacturer #=> String
# resp.remote_access_sessions[0].device.model #=> String
# resp.remote_access_sessions[0].device.model_id #=> String
# resp.remote_access_sessions[0].device.form_factor #=> String, one of "PHONE", "TABLET"
# resp.remote_access_sessions[0].device.platform #=> String, one of "ANDROID", "IOS"
# resp.remote_access_sessions[0].device.os #=> String
# resp.remote_access_sessions[0].device.cpu.frequency #=> String
# resp.remote_access_sessions[0].device.cpu.architecture #=> String
# resp.remote_access_sessions[0].device.cpu.clock #=> Float
# resp.remote_access_sessions[0].device.resolution.width #=> Integer
# resp.remote_access_sessions[0].device.resolution.height #=> Integer
# resp.remote_access_sessions[0].device.heap_size #=> Integer
# resp.remote_access_sessions[0].device.memory #=> Integer
# resp.remote_access_sessions[0].device.image #=> String
# resp.remote_access_sessions[0].device.carrier #=> String
# resp.remote_access_sessions[0].device.radio #=> String
# resp.remote_access_sessions[0].device.remote_access_enabled #=> Boolean
# resp.remote_access_sessions[0].device.remote_debug_enabled #=> Boolean
# resp.remote_access_sessions[0].device.fleet_type #=> String
# resp.remote_access_sessions[0].device.fleet_name #=> String
# resp.remote_access_sessions[0].device.instances #=> Array
# resp.remote_access_sessions[0].device.instances[0].arn #=> String
# resp.remote_access_sessions[0].device.instances[0].device_arn #=> String
# resp.remote_access_sessions[0].device.instances[0].labels #=> Array
# resp.remote_access_sessions[0].device.instances[0].labels[0] #=> String
# resp.remote_access_sessions[0].device.instances[0].status #=> String, one of "IN_USE", "PREPARING", "AVAILABLE", "NOT_AVAILABLE"
# resp.remote_access_sessions[0].device.instances[0].udid #=> String
# resp.remote_access_sessions[0].device.instances[0].instance_profile.arn #=> String
# resp.remote_access_sessions[0].device.instances[0].instance_profile.package_cleanup #=> Boolean
# resp.remote_access_sessions[0].device.instances[0].instance_profile.exclude_app_packages_from_cleanup #=> Array
# resp.remote_access_sessions[0].device.instances[0].instance_profile.exclude_app_packages_from_cleanup[0] #=> String
# resp.remote_access_sessions[0].device.instances[0].instance_profile.reboot_after_use #=> Boolean
# resp.remote_access_sessions[0].device.instances[0].instance_profile.name #=> String
# resp.remote_access_sessions[0].device.instances[0].instance_profile.description #=> String
# resp.remote_access_sessions[0].device.availability #=> String, one of "TEMPORARY_NOT_AVAILABLE", "BUSY", "AVAILABLE", "HIGHLY_AVAILABLE"
# resp.remote_access_sessions[0].instance_arn #=> String
# resp.remote_access_sessions[0].remote_debug_enabled #=> Boolean
# resp.remote_access_sessions[0].remote_record_enabled #=> Boolean
# resp.remote_access_sessions[0].remote_record_app_arn #=> String
# resp.remote_access_sessions[0].host_address #=> String
# resp.remote_access_sessions[0].client_id #=> String
# resp.remote_access_sessions[0].billing_method #=> String, one of "METERED", "UNMETERED"
# resp.remote_access_sessions[0].device_minutes.total #=> Float
# resp.remote_access_sessions[0].device_minutes.metered #=> Float
# resp.remote_access_sessions[0].device_minutes.unmetered #=> Float
# resp.remote_access_sessions[0].endpoint #=> String
# resp.remote_access_sessions[0].device_udid #=> String
# resp.remote_access_sessions[0].interaction_mode #=> String, one of "INTERACTIVE", "NO_VIDEO", "VIDEO_ONLY"
# resp.remote_access_sessions[0].skip_app_resign #=> Boolean
# resp.next_token #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/ListRemoteAccessSessions AWS API Documentation
#
# @overload list_remote_access_sessions(params = {})
# @param [Hash] params ({})
def list_remote_access_sessions(params = {}, options = {})
req = build_request(:list_remote_access_sessions, params)
req.send_request(options)
end
# Gets information about runs, given an AWS Device Farm project ARN.
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) of the project for which you want to
# list runs.
#
# @option params [String] :next_token
# An identifier that was returned from the previous call to this
# operation, which can be used to return the next set of items in the
# list.
#
# @return [Types::ListRunsResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::ListRunsResult#runs #runs} => Array<Types::Run>
# * {Types::ListRunsResult#next_token #next_token} => String
#
#
# @example Example: To get information about a test run
#
# # The following example returns information about a specific test run.
#
# resp = client.list_runs({
# arn: "arn:aws:devicefarm:us-west-2:123456789101:run:5e01a8c7-c861-4c0a-b1d5-5ec6e6c6dd23/0fcac17b-6122-44d7-ae5a-12345EXAMPLE", # You can get the Amazon Resource Name (ARN) of the run by using the list-runs CLI command.
# next_token: "RW5DdDJkMWYwZjM2MzM2VHVpOHJIUXlDUXlhc2QzRGViYnc9SEXAMPLE", # A dynamically generated value, used for paginating results.
# })
#
# resp.to_h outputs the following:
# {
# runs: [
# {
# name: "My Test Run",
# type: "BUILTIN_EXPLORER",
# arn: "arn:aws:devicefarm:us-west-2:123456789101:run:5e01a8c7-c861-4c0a-b1d5-5ec6e6c6dd23/0fcac17b-6122-44d7-ae5a-12345EXAMPLE",
# billing_method: "METERED",
# completed_jobs: 0,
# counters: {
# errored: 0,
# failed: 0,
# passed: 0,
# skipped: 0,
# stopped: 0,
# total: 0,
# warned: 0,
# },
# created: Time.parse("1472667509.852"),
# device_minutes: {
# metered: 0.0,
# total: 0.0,
# unmetered: 0.0,
# },
# platform: "ANDROID",
# result: "PENDING",
# status: "RUNNING",
# total_jobs: 3,
# },
# ],
# }
#
# @example Request syntax with placeholder values
#
# resp = client.list_runs({
# arn: "AmazonResourceName", # required
# next_token: "PaginationToken",
# })
#
# @example Response structure
#
# resp.runs #=> Array
# resp.runs[0].arn #=> String
# resp.runs[0].name #=> String
# resp.runs[0].type #=> String, one of "BUILTIN_FUZZ", "BUILTIN_EXPLORER", "WEB_PERFORMANCE_PROFILE", "APPIUM_JAVA_JUNIT", "APPIUM_JAVA_TESTNG", "APPIUM_PYTHON", "APPIUM_NODE", "APPIUM_RUBY", "APPIUM_WEB_JAVA_JUNIT", "APPIUM_WEB_JAVA_TESTNG", "APPIUM_WEB_PYTHON", "APPIUM_WEB_NODE", "APPIUM_WEB_RUBY", "CALABASH", "INSTRUMENTATION", "UIAUTOMATION", "UIAUTOMATOR", "XCTEST", "XCTEST_UI", "REMOTE_ACCESS_RECORD", "REMOTE_ACCESS_REPLAY"
# resp.runs[0].platform #=> String, one of "ANDROID", "IOS"
# resp.runs[0].created #=> Time
# resp.runs[0].status #=> String, one of "PENDING", "PENDING_CONCURRENCY", "PENDING_DEVICE", "PROCESSING", "SCHEDULING", "PREPARING", "RUNNING", "COMPLETED", "STOPPING"
# resp.runs[0].result #=> String, one of "PENDING", "PASSED", "WARNED", "FAILED", "SKIPPED", "ERRORED", "STOPPED"
# resp.runs[0].started #=> Time
# resp.runs[0].stopped #=> Time
# resp.runs[0].counters.total #=> Integer
# resp.runs[0].counters.passed #=> Integer
# resp.runs[0].counters.failed #=> Integer
# resp.runs[0].counters.warned #=> Integer
# resp.runs[0].counters.errored #=> Integer
# resp.runs[0].counters.stopped #=> Integer
# resp.runs[0].counters.skipped #=> Integer
# resp.runs[0].message #=> String
# resp.runs[0].total_jobs #=> Integer
# resp.runs[0].completed_jobs #=> Integer
# resp.runs[0].billing_method #=> String, one of "METERED", "UNMETERED"
# resp.runs[0].device_minutes.total #=> Float
# resp.runs[0].device_minutes.metered #=> Float
# resp.runs[0].device_minutes.unmetered #=> Float
# resp.runs[0].network_profile.arn #=> String
# resp.runs[0].network_profile.name #=> String
# resp.runs[0].network_profile.description #=> String
# resp.runs[0].network_profile.type #=> String, one of "CURATED", "PRIVATE"
# resp.runs[0].network_profile.uplink_bandwidth_bits #=> Integer
# resp.runs[0].network_profile.downlink_bandwidth_bits #=> Integer
# resp.runs[0].network_profile.uplink_delay_ms #=> Integer
# resp.runs[0].network_profile.downlink_delay_ms #=> Integer
# resp.runs[0].network_profile.uplink_jitter_ms #=> Integer
# resp.runs[0].network_profile.downlink_jitter_ms #=> Integer
# resp.runs[0].network_profile.uplink_loss_percent #=> Integer
# resp.runs[0].network_profile.downlink_loss_percent #=> Integer
# resp.runs[0].parsing_result_url #=> String
# resp.runs[0].result_code #=> String, one of "PARSING_FAILED", "VPC_ENDPOINT_SETUP_FAILED"
# resp.runs[0].seed #=> Integer
# resp.runs[0].app_upload #=> String
# resp.runs[0].event_count #=> Integer
# resp.runs[0].job_timeout_minutes #=> Integer
# resp.runs[0].device_pool_arn #=> String
# resp.runs[0].locale #=> String
# resp.runs[0].radios.wifi #=> Boolean
# resp.runs[0].radios.bluetooth #=> Boolean
# resp.runs[0].radios.nfc #=> Boolean
# resp.runs[0].radios.gps #=> Boolean
# resp.runs[0].location.latitude #=> Float
# resp.runs[0].location.longitude #=> Float
# resp.runs[0].customer_artifact_paths.ios_paths #=> Array
# resp.runs[0].customer_artifact_paths.ios_paths[0] #=> String
# resp.runs[0].customer_artifact_paths.android_paths #=> Array
# resp.runs[0].customer_artifact_paths.android_paths[0] #=> String
# resp.runs[0].customer_artifact_paths.device_host_paths #=> Array
# resp.runs[0].customer_artifact_paths.device_host_paths[0] #=> String
# resp.runs[0].web_url #=> String
# resp.runs[0].skip_app_resign #=> Boolean
# resp.runs[0].test_spec_arn #=> String
# resp.runs[0].device_selection_result.filters #=> Array
# resp.runs[0].device_selection_result.filters[0].attribute #=> String, one of "ARN", "PLATFORM", "OS_VERSION", "MODEL", "AVAILABILITY", "FORM_FACTOR", "MANUFACTURER", "REMOTE_ACCESS_ENABLED", "REMOTE_DEBUG_ENABLED", "INSTANCE_ARN", "INSTANCE_LABELS", "FLEET_TYPE"
# resp.runs[0].device_selection_result.filters[0].operator #=> String, one of "EQUALS", "LESS_THAN", "LESS_THAN_OR_EQUALS", "GREATER_THAN", "GREATER_THAN_OR_EQUALS", "IN", "NOT_IN", "CONTAINS"
# resp.runs[0].device_selection_result.filters[0].values #=> Array
# resp.runs[0].device_selection_result.filters[0].values[0] #=> String
# resp.runs[0].device_selection_result.matched_devices_count #=> Integer
# resp.runs[0].device_selection_result.max_devices #=> Integer
# resp.next_token #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/ListRuns AWS API Documentation
#
# @overload list_runs(params = {})
# @param [Hash] params ({})
def list_runs(params = {}, options = {})
req = build_request(:list_runs, params)
req.send_request(options)
end
# Gets information about samples, given an AWS Device Farm job ARN.
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) of the job used to list samples.
#
# @option params [String] :next_token
# An identifier that was returned from the previous call to this
# operation, which can be used to return the next set of items in the
# list.
#
# @return [Types::ListSamplesResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::ListSamplesResult#samples #samples} => Array<Types::Sample>
# * {Types::ListSamplesResult#next_token #next_token} => String
#
#
# @example Example: To get information about samples
#
# # The following example returns information about samples, given a specific Device Farm project.
#
# resp = client.list_samples({
# arn: "arn:aws:devicefarm:us-west-2:123456789101:project:EXAMPLE-GUID-123-456", # You can get the Amazon Resource Name (ARN) of the project by using the list-projects CLI command.
# next_token: "RW5DdDJkMWYwZjM2MzM2VHVpOHJIUXlDUXlhc2QzRGViYnc9SEXAMPLE", # A dynamically generated value, used for paginating results.
# })
#
# resp.to_h outputs the following:
# {
# samples: [
# ],
# }
#
# @example Request syntax with placeholder values
#
# resp = client.list_samples({
# arn: "AmazonResourceName", # required
# next_token: "PaginationToken",
# })
#
# @example Response structure
#
# resp.samples #=> Array
# resp.samples[0].arn #=> String
# resp.samples[0].type #=> String, one of "CPU", "MEMORY", "THREADS", "RX_RATE", "TX_RATE", "RX", "TX", "NATIVE_FRAMES", "NATIVE_FPS", "NATIVE_MIN_DRAWTIME", "NATIVE_AVG_DRAWTIME", "NATIVE_MAX_DRAWTIME", "OPENGL_FRAMES", "OPENGL_FPS", "OPENGL_MIN_DRAWTIME", "OPENGL_AVG_DRAWTIME", "OPENGL_MAX_DRAWTIME"
# resp.samples[0].url #=> String
# resp.next_token #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/ListSamples AWS API Documentation
#
# @overload list_samples(params = {})
# @param [Hash] params ({})
def list_samples(params = {}, options = {})
req = build_request(:list_samples, params)
req.send_request(options)
end
# Gets information about test suites for a given job.
#
# @option params [required, String] :arn
# The job's Amazon Resource Name (ARN).
#
# @option params [String] :next_token
# An identifier that was returned from the previous call to this
# operation, which can be used to return the next set of items in the
# list.
#
# @return [Types::ListSuitesResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::ListSuitesResult#suites #suites} => Array<Types::Suite>
# * {Types::ListSuitesResult#next_token #next_token} => String
#
#
# @example Example: To get information about suites
#
# # The following example returns information about suites, given a specific Device Farm job.
#
# resp = client.list_suites({
# arn: "arn:aws:devicefarm:us-west-2:123456789101:job:EXAMPLE-GUID-123-456", # You can get the Amazon Resource Name (ARN) of the job by using the list-jobs CLI command.
# next_token: "RW5DdDJkMWYwZjM2MzM2VHVpOHJIUXlDUXlhc2QzRGViYnc9SEXAMPLE", # A dynamically generated value, used for paginating results.
# })
#
# resp.to_h outputs the following:
# {
# suites: [
# ],
# }
#
# @example Request syntax with placeholder values
#
# resp = client.list_suites({
# arn: "AmazonResourceName", # required
# next_token: "PaginationToken",
# })
#
# @example Response structure
#
# resp.suites #=> Array
# resp.suites[0].arn #=> String
# resp.suites[0].name #=> String
# resp.suites[0].type #=> String, one of "BUILTIN_FUZZ", "BUILTIN_EXPLORER", "WEB_PERFORMANCE_PROFILE", "APPIUM_JAVA_JUNIT", "APPIUM_JAVA_TESTNG", "APPIUM_PYTHON", "APPIUM_NODE", "APPIUM_RUBY", "APPIUM_WEB_JAVA_JUNIT", "APPIUM_WEB_JAVA_TESTNG", "APPIUM_WEB_PYTHON", "APPIUM_WEB_NODE", "APPIUM_WEB_RUBY", "CALABASH", "INSTRUMENTATION", "UIAUTOMATION", "UIAUTOMATOR", "XCTEST", "XCTEST_UI", "REMOTE_ACCESS_RECORD", "REMOTE_ACCESS_REPLAY"
# resp.suites[0].created #=> Time
# resp.suites[0].status #=> String, one of "PENDING", "PENDING_CONCURRENCY", "PENDING_DEVICE", "PROCESSING", "SCHEDULING", "PREPARING", "RUNNING", "COMPLETED", "STOPPING"
# resp.suites[0].result #=> String, one of "PENDING", "PASSED", "WARNED", "FAILED", "SKIPPED", "ERRORED", "STOPPED"
# resp.suites[0].started #=> Time
# resp.suites[0].stopped #=> Time
# resp.suites[0].counters.total #=> Integer
# resp.suites[0].counters.passed #=> Integer
# resp.suites[0].counters.failed #=> Integer
# resp.suites[0].counters.warned #=> Integer
# resp.suites[0].counters.errored #=> Integer
# resp.suites[0].counters.stopped #=> Integer
# resp.suites[0].counters.skipped #=> Integer
# resp.suites[0].message #=> String
# resp.suites[0].device_minutes.total #=> Float
# resp.suites[0].device_minutes.metered #=> Float
# resp.suites[0].device_minutes.unmetered #=> Float
# resp.next_token #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/ListSuites AWS API Documentation
#
# @overload list_suites(params = {})
# @param [Hash] params ({})
def list_suites(params = {}, options = {})
req = build_request(:list_suites, params)
req.send_request(options)
end
# List the tags for an AWS Device Farm resource.
#
# @option params [required, String] :resource_arn
# The Amazon Resource Name (ARN) of the resource(s) for which to list
# tags. You can associate tags with the following Device Farm resources:
# `PROJECT`, `RUN`, `NETWORK_PROFILE`, `INSTANCE_PROFILE`,
# `DEVICE_INSTANCE`, `SESSION`, `DEVICE_POOL`, `DEVICE`, and
# `VPCE_CONFIGURATION`.
#
# @return [Types::ListTagsForResourceResponse] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::ListTagsForResourceResponse#tags #tags} => Array<Types::Tag>
#
# @example Request syntax with placeholder values
#
# resp = client.list_tags_for_resource({
# resource_arn: "AmazonResourceName", # required
# })
#
# @example Response structure
#
# resp.tags #=> Array
# resp.tags[0].key #=> String
# resp.tags[0].value #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/ListTagsForResource AWS API Documentation
#
# @overload list_tags_for_resource(params = {})
# @param [Hash] params ({})
def list_tags_for_resource(params = {}, options = {})
req = build_request(:list_tags_for_resource, params)
req.send_request(options)
end
# Gets information about tests in a given test suite.
#
# @option params [required, String] :arn
# The test suite's Amazon Resource Name (ARN).
#
# @option params [String] :next_token
# An identifier that was returned from the previous call to this
# operation, which can be used to return the next set of items in the
# list.
#
# @return [Types::ListTestsResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::ListTestsResult#tests #tests} => Array<Types::Test>
# * {Types::ListTestsResult#next_token #next_token} => String
#
#
# @example Example: To get information about tests
#
# # The following example returns information about tests, given a specific Device Farm project.
#
# resp = client.list_tests({
# arn: "arn:aws:devicefarm:us-west-2:123456789101:project:EXAMPLE-GUID-123-456", # You can get the Amazon Resource Name (ARN) of the project by using the list-projects CLI command.
# next_token: "RW5DdDJkMWYwZjM2MzM2VHVpOHJIUXlDUXlhc2QzRGViYnc9SEXAMPLE", # A dynamically generated value, used for paginating results.
# })
#
# resp.to_h outputs the following:
# {
# tests: [
# ],
# }
#
# @example Request syntax with placeholder values
#
# resp = client.list_tests({
# arn: "AmazonResourceName", # required
# next_token: "PaginationToken",
# })
#
# @example Response structure
#
# resp.tests #=> Array
# resp.tests[0].arn #=> String
# resp.tests[0].name #=> String
# resp.tests[0].type #=> String, one of "BUILTIN_FUZZ", "BUILTIN_EXPLORER", "WEB_PERFORMANCE_PROFILE", "APPIUM_JAVA_JUNIT", "APPIUM_JAVA_TESTNG", "APPIUM_PYTHON", "APPIUM_NODE", "APPIUM_RUBY", "APPIUM_WEB_JAVA_JUNIT", "APPIUM_WEB_JAVA_TESTNG", "APPIUM_WEB_PYTHON", "APPIUM_WEB_NODE", "APPIUM_WEB_RUBY", "CALABASH", "INSTRUMENTATION", "UIAUTOMATION", "UIAUTOMATOR", "XCTEST", "XCTEST_UI", "REMOTE_ACCESS_RECORD", "REMOTE_ACCESS_REPLAY"
# resp.tests[0].created #=> Time
# resp.tests[0].status #=> String, one of "PENDING", "PENDING_CONCURRENCY", "PENDING_DEVICE", "PROCESSING", "SCHEDULING", "PREPARING", "RUNNING", "COMPLETED", "STOPPING"
# resp.tests[0].result #=> String, one of "PENDING", "PASSED", "WARNED", "FAILED", "SKIPPED", "ERRORED", "STOPPED"
# resp.tests[0].started #=> Time
# resp.tests[0].stopped #=> Time
# resp.tests[0].counters.total #=> Integer
# resp.tests[0].counters.passed #=> Integer
# resp.tests[0].counters.failed #=> Integer
# resp.tests[0].counters.warned #=> Integer
# resp.tests[0].counters.errored #=> Integer
# resp.tests[0].counters.stopped #=> Integer
# resp.tests[0].counters.skipped #=> Integer
# resp.tests[0].message #=> String
# resp.tests[0].device_minutes.total #=> Float
# resp.tests[0].device_minutes.metered #=> Float
# resp.tests[0].device_minutes.unmetered #=> Float
# resp.next_token #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/ListTests AWS API Documentation
#
# @overload list_tests(params = {})
# @param [Hash] params ({})
def list_tests(params = {}, options = {})
req = build_request(:list_tests, params)
req.send_request(options)
end
# Gets information about unique problems.
#
# @option params [required, String] :arn
# The unique problems' ARNs.
#
# @option params [String] :next_token
# An identifier that was returned from the previous call to this
# operation, which can be used to return the next set of items in the
# list.
#
# @return [Types::ListUniqueProblemsResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::ListUniqueProblemsResult#unique_problems #unique_problems} => Hash<String,Array<Types::UniqueProblem>>
# * {Types::ListUniqueProblemsResult#next_token #next_token} => String
#
#
# @example Example: To get information about unique problems
#
# # The following example returns information about unique problems, given a specific Device Farm project.
#
# resp = client.list_unique_problems({
# arn: "arn:aws:devicefarm:us-west-2:123456789101:project:EXAMPLE-GUID-123-456", # You can get the Amazon Resource Name (ARN) of the project by using the list-projects CLI command.
# next_token: "RW5DdDJkMWYwZjM2MzM2VHVpOHJIUXlDUXlhc2QzRGViYnc9SEXAMPLE", # A dynamically generated value, used for paginating results.
# })
#
# resp.to_h outputs the following:
# {
# unique_problems: {
# },
# }
#
# @example Request syntax with placeholder values
#
# resp = client.list_unique_problems({
# arn: "AmazonResourceName", # required
# next_token: "PaginationToken",
# })
#
# @example Response structure
#
# resp.unique_problems #=> Hash
# resp.unique_problems["ExecutionResult"] #=> Array
# resp.unique_problems["ExecutionResult"][0].message #=> String
# resp.unique_problems["ExecutionResult"][0].problems #=> Array
# resp.unique_problems["ExecutionResult"][0].problems[0].run.arn #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].run.name #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].job.arn #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].job.name #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].suite.arn #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].suite.name #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].test.arn #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].test.name #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].device.arn #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].device.name #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].device.manufacturer #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].device.model #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].device.model_id #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].device.form_factor #=> String, one of "PHONE", "TABLET"
# resp.unique_problems["ExecutionResult"][0].problems[0].device.platform #=> String, one of "ANDROID", "IOS"
# resp.unique_problems["ExecutionResult"][0].problems[0].device.os #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].device.cpu.frequency #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].device.cpu.architecture #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].device.cpu.clock #=> Float
# resp.unique_problems["ExecutionResult"][0].problems[0].device.resolution.width #=> Integer
# resp.unique_problems["ExecutionResult"][0].problems[0].device.resolution.height #=> Integer
# resp.unique_problems["ExecutionResult"][0].problems[0].device.heap_size #=> Integer
# resp.unique_problems["ExecutionResult"][0].problems[0].device.memory #=> Integer
# resp.unique_problems["ExecutionResult"][0].problems[0].device.image #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].device.carrier #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].device.radio #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].device.remote_access_enabled #=> Boolean
# resp.unique_problems["ExecutionResult"][0].problems[0].device.remote_debug_enabled #=> Boolean
# resp.unique_problems["ExecutionResult"][0].problems[0].device.fleet_type #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].device.fleet_name #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].device.instances #=> Array
# resp.unique_problems["ExecutionResult"][0].problems[0].device.instances[0].arn #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].device.instances[0].device_arn #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].device.instances[0].labels #=> Array
# resp.unique_problems["ExecutionResult"][0].problems[0].device.instances[0].labels[0] #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].device.instances[0].status #=> String, one of "IN_USE", "PREPARING", "AVAILABLE", "NOT_AVAILABLE"
# resp.unique_problems["ExecutionResult"][0].problems[0].device.instances[0].udid #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].device.instances[0].instance_profile.arn #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].device.instances[0].instance_profile.package_cleanup #=> Boolean
# resp.unique_problems["ExecutionResult"][0].problems[0].device.instances[0].instance_profile.exclude_app_packages_from_cleanup #=> Array
# resp.unique_problems["ExecutionResult"][0].problems[0].device.instances[0].instance_profile.exclude_app_packages_from_cleanup[0] #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].device.instances[0].instance_profile.reboot_after_use #=> Boolean
# resp.unique_problems["ExecutionResult"][0].problems[0].device.instances[0].instance_profile.name #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].device.instances[0].instance_profile.description #=> String
# resp.unique_problems["ExecutionResult"][0].problems[0].device.availability #=> String, one of "TEMPORARY_NOT_AVAILABLE", "BUSY", "AVAILABLE", "HIGHLY_AVAILABLE"
# resp.unique_problems["ExecutionResult"][0].problems[0].result #=> String, one of "PENDING", "PASSED", "WARNED", "FAILED", "SKIPPED", "ERRORED", "STOPPED"
# resp.unique_problems["ExecutionResult"][0].problems[0].message #=> String
# resp.next_token #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/ListUniqueProblems AWS API Documentation
#
# @overload list_unique_problems(params = {})
# @param [Hash] params ({})
def list_unique_problems(params = {}, options = {})
req = build_request(:list_unique_problems, params)
req.send_request(options)
end
# Gets information about uploads, given an AWS Device Farm project ARN.
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) of the project for which you want to
# list uploads.
#
# @option params [String] :type
# The type of upload.
#
# Must be one of the following values:
#
# * ANDROID\_APP: An Android upload.
#
# * IOS\_APP: An iOS upload.
#
# * WEB\_APP: A web application upload.
#
# * EXTERNAL\_DATA: An external data upload.
#
# * APPIUM\_JAVA\_JUNIT\_TEST\_PACKAGE: An Appium Java JUnit test
# package upload.
#
# * APPIUM\_JAVA\_TESTNG\_TEST\_PACKAGE: An Appium Java TestNG test
# package upload.
#
# * APPIUM\_PYTHON\_TEST\_PACKAGE: An Appium Python test package upload.
#
# * APPIUM\_NODE\_TEST\_PACKAGE: An Appium Node.js test package upload.
#
# * APPIUM\_RUBY\_TEST\_PACKAGE: An Appium Ruby test package upload.
#
# * APPIUM\_WEB\_JAVA\_JUNIT\_TEST\_PACKAGE: An Appium Java JUnit test
# package upload for a web app.
#
# * APPIUM\_WEB\_JAVA\_TESTNG\_TEST\_PACKAGE: An Appium Java TestNG test
# package upload for a web app.
#
# * APPIUM\_WEB\_PYTHON\_TEST\_PACKAGE: An Appium Python test package
# upload for a web app.
#
# * APPIUM\_WEB\_NODE\_TEST\_PACKAGE: An Appium Node.js test package
# upload for a web app.
#
# * APPIUM\_WEB\_RUBY\_TEST\_PACKAGE: An Appium Ruby test package upload
# for a web app.
#
# * CALABASH\_TEST\_PACKAGE: A Calabash test package upload.
#
# * INSTRUMENTATION\_TEST\_PACKAGE: An instrumentation upload.
#
# * UIAUTOMATION\_TEST\_PACKAGE: A uiautomation test package upload.
#
# * UIAUTOMATOR\_TEST\_PACKAGE: A uiautomator test package upload.
#
# * XCTEST\_TEST\_PACKAGE: An Xcode test package upload.
#
# * XCTEST\_UI\_TEST\_PACKAGE: An Xcode UI test package upload.
#
# * APPIUM\_JAVA\_JUNIT\_TEST\_SPEC: An Appium Java JUnit test spec
# upload.
#
# * APPIUM\_JAVA\_TESTNG\_TEST\_SPEC: An Appium Java TestNG test spec
# upload.
#
# * APPIUM\_PYTHON\_TEST\_SPEC: An Appium Python test spec upload.
#
# * APPIUM\_NODE\_TEST\_SPEC: An Appium Node.js test spec upload.
#
# * APPIUM\_RUBY\_TEST\_SPEC: An Appium Ruby test spec upload.
#
# * APPIUM\_WEB\_JAVA\_JUNIT\_TEST\_SPEC: An Appium Java JUnit test spec
# upload for a web app.
#
# * APPIUM\_WEB\_JAVA\_TESTNG\_TEST\_SPEC: An Appium Java TestNG test
# spec upload for a web app.
#
# * APPIUM\_WEB\_PYTHON\_TEST\_SPEC: An Appium Python test spec upload
# for a web app.
#
# * APPIUM\_WEB\_NODE\_TEST\_SPEC: An Appium Node.js test spec upload
# for a web app.
#
# * APPIUM\_WEB\_RUBY\_TEST\_SPEC: An Appium Ruby test spec upload for a
# web app.
#
# * INSTRUMENTATION\_TEST\_SPEC: An instrumentation test spec upload.
#
# * XCTEST\_UI\_TEST\_SPEC: An Xcode UI test spec upload.
#
# @option params [String] :next_token
# An identifier that was returned from the previous call to this
# operation, which can be used to return the next set of items in the
# list.
#
# @return [Types::ListUploadsResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::ListUploadsResult#uploads #uploads} => Array<Types::Upload>
# * {Types::ListUploadsResult#next_token #next_token} => String
#
#
# @example Example: To get information about uploads
#
# # The following example returns information about uploads, given a specific Device Farm project.
#
# resp = client.list_uploads({
# arn: "arn:aws:devicefarm:us-west-2:123456789101:project:EXAMPLE-GUID-123-456", # You can get the Amazon Resource Name (ARN) of the project by using the list-projects CLI command.
# next_token: "RW5DdDJkMWYwZjM2MzM2VHVpOHJIUXlDUXlhc2QzRGViYnc9SEXAMPLE", # A dynamically generated value, used for paginating results.
# })
#
# resp.to_h outputs the following:
# {
# uploads: [
# ],
# }
#
# @example Request syntax with placeholder values
#
# resp = client.list_uploads({
# arn: "AmazonResourceName", # required
# type: "ANDROID_APP", # accepts ANDROID_APP, IOS_APP, WEB_APP, EXTERNAL_DATA, APPIUM_JAVA_JUNIT_TEST_PACKAGE, APPIUM_JAVA_TESTNG_TEST_PACKAGE, APPIUM_PYTHON_TEST_PACKAGE, APPIUM_NODE_TEST_PACKAGE, APPIUM_RUBY_TEST_PACKAGE, APPIUM_WEB_JAVA_JUNIT_TEST_PACKAGE, APPIUM_WEB_JAVA_TESTNG_TEST_PACKAGE, APPIUM_WEB_PYTHON_TEST_PACKAGE, APPIUM_WEB_NODE_TEST_PACKAGE, APPIUM_WEB_RUBY_TEST_PACKAGE, CALABASH_TEST_PACKAGE, INSTRUMENTATION_TEST_PACKAGE, UIAUTOMATION_TEST_PACKAGE, UIAUTOMATOR_TEST_PACKAGE, XCTEST_TEST_PACKAGE, XCTEST_UI_TEST_PACKAGE, APPIUM_JAVA_JUNIT_TEST_SPEC, APPIUM_JAVA_TESTNG_TEST_SPEC, APPIUM_PYTHON_TEST_SPEC, APPIUM_NODE_TEST_SPEC, APPIUM_RUBY_TEST_SPEC, APPIUM_WEB_JAVA_JUNIT_TEST_SPEC, APPIUM_WEB_JAVA_TESTNG_TEST_SPEC, APPIUM_WEB_PYTHON_TEST_SPEC, APPIUM_WEB_NODE_TEST_SPEC, APPIUM_WEB_RUBY_TEST_SPEC, INSTRUMENTATION_TEST_SPEC, XCTEST_UI_TEST_SPEC
# next_token: "PaginationToken",
# })
#
# @example Response structure
#
# resp.uploads #=> Array
# resp.uploads[0].arn #=> String
# resp.uploads[0].name #=> String
# resp.uploads[0].created #=> Time
# resp.uploads[0].type #=> String, one of "ANDROID_APP", "IOS_APP", "WEB_APP", "EXTERNAL_DATA", "APPIUM_JAVA_JUNIT_TEST_PACKAGE", "APPIUM_JAVA_TESTNG_TEST_PACKAGE", "APPIUM_PYTHON_TEST_PACKAGE", "APPIUM_NODE_TEST_PACKAGE", "APPIUM_RUBY_TEST_PACKAGE", "APPIUM_WEB_JAVA_JUNIT_TEST_PACKAGE", "APPIUM_WEB_JAVA_TESTNG_TEST_PACKAGE", "APPIUM_WEB_PYTHON_TEST_PACKAGE", "APPIUM_WEB_NODE_TEST_PACKAGE", "APPIUM_WEB_RUBY_TEST_PACKAGE", "CALABASH_TEST_PACKAGE", "INSTRUMENTATION_TEST_PACKAGE", "UIAUTOMATION_TEST_PACKAGE", "UIAUTOMATOR_TEST_PACKAGE", "XCTEST_TEST_PACKAGE", "XCTEST_UI_TEST_PACKAGE", "APPIUM_JAVA_JUNIT_TEST_SPEC", "APPIUM_JAVA_TESTNG_TEST_SPEC", "APPIUM_PYTHON_TEST_SPEC", "APPIUM_NODE_TEST_SPEC", "APPIUM_RUBY_TEST_SPEC", "APPIUM_WEB_JAVA_JUNIT_TEST_SPEC", "APPIUM_WEB_JAVA_TESTNG_TEST_SPEC", "APPIUM_WEB_PYTHON_TEST_SPEC", "APPIUM_WEB_NODE_TEST_SPEC", "APPIUM_WEB_RUBY_TEST_SPEC", "INSTRUMENTATION_TEST_SPEC", "XCTEST_UI_TEST_SPEC"
# resp.uploads[0].status #=> String, one of "INITIALIZED", "PROCESSING", "SUCCEEDED", "FAILED"
# resp.uploads[0].url #=> String
# resp.uploads[0].metadata #=> String
# resp.uploads[0].content_type #=> String
# resp.uploads[0].message #=> String
# resp.uploads[0].category #=> String, one of "CURATED", "PRIVATE"
# resp.next_token #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/ListUploads AWS API Documentation
#
# @overload list_uploads(params = {})
# @param [Hash] params ({})
def list_uploads(params = {}, options = {})
req = build_request(:list_uploads, params)
req.send_request(options)
end
# Returns information about all Amazon Virtual Private Cloud (VPC)
# endpoint configurations in the AWS account.
#
# @option params [Integer] :max_results
# An integer specifying the maximum number of items you want to return
# in the API response.
#
# @option params [String] :next_token
# An identifier that was returned from the previous call to this
# operation, which can be used to return the next set of items in the
# list.
#
# @return [Types::ListVPCEConfigurationsResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::ListVPCEConfigurationsResult#vpce_configurations #vpce_configurations} => Array<Types::VPCEConfiguration>
# * {Types::ListVPCEConfigurationsResult#next_token #next_token} => String
#
# @example Request syntax with placeholder values
#
# resp = client.list_vpce_configurations({
# max_results: 1,
# next_token: "PaginationToken",
# })
#
# @example Response structure
#
# resp.vpce_configurations #=> Array
# resp.vpce_configurations[0].arn #=> String
# resp.vpce_configurations[0].vpce_configuration_name #=> String
# resp.vpce_configurations[0].vpce_service_name #=> String
# resp.vpce_configurations[0].service_dns_name #=> String
# resp.vpce_configurations[0].vpce_configuration_description #=> String
# resp.next_token #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/ListVPCEConfigurations AWS API Documentation
#
# @overload list_vpce_configurations(params = {})
# @param [Hash] params ({})
def list_vpce_configurations(params = {}, options = {})
req = build_request(:list_vpce_configurations, params)
req.send_request(options)
end
# Immediately purchases offerings for an AWS account. Offerings renew
# with the latest total purchased quantity for an offering, unless the
# renewal was overridden. The API returns a `NotEligible` error if the
# user is not permitted to invoke the operation. Please contact
# [[email protected]](mailto:[email protected])
# if you believe that you should be able to invoke this operation.
#
# @option params [String] :offering_id
# The ID of the offering.
#
# @option params [Integer] :quantity
# The number of device slots you wish to purchase in an offering
# request.
#
# @option params [String] :offering_promotion_id
# The ID of the offering promotion to be applied to the purchase.
#
# @return [Types::PurchaseOfferingResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::PurchaseOfferingResult#offering_transaction #offering_transaction} => Types::OfferingTransaction
#
#
# @example Example: To purchase a device slot offering
#
# # The following example purchases a specific device slot offering.
#
# resp = client.purchase_offering({
# offering_id: "D68B3C05-1BA6-4360-BC69-12345EXAMPLE", # You can get the offering ID by using the list-offerings CLI command.
# quantity: 1,
# })
#
# resp.to_h outputs the following:
# {
# offering_transaction: {
# cost: {
# amount: 8.07,
# currency_code: "USD",
# },
# created_on: Time.parse("1472648340"),
# offering_status: {
# type: "PURCHASE",
# effective_on: Time.parse("1472648340"),
# offering: {
# type: "RECURRING",
# description: "Android Remote Access Unmetered Device Slot",
# id: "D68B3C05-1BA6-4360-BC69-12345EXAMPLE",
# platform: "ANDROID",
# },
# quantity: 1,
# },
# transaction_id: "d30614ed-1b03-404c-9893-12345EXAMPLE",
# },
# }
#
# @example Request syntax with placeholder values
#
# resp = client.purchase_offering({
# offering_id: "OfferingIdentifier",
# quantity: 1,
# offering_promotion_id: "OfferingPromotionIdentifier",
# })
#
# @example Response structure
#
# resp.offering_transaction.offering_status.type #=> String, one of "PURCHASE", "RENEW", "SYSTEM"
# resp.offering_transaction.offering_status.offering.id #=> String
# resp.offering_transaction.offering_status.offering.description #=> String
# resp.offering_transaction.offering_status.offering.type #=> String, one of "RECURRING"
# resp.offering_transaction.offering_status.offering.platform #=> String, one of "ANDROID", "IOS"
# resp.offering_transaction.offering_status.offering.recurring_charges #=> Array
# resp.offering_transaction.offering_status.offering.recurring_charges[0].cost.amount #=> Float
# resp.offering_transaction.offering_status.offering.recurring_charges[0].cost.currency_code #=> String, one of "USD"
# resp.offering_transaction.offering_status.offering.recurring_charges[0].frequency #=> String, one of "MONTHLY"
# resp.offering_transaction.offering_status.quantity #=> Integer
# resp.offering_transaction.offering_status.effective_on #=> Time
# resp.offering_transaction.transaction_id #=> String
# resp.offering_transaction.offering_promotion_id #=> String
# resp.offering_transaction.created_on #=> Time
# resp.offering_transaction.cost.amount #=> Float
# resp.offering_transaction.cost.currency_code #=> String, one of "USD"
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/PurchaseOffering AWS API Documentation
#
# @overload purchase_offering(params = {})
# @param [Hash] params ({})
def purchase_offering(params = {}, options = {})
req = build_request(:purchase_offering, params)
req.send_request(options)
end
# Explicitly sets the quantity of devices to renew for an offering,
# starting from the `effectiveDate` of the next period. The API returns
# a `NotEligible` error if the user is not permitted to invoke the
# operation. Please contact
# [[email protected]](mailto:[email protected])
# if you believe that you should be able to invoke this operation.
#
# @option params [String] :offering_id
# The ID of a request to renew an offering.
#
# @option params [Integer] :quantity
# The quantity requested in an offering renewal.
#
# @return [Types::RenewOfferingResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::RenewOfferingResult#offering_transaction #offering_transaction} => Types::OfferingTransaction
#
#
# @example Example: To renew a device slot offering
#
# # The following example renews a specific device slot offering.
#
# resp = client.renew_offering({
# offering_id: "D68B3C05-1BA6-4360-BC69-12345EXAMPLE", # You can get the offering ID by using the list-offerings CLI command.
# quantity: 1,
# })
#
# resp.to_h outputs the following:
# {
# offering_transaction: {
# cost: {
# amount: 250,
# currency_code: "USD",
# },
# created_on: Time.parse("1472648880"),
# offering_status: {
# type: "RENEW",
# effective_on: Time.parse("1472688000"),
# offering: {
# type: "RECURRING",
# description: "Android Remote Access Unmetered Device Slot",
# id: "D68B3C05-1BA6-4360-BC69-12345EXAMPLE",
# platform: "ANDROID",
# },
# quantity: 1,
# },
# transaction_id: "e90f1405-8c35-4561-be43-12345EXAMPLE",
# },
# }
#
# @example Request syntax with placeholder values
#
# resp = client.renew_offering({
# offering_id: "OfferingIdentifier",
# quantity: 1,
# })
#
# @example Response structure
#
# resp.offering_transaction.offering_status.type #=> String, one of "PURCHASE", "RENEW", "SYSTEM"
# resp.offering_transaction.offering_status.offering.id #=> String
# resp.offering_transaction.offering_status.offering.description #=> String
# resp.offering_transaction.offering_status.offering.type #=> String, one of "RECURRING"
# resp.offering_transaction.offering_status.offering.platform #=> String, one of "ANDROID", "IOS"
# resp.offering_transaction.offering_status.offering.recurring_charges #=> Array
# resp.offering_transaction.offering_status.offering.recurring_charges[0].cost.amount #=> Float
# resp.offering_transaction.offering_status.offering.recurring_charges[0].cost.currency_code #=> String, one of "USD"
# resp.offering_transaction.offering_status.offering.recurring_charges[0].frequency #=> String, one of "MONTHLY"
# resp.offering_transaction.offering_status.quantity #=> Integer
# resp.offering_transaction.offering_status.effective_on #=> Time
# resp.offering_transaction.transaction_id #=> String
# resp.offering_transaction.offering_promotion_id #=> String
# resp.offering_transaction.created_on #=> Time
# resp.offering_transaction.cost.amount #=> Float
# resp.offering_transaction.cost.currency_code #=> String, one of "USD"
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/RenewOffering AWS API Documentation
#
# @overload renew_offering(params = {})
# @param [Hash] params ({})
def renew_offering(params = {}, options = {})
req = build_request(:renew_offering, params)
req.send_request(options)
end
# Schedules a run.
#
# @option params [required, String] :project_arn
# The ARN of the project for the run to be scheduled.
#
# @option params [String] :app_arn
# The ARN of the app to schedule a run.
#
# @option params [String] :device_pool_arn
# The ARN of the device pool for the run to be scheduled.
#
# @option params [Types::DeviceSelectionConfiguration] :device_selection_configuration
# The filter criteria used to dynamically select a set of devices for a
# test run, as well as the maximum number of devices to be included in
# the run.
#
# Either <b> <code>devicePoolArn</code> </b> or <b>
# <code>deviceSelectionConfiguration</code> </b> is required in a
# request.
#
# @option params [String] :name
# The name for the run to be scheduled.
#
# @option params [required, Types::ScheduleRunTest] :test
# Information about the test for the run to be scheduled.
#
# @option params [Types::ScheduleRunConfiguration] :configuration
# Information about the settings for the run to be scheduled.
#
# @option params [Types::ExecutionConfiguration] :execution_configuration
# Specifies configuration information about a test run, such as the
# execution timeout (in minutes).
#
# @return [Types::ScheduleRunResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::ScheduleRunResult#run #run} => Types::Run
#
#
# @example Example: To schedule a test run
#
# # The following example schedules a test run named MyRun.
#
# resp = client.schedule_run({
# name: "MyRun",
# device_pool_arn: "arn:aws:devicefarm:us-west-2:123456789101:pool:EXAMPLE-GUID-123-456", # You can get the Amazon Resource Name (ARN) of the device pool by using the list-pools CLI command.
# project_arn: "arn:aws:devicefarm:us-west-2:123456789101:project:EXAMPLE-GUID-123-456", # You can get the Amazon Resource Name (ARN) of the project by using the list-projects CLI command.
# test: {
# type: "APPIUM_JAVA_JUNIT",
# test_package_arn: "arn:aws:devicefarm:us-west-2:123456789101:test:EXAMPLE-GUID-123-456",
# },
# })
#
# resp.to_h outputs the following:
# {
# run: {
# },
# }
#
# @example Request syntax with placeholder values
#
# resp = client.schedule_run({
# project_arn: "AmazonResourceName", # required
# app_arn: "AmazonResourceName",
# device_pool_arn: "AmazonResourceName",
# device_selection_configuration: {
# filters: [ # required
# {
# attribute: "ARN", # accepts ARN, PLATFORM, OS_VERSION, MODEL, AVAILABILITY, FORM_FACTOR, MANUFACTURER, REMOTE_ACCESS_ENABLED, REMOTE_DEBUG_ENABLED, INSTANCE_ARN, INSTANCE_LABELS, FLEET_TYPE
# operator: "EQUALS", # accepts EQUALS, LESS_THAN, LESS_THAN_OR_EQUALS, GREATER_THAN, GREATER_THAN_OR_EQUALS, IN, NOT_IN, CONTAINS
# values: ["String"],
# },
# ],
# max_devices: 1, # required
# },
# name: "Name",
# test: { # required
# type: "BUILTIN_FUZZ", # required, accepts BUILTIN_FUZZ, BUILTIN_EXPLORER, WEB_PERFORMANCE_PROFILE, APPIUM_JAVA_JUNIT, APPIUM_JAVA_TESTNG, APPIUM_PYTHON, APPIUM_NODE, APPIUM_RUBY, APPIUM_WEB_JAVA_JUNIT, APPIUM_WEB_JAVA_TESTNG, APPIUM_WEB_PYTHON, APPIUM_WEB_NODE, APPIUM_WEB_RUBY, CALABASH, INSTRUMENTATION, UIAUTOMATION, UIAUTOMATOR, XCTEST, XCTEST_UI, REMOTE_ACCESS_RECORD, REMOTE_ACCESS_REPLAY
# test_package_arn: "AmazonResourceName",
# test_spec_arn: "AmazonResourceName",
# filter: "Filter",
# parameters: {
# "String" => "String",
# },
# },
# configuration: {
# extra_data_package_arn: "AmazonResourceName",
# network_profile_arn: "AmazonResourceName",
# locale: "String",
# location: {
# latitude: 1.0, # required
# longitude: 1.0, # required
# },
# vpce_configuration_arns: ["AmazonResourceName"],
# customer_artifact_paths: {
# ios_paths: ["String"],
# android_paths: ["String"],
# device_host_paths: ["String"],
# },
# radios: {
# wifi: false,
# bluetooth: false,
# nfc: false,
# gps: false,
# },
# auxiliary_apps: ["AmazonResourceName"],
# billing_method: "METERED", # accepts METERED, UNMETERED
# },
# execution_configuration: {
# job_timeout_minutes: 1,
# accounts_cleanup: false,
# app_packages_cleanup: false,
# video_capture: false,
# skip_app_resign: false,
# },
# })
#
# @example Response structure
#
# resp.run.arn #=> String
# resp.run.name #=> String
# resp.run.type #=> String, one of "BUILTIN_FUZZ", "BUILTIN_EXPLORER", "WEB_PERFORMANCE_PROFILE", "APPIUM_JAVA_JUNIT", "APPIUM_JAVA_TESTNG", "APPIUM_PYTHON", "APPIUM_NODE", "APPIUM_RUBY", "APPIUM_WEB_JAVA_JUNIT", "APPIUM_WEB_JAVA_TESTNG", "APPIUM_WEB_PYTHON", "APPIUM_WEB_NODE", "APPIUM_WEB_RUBY", "CALABASH", "INSTRUMENTATION", "UIAUTOMATION", "UIAUTOMATOR", "XCTEST", "XCTEST_UI", "REMOTE_ACCESS_RECORD", "REMOTE_ACCESS_REPLAY"
# resp.run.platform #=> String, one of "ANDROID", "IOS"
# resp.run.created #=> Time
# resp.run.status #=> String, one of "PENDING", "PENDING_CONCURRENCY", "PENDING_DEVICE", "PROCESSING", "SCHEDULING", "PREPARING", "RUNNING", "COMPLETED", "STOPPING"
# resp.run.result #=> String, one of "PENDING", "PASSED", "WARNED", "FAILED", "SKIPPED", "ERRORED", "STOPPED"
# resp.run.started #=> Time
# resp.run.stopped #=> Time
# resp.run.counters.total #=> Integer
# resp.run.counters.passed #=> Integer
# resp.run.counters.failed #=> Integer
# resp.run.counters.warned #=> Integer
# resp.run.counters.errored #=> Integer
# resp.run.counters.stopped #=> Integer
# resp.run.counters.skipped #=> Integer
# resp.run.message #=> String
# resp.run.total_jobs #=> Integer
# resp.run.completed_jobs #=> Integer
# resp.run.billing_method #=> String, one of "METERED", "UNMETERED"
# resp.run.device_minutes.total #=> Float
# resp.run.device_minutes.metered #=> Float
# resp.run.device_minutes.unmetered #=> Float
# resp.run.network_profile.arn #=> String
# resp.run.network_profile.name #=> String
# resp.run.network_profile.description #=> String
# resp.run.network_profile.type #=> String, one of "CURATED", "PRIVATE"
# resp.run.network_profile.uplink_bandwidth_bits #=> Integer
# resp.run.network_profile.downlink_bandwidth_bits #=> Integer
# resp.run.network_profile.uplink_delay_ms #=> Integer
# resp.run.network_profile.downlink_delay_ms #=> Integer
# resp.run.network_profile.uplink_jitter_ms #=> Integer
# resp.run.network_profile.downlink_jitter_ms #=> Integer
# resp.run.network_profile.uplink_loss_percent #=> Integer
# resp.run.network_profile.downlink_loss_percent #=> Integer
# resp.run.parsing_result_url #=> String
# resp.run.result_code #=> String, one of "PARSING_FAILED", "VPC_ENDPOINT_SETUP_FAILED"
# resp.run.seed #=> Integer
# resp.run.app_upload #=> String
# resp.run.event_count #=> Integer
# resp.run.job_timeout_minutes #=> Integer
# resp.run.device_pool_arn #=> String
# resp.run.locale #=> String
# resp.run.radios.wifi #=> Boolean
# resp.run.radios.bluetooth #=> Boolean
# resp.run.radios.nfc #=> Boolean
# resp.run.radios.gps #=> Boolean
# resp.run.location.latitude #=> Float
# resp.run.location.longitude #=> Float
# resp.run.customer_artifact_paths.ios_paths #=> Array
# resp.run.customer_artifact_paths.ios_paths[0] #=> String
# resp.run.customer_artifact_paths.android_paths #=> Array
# resp.run.customer_artifact_paths.android_paths[0] #=> String
# resp.run.customer_artifact_paths.device_host_paths #=> Array
# resp.run.customer_artifact_paths.device_host_paths[0] #=> String
# resp.run.web_url #=> String
# resp.run.skip_app_resign #=> Boolean
# resp.run.test_spec_arn #=> String
# resp.run.device_selection_result.filters #=> Array
# resp.run.device_selection_result.filters[0].attribute #=> String, one of "ARN", "PLATFORM", "OS_VERSION", "MODEL", "AVAILABILITY", "FORM_FACTOR", "MANUFACTURER", "REMOTE_ACCESS_ENABLED", "REMOTE_DEBUG_ENABLED", "INSTANCE_ARN", "INSTANCE_LABELS", "FLEET_TYPE"
# resp.run.device_selection_result.filters[0].operator #=> String, one of "EQUALS", "LESS_THAN", "LESS_THAN_OR_EQUALS", "GREATER_THAN", "GREATER_THAN_OR_EQUALS", "IN", "NOT_IN", "CONTAINS"
# resp.run.device_selection_result.filters[0].values #=> Array
# resp.run.device_selection_result.filters[0].values[0] #=> String
# resp.run.device_selection_result.matched_devices_count #=> Integer
# resp.run.device_selection_result.max_devices #=> Integer
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/ScheduleRun AWS API Documentation
#
# @overload schedule_run(params = {})
# @param [Hash] params ({})
def schedule_run(params = {}, options = {})
req = build_request(:schedule_run, params)
req.send_request(options)
end
# Initiates a stop request for the current job. AWS Device Farm will
# immediately stop the job on the device where tests have not started
# executing, and you will not be billed for this device. On the device
# where tests have started executing, Setup Suite and Teardown Suite
# tests will run to completion before stopping execution on the device.
# You will be billed for Setup, Teardown, and any tests that were in
# progress or already completed.
#
# @option params [required, String] :arn
# Represents the Amazon Resource Name (ARN) of the Device Farm job you
# wish to stop.
#
# @return [Types::StopJobResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::StopJobResult#job #job} => Types::Job
#
# @example Request syntax with placeholder values
#
# resp = client.stop_job({
# arn: "AmazonResourceName", # required
# })
#
# @example Response structure
#
# resp.job.arn #=> String
# resp.job.name #=> String
# resp.job.type #=> String, one of "BUILTIN_FUZZ", "BUILTIN_EXPLORER", "WEB_PERFORMANCE_PROFILE", "APPIUM_JAVA_JUNIT", "APPIUM_JAVA_TESTNG", "APPIUM_PYTHON", "APPIUM_NODE", "APPIUM_RUBY", "APPIUM_WEB_JAVA_JUNIT", "APPIUM_WEB_JAVA_TESTNG", "APPIUM_WEB_PYTHON", "APPIUM_WEB_NODE", "APPIUM_WEB_RUBY", "CALABASH", "INSTRUMENTATION", "UIAUTOMATION", "UIAUTOMATOR", "XCTEST", "XCTEST_UI", "REMOTE_ACCESS_RECORD", "REMOTE_ACCESS_REPLAY"
# resp.job.created #=> Time
# resp.job.status #=> String, one of "PENDING", "PENDING_CONCURRENCY", "PENDING_DEVICE", "PROCESSING", "SCHEDULING", "PREPARING", "RUNNING", "COMPLETED", "STOPPING"
# resp.job.result #=> String, one of "PENDING", "PASSED", "WARNED", "FAILED", "SKIPPED", "ERRORED", "STOPPED"
# resp.job.started #=> Time
# resp.job.stopped #=> Time
# resp.job.counters.total #=> Integer
# resp.job.counters.passed #=> Integer
# resp.job.counters.failed #=> Integer
# resp.job.counters.warned #=> Integer
# resp.job.counters.errored #=> Integer
# resp.job.counters.stopped #=> Integer
# resp.job.counters.skipped #=> Integer
# resp.job.message #=> String
# resp.job.device.arn #=> String
# resp.job.device.name #=> String
# resp.job.device.manufacturer #=> String
# resp.job.device.model #=> String
# resp.job.device.model_id #=> String
# resp.job.device.form_factor #=> String, one of "PHONE", "TABLET"
# resp.job.device.platform #=> String, one of "ANDROID", "IOS"
# resp.job.device.os #=> String
# resp.job.device.cpu.frequency #=> String
# resp.job.device.cpu.architecture #=> String
# resp.job.device.cpu.clock #=> Float
# resp.job.device.resolution.width #=> Integer
# resp.job.device.resolution.height #=> Integer
# resp.job.device.heap_size #=> Integer
# resp.job.device.memory #=> Integer
# resp.job.device.image #=> String
# resp.job.device.carrier #=> String
# resp.job.device.radio #=> String
# resp.job.device.remote_access_enabled #=> Boolean
# resp.job.device.remote_debug_enabled #=> Boolean
# resp.job.device.fleet_type #=> String
# resp.job.device.fleet_name #=> String
# resp.job.device.instances #=> Array
# resp.job.device.instances[0].arn #=> String
# resp.job.device.instances[0].device_arn #=> String
# resp.job.device.instances[0].labels #=> Array
# resp.job.device.instances[0].labels[0] #=> String
# resp.job.device.instances[0].status #=> String, one of "IN_USE", "PREPARING", "AVAILABLE", "NOT_AVAILABLE"
# resp.job.device.instances[0].udid #=> String
# resp.job.device.instances[0].instance_profile.arn #=> String
# resp.job.device.instances[0].instance_profile.package_cleanup #=> Boolean
# resp.job.device.instances[0].instance_profile.exclude_app_packages_from_cleanup #=> Array
# resp.job.device.instances[0].instance_profile.exclude_app_packages_from_cleanup[0] #=> String
# resp.job.device.instances[0].instance_profile.reboot_after_use #=> Boolean
# resp.job.device.instances[0].instance_profile.name #=> String
# resp.job.device.instances[0].instance_profile.description #=> String
# resp.job.device.availability #=> String, one of "TEMPORARY_NOT_AVAILABLE", "BUSY", "AVAILABLE", "HIGHLY_AVAILABLE"
# resp.job.instance_arn #=> String
# resp.job.device_minutes.total #=> Float
# resp.job.device_minutes.metered #=> Float
# resp.job.device_minutes.unmetered #=> Float
# resp.job.video_endpoint #=> String
# resp.job.video_capture #=> Boolean
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/StopJob AWS API Documentation
#
# @overload stop_job(params = {})
# @param [Hash] params ({})
def stop_job(params = {}, options = {})
req = build_request(:stop_job, params)
req.send_request(options)
end
# Ends a specified remote access session.
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) of the remote access session you wish
# to stop.
#
# @return [Types::StopRemoteAccessSessionResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::StopRemoteAccessSessionResult#remote_access_session #remote_access_session} => Types::RemoteAccessSession
#
# @example Request syntax with placeholder values
#
# resp = client.stop_remote_access_session({
# arn: "AmazonResourceName", # required
# })
#
# @example Response structure
#
# resp.remote_access_session.arn #=> String
# resp.remote_access_session.name #=> String
# resp.remote_access_session.created #=> Time
# resp.remote_access_session.status #=> String, one of "PENDING", "PENDING_CONCURRENCY", "PENDING_DEVICE", "PROCESSING", "SCHEDULING", "PREPARING", "RUNNING", "COMPLETED", "STOPPING"
# resp.remote_access_session.result #=> String, one of "PENDING", "PASSED", "WARNED", "FAILED", "SKIPPED", "ERRORED", "STOPPED"
# resp.remote_access_session.message #=> String
# resp.remote_access_session.started #=> Time
# resp.remote_access_session.stopped #=> Time
# resp.remote_access_session.device.arn #=> String
# resp.remote_access_session.device.name #=> String
# resp.remote_access_session.device.manufacturer #=> String
# resp.remote_access_session.device.model #=> String
# resp.remote_access_session.device.model_id #=> String
# resp.remote_access_session.device.form_factor #=> String, one of "PHONE", "TABLET"
# resp.remote_access_session.device.platform #=> String, one of "ANDROID", "IOS"
# resp.remote_access_session.device.os #=> String
# resp.remote_access_session.device.cpu.frequency #=> String
# resp.remote_access_session.device.cpu.architecture #=> String
# resp.remote_access_session.device.cpu.clock #=> Float
# resp.remote_access_session.device.resolution.width #=> Integer
# resp.remote_access_session.device.resolution.height #=> Integer
# resp.remote_access_session.device.heap_size #=> Integer
# resp.remote_access_session.device.memory #=> Integer
# resp.remote_access_session.device.image #=> String
# resp.remote_access_session.device.carrier #=> String
# resp.remote_access_session.device.radio #=> String
# resp.remote_access_session.device.remote_access_enabled #=> Boolean
# resp.remote_access_session.device.remote_debug_enabled #=> Boolean
# resp.remote_access_session.device.fleet_type #=> String
# resp.remote_access_session.device.fleet_name #=> String
# resp.remote_access_session.device.instances #=> Array
# resp.remote_access_session.device.instances[0].arn #=> String
# resp.remote_access_session.device.instances[0].device_arn #=> String
# resp.remote_access_session.device.instances[0].labels #=> Array
# resp.remote_access_session.device.instances[0].labels[0] #=> String
# resp.remote_access_session.device.instances[0].status #=> String, one of "IN_USE", "PREPARING", "AVAILABLE", "NOT_AVAILABLE"
# resp.remote_access_session.device.instances[0].udid #=> String
# resp.remote_access_session.device.instances[0].instance_profile.arn #=> String
# resp.remote_access_session.device.instances[0].instance_profile.package_cleanup #=> Boolean
# resp.remote_access_session.device.instances[0].instance_profile.exclude_app_packages_from_cleanup #=> Array
# resp.remote_access_session.device.instances[0].instance_profile.exclude_app_packages_from_cleanup[0] #=> String
# resp.remote_access_session.device.instances[0].instance_profile.reboot_after_use #=> Boolean
# resp.remote_access_session.device.instances[0].instance_profile.name #=> String
# resp.remote_access_session.device.instances[0].instance_profile.description #=> String
# resp.remote_access_session.device.availability #=> String, one of "TEMPORARY_NOT_AVAILABLE", "BUSY", "AVAILABLE", "HIGHLY_AVAILABLE"
# resp.remote_access_session.instance_arn #=> String
# resp.remote_access_session.remote_debug_enabled #=> Boolean
# resp.remote_access_session.remote_record_enabled #=> Boolean
# resp.remote_access_session.remote_record_app_arn #=> String
# resp.remote_access_session.host_address #=> String
# resp.remote_access_session.client_id #=> String
# resp.remote_access_session.billing_method #=> String, one of "METERED", "UNMETERED"
# resp.remote_access_session.device_minutes.total #=> Float
# resp.remote_access_session.device_minutes.metered #=> Float
# resp.remote_access_session.device_minutes.unmetered #=> Float
# resp.remote_access_session.endpoint #=> String
# resp.remote_access_session.device_udid #=> String
# resp.remote_access_session.interaction_mode #=> String, one of "INTERACTIVE", "NO_VIDEO", "VIDEO_ONLY"
# resp.remote_access_session.skip_app_resign #=> Boolean
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/StopRemoteAccessSession AWS API Documentation
#
# @overload stop_remote_access_session(params = {})
# @param [Hash] params ({})
def stop_remote_access_session(params = {}, options = {})
req = build_request(:stop_remote_access_session, params)
req.send_request(options)
end
# Initiates a stop request for the current test run. AWS Device Farm
# will immediately stop the run on devices where tests have not started
# executing, and you will not be billed for these devices. On devices
# where tests have started executing, Setup Suite and Teardown Suite
# tests will run to completion before stopping execution on those
# devices. You will be billed for Setup, Teardown, and any tests that
# were in progress or already completed.
#
# @option params [required, String] :arn
# Represents the Amazon Resource Name (ARN) of the Device Farm run you
# wish to stop.
#
# @return [Types::StopRunResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::StopRunResult#run #run} => Types::Run
#
#
# @example Example: To stop a test run
#
# # The following example stops a specific test run.
#
# resp = client.stop_run({
# arn: "arn:aws:devicefarm:us-west-2:123456789101:run:EXAMPLE-GUID-123-456", # You can get the Amazon Resource Name (ARN) of the test run by using the list-runs CLI command.
# })
#
# resp.to_h outputs the following:
# {
# run: {
# },
# }
#
# @example Request syntax with placeholder values
#
# resp = client.stop_run({
# arn: "AmazonResourceName", # required
# })
#
# @example Response structure
#
# resp.run.arn #=> String
# resp.run.name #=> String
# resp.run.type #=> String, one of "BUILTIN_FUZZ", "BUILTIN_EXPLORER", "WEB_PERFORMANCE_PROFILE", "APPIUM_JAVA_JUNIT", "APPIUM_JAVA_TESTNG", "APPIUM_PYTHON", "APPIUM_NODE", "APPIUM_RUBY", "APPIUM_WEB_JAVA_JUNIT", "APPIUM_WEB_JAVA_TESTNG", "APPIUM_WEB_PYTHON", "APPIUM_WEB_NODE", "APPIUM_WEB_RUBY", "CALABASH", "INSTRUMENTATION", "UIAUTOMATION", "UIAUTOMATOR", "XCTEST", "XCTEST_UI", "REMOTE_ACCESS_RECORD", "REMOTE_ACCESS_REPLAY"
# resp.run.platform #=> String, one of "ANDROID", "IOS"
# resp.run.created #=> Time
# resp.run.status #=> String, one of "PENDING", "PENDING_CONCURRENCY", "PENDING_DEVICE", "PROCESSING", "SCHEDULING", "PREPARING", "RUNNING", "COMPLETED", "STOPPING"
# resp.run.result #=> String, one of "PENDING", "PASSED", "WARNED", "FAILED", "SKIPPED", "ERRORED", "STOPPED"
# resp.run.started #=> Time
# resp.run.stopped #=> Time
# resp.run.counters.total #=> Integer
# resp.run.counters.passed #=> Integer
# resp.run.counters.failed #=> Integer
# resp.run.counters.warned #=> Integer
# resp.run.counters.errored #=> Integer
# resp.run.counters.stopped #=> Integer
# resp.run.counters.skipped #=> Integer
# resp.run.message #=> String
# resp.run.total_jobs #=> Integer
# resp.run.completed_jobs #=> Integer
# resp.run.billing_method #=> String, one of "METERED", "UNMETERED"
# resp.run.device_minutes.total #=> Float
# resp.run.device_minutes.metered #=> Float
# resp.run.device_minutes.unmetered #=> Float
# resp.run.network_profile.arn #=> String
# resp.run.network_profile.name #=> String
# resp.run.network_profile.description #=> String
# resp.run.network_profile.type #=> String, one of "CURATED", "PRIVATE"
# resp.run.network_profile.uplink_bandwidth_bits #=> Integer
# resp.run.network_profile.downlink_bandwidth_bits #=> Integer
# resp.run.network_profile.uplink_delay_ms #=> Integer
# resp.run.network_profile.downlink_delay_ms #=> Integer
# resp.run.network_profile.uplink_jitter_ms #=> Integer
# resp.run.network_profile.downlink_jitter_ms #=> Integer
# resp.run.network_profile.uplink_loss_percent #=> Integer
# resp.run.network_profile.downlink_loss_percent #=> Integer
# resp.run.parsing_result_url #=> String
# resp.run.result_code #=> String, one of "PARSING_FAILED", "VPC_ENDPOINT_SETUP_FAILED"
# resp.run.seed #=> Integer
# resp.run.app_upload #=> String
# resp.run.event_count #=> Integer
# resp.run.job_timeout_minutes #=> Integer
# resp.run.device_pool_arn #=> String
# resp.run.locale #=> String
# resp.run.radios.wifi #=> Boolean
# resp.run.radios.bluetooth #=> Boolean
# resp.run.radios.nfc #=> Boolean
# resp.run.radios.gps #=> Boolean
# resp.run.location.latitude #=> Float
# resp.run.location.longitude #=> Float
# resp.run.customer_artifact_paths.ios_paths #=> Array
# resp.run.customer_artifact_paths.ios_paths[0] #=> String
# resp.run.customer_artifact_paths.android_paths #=> Array
# resp.run.customer_artifact_paths.android_paths[0] #=> String
# resp.run.customer_artifact_paths.device_host_paths #=> Array
# resp.run.customer_artifact_paths.device_host_paths[0] #=> String
# resp.run.web_url #=> String
# resp.run.skip_app_resign #=> Boolean
# resp.run.test_spec_arn #=> String
# resp.run.device_selection_result.filters #=> Array
# resp.run.device_selection_result.filters[0].attribute #=> String, one of "ARN", "PLATFORM", "OS_VERSION", "MODEL", "AVAILABILITY", "FORM_FACTOR", "MANUFACTURER", "REMOTE_ACCESS_ENABLED", "REMOTE_DEBUG_ENABLED", "INSTANCE_ARN", "INSTANCE_LABELS", "FLEET_TYPE"
# resp.run.device_selection_result.filters[0].operator #=> String, one of "EQUALS", "LESS_THAN", "LESS_THAN_OR_EQUALS", "GREATER_THAN", "GREATER_THAN_OR_EQUALS", "IN", "NOT_IN", "CONTAINS"
# resp.run.device_selection_result.filters[0].values #=> Array
# resp.run.device_selection_result.filters[0].values[0] #=> String
# resp.run.device_selection_result.matched_devices_count #=> Integer
# resp.run.device_selection_result.max_devices #=> Integer
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/StopRun AWS API Documentation
#
# @overload stop_run(params = {})
# @param [Hash] params ({})
def stop_run(params = {}, options = {})
req = build_request(:stop_run, params)
req.send_request(options)
end
# Associates the specified tags to a resource with the specified
# `resourceArn`. If existing tags on a resource are not specified in the
# request parameters, they are not changed. When a resource is deleted,
# the tags associated with that resource are deleted as well.
#
# @option params [required, String] :resource_arn
# The Amazon Resource Name (ARN) of the resource(s) to which to add
# tags. You can associate tags with the following Device Farm resources:
# `PROJECT`, `RUN`, `NETWORK_PROFILE`, `INSTANCE_PROFILE`,
# `DEVICE_INSTANCE`, `SESSION`, `DEVICE_POOL`, `DEVICE`, and
# `VPCE_CONFIGURATION`.
#
# @option params [required, Array<Types::Tag>] :tags
# The tags to add to the resource. A tag is an array of key-value pairs.
# Tag keys can have a maximum character length of 128 characters, and
# tag values can have a maximum length of 256 characters.
#
# @return [Struct] Returns an empty {Seahorse::Client::Response response}.
#
# @example Request syntax with placeholder values
#
# resp = client.tag_resource({
# resource_arn: "AmazonResourceName", # required
# tags: [ # required
# {
# key: "TagKey", # required
# value: "TagValue", # required
# },
# ],
# })
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/TagResource AWS API Documentation
#
# @overload tag_resource(params = {})
# @param [Hash] params ({})
def tag_resource(params = {}, options = {})
req = build_request(:tag_resource, params)
req.send_request(options)
end
# Deletes the specified tags from a resource.
#
# @option params [required, String] :resource_arn
# The Amazon Resource Name (ARN) of the resource(s) from which to delete
# tags. You can associate tags with the following Device Farm resources:
# `PROJECT`, `RUN`, `NETWORK_PROFILE`, `INSTANCE_PROFILE`,
# `DEVICE_INSTANCE`, `SESSION`, `DEVICE_POOL`, `DEVICE`, and
# `VPCE_CONFIGURATION`.
#
# @option params [required, Array<String>] :tag_keys
# The keys of the tags to be removed.
#
# @return [Struct] Returns an empty {Seahorse::Client::Response response}.
#
# @example Request syntax with placeholder values
#
# resp = client.untag_resource({
# resource_arn: "AmazonResourceName", # required
# tag_keys: ["TagKey"], # required
# })
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/UntagResource AWS API Documentation
#
# @overload untag_resource(params = {})
# @param [Hash] params ({})
def untag_resource(params = {}, options = {})
req = build_request(:untag_resource, params)
req.send_request(options)
end
# Updates information about an existing private device instance.
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) of the device instance.
#
# @option params [String] :profile_arn
# The Amazon Resource Name (ARN) of the profile that you want to
# associate with the device instance.
#
# @option params [Array<String>] :labels
# An array of strings that you want to associate with the device
# instance.
#
# @return [Types::UpdateDeviceInstanceResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::UpdateDeviceInstanceResult#device_instance #device_instance} => Types::DeviceInstance
#
# @example Request syntax with placeholder values
#
# resp = client.update_device_instance({
# arn: "AmazonResourceName", # required
# profile_arn: "AmazonResourceName",
# labels: ["String"],
# })
#
# @example Response structure
#
# resp.device_instance.arn #=> String
# resp.device_instance.device_arn #=> String
# resp.device_instance.labels #=> Array
# resp.device_instance.labels[0] #=> String
# resp.device_instance.status #=> String, one of "IN_USE", "PREPARING", "AVAILABLE", "NOT_AVAILABLE"
# resp.device_instance.udid #=> String
# resp.device_instance.instance_profile.arn #=> String
# resp.device_instance.instance_profile.package_cleanup #=> Boolean
# resp.device_instance.instance_profile.exclude_app_packages_from_cleanup #=> Array
# resp.device_instance.instance_profile.exclude_app_packages_from_cleanup[0] #=> String
# resp.device_instance.instance_profile.reboot_after_use #=> Boolean
# resp.device_instance.instance_profile.name #=> String
# resp.device_instance.instance_profile.description #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/UpdateDeviceInstance AWS API Documentation
#
# @overload update_device_instance(params = {})
# @param [Hash] params ({})
def update_device_instance(params = {}, options = {})
req = build_request(:update_device_instance, params)
req.send_request(options)
end
# Modifies the name, description, and rules in a device pool given the
# attributes and the pool ARN. Rule updates are all-or-nothing, meaning
# they can only be updated as a whole (or not at all).
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) of the Device Farm device pool you wish
# to update.
#
# @option params [String] :name
# A string representing the name of the device pool you wish to update.
#
# @option params [String] :description
# A description of the device pool you wish to update.
#
# @option params [Array<Types::Rule>] :rules
# Represents the rules you wish to modify for the device pool. Updating
# rules is optional; however, if you choose to update rules for your
# request, the update will replace the existing rules.
#
# @option params [Integer] :max_devices
# The number of devices that Device Farm can add to your device pool.
# Device Farm adds devices that are available and that meet the criteria
# that you assign for the `rules` parameter. Depending on how many
# devices meet these constraints, your device pool might contain fewer
# devices than the value for this parameter.
#
# By specifying the maximum number of devices, you can control the costs
# that you incur by running tests.
#
# If you use this parameter in your request, you cannot use the
# `clearMaxDevices` parameter in the same request.
#
# @option params [Boolean] :clear_max_devices
# Sets whether the `maxDevices` parameter applies to your device pool.
# If you set this parameter to `true`, the `maxDevices` parameter does
# not apply, and Device Farm does not limit the number of devices that
# it adds to your device pool. In this case, Device Farm adds all
# available devices that meet the criteria that are specified for the
# `rules` parameter.
#
# If you use this parameter in your request, you cannot use the
# `maxDevices` parameter in the same request.
#
# @return [Types::UpdateDevicePoolResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::UpdateDevicePoolResult#device_pool #device_pool} => Types::DevicePool
#
#
# @example Example: To update a device pool
#
# # The following example updates the specified device pool with a new name and description. It also enables remote access
# # of devices in the device pool.
#
# resp = client.update_device_pool({
# name: "NewName",
# arn: "arn:aws:devicefarm:us-west-2::devicepool:082d10e5-d7d7-48a5-ba5c-12345EXAMPLE", # You can get the Amazon Resource Name (ARN) of the device pool by using the list-pools CLI command.
# description: "NewDescription",
# rules: [
# {
# value: "True",
# attribute: "REMOTE_ACCESS_ENABLED",
# operator: "EQUALS",
# },
# ],
# })
#
# resp.to_h outputs the following:
# {
# device_pool: {
# }, # Note: you cannot update curated device pools.
# }
#
# @example Request syntax with placeholder values
#
# resp = client.update_device_pool({
# arn: "AmazonResourceName", # required
# name: "Name",
# description: "Message",
# rules: [
# {
# attribute: "ARN", # accepts ARN, PLATFORM, FORM_FACTOR, MANUFACTURER, REMOTE_ACCESS_ENABLED, REMOTE_DEBUG_ENABLED, APPIUM_VERSION, INSTANCE_ARN, INSTANCE_LABELS, FLEET_TYPE, OS_VERSION, MODEL, AVAILABILITY
# operator: "EQUALS", # accepts EQUALS, LESS_THAN, LESS_THAN_OR_EQUALS, GREATER_THAN, GREATER_THAN_OR_EQUALS, IN, NOT_IN, CONTAINS
# value: "String",
# },
# ],
# max_devices: 1,
# clear_max_devices: false,
# })
#
# @example Response structure
#
# resp.device_pool.arn #=> String
# resp.device_pool.name #=> String
# resp.device_pool.description #=> String
# resp.device_pool.type #=> String, one of "CURATED", "PRIVATE"
# resp.device_pool.rules #=> Array
# resp.device_pool.rules[0].attribute #=> String, one of "ARN", "PLATFORM", "FORM_FACTOR", "MANUFACTURER", "REMOTE_ACCESS_ENABLED", "REMOTE_DEBUG_ENABLED", "APPIUM_VERSION", "INSTANCE_ARN", "INSTANCE_LABELS", "FLEET_TYPE", "OS_VERSION", "MODEL", "AVAILABILITY"
# resp.device_pool.rules[0].operator #=> String, one of "EQUALS", "LESS_THAN", "LESS_THAN_OR_EQUALS", "GREATER_THAN", "GREATER_THAN_OR_EQUALS", "IN", "NOT_IN", "CONTAINS"
# resp.device_pool.rules[0].value #=> String
# resp.device_pool.max_devices #=> Integer
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/UpdateDevicePool AWS API Documentation
#
# @overload update_device_pool(params = {})
# @param [Hash] params ({})
def update_device_pool(params = {}, options = {})
req = build_request(:update_device_pool, params)
req.send_request(options)
end
# Updates information about an existing private device instance profile.
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) of the instance profile.
#
# @option params [String] :name
# The updated name for your instance profile.
#
# @option params [String] :description
# The updated description for your instance profile.
#
# @option params [Boolean] :package_cleanup
# The updated choice for whether you want to specify package cleanup.
# The default value is `false` for private devices.
#
# @option params [Array<String>] :exclude_app_packages_from_cleanup
# An array of strings specifying the list of app packages that should
# not be cleaned up from the device after a test run is over.
#
# The list of packages is only considered if you set `packageCleanup` to
# `true`.
#
# @option params [Boolean] :reboot_after_use
# The updated choice for whether you want to reboot the device after
# use. The default value is `true`.
#
# @return [Types::UpdateInstanceProfileResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::UpdateInstanceProfileResult#instance_profile #instance_profile} => Types::InstanceProfile
#
# @example Request syntax with placeholder values
#
# resp = client.update_instance_profile({
# arn: "AmazonResourceName", # required
# name: "Name",
# description: "Message",
# package_cleanup: false,
# exclude_app_packages_from_cleanup: ["String"],
# reboot_after_use: false,
# })
#
# @example Response structure
#
# resp.instance_profile.arn #=> String
# resp.instance_profile.package_cleanup #=> Boolean
# resp.instance_profile.exclude_app_packages_from_cleanup #=> Array
# resp.instance_profile.exclude_app_packages_from_cleanup[0] #=> String
# resp.instance_profile.reboot_after_use #=> Boolean
# resp.instance_profile.name #=> String
# resp.instance_profile.description #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/UpdateInstanceProfile AWS API Documentation
#
# @overload update_instance_profile(params = {})
# @param [Hash] params ({})
def update_instance_profile(params = {}, options = {})
req = build_request(:update_instance_profile, params)
req.send_request(options)
end
# Updates the network profile with specific settings.
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) of the project for which you want to
# update network profile settings.
#
# @option params [String] :name
# The name of the network profile about which you are returning
# information.
#
# @option params [String] :description
# The description of the network profile about which you are returning
# information.
#
# @option params [String] :type
# The type of network profile you wish to return information about.
# Valid values are listed below.
#
# @option params [Integer] :uplink_bandwidth_bits
# The data throughput rate in bits per second, as an integer from 0 to
# 104857600.
#
# @option params [Integer] :downlink_bandwidth_bits
# The data throughput rate in bits per second, as an integer from 0 to
# 104857600.
#
# @option params [Integer] :uplink_delay_ms
# Delay time for all packets to destination in milliseconds as an
# integer from 0 to 2000.
#
# @option params [Integer] :downlink_delay_ms
# Delay time for all packets to destination in milliseconds as an
# integer from 0 to 2000.
#
# @option params [Integer] :uplink_jitter_ms
# Time variation in the delay of received packets in milliseconds as an
# integer from 0 to 2000.
#
# @option params [Integer] :downlink_jitter_ms
# Time variation in the delay of received packets in milliseconds as an
# integer from 0 to 2000.
#
# @option params [Integer] :uplink_loss_percent
# Proportion of transmitted packets that fail to arrive from 0 to 100
# percent.
#
# @option params [Integer] :downlink_loss_percent
# Proportion of received packets that fail to arrive from 0 to 100
# percent.
#
# @return [Types::UpdateNetworkProfileResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::UpdateNetworkProfileResult#network_profile #network_profile} => Types::NetworkProfile
#
# @example Request syntax with placeholder values
#
# resp = client.update_network_profile({
# arn: "AmazonResourceName", # required
# name: "Name",
# description: "Message",
# type: "CURATED", # accepts CURATED, PRIVATE
# uplink_bandwidth_bits: 1,
# downlink_bandwidth_bits: 1,
# uplink_delay_ms: 1,
# downlink_delay_ms: 1,
# uplink_jitter_ms: 1,
# downlink_jitter_ms: 1,
# uplink_loss_percent: 1,
# downlink_loss_percent: 1,
# })
#
# @example Response structure
#
# resp.network_profile.arn #=> String
# resp.network_profile.name #=> String
# resp.network_profile.description #=> String
# resp.network_profile.type #=> String, one of "CURATED", "PRIVATE"
# resp.network_profile.uplink_bandwidth_bits #=> Integer
# resp.network_profile.downlink_bandwidth_bits #=> Integer
# resp.network_profile.uplink_delay_ms #=> Integer
# resp.network_profile.downlink_delay_ms #=> Integer
# resp.network_profile.uplink_jitter_ms #=> Integer
# resp.network_profile.downlink_jitter_ms #=> Integer
# resp.network_profile.uplink_loss_percent #=> Integer
# resp.network_profile.downlink_loss_percent #=> Integer
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/UpdateNetworkProfile AWS API Documentation
#
# @overload update_network_profile(params = {})
# @param [Hash] params ({})
def update_network_profile(params = {}, options = {})
req = build_request(:update_network_profile, params)
req.send_request(options)
end
# Modifies the specified project name, given the project ARN and a new
# name.
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) of the project whose name you wish to
# update.
#
# @option params [String] :name
# A string representing the new name of the project that you are
# updating.
#
# @option params [Integer] :default_job_timeout_minutes
# The number of minutes a test run in the project will execute before it
# times out.
#
# @return [Types::UpdateProjectResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::UpdateProjectResult#project #project} => Types::Project
#
#
# @example Example: To update a device pool
#
# # The following example updates the specified project with a new name.
#
# resp = client.update_project({
# name: "NewName",
# arn: "arn:aws:devicefarm:us-west-2:123456789101:project:8f75187d-101e-4625-accc-12345EXAMPLE", # You can get the Amazon Resource Name (ARN) of the project by using the list-projects CLI command.
# })
#
# resp.to_h outputs the following:
# {
# project: {
# name: "NewName",
# arn: "arn:aws:devicefarm:us-west-2:123456789101:project:8f75187d-101e-4625-accc-12345EXAMPLE",
# created: Time.parse("1448400709.927"),
# },
# }
#
# @example Request syntax with placeholder values
#
# resp = client.update_project({
# arn: "AmazonResourceName", # required
# name: "Name",
# default_job_timeout_minutes: 1,
# })
#
# @example Response structure
#
# resp.project.arn #=> String
# resp.project.name #=> String
# resp.project.default_job_timeout_minutes #=> Integer
# resp.project.created #=> Time
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/UpdateProject AWS API Documentation
#
# @overload update_project(params = {})
# @param [Hash] params ({})
def update_project(params = {}, options = {})
req = build_request(:update_project, params)
req.send_request(options)
end
# Update an uploaded test specification (test spec).
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) of the uploaded test spec.
#
# @option params [String] :name
# The upload's test spec file name. The name should not contain the
# '/' character. The test spec file name must end with the `.yaml` or
# `.yml` file extension.
#
# @option params [String] :content_type
# The upload's content type (for example, "application/x-yaml").
#
# @option params [Boolean] :edit_content
# Set to true if the YAML file has changed and needs to be updated;
# otherwise, set to false.
#
# @return [Types::UpdateUploadResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::UpdateUploadResult#upload #upload} => Types::Upload
#
# @example Request syntax with placeholder values
#
# resp = client.update_upload({
# arn: "AmazonResourceName", # required
# name: "Name",
# content_type: "ContentType",
# edit_content: false,
# })
#
# @example Response structure
#
# resp.upload.arn #=> String
# resp.upload.name #=> String
# resp.upload.created #=> Time
# resp.upload.type #=> String, one of "ANDROID_APP", "IOS_APP", "WEB_APP", "EXTERNAL_DATA", "APPIUM_JAVA_JUNIT_TEST_PACKAGE", "APPIUM_JAVA_TESTNG_TEST_PACKAGE", "APPIUM_PYTHON_TEST_PACKAGE", "APPIUM_NODE_TEST_PACKAGE", "APPIUM_RUBY_TEST_PACKAGE", "APPIUM_WEB_JAVA_JUNIT_TEST_PACKAGE", "APPIUM_WEB_JAVA_TESTNG_TEST_PACKAGE", "APPIUM_WEB_PYTHON_TEST_PACKAGE", "APPIUM_WEB_NODE_TEST_PACKAGE", "APPIUM_WEB_RUBY_TEST_PACKAGE", "CALABASH_TEST_PACKAGE", "INSTRUMENTATION_TEST_PACKAGE", "UIAUTOMATION_TEST_PACKAGE", "UIAUTOMATOR_TEST_PACKAGE", "XCTEST_TEST_PACKAGE", "XCTEST_UI_TEST_PACKAGE", "APPIUM_JAVA_JUNIT_TEST_SPEC", "APPIUM_JAVA_TESTNG_TEST_SPEC", "APPIUM_PYTHON_TEST_SPEC", "APPIUM_NODE_TEST_SPEC", "APPIUM_RUBY_TEST_SPEC", "APPIUM_WEB_JAVA_JUNIT_TEST_SPEC", "APPIUM_WEB_JAVA_TESTNG_TEST_SPEC", "APPIUM_WEB_PYTHON_TEST_SPEC", "APPIUM_WEB_NODE_TEST_SPEC", "APPIUM_WEB_RUBY_TEST_SPEC", "INSTRUMENTATION_TEST_SPEC", "XCTEST_UI_TEST_SPEC"
# resp.upload.status #=> String, one of "INITIALIZED", "PROCESSING", "SUCCEEDED", "FAILED"
# resp.upload.url #=> String
# resp.upload.metadata #=> String
# resp.upload.content_type #=> String
# resp.upload.message #=> String
# resp.upload.category #=> String, one of "CURATED", "PRIVATE"
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/UpdateUpload AWS API Documentation
#
# @overload update_upload(params = {})
# @param [Hash] params ({})
def update_upload(params = {}, options = {})
req = build_request(:update_upload, params)
req.send_request(options)
end
# Updates information about an existing Amazon Virtual Private Cloud
# (VPC) endpoint configuration.
#
# @option params [required, String] :arn
# The Amazon Resource Name (ARN) of the VPC endpoint configuration you
# want to update.
#
# @option params [String] :vpce_configuration_name
# The friendly name you give to your VPC endpoint configuration, to
# manage your configurations more easily.
#
# @option params [String] :vpce_service_name
# The name of the VPC endpoint service running inside your AWS account
# that you want Device Farm to test.
#
# @option params [String] :service_dns_name
# The DNS (domain) name used to connect to your private service in your
# Amazon VPC. The DNS name must not already be in use on the Internet.
#
# @option params [String] :vpce_configuration_description
# An optional description, providing more details about your VPC
# endpoint configuration.
#
# @return [Types::UpdateVPCEConfigurationResult] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
#
# * {Types::UpdateVPCEConfigurationResult#vpce_configuration #vpce_configuration} => Types::VPCEConfiguration
#
# @example Request syntax with placeholder values
#
# resp = client.update_vpce_configuration({
# arn: "AmazonResourceName", # required
# vpce_configuration_name: "VPCEConfigurationName",
# vpce_service_name: "VPCEServiceName",
# service_dns_name: "ServiceDnsName",
# vpce_configuration_description: "VPCEConfigurationDescription",
# })
#
# @example Response structure
#
# resp.vpce_configuration.arn #=> String
# resp.vpce_configuration.vpce_configuration_name #=> String
# resp.vpce_configuration.vpce_service_name #=> String
# resp.vpce_configuration.service_dns_name #=> String
# resp.vpce_configuration.vpce_configuration_description #=> String
#
# @see http://docs.aws.amazon.com/goto/WebAPI/devicefarm-2015-06-23/UpdateVPCEConfiguration AWS API Documentation
#
# @overload update_vpce_configuration(params = {})
# @param [Hash] params ({})
def update_vpce_configuration(params = {}, options = {})
req = build_request(:update_vpce_configuration, params)
req.send_request(options)
end
# @!endgroup
# @param params ({})
# @api private
def build_request(operation_name, params = {})
handlers = @handlers.for(operation_name)
context = Seahorse::Client::RequestContext.new(
operation_name: operation_name,
operation: config.api.operation(operation_name),
client: self,
params: params,
config: config)
context[:gem_name] = 'aws-sdk-devicefarm'
context[:gem_version] = '1.29.0'
Seahorse::Client::Request.new(handlers, context)
end
# @api private
# @deprecated
def waiter_names
[]
end
class << self
# @api private
attr_reader :identifier
# @api private
def errors_module
Errors
end
end
end
end
| 47.641217 | 945 | 0.659666 |
1af5ee54981437099d0a353be25a382d9feb3607 | 280 | class Store < ActiveRecord::Base
has_and_belongs_to_many(:brands)
validates :name, length: {minimum: 2,
too_long: "Thats too short for a store name."}
before_save(:format_input)
private
define_method(:format_input) do
self.name = self.name.capitalize()
end
end
| 23.333333 | 50 | 0.732143 |
38523bc96230c1bf1e9b06f0f6f2464b6b3bde14 | 559 | # frozen_string_literal: true
module DashboardHelper
def encoded_social_quote(my_neutral_months)
quote = I18n.t('i_have_lived_climate_neutral_for_join_me', count: my_neutral_months)
CGI.escape("#{quote} -> #{root_url}")
end
def encoded_social_quote_without_subscription_months
CGI.escape("#{t('share_quote_without_months')} #{root_url}")
end
def handle_encoded_social_quote(show_months, number_of_months)
return encoded_social_quote(number_of_months) if show_months
encoded_social_quote_without_subscription_months
end
end
| 29.421053 | 88 | 0.799642 |
bf814a0f5e99bb92e569f324f8a98a51c570baa8 | 9,387 | require 'spec_helper'
module Bosh::Director
describe DeploymentPlan::NetworkPlanner::VipPlanner do
include IpUtil
subject(:planner) { DeploymentPlan::NetworkPlanner::VipPlanner.new(network_planner, logger) }
let(:network_planner) { DeploymentPlan::NetworkPlanner::Planner.new(logger) }
let(:deployment_model) { Models::Deployment.make(name: 'my-deployment') }
let(:variables_interpolator) { double(Bosh::Director::ConfigServer::VariablesInterpolator) }
let(:instance_plans) do
[instance_plan]
end
let(:instance_plan) do
make_instance_plan
end
let(:instance_group) do
instance_group = DeploymentPlan::InstanceGroup.new(logger)
instance_group.name = 'fake-job'
instance_group
end
def make_instance_plan
instance_model = Models::Instance.make
instance = DeploymentPlan::Instance.create_from_instance_group(
instance_group,
instance_model.index,
'started',
deployment_model,
{},
nil,
logger,
variables_interpolator,
)
instance.bind_existing_instance_model(instance_model)
DeploymentPlan::InstancePlan.new(
existing_instance: instance_model,
desired_instance: DeploymentPlan::DesiredInstance.new,
instance: instance,
network_plans: [],
variables_interpolator: variables_interpolator,
)
end
context 'when there are vip networks' do
let(:vip_networks) { [vip_network1, vip_network2] }
let(:vip_network1) do
DeploymentPlan::JobNetwork.new(
'fake-network-1',
instance_group_static_ips1,
[],
vip_deployment_network1,
)
end
let(:vip_network2) do
DeploymentPlan::JobNetwork.new(
'fake-network-2',
instance_group_static_ips2,
[],
vip_deployment_network2,
)
end
let(:vip_deployment_network1) do
DeploymentPlan::VipNetwork.parse(vip_network_spec1, [], logger)
end
let(:vip_deployment_network2) do
DeploymentPlan::VipNetwork.parse(vip_network_spec2, [], logger)
end
context 'and there are static ips defined only on the job network' do
let(:instance_group_static_ips1) { [ip_to_i('68.68.68.68'), ip_to_i('69.69.69.69')] }
let(:instance_group_static_ips2) { [ip_to_i('77.77.77.77'), ip_to_i('79.79.79.79')] }
let(:vip_network_spec1) { { 'name' => 'vip-network-1' } }
let(:vip_network_spec2) { { 'name' => 'vip-network-2' } }
it 'creates network plans with static IP from each vip network' do
planner.add_vip_network_plans(instance_plans, vip_networks)
expect(instance_plan.network_plans[0].reservation.ip).to eq(ip_to_i('68.68.68.68'))
expect(instance_plan.network_plans[0].reservation.network).to eq(vip_deployment_network1)
expect(instance_plan.network_plans[1].reservation.ip).to eq(ip_to_i('77.77.77.77'))
expect(instance_plan.network_plans[1].reservation.network).to eq(vip_deployment_network2)
end
context 'when instance already has vip networks' do
context 'when existing instance IPs can be reused' do
before do
Models::IpAddress.make(
address_str: ip_to_i('69.69.69.69').to_s,
network_name: 'fake-network-1',
instance: instance_plan.existing_instance,
)
Models::IpAddress.make(
address_str: ip_to_i('79.79.79.79').to_s,
network_name: 'fake-network-2',
instance: instance_plan.existing_instance,
)
end
it 'assigns vip static IP that instance is currently using' do
planner.add_vip_network_plans(instance_plans, vip_networks)
expect(instance_plan.network_plans[0].reservation.ip).to eq(ip_to_i('69.69.69.69'))
expect(instance_plan.network_plans[0].reservation.network).to eq(vip_deployment_network1)
expect(instance_plan.network_plans[1].reservation.ip).to eq(ip_to_i('79.79.79.79'))
expect(instance_plan.network_plans[1].reservation.network).to eq(vip_deployment_network2)
end
end
context 'when existing instance static IP is no longer in the list of IPs' do
before do
Models::IpAddress.make(
address_str: ip_to_i('65.65.65.65').to_s,
network_name: 'fake-network-1',
instance: instance_plan.existing_instance,
)
Models::IpAddress.make(
address_str: ip_to_i('79.79.79.79').to_s,
network_name: 'fake-network-2',
instance: instance_plan.existing_instance,
)
end
it 'picks new IP for instance' do
planner.add_vip_network_plans(instance_plans, vip_networks)
instance_plan = instance_plans.first
expect(instance_plan.network_plans[0].reservation.ip).to eq(ip_to_i('68.68.68.68'))
expect(instance_plan.network_plans[0].reservation.network).to eq(vip_deployment_network1)
expect(instance_plan.network_plans[1].reservation.ip).to eq(ip_to_i('79.79.79.79'))
expect(instance_plan.network_plans[1].reservation.network).to eq(vip_deployment_network2)
end
end
context 'with several instances' do
let(:instance_plans) do
[make_instance_plan, make_instance_plan]
end
before do
Models::IpAddress.make(
address_str: ip_to_i('68.68.68.68').to_s,
network_name: 'fake-network-1',
instance: instance_plans[1].existing_instance,
)
Models::IpAddress.make(
address_str: ip_to_i('77.77.77.77').to_s,
network_name: 'fake-network-2',
instance: instance_plans[1].existing_instance,
)
end
it 'properly assigns vip IPs based on current instance IPs' do
planner.add_vip_network_plans(instance_plans, vip_networks)
first_instance_plan = instance_plans[0]
expect(first_instance_plan.network_plans[0].reservation.ip).to eq(ip_to_i('69.69.69.69'))
expect(first_instance_plan.network_plans[0].reservation.network).to eq(vip_deployment_network1)
expect(first_instance_plan.network_plans[1].reservation.ip).to eq(ip_to_i('79.79.79.79'))
expect(first_instance_plan.network_plans[1].reservation.network).to eq(vip_deployment_network2)
second_instance_plan = instance_plans[1]
expect(second_instance_plan.network_plans[0].reservation.ip).to eq(ip_to_i('68.68.68.68'))
expect(second_instance_plan.network_plans[0].reservation.network).to eq(vip_deployment_network1)
expect(second_instance_plan.network_plans[1].reservation.ip).to eq(ip_to_i('77.77.77.77'))
expect(second_instance_plan.network_plans[1].reservation.network).to eq(vip_deployment_network2)
end
end
end
end
context 'and there are static ips defined only on network in the cloud config' do
let(:instance_group_static_ips1) { [] }
let(:instance_group_static_ips2) { [] }
let(:vip_network_spec1) do
{
'name' => 'vip-network-1',
'subnets' => [{ 'static' => ['68.68.68.68', '69.69.69.69'] }],
}
end
let(:vip_network_spec2) do
{
'name' => 'vip-network-2',
'subnets' => [{ 'static' => ['77.77.77.77', '79.79.79.79'] }],
}
end
it 'creates a dynamic reservation' do
planner.add_vip_network_plans(instance_plans, vip_networks)
expect(instance_plan.network_plans[0].reservation.network).to eq(vip_deployment_network1)
expect(instance_plan.network_plans[0].reservation.type).to eq(:dynamic)
expect(instance_plan.network_plans[1].reservation.network).to eq(vip_deployment_network2)
expect(instance_plan.network_plans[1].reservation.type).to eq(:dynamic)
end
end
context 'and there are static ips defined on the job network and in the network in the cloud config' do
let(:instance_group_static_ips1) { [ip_to_i('68.68.68.68'), ip_to_i('69.69.69.69')] }
let(:instance_group_static_ips2) { [] }
let(:vip_network_spec1) { { 'name' => 'vip-network-1', 'subnets' => [{ 'static' => ['1.1.1.1'] }] } }
let(:vip_network_spec2) { { 'name' => 'vip-network-2' } }
it 'raises an error' do
expect do
planner.add_vip_network_plans(instance_plans, vip_networks)
end.to raise_error(
NetworkReservationVipMisconfigured,
'IPs cannot be specified in both the instance group and the cloud config',
)
end
end
end
context 'when there are no vip networks' do
let(:vip_networks) { [] }
it 'does not modify instance plans' do
planner.add_vip_network_plans(instance_plans, vip_networks)
expect(instance_plans).to eq(instance_plans)
end
end
end
end
| 39.441176 | 110 | 0.626292 |
5d89d46d32eea05679c012bd352f8aea82fb2590 | 4,938 | namespace :spree_roles do
namespace :permissions do
desc "Create admin username and password"
task :populate => :environment do
admin = Spree::Role.where(name: 'admin').first_or_create!
user = Spree::Role.where(name: 'user').first_or_create!
user.is_default = true
user.save!
permission1 = Spree::Permission.where(title: 'can-manage-all', priority: 0).first_or_create!
permission2 = Spree::Permission.where(title: 'default-permissions', priority: 1).first_or_create!
user.permissions = [permission2]
admin.permissions = [permission1]
end
task :populate_other_roles => :environment do
manager = Spree::Role.where(name: 'manager').first_or_create!
customer_service = Spree::Role.where(name: 'customer service').first_or_create!
warehouse = Spree::Role.where(name: 'warehouse').first_or_create!
permission2 = Spree::Permission.where(title: 'default-permissions', priority: 1).first_or_create!
permission3 = Spree::Permission.where(title: 'can-manage-spree/products', priority: 2).first_or_create!
permission4 = Spree::Permission.where(title: 'can-manage-spree/orders', priority: 2).first_or_create!
permission5 = Spree::Permission.where(title: 'can-manage-spree/users', priority: 2).first_or_create!
permission6 = Spree::Permission.where(title: 'can-manage-spree/stock_locations', priority: 2).first_or_create!
permission7 = Spree::Permission.where(title: 'can-read-spree/products', priority: 3).first_or_create!
permission8 = Spree::Permission.where(title: 'can-index-spree/products', priority: 3).first_or_create!
permission9 = Spree::Permission.where(title: 'can-update-spree/products', priority: 3).first_or_create!
permission10 = Spree::Permission.where(title: 'can-create-spree/products', priority: 3).first_or_create!
permission11 = Spree::Permission.where(title: 'can-read-spree/users', priority: 3).first_or_create!
permission12 = Spree::Permission.where(title: 'can-index-spree/users', priority: 3).first_or_create!
permission13 = Spree::Permission.where(title: 'can-update-spree/users', priority: 3).first_or_create!
permission14 = Spree::Permission.where(title: 'can-create-spree/users', priority: 3).first_or_create!
permission15 = Spree::Permission.where(title: 'can-read-spree/orders', priority: 3).first_or_create!
permission16 = Spree::Permission.where(title: 'can-index-spree/orders', priority: 3).first_or_create!
permission17 = Spree::Permission.where(title: 'can-update-spree/orders', priority: 3).first_or_create!
permission18 = Spree::Permission.where(title: 'can-create-spree/orders', priority: 3).first_or_create!
permission19 = Spree::Permission.where(title: 'can-read-spree/stock_locations', priority: 3).first_or_create!
permission20 = Spree::Permission.where(title: 'can-index-spree/stock_locations', priority: 3).first_or_create!
permission21 = Spree::Permission.where(title: 'can-update-spree/stock_locations', priority: 3).first_or_create!
permission22 = Spree::Permission.where(title: 'can-create-spree/stock_locations', priority: 3).first_or_create!
permission23 = Spree::Permission.where(title: 'can-manage-spree/taxons', priority: 2).first_or_create!
permission24 = Spree::Permission.where(title: 'can-manage-spree/option_types', priority: 2).first_or_create!
permission25 = Spree::Permission.where(title: 'can-manage-spree/taxonomies', priority: 2).first_or_create!
permission26 = Spree::Permission.where(title: 'can-manage-spree/images', priority: 2).first_or_create!
permission27 = Spree::Permission.where(title: 'can-manage-spree/product_properties', priority: 2).first_or_create!
permission28 = Spree::Permission.where(title: 'can-manage-spree/stocks', priority: 2).first_or_create!
manager.permissions = [ permission2,
permission3,
permission4,
permission24,
permission25,
permission26,
permission27,
permission28,
permission6
]
customer_service.permissions = [ permission2,
permission15,
permission16,
permission17
]
warehouse.permissions = [ permission2,
permission4,
permission6,
permission15,
permission16,
permission17,
permission28
]
end
end
end | 62.506329 | 120 | 0.640138 |
acc348c7598f34efc7929c0fadfc3213f5cc3d3f | 465 | # frozen_string_literal: true
module GlobalConstant
class Google
class << self
def usage_report_spreadsheet_id
config[:usage_report_spreadsheet_id]
end
def private_key
config[:private_key]
end
def client_email
config[:client_email]
end
def project_id
config[:project_id]
end
private
def config
GlobalConstant::Base.google
end
end
end
end
| 14.090909 | 44 | 0.612903 |
7afc924420b5eb1315e071a36fbd375a25937e66 | 490 | class PassthroughController < ApplicationController
after_action :skip_authorization
def index
if first_permitted_format
redirect_to documents_path(document_type_slug: first_permitted_format.slug)
else
redirect_to error_path
end
end
def error; end
private
def first_permitted_format
@first_permitted_format ||= document_models.sort_by(&:name).find do |document_class|
DocumentPolicy.new(current_user, document_class).index?
end
end
end
| 22.272727 | 88 | 0.769388 |
bbb495e4b6ba000e9afc63e48fb8b5cbdfee775a | 2,810 | # -*- coding: utf-8 -*-
require 'gtk2'
module Plugin::ListForProfile
class ProfileTab < ::Gtk::ListList
include Gtk::TreeViewPrettyScroll
MEMBER = 0
NAME = 1
LIST = 2
SERVICE = 3
def initialize(plugin, dest)
type_strict plugin => Plugin, dest => User
@plugin = plugin
@dest_user = dest
@locked = {}
super()
self.creatable = self.updatable = self.deletable = false
set_auto_getter(@plugin, true) do |service, list, iter|
iter[MEMBER] = list.member?(@dest_user)
iter[NAME] = "@#{list[:user].idname}/#{list[:name]}"
iter[LIST] = list
iter[SERVICE] = service end
toggled = get_column(0).cell_renderers[0]
toggled.activatable = false
Service.primary.list_user_followers(user_id: @dest_user[:id], filter_to_owned_lists: 1).next{ |res|
if res and not destroyed?
followed_list_ids = res.map{|list| list['id'].to_i}
model.each{ |m, path, iter|
if followed_list_ids.include? iter[LIST][:id]
iter[MEMBER] = true
iter[LIST].add_member(@dest_user) end }
toggled.activatable = true
queue_draw end
}.terminate(@plugin._("@%{user} が入っているリストが取得できませんでした。雰囲気で適当に表示しておきますね") % {user: @dest_user[:idname]}).trap{ |e|
if not destroyed?
toggled.activatable = true
queue_draw end } end
def on_updated(iter)
if iter[LIST].member?(@dest_user) != iter[MEMBER]
if not @locked[iter[LIST].id]
@locked[iter[LIST].id] = true
flag, list, service = iter[MEMBER], iter[LIST], iter[SERVICE]
service.__send__(flag ? :add_list_member : :delete_list_member,
:list_id => list.id,
:user_id => @dest_user[:id]).next{ |result|
@locked[list.id] = false
if flag
list.add_member(@dest_user)
Plugin.call(:list_member_added, service, @dest_user, list, service.user_obj)
else
list.remove_member(@dest_user)
Plugin.call(:list_member_removed, service, @dest_user, list, service.user_obj) end
}.terminate{ |e|
iter[MEMBER] = !flag if not destroyed?
@locked[iter[LIST].id] = false
@plugin._("@%{user} をリスト %{list_name} に追加できませんでした") % {
user: @dest_user[:idname],
list_name: list[:full_name] } } end end end
def column_schemer
[{:kind => :active, :widget => :boolean, :type => TrueClass, :label => @plugin._('リスト行き')},
{:kind => :text, :type => String, :label => @plugin._('リスト名')},
{:type => UserList},
{:type => Service}
].freeze
end
# 右クリックメニューを禁止する
def menu_pop(widget, event)
end
end
end
| 36.493506 | 118 | 0.574377 |
397885806c4bd69309fa7126ba53d50c381f84e6 | 76,368 | # coding: utf-8
require 'rdoc/test_case'
class TestRDocParserRuby < RDoc::TestCase
def setup
super
@tempfile = Tempfile.new self.class.name
@filename = @tempfile.path
# Some tests need two paths.
@tempfile2 = Tempfile.new self.class.name
@filename2 = @tempfile2.path
@top_level = @store.add_file @filename
@top_level2 = @store.add_file @filename2
@options = RDoc::Options.new
@options.quiet = true
@options.option_parser = OptionParser.new
@comment = RDoc::Comment.new '', @top_level
@stats = RDoc::Stats.new @store, 0
end
def teardown
super
@tempfile.close
@tempfile2.close
end
def test_collect_first_comment
p = util_parser <<-CONTENT
# first
# second
class C; end
CONTENT
comment = p.collect_first_comment
assert_equal RDoc::Comment.new("# first\n", @top_level), comment
end
def test_collect_first_comment_encoding
skip "Encoding not implemented" unless Object.const_defined? :Encoding
@options.encoding = Encoding::CP852
p = util_parser <<-CONTENT
# first
# second
class C; end
CONTENT
comment = p.collect_first_comment
assert_equal Encoding::CP852, comment.text.encoding
end
def test_get_class_or_module
ctxt = RDoc::Context.new
ctxt.store = @store
cont, name_t, given_name = util_parser('A') .get_class_or_module ctxt
assert_equal ctxt, cont
assert_equal 'A', name_t.text
assert_equal 'A', given_name
cont, name_t, given_name = util_parser('B::C') .get_class_or_module ctxt
b = @store.find_module_named('B')
assert_equal b, cont
assert_equal [@top_level], b.in_files
assert_equal 'C', name_t.text
assert_equal 'B::C', given_name
cont, name_t, given_name = util_parser('D:: E').get_class_or_module ctxt
assert_equal @store.find_module_named('D'), cont
assert_equal 'E', name_t.text
assert_equal 'D::E', given_name
assert_raises NoMethodError do
util_parser("A::\nB").get_class_or_module ctxt
end
end
def test_get_class_or_module_document_children
ctxt = @top_level.add_class RDoc::NormalClass, 'A'
ctxt.stop_doc
util_parser('B::C').get_class_or_module ctxt
b = @store.find_module_named('A::B')
assert b.ignored?
d = @top_level.add_class RDoc::NormalClass, 'A::D'
util_parser('D::E').get_class_or_module ctxt
refute d.ignored?
end
def test_get_class_or_module_ignore_constants
ctxt = RDoc::Context.new
ctxt.store = @store
util_parser('A') .get_class_or_module ctxt, true
util_parser('A::B').get_class_or_module ctxt, true
assert_empty ctxt.constants
assert_empty @store.modules_hash.keys
assert_empty @store.classes_hash.keys
end
def test_get_class_specification
assert_equal 'A', util_parser('A') .get_class_specification
assert_equal 'A::B', util_parser('A::B').get_class_specification
assert_equal '::A', util_parser('::A').get_class_specification
assert_equal 'self', util_parser('self').get_class_specification
assert_equal '', util_parser('').get_class_specification
assert_equal '', util_parser('$g').get_class_specification
end
def test_get_symbol_or_name
util_parser "* & | + 5 / 4"
assert_equal '*', @parser.get_symbol_or_name
@parser.skip_tkspace
assert_equal '&', @parser.get_symbol_or_name
@parser.skip_tkspace
assert_equal '|', @parser.get_symbol_or_name
@parser.skip_tkspace
assert_equal '+', @parser.get_symbol_or_name
@parser.skip_tkspace
@parser.get_tk
@parser.skip_tkspace
assert_equal '/', @parser.get_symbol_or_name
end
def test_suppress_parents
a = @top_level.add_class RDoc::NormalClass, 'A'
b = a.add_class RDoc::NormalClass, 'B'
c = b.add_class RDoc::NormalClass, 'C'
util_parser ''
@parser.suppress_parents c, a
assert c.suppressed?
assert b.suppressed?
refute a.suppressed?
end
def test_suppress_parents_documented
a = @top_level.add_class RDoc::NormalClass, 'A'
b = a.add_class RDoc::NormalClass, 'B'
b.add_comment RDoc::Comment.new("hello"), @top_level
c = b.add_class RDoc::NormalClass, 'C'
util_parser ''
@parser.suppress_parents c, a
assert c.suppressed?
refute b.suppressed?
refute a.suppressed?
end
def test_look_for_directives_in_attr
util_parser ""
comment = RDoc::Comment.new "# :attr: my_attr\n", @top_level
@parser.look_for_directives_in @top_level, comment
assert_equal "# :attr: my_attr\n", comment.text
comment = RDoc::Comment.new "# :attr_reader: my_method\n", @top_level
@parser.look_for_directives_in @top_level, comment
assert_equal "# :attr_reader: my_method\n", comment.text
comment = RDoc::Comment.new "# :attr_writer: my_method\n", @top_level
@parser.look_for_directives_in @top_level, comment
assert_equal "# :attr_writer: my_method\n", comment.text
end
def test_look_for_directives_in_commented
util_parser ""
comment = RDoc::Comment.new <<-COMMENT, @top_level
# how to make a section:
# # :section: new section
COMMENT
@parser.look_for_directives_in @top_level, comment
section = @top_level.current_section
assert_equal nil, section.title
assert_equal nil, section.comment
assert_equal "# how to make a section:\n# # :section: new section\n",
comment.text
end
def test_look_for_directives_in_method
util_parser ""
comment = RDoc::Comment.new "# :method: my_method\n", @top_level
@parser.look_for_directives_in @top_level, comment
assert_equal "# :method: my_method\n", comment.text
comment = RDoc::Comment.new "# :singleton-method: my_method\n", @top_level
@parser.look_for_directives_in @top_level, comment
assert_equal "# :singleton-method: my_method\n", comment.text
end
def test_look_for_directives_in_section
util_parser ""
comment = RDoc::Comment.new <<-COMMENT, @top_level
# :section: new section
# woo stuff
COMMENT
@parser.look_for_directives_in @top_level, comment
section = @top_level.current_section
assert_equal 'new section', section.title
assert_equal [comment("# woo stuff\n", @top_level)], section.comments
assert_empty comment
end
def test_look_for_directives_in_unhandled
util_parser ""
comment = RDoc::Comment.new "# :unhandled: blah\n", @top_level
@parser.look_for_directives_in @top_level, comment
assert_equal 'blah', @top_level.metadata['unhandled']
end
def test_parse_alias
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
util_parser "alias :next= :bar"
tk = @parser.get_tk
alas = @parser.parse_alias klass, RDoc::Parser::Ruby::NORMAL, tk, 'comment'
assert_equal 'bar', alas.old_name
assert_equal 'next=', alas.new_name
assert_equal klass, alas.parent
assert_equal 'comment', alas.comment
assert_equal @top_level, alas.file
assert_equal 0, alas.offset
assert_equal 1, alas.line
end
def test_parse_alias_singleton
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
util_parser "alias :next= :bar"
tk = @parser.get_tk
alas = @parser.parse_alias klass, RDoc::Parser::Ruby::SINGLE, tk, 'comment'
assert_equal 'bar', alas.old_name
assert_equal 'next=', alas.new_name
assert_equal klass, alas.parent
assert_equal 'comment', alas.comment
assert_equal @top_level, alas.file
assert alas.singleton
end
def test_parse_alias_stopdoc
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
klass.stop_doc
util_parser "alias :next= :bar"
tk = @parser.get_tk
@parser.parse_alias klass, RDoc::Parser::Ruby::NORMAL, tk, 'comment'
assert_empty klass.aliases
assert_empty klass.unmatched_alias_lists
end
def test_parse_alias_meta
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
util_parser "alias m.chop m"
tk = @parser.get_tk
alas = @parser.parse_alias klass, RDoc::Parser::Ruby::NORMAL, tk, 'comment'
assert_nil alas
end
def test_parse_attr
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
comment = RDoc::Comment.new "##\n# my attr\n", @top_level
util_parser "attr :foo, :bar"
tk = @parser.get_tk
@parser.parse_attr klass, RDoc::Parser::Ruby::NORMAL, tk, comment
assert_equal 1, klass.attributes.length
foo = klass.attributes.first
assert_equal 'foo', foo.name
assert_equal 'my attr', foo.comment.text
assert_equal @top_level, foo.file
assert_equal 0, foo.offset
assert_equal 1, foo.line
end
def test_parse_attr_stopdoc
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
klass.stop_doc
comment = RDoc::Comment.new "##\n# my attr\n", @top_level
util_parser "attr :foo, :bar"
tk = @parser.get_tk
@parser.parse_attr klass, RDoc::Parser::Ruby::NORMAL, tk, comment
assert_empty klass.attributes
end
def test_parse_attr_accessor
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
comment = RDoc::Comment.new "##\n# my attr\n", @top_level
util_parser "attr_accessor :foo, :bar"
tk = @parser.get_tk
@parser.parse_attr_accessor klass, RDoc::Parser::Ruby::NORMAL, tk, comment
assert_equal 2, klass.attributes.length
foo = klass.attributes.first
assert_equal 'foo', foo.name
assert_equal 'RW', foo.rw
assert_equal 'my attr', foo.comment.text
assert_equal @top_level, foo.file
assert_equal 0, foo.offset
assert_equal 1, foo.line
bar = klass.attributes.last
assert_equal 'bar', bar.name
assert_equal 'RW', bar.rw
assert_equal 'my attr', bar.comment.text
end
def test_parse_attr_accessor_nodoc
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
comment = RDoc::Comment.new "##\n# my attr\n", @top_level
util_parser "attr_accessor :foo, :bar # :nodoc:"
tk = @parser.get_tk
@parser.parse_attr_accessor klass, RDoc::Parser::Ruby::NORMAL, tk, comment
assert_equal 0, klass.attributes.length
end
def test_parse_attr_accessor_nodoc_track
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
comment = RDoc::Comment.new "##\n# my attr\n", @top_level
@options.visibility = :nodoc
util_parser "attr_accessor :foo, :bar # :nodoc:"
tk = @parser.get_tk
@parser.parse_attr_accessor klass, RDoc::Parser::Ruby::NORMAL, tk, comment
refute_empty klass.attributes
end
def test_parse_attr_accessor_stopdoc
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
klass.stop_doc
comment = RDoc::Comment.new "##\n# my attr\n", @top_level
util_parser "attr_accessor :foo, :bar"
tk = @parser.get_tk
@parser.parse_attr_accessor klass, RDoc::Parser::Ruby::NORMAL, tk, comment
assert_empty klass.attributes
end
def test_parse_attr_accessor_writer
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
comment = RDoc::Comment.new "##\n# my attr\n", @top_level
util_parser "attr_writer :foo, :bar"
tk = @parser.get_tk
@parser.parse_attr_accessor klass, RDoc::Parser::Ruby::NORMAL, tk, comment
assert_equal 2, klass.attributes.length
foo = klass.attributes.first
assert_equal 'foo', foo.name
assert_equal 'W', foo.rw
assert_equal "my attr", foo.comment.text
assert_equal @top_level, foo.file
bar = klass.attributes.last
assert_equal 'bar', bar.name
assert_equal 'W', bar.rw
assert_equal "my attr", bar.comment.text
end
def test_parse_meta_attr
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
comment = RDoc::Comment.new "##\n# :attr: \n# my method\n", @top_level
util_parser "add_my_method :foo, :bar"
tk = @parser.get_tk
@parser.parse_meta_attr klass, RDoc::Parser::Ruby::NORMAL, tk, comment
assert_equal 2, klass.attributes.length
foo = klass.attributes.first
assert_equal 'foo', foo.name
assert_equal 'RW', foo.rw
assert_equal "my method", foo.comment.text
assert_equal @top_level, foo.file
end
def test_parse_meta_attr_accessor
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
comment =
RDoc::Comment.new "##\n# :attr_accessor: \n# my method\n", @top_level
util_parser "add_my_method :foo, :bar"
tk = @parser.get_tk
@parser.parse_meta_attr klass, RDoc::Parser::Ruby::NORMAL, tk, comment
assert_equal 2, klass.attributes.length
foo = klass.attributes.first
assert_equal 'foo', foo.name
assert_equal 'RW', foo.rw
assert_equal 'my method', foo.comment.text
assert_equal @top_level, foo.file
end
def test_parse_meta_attr_named
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
comment = RDoc::Comment.new "##\n# :attr: foo\n# my method\n", @top_level
util_parser "add_my_method :foo, :bar"
tk = @parser.get_tk
@parser.parse_meta_attr klass, RDoc::Parser::Ruby::NORMAL, tk, comment
assert_equal 1, klass.attributes.length
foo = klass.attributes.first
assert_equal 'foo', foo.name
assert_equal 'RW', foo.rw
assert_equal 'my method', foo.comment.text
assert_equal @top_level, foo.file
end
def test_parse_meta_attr_reader
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
comment =
RDoc::Comment.new "##\n# :attr_reader: \n# my method\n", @top_level
util_parser "add_my_method :foo, :bar"
tk = @parser.get_tk
@parser.parse_meta_attr klass, RDoc::Parser::Ruby::NORMAL, tk, comment
foo = klass.attributes.first
assert_equal 'foo', foo.name
assert_equal 'R', foo.rw
assert_equal 'my method', foo.comment.text
assert_equal @top_level, foo.file
end
def test_parse_meta_attr_stopdoc
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
klass.stop_doc
comment = RDoc::Comment.new "##\n# :attr: \n# my method\n", @top_level
util_parser "add_my_method :foo, :bar"
tk = @parser.get_tk
@parser.parse_meta_attr klass, RDoc::Parser::Ruby::NORMAL, tk, comment
assert_empty klass.attributes
end
def test_parse_meta_attr_writer
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
comment =
RDoc::Comment.new "##\n# :attr_writer: \n# my method\n", @top_level
util_parser "add_my_method :foo, :bar"
tk = @parser.get_tk
@parser.parse_meta_attr klass, RDoc::Parser::Ruby::NORMAL, tk, comment
foo = klass.attributes.first
assert_equal 'foo', foo.name
assert_equal 'W', foo.rw
assert_equal "my method", foo.comment.text
assert_equal @top_level, foo.file
end
def test_parse_class
comment = RDoc::Comment.new "##\n# my class\n", @top_level
util_parser "class Foo\nend"
tk = @parser.get_tk
@parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, comment
foo = @top_level.classes.first
assert_equal 'Foo', foo.full_name
assert_equal 'my class', foo.comment.text
assert_equal [@top_level], foo.in_files
assert_equal 0, foo.offset
assert_equal 1, foo.line
end
def test_parse_class_singleton
comment = RDoc::Comment.new "##\n# my class\n", @top_level
util_parser <<-RUBY
class C
class << self
end
end
RUBY
tk = @parser.get_tk
@parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, comment
c = @top_level.classes.first
assert_equal 'C', c.full_name
assert_equal 0, c.offset
assert_equal 1, c.line
end
def test_parse_class_ghost_method
util_parser <<-CLASS
class Foo
##
# :method: blah
# my method
end
CLASS
tk = @parser.get_tk
@parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
foo = @top_level.classes.first
assert_equal 'Foo', foo.full_name
blah = foo.method_list.first
assert_equal 'Foo#blah', blah.full_name
assert_equal @top_level, blah.file
end
def test_parse_class_ghost_method_yields
util_parser <<-CLASS
class Foo
##
# :method:
# :call-seq:
# yields(name)
end
CLASS
tk = @parser.get_tk
@parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
foo = @top_level.classes.first
assert_equal 'Foo', foo.full_name
blah = foo.method_list.first
assert_equal 'Foo#yields', blah.full_name
assert_equal 'yields(name)', blah.call_seq
assert_equal @top_level, blah.file
end
def test_parse_class_multi_ghost_methods
util_parser <<-'CLASS'
class Foo
##
# :method: one
#
# my method
##
# :method: two
#
# my method
[:one, :two].each do |t|
eval("def #{t}; \"#{t}\"; end")
end
end
CLASS
tk = @parser.get_tk
@parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
foo = @top_level.classes.first
assert_equal 'Foo', foo.full_name
assert_equal 2, foo.method_list.length
end
def test_parse_class_nodoc
comment = RDoc::Comment.new "##\n# my class\n", @top_level
util_parser "class Foo # :nodoc:\nend"
tk = @parser.get_tk
@parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, comment
foo = @top_level.classes.first
assert_equal 'Foo', foo.full_name
assert_empty foo.comment
assert_equal [@top_level], foo.in_files
assert_equal 0, foo.offset
assert_equal 1, foo.line
end
def test_parse_class_single_root
comment = RDoc::Comment.new "##\n# my class\n", @top_level
util_parser "class << ::Foo\nend"
tk = @parser.get_tk
@parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, comment
foo = @store.all_modules.first
assert_equal 'Foo', foo.full_name
end
def test_parse_class_stopdoc
@top_level.stop_doc
comment = RDoc::Comment.new "##\n# my class\n", @top_level
util_parser "class Foo\nend"
tk = @parser.get_tk
@parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, comment
assert_empty @top_level.classes.first.comment
end
def test_parse_multi_ghost_methods
util_parser <<-'CLASS'
class Foo
##
# :method: one
#
# my method
##
# :method: two
#
# my method
[:one, :two].each do |t|
eval("def #{t}; \"#{t}\"; end")
end
end
CLASS
tk = @parser.get_tk
@parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
foo = @top_level.classes.first
assert_equal 'Foo', foo.full_name
assert_equal 2, foo.method_list.length
end
def test_parse_const_fail_w_meta_method
util_parser <<-CLASS
class ConstFailMeta
##
# :attr: one
#
# an attribute
OtherModule.define_attr(self, :one)
end
CLASS
tk = @parser.get_tk
@parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
const_fail_meta = @top_level.classes.first
assert_equal 'ConstFailMeta', const_fail_meta.full_name
assert_equal 1, const_fail_meta.attributes.length
end
def test_parse_const_third_party
util_parser <<-CLASS
class A
true if B::C
true if D::E::F
end
CLASS
tk = @parser.get_tk
@parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
a = @top_level.classes.first
assert_equal 'A', a.full_name
visible = @store.all_modules.reject { |mod| mod.suppressed? }
visible = visible.map { |mod| mod.full_name }
assert_empty visible
end
def test_parse_class_nested_superclass
foo = @top_level.add_module RDoc::NormalModule, 'Foo'
util_parser "class Bar < Super\nend"
tk = @parser.get_tk
@parser.parse_class foo, RDoc::Parser::Ruby::NORMAL, tk, @comment
bar = foo.classes.first
assert_equal 'Super', bar.superclass
end
def test_parse_module
comment = RDoc::Comment.new "##\n# my module\n", @top_level
util_parser "module Foo\nend"
tk = @parser.get_tk
@parser.parse_module @top_level, RDoc::Parser::Ruby::NORMAL, tk, comment
foo = @top_level.modules.first
assert_equal 'Foo', foo.full_name
assert_equal 'my module', foo.comment.text
end
def test_parse_module_nodoc
@top_level.stop_doc
comment = RDoc::Comment.new "##\n# my module\n", @top_level
util_parser "module Foo # :nodoc:\nend"
tk = @parser.get_tk
@parser.parse_module @top_level, RDoc::Parser::Ruby::NORMAL, tk, comment
foo = @top_level.modules.first
assert_equal 'Foo', foo.full_name
assert_empty foo.comment
end
def test_parse_module_stopdoc
@top_level.stop_doc
comment = RDoc::Comment.new "##\n# my module\n", @top_level
util_parser "module Foo\nend"
tk = @parser.get_tk
@parser.parse_module @top_level, RDoc::Parser::Ruby::NORMAL, tk, comment
foo = @top_level.modules.first
assert_equal 'Foo', foo.full_name
assert_empty foo.comment
end
def test_parse_class_colon3
code = <<-CODE
class A
class ::B
end
end
CODE
util_parser code
@parser.parse_class @top_level, false, @parser.get_tk, @comment
assert_equal %w[A B], @store.all_classes.map { |c| c.full_name }.sort
end
def test_parse_class_colon3_self_reference
code = <<-CODE
class A::B
class ::A
end
end
CODE
util_parser code
@parser.parse_class @top_level, false, @parser.get_tk, @comment
assert_equal %w[A A::B], @store.all_classes.map { |c| c.full_name }.sort
end
def test_parse_class_single
code = <<-CODE
class A
class << B
end
class << d = Object.new
def foo; end
alias bar foo
end
end
CODE
util_parser code
@parser.parse_class @top_level, false, @parser.get_tk, @comment
assert_equal %w[A], @store.all_classes.map { |c| c.full_name }
modules = @store.all_modules.sort_by { |c| c.full_name }
assert_equal %w[A::B A::d], modules.map { |c| c.full_name }
b = modules.first
assert_equal 10, b.offset
assert_equal 2, b.line
# make sure method/alias was not added to enclosing class/module
a = @store.classes_hash['A']
assert_empty a.method_list
# make sure non-constant-named module will be removed from documentation
d = @store.modules_hash['A::d']
assert d.remove_from_documentation?
end
def test_parse_class_single_gvar
code = <<-CODE
class << $g
def m
end
end
CODE
util_parser code
@parser.parse_class @top_level, false, @parser.get_tk, ''
assert_empty @store.all_classes
mod = @store.all_modules.first
refute mod.document_self
assert_empty mod.method_list
end
# TODO this is really a Context#add_class test
def test_parse_class_object
code = <<-CODE
module A
class B
end
class Object
end
class C < Object
end
end
CODE
util_parser code
@parser.parse_module @top_level, false, @parser.get_tk, @comment
assert_equal %w[A],
@store.all_modules.map { |c| c.full_name }
assert_equal %w[A::B A::C A::Object],
@store.all_classes.map { |c| c.full_name }.sort
assert_equal 'Object', @store.classes_hash['A::B'].superclass
assert_equal 'Object', @store.classes_hash['A::Object'].superclass
assert_equal 'A::Object', @store.classes_hash['A::C'].superclass.full_name
end
def test_parse_class_mistaken_for_module
# The code below is not strictly legal Ruby (Foo must have been defined
# before Foo::Bar is encountered), but RDoc might encounter Foo::Bar
# before Foo if they live in different files.
code = <<-RUBY
class Foo::Bar
end
module Foo::Baz
end
class Foo
end
RUBY
util_parser code
@parser.scan
assert_equal %w[Foo::Baz], @store.modules_hash.keys
assert_empty @top_level.modules
foo = @top_level.classes.first
assert_equal 'Foo', foo.full_name
bar = foo.classes.first
assert_equal 'Foo::Bar', bar.full_name
baz = foo.modules.first
assert_equal 'Foo::Baz', baz.full_name
end
def test_parse_class_definition_encountered_after_class_reference
# The code below is not legal Ruby (Foo must have been defined before
# Foo.bar is encountered), but RDoc might encounter Foo.bar before Foo if
# they live in different files.
code = <<-EOF
def Foo.bar
end
class Foo < IO
end
EOF
util_parser code
@parser.scan
assert_empty @store.modules_hash
assert_empty @store.all_modules
foo = @top_level.classes.first
assert_equal 'Foo', foo.full_name
assert_equal 'IO', foo.superclass
bar = foo.method_list.first
assert_equal 'bar', bar.name
end
def test_parse_module_relative_to_top_level_namespace
comment = RDoc::Comment.new <<-EOF, @top_level
#
# Weirdly named module
#
EOF
code = <<-EOF
#{comment.text}
module ::Foo
class Helper
end
end
EOF
util_parser code
@parser.scan()
foo = @top_level.modules.first
assert_equal 'Foo', foo.full_name
assert_equal 'Weirdly named module', foo.comment.text
helper = foo.classes.first
assert_equal 'Foo::Helper', helper.full_name
end
def test_parse_comment_attr
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
comment = RDoc::Comment.new "##\n# :attr: foo\n# my attr\n", @top_level
util_parser "\n"
tk = @parser.get_tk
@parser.parse_comment klass, tk, comment
foo = klass.attributes.first
assert_equal 'foo', foo.name
assert_equal 'RW', foo.rw
assert_equal 'my attr', foo.comment.text
assert_equal @top_level, foo.file
assert_equal 0, foo.offset
assert_equal 1, foo.line
assert_equal nil, foo.viewer
assert_equal true, foo.document_children
assert_equal true, foo.document_self
assert_equal false, foo.done_documenting
assert_equal false, foo.force_documentation
assert_equal klass, foo.parent
assert_equal :public, foo.visibility
assert_equal "\n", foo.text
assert_equal klass.current_section, foo.section
end
def test_parse_comment_attr_attr_reader
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
comment = RDoc::Comment.new "##\n# :attr_reader: foo\n", @top_level
util_parser "\n"
tk = @parser.get_tk
@parser.parse_comment klass, tk, comment
foo = klass.attributes.first
assert_equal 'foo', foo.name
assert_equal 'R', foo.rw
end
def test_parse_comment_attr_stopdoc
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
klass.stop_doc
comment = RDoc::Comment.new "##\n# :attr: foo\n# my attr\n", @top_level
util_parser "\n"
tk = @parser.get_tk
@parser.parse_comment klass, tk, comment
assert_empty klass.attributes
end
def test_parse_comment_method
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
comment = RDoc::Comment.new "##\n# :method: foo\n# my method\n", @top_level
util_parser "\n"
tk = @parser.get_tk
@parser.parse_comment klass, tk, comment
foo = klass.method_list.first
assert_equal 'foo', foo.name
assert_equal 'my method', foo.comment.text
assert_equal @top_level, foo.file
assert_equal 0, foo.offset
assert_equal 1, foo.line
assert_equal [], foo.aliases
assert_equal nil, foo.block_params
assert_equal nil, foo.call_seq
assert_equal nil, foo.is_alias_for
assert_equal nil, foo.viewer
assert_equal true, foo.document_children
assert_equal true, foo.document_self
assert_equal '', foo.params
assert_equal false, foo.done_documenting
assert_equal false, foo.dont_rename_initialize
assert_equal false, foo.force_documentation
assert_equal klass, foo.parent
assert_equal false, foo.singleton
assert_equal :public, foo.visibility
assert_equal "\n", foo.text
assert_equal klass.current_section, foo.section
stream = [
tk(:COMMENT, 0, 1, 1, nil,
"# File #{@top_level.relative_name}, line 1"),
RDoc::Parser::Ruby::NEWLINE_TOKEN,
tk(:SPACE, 0, 1, 1, nil, ''),
]
assert_equal stream, foo.token_stream
end
def test_parse_comment_method_args
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
util_parser "\n"
tk = @parser.get_tk
@parser.parse_comment klass, tk,
comment("##\n# :method: foo\n# :args: a, b\n")
foo = klass.method_list.first
assert_equal 'foo', foo.name
assert_equal 'a, b', foo.params
end
def test_parse_comment_method_stopdoc
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
klass.stop_doc
comment = RDoc::Comment.new "##\n# :method: foo\n# my method\n", @top_level
util_parser "\n"
tk = @parser.get_tk
@parser.parse_comment klass, tk, comment
assert_empty klass.method_list
end
def test_parse_constant
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
util_parser "A = v"
tk = @parser.get_tk
@parser.parse_constant klass, tk, @comment
foo = klass.constants.first
assert_equal 'A', foo.name
assert_equal @top_level, foo.file
assert_equal 0, foo.offset
assert_equal 1, foo.line
end
def test_parse_constant_attrasgn
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
util_parser "A[k] = v"
tk = @parser.get_tk
@parser.parse_constant klass, tk, @comment
assert klass.constants.empty?
end
def test_parse_constant_alias
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
klass.add_class RDoc::NormalClass, 'B'
util_parser "A = B"
tk = @parser.get_tk
@parser.parse_constant klass, tk, @comment
assert_equal 'Foo::A', klass.find_module_named('A').full_name
end
def test_parse_constant_alias_same_name
foo = @top_level.add_class RDoc::NormalClass, 'Foo'
@top_level.add_class RDoc::NormalClass, 'Bar'
bar = foo.add_class RDoc::NormalClass, 'Bar'
assert @store.find_class_or_module('::Bar')
util_parser "A = ::Bar"
tk = @parser.get_tk
@parser.parse_constant foo, tk, @comment
assert_equal 'A', bar.find_module_named('A').full_name
end
def test_parse_constant_in_method
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
util_parser 'A::B = v'
tk = @parser.get_tk
@parser.parse_constant klass, tk, @comment, true
assert_empty klass.constants
assert_empty @store.modules_hash.keys
assert_equal %w[Foo], @store.classes_hash.keys
end
def test_parse_constant_rescue
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
util_parser "A => e"
tk = @parser.get_tk
@parser.parse_constant klass, tk, @comment
assert_empty klass.constants
assert_empty klass.modules
assert_empty @store.modules_hash.keys
assert_equal %w[Foo], @store.classes_hash.keys
end
def test_parse_constant_stopdoc
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
klass.stop_doc
util_parser "A = v"
tk = @parser.get_tk
@parser.parse_constant klass, tk, @comment
assert_empty klass.constants
end
def test_parse_comment_nested
content = <<-CONTENT
A::B::C = 1
CONTENT
util_parser content
tk = @parser.get_tk
parsed = @parser.parse_constant @top_level, tk, 'comment'
assert parsed
a = @top_level.find_module_named 'A'
b = a.find_module_named 'B'
c = b.constants.first
assert_equal 'A::B::C', c.full_name
assert_equal 'comment', c.comment
end
def test_parse_extend_or_include_extend
klass = RDoc::NormalClass.new 'C'
klass.parent = @top_level
comment = RDoc::Comment.new "# my extend\n", @top_level
util_parser "extend I"
@parser.get_tk # extend
@parser.parse_extend_or_include RDoc::Extend, klass, comment
assert_equal 1, klass.extends.length
ext = klass.extends.first
assert_equal 'I', ext.name
assert_equal 'my extend', ext.comment.text
assert_equal @top_level, ext.file
end
def test_parse_extend_or_include_include
klass = RDoc::NormalClass.new 'C'
klass.parent = @top_level
comment = RDoc::Comment.new "# my include\n", @top_level
util_parser "include I"
@parser.get_tk # include
@parser.parse_extend_or_include RDoc::Include, klass, comment
assert_equal 1, klass.includes.length
incl = klass.includes.first
assert_equal 'I', incl.name
assert_equal 'my include', incl.comment.text
assert_equal @top_level, incl.file
end
def test_parse_meta_method
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
comment = RDoc::Comment.new "##\n# my method\n", @top_level
util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
tk = @parser.get_tk
@parser.parse_meta_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
foo = klass.method_list.first
assert_equal 'foo', foo.name
assert_equal 'my method', foo.comment.text
assert_equal @top_level, foo.file
assert_equal 0, foo.offset
assert_equal 1, foo.line
assert_equal [], foo.aliases
assert_equal nil, foo.block_params
assert_equal nil, foo.call_seq
assert_equal true, foo.document_children
assert_equal true, foo.document_self
assert_equal false, foo.done_documenting
assert_equal false, foo.dont_rename_initialize
assert_equal false, foo.force_documentation
assert_equal nil, foo.is_alias_for
assert_equal '', foo.params
assert_equal klass, foo.parent
assert_equal false, foo.singleton
assert_equal 'add_my_method :foo', foo.text
assert_equal nil, foo.viewer
assert_equal :public, foo.visibility
assert_equal klass.current_section, foo.section
stream = [
tk(:COMMENT, 0, 1, 1, nil,
"# File #{@top_level.relative_name}, line 1"),
RDoc::Parser::Ruby::NEWLINE_TOKEN,
tk(:SPACE, 0, 1, 1, nil, ''),
tk(:IDENTIFIER, 0, 1, 0, 'add_my_method', 'add_my_method'),
tk(:SPACE, 0, 1, 13, nil, ' '),
tk(:SYMBOL, 0, 1, 14, nil, ':foo'),
tk(:COMMA, 0, 1, 18, nil, ','),
tk(:SPACE, 0, 1, 19, nil, ' '),
tk(:SYMBOL, 0, 1, 20, nil, ':bar'),
tk(:NL, 0, 1, 24, nil, "\n"),
]
assert_equal stream, foo.token_stream
end
def test_parse_meta_method_block
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
comment = RDoc::Comment.new "##\n# my method\n", @top_level
content = <<-CONTENT
inline(:my_method) do |*args|
"this method causes z to disappear"
end
CONTENT
util_parser content
tk = @parser.get_tk
@parser.parse_meta_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
assert_equal tk(:NL, 0, 3, 3, 3, "\n"), @parser.get_tk
end
def test_parse_meta_method_define_method
klass = RDoc::NormalClass.new 'Foo'
comment = RDoc::Comment.new "##\n# my method\n", @top_level
util_parser "define_method :foo do end"
tk = @parser.get_tk
@parser.parse_meta_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
foo = klass.method_list.first
assert_equal 'foo', foo.name
assert_equal 'my method', foo.comment.text
assert_equal @top_level, foo.file
end
def test_parse_meta_method_name
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
comment =
RDoc::Comment.new "##\n# :method: woo_hoo!\n# my method\n", @top_level
util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
tk = @parser.get_tk
@parser.parse_meta_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
foo = klass.method_list.first
assert_equal 'woo_hoo!', foo.name
assert_equal 'my method', foo.comment.text
assert_equal @top_level, foo.file
end
def test_parse_meta_method_singleton
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
comment =
RDoc::Comment.new "##\n# :singleton-method:\n# my method\n", @top_level
util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
tk = @parser.get_tk
@parser.parse_meta_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
foo = klass.method_list.first
assert_equal 'foo', foo.name
assert_equal true, foo.singleton, 'singleton method'
assert_equal 'my method', foo.comment.text
assert_equal @top_level, foo.file
end
def test_parse_meta_method_singleton_name
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
comment =
RDoc::Comment.new "##\n# :singleton-method: woo_hoo!\n# my method\n",
@top_level
util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
tk = @parser.get_tk
@parser.parse_meta_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
foo = klass.method_list.first
assert_equal 'woo_hoo!', foo.name
assert_equal true, foo.singleton, 'singleton method'
assert_equal 'my method', foo.comment.text
assert_equal @top_level, foo.file
end
def test_parse_meta_method_string_name
klass = RDoc::NormalClass.new 'Foo'
comment = RDoc::Comment.new "##\n# my method\n", @top_level
util_parser "add_my_method 'foo'"
tk = @parser.get_tk
@parser.parse_meta_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
foo = klass.method_list.first
assert_equal 'foo', foo.name
assert_equal 'my method', foo.comment.text
assert_equal @top_level, foo.file
end
def test_parse_meta_method_stopdoc
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
klass.stop_doc
comment = RDoc::Comment.new "##\n# my method\n", @top_level
util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
tk = @parser.get_tk
@parser.parse_meta_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
assert_empty klass.method_list
end
def test_parse_meta_method_unknown
klass = RDoc::NormalClass.new 'Foo'
comment = RDoc::Comment.new "##\n# my method\n", @top_level
util_parser "add_my_method ('foo')"
tk = @parser.get_tk
@parser.parse_meta_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
foo = klass.method_list.first
assert_equal 'unknown', foo.name
assert_equal 'my method', foo.comment.text
assert_equal @top_level, foo.file
end
def test_parse_method
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
comment = RDoc::Comment.new "##\n# my method\n", @top_level
util_parser "def foo() :bar end"
tk = @parser.get_tk
@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
foo = klass.method_list.first
assert_equal 'foo', foo.name
assert_equal 'my method', foo.comment.text
assert_equal @top_level, foo.file
assert_equal 0, foo.offset
assert_equal 1, foo.line
assert_equal [], foo.aliases
assert_equal nil, foo.block_params
assert_equal nil, foo.call_seq
assert_equal nil, foo.is_alias_for
assert_equal nil, foo.viewer
assert_equal true, foo.document_children
assert_equal true, foo.document_self
assert_equal '()', foo.params
assert_equal false, foo.done_documenting
assert_equal false, foo.dont_rename_initialize
assert_equal false, foo.force_documentation
assert_equal klass, foo.parent
assert_equal false, foo.singleton
assert_equal :public, foo.visibility
assert_equal 'def foo', foo.text
assert_equal klass.current_section, foo.section
stream = [
tk(:COMMENT, 0, 1, 1, nil,
"# File #{@top_level.relative_name}, line 1"),
RDoc::Parser::Ruby::NEWLINE_TOKEN,
tk(:SPACE, 0, 1, 1, nil, ''),
tk(:DEF, 0, 1, 0, 'def', 'def'),
tk(:SPACE, 3, 1, 3, nil, ' '),
tk(:IDENTIFIER, 4, 1, 4, 'foo', 'foo'),
tk(:LPAREN, 7, 1, 7, nil, '('),
tk(:RPAREN, 8, 1, 8, nil, ')'),
tk(:SPACE, 9, 1, 9, nil, ' '),
tk(:COLON, 10, 1, 10, nil, ':'),
tk(:IDENTIFIER, 11, 1, 11, 'bar', 'bar'),
tk(:SPACE, 14, 1, 14, nil, ' '),
tk(:END, 15, 1, 15, 'end', 'end'),
]
assert_equal stream, foo.token_stream
end
def test_parse_method_alias
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
util_parser "def m() alias a b; end"
tk = @parser.get_tk
@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
assert klass.aliases.empty?
end
def test_parse_method_ampersand
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
util_parser "def self.&\nend"
tk = @parser.get_tk
@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
ampersand = klass.method_list.first
assert_equal '&', ampersand.name
assert ampersand.singleton
end
def test_parse_method_constant
c = RDoc::Constant.new 'CONST', nil, ''
m = @top_level.add_class RDoc::NormalModule, 'M'
m.add_constant c
util_parser "def CONST.m() end"
tk = @parser.get_tk
@parser.parse_method m, RDoc::Parser::Ruby::NORMAL, tk, @comment
assert_empty @store.modules_hash.keys
assert_equal %w[M], @store.classes_hash.keys
end
def test_parse_method_false
util_parser "def false.foo() :bar end"
tk = @parser.get_tk
@parser.parse_method @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
klass = @store.find_class_named 'FalseClass'
foo = klass.method_list.first
assert_equal 'foo', foo.name
end
def test_parse_method_funky
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
util_parser "def (blah).foo() :bar end"
tk = @parser.get_tk
@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
assert_empty klass.method_list
end
def test_parse_method_gvar
util_parser "def $stdout.foo() :bar end"
tk = @parser.get_tk
@parser.parse_method @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
assert @top_level.method_list.empty?
end
def test_parse_method_gvar_insane
util_parser "def $stdout.foo() class << $other; end; end"
tk = @parser.get_tk
@parser.parse_method @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
assert @top_level.method_list.empty?
assert_empty @store.all_classes
assert_equal 1, @store.all_modules.length
refute @store.all_modules.first.document_self
end
def test_parse_method_internal_gvar
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
util_parser "def foo() def $blah.bar() end end"
tk = @parser.get_tk
@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
assert_equal 1, klass.method_list.length
end
def test_parse_method_internal_ivar
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
util_parser "def foo() def @blah.bar() end end"
tk = @parser.get_tk
@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
assert_equal 1, klass.method_list.length
end
def test_parse_method_internal_lvar
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
util_parser "def foo() def blah.bar() end end"
tk = @parser.get_tk
@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
assert_equal 1, klass.method_list.length
end
def test_parse_method_nil
util_parser "def nil.foo() :bar end"
tk = @parser.get_tk
@parser.parse_method @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
klass = @store.find_class_named 'NilClass'
foo = klass.method_list.first
assert_equal 'foo', foo.name
end
def test_parse_method_nodoc
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
util_parser "def foo # :nodoc:\nend"
tk = @parser.get_tk
@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment('')
assert_empty klass.method_list
end
def test_parse_method_nodoc_track
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
@options.visibility = :nodoc
util_parser "def foo # :nodoc:\nend"
tk = @parser.get_tk
@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment('')
refute_empty klass.method_list
end
def test_parse_method_no_parens
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
util_parser "def foo arg1, arg2 = {}\nend"
tk = @parser.get_tk
@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
foo = klass.method_list.first
assert_equal '(arg1, arg2 = {})', foo.params
assert_equal @top_level, foo.file
end
def test_parse_method_parameters_comment
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
util_parser "def foo arg1, arg2 # some useful comment\nend"
tk = @parser.get_tk
@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
foo = klass.method_list.first
assert_equal '(arg1, arg2)', foo.params
end
def test_parse_method_parameters_comment_continue
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
util_parser "def foo arg1, arg2, # some useful comment\narg3\nend"
tk = @parser.get_tk
@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
foo = klass.method_list.first
assert_equal '(arg1, arg2, arg3)', foo.params
end
def test_parse_method_star
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
util_parser "def self.*\nend"
tk = @parser.get_tk
@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
ampersand = klass.method_list.first
assert_equal '*', ampersand.name
assert ampersand.singleton
end
def test_parse_method_stopdoc
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
klass.stop_doc
comment = RDoc::Comment.new "##\n# my method\n", @top_level
util_parser "def foo() :bar end"
tk = @parser.get_tk
@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
assert_empty klass.method_list
end
def test_parse_method_toplevel
klass = @top_level
util_parser "def foo arg1, arg2\nend"
tk = @parser.get_tk
@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
object = @store.find_class_named 'Object'
foo = object.method_list.first
assert_equal 'Object#foo', foo.full_name
assert_equal @top_level, foo.file
end
def test_parse_method_toplevel_class
klass = @top_level
util_parser "def Object.foo arg1, arg2\nend"
tk = @parser.get_tk
@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
object = @store.find_class_named 'Object'
foo = object.method_list.first
assert_equal 'Object::foo', foo.full_name
end
def test_parse_method_true
util_parser "def true.foo() :bar end"
tk = @parser.get_tk
@parser.parse_method @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
klass = @store.find_class_named 'TrueClass'
foo = klass.method_list.first
assert_equal 'foo', foo.name
end
def test_parse_method_utf8
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
method = "def ω() end"
assert_equal Encoding::UTF_8, method.encoding if
Object.const_defined? :Encoding
util_parser method
tk = @parser.get_tk
@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
omega = klass.method_list.first
assert_equal "def \317\211", omega.text
end
def test_parse_method_dummy
util_parser ".method() end"
@parser.parse_method_dummy @top_level
assert_nil @parser.get_tk
end
def test_parse_method_or_yield_parameters_hash
util_parser "({})\n"
m = RDoc::AnyMethod.new nil, 'm'
result = @parser.parse_method_or_yield_parameters m
assert_equal '({})', result
end
def test_parse_statements_class_if
util_parser <<-CODE
module Foo
X = if TRUE then
''
end
def blah
end
end
CODE
@parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil
foo = @top_level.modules.first
assert_equal 'Foo', foo.full_name, 'module Foo'
methods = foo.method_list
assert_equal 1, methods.length
assert_equal 'Foo#blah', methods.first.full_name
end
def test_parse_statements_class_nested
comment = RDoc::Comment.new "##\n# my method\n", @top_level
util_parser "module Foo\n#{comment.text}class Bar\nend\nend"
@parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL
foo = @top_level.modules.first
assert_equal 'Foo', foo.full_name, 'module Foo'
bar = foo.classes.first
assert_equal 'Foo::Bar', bar.full_name, 'class Foo::Bar'
assert_equal 'my method', bar.comment.text
end
def test_parse_statements_def_percent_string_pound
util_parser "class C\ndef a\n%r{#}\nend\ndef b() end\nend"
@parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL
x = @top_level.classes.first
assert_equal 2, x.method_list.length
a = x.method_list.first
expected = [
tk(:COMMENT, 0, 2, 1, nil, "# File #{@filename}, line 2"),
tk(:NL, 0, 0, 0, nil, "\n"),
tk(:SPACE, 0, 1, 1, nil, ''),
tk(:DEF, 8, 2, 0, 'def', 'def'),
tk(:SPACE, 11, 2, 3, nil, ' '),
tk(:IDENTIFIER, 12, 2, 4, 'a', 'a'),
tk(:NL, 13, 2, 5, nil, "\n"),
tk(:DREGEXP, 14, 3, 0, nil, '%r{#}'),
tk(:NL, 19, 3, 5, nil, "\n"),
tk(:END, 20, 4, 0, 'end', 'end'),
]
assert_equal expected, a.token_stream
end
def test_parse_statements_encoding
skip "Encoding not implemented" unless Object.const_defined? :Encoding
@options.encoding = Encoding::CP852
content = <<-EOF
class Foo
##
# this is my method
add_my_method :foo
end
EOF
util_parser content
@parser.parse_statements @top_level
foo = @top_level.classes.first.method_list.first
assert_equal 'foo', foo.name
assert_equal 'this is my method', foo.comment.text
assert_equal Encoding::CP852, foo.comment.text.encoding
end
def test_parse_statements_enddoc
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
util_parser "\n# :enddoc:"
@parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
assert klass.done_documenting
end
def test_parse_statements_enddoc_top_level
util_parser "\n# :enddoc:"
assert_throws :eof do
@parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil
end
end
def test_parse_statements_identifier_meta_method
content = <<-EOF
class Foo
##
# this is my method
add_my_method :foo
end
EOF
util_parser content
@parser.parse_statements @top_level
foo = @top_level.classes.first.method_list.first
assert_equal 'foo', foo.name
end
def test_parse_statements_identifier_alias_method
content = <<-RUBY
class Foo
def foo() end
alias_method :foo2, :foo
end
RUBY
util_parser content
@parser.parse_statements @top_level
foo = @top_level.classes.first.method_list[0]
assert_equal 'foo', foo.name
foo2 = @top_level.classes.first.method_list.last
assert_equal 'foo2', foo2.name
assert_equal 'foo', foo2.is_alias_for.name
assert @top_level.classes.first.aliases.empty?
end
def test_parse_statements_identifier_alias_method_before_original_method
# This is not strictly legal Ruby code, but it simulates finding an alias
# for a method before finding the original method, which might happen
# to rdoc if the alias is in a different file than the original method
# and rdoc processes the alias' file first.
content = <<-EOF
class Foo
alias_method :foo2, :foo
alias_method :foo3, :foo
def foo()
end
alias_method :foo4, :foo
alias_method :foo5, :unknown
end
EOF
util_parser content
@parser.parse_statements @top_level
foo = @top_level.classes.first.method_list[0]
assert_equal 'foo', foo.name
foo2 = @top_level.classes.first.method_list[1]
assert_equal 'foo2', foo2.name
assert_equal 'foo', foo2.is_alias_for.name
foo3 = @top_level.classes.first.method_list[2]
assert_equal 'foo3', foo3.name
assert_equal 'foo', foo3.is_alias_for.name
foo4 = @top_level.classes.first.method_list.last
assert_equal 'foo4', foo4.name
assert_equal 'foo', foo4.is_alias_for.name
assert_equal 'unknown', @top_level.classes.first.external_aliases[0].old_name
end
def test_parse_statements_identifier_args
comment = "##\n# :args: x\n# :method: b\n# my method\n"
util_parser "module M\n#{comment}def_delegator :a, :b, :b\nend"
@parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL
m = @top_level.modules.first
assert_equal 'M', m.full_name
b = m.method_list.first
assert_equal 'M#b', b.full_name
assert_equal 'x', b.params
assert_equal 'my method', b.comment.text
assert_nil m.params, 'Module parameter not removed'
end
def test_parse_statements_identifier_constant
sixth_constant = <<-EOF
Class.new do
rule :file do
all(x, y, z) {
def value
find(:require).each {|r| require r.value }
find(:grammar).map {|g| g.value }
end
def min; end
}
end
end
EOF
content = <<-EOF
class Foo
FIRST_CONSTANT = 5
SECOND_CONSTANT = [
1,
2,
3
]
THIRD_CONSTANT = {
:foo => 'bar',
:x => 'y'
}
FOURTH_CONSTANT = SECOND_CONSTANT.map do |element|
element + 1
element + 2
end
FIFTH_CONSTANT = SECOND_CONSTANT.map { |element| element + 1 }
SIXTH_CONSTANT = #{sixth_constant}
SEVENTH_CONSTANT = proc { |i| begin i end }
end
EOF
util_parser content
@parser.parse_statements @top_level
constants = @top_level.classes.first.constants
constant = constants[0]
assert_equal 'FIRST_CONSTANT', constant.name
assert_equal '5', constant.value
assert_equal @top_level, constant.file
constant = constants[1]
assert_equal 'SECOND_CONSTANT', constant.name
assert_equal "[\n1,\n2,\n3\n]", constant.value
assert_equal @top_level, constant.file
constant = constants[2]
assert_equal 'THIRD_CONSTANT', constant.name
assert_equal "{\n:foo => 'bar',\n:x => 'y'\n}", constant.value
assert_equal @top_level, constant.file
constant = constants[3]
assert_equal 'FOURTH_CONSTANT', constant.name
assert_equal "SECOND_CONSTANT.map do |element|\nelement + 1\nelement + 2\nend", constant.value
assert_equal @top_level, constant.file
constant = constants[4]
assert_equal 'FIFTH_CONSTANT', constant.name
assert_equal 'SECOND_CONSTANT.map { |element| element + 1 }', constant.value
assert_equal @top_level, constant.file
# TODO: parse as class
constant = constants[5]
assert_equal 'SIXTH_CONSTANT', constant.name
assert_equal sixth_constant.lines.map(&:strip).join("\n"), constant.value
assert_equal @top_level, constant.file
# TODO: parse as method
constant = constants[6]
assert_equal 'SEVENTH_CONSTANT', constant.name
assert_equal "proc { |i| begin i end }", constant.value
assert_equal @top_level, constant.file
end
def test_parse_statements_identifier_attr
content = "class Foo\nattr :foo\nend"
util_parser content
@parser.parse_statements @top_level
foo = @top_level.classes.first.attributes.first
assert_equal 'foo', foo.name
assert_equal 'R', foo.rw
end
def test_parse_statements_identifier_attr_accessor
content = "class Foo\nattr_accessor :foo\nend"
util_parser content
@parser.parse_statements @top_level
foo = @top_level.classes.first.attributes.first
assert_equal 'foo', foo.name
assert_equal 'RW', foo.rw
end
def test_parse_statements_identifier_define_method
util_parser <<-RUBY
class C
##
# :method: a
define_method :a do end
##
# :method: b
define_method :b do end
end
RUBY
@parser.parse_statements @top_level
c = @top_level.classes.first
assert_equal %w[a b], c.method_list.map { |m| m.name }
end
def test_parse_statements_identifier_include
content = "class Foo\ninclude Bar\nend"
util_parser content
@parser.parse_statements @top_level
foo = @top_level.classes.first
assert_equal 'Foo', foo.name
assert_equal 1, foo.includes.length
end
def test_parse_statements_identifier_module_function
content = "module Foo\ndef foo() end\nmodule_function :foo\nend"
util_parser content
@parser.parse_statements @top_level
foo, s_foo = @top_level.modules.first.method_list
assert_equal 'foo', foo.name, 'instance method name'
assert_equal :private, foo.visibility, 'instance method visibility'
assert_equal false, foo.singleton, 'instance method singleton'
assert_equal 'foo', s_foo.name, 'module function name'
assert_equal :public, s_foo.visibility, 'module function visibility'
assert_equal true, s_foo.singleton, 'module function singleton'
end
def test_parse_statements_identifier_private
content = "class Foo\nprivate\ndef foo() end\nend"
util_parser content
@parser.parse_statements @top_level
foo = @top_level.classes.first.method_list.first
assert_equal 'foo', foo.name
assert_equal :private, foo.visibility
end
def test_parse_statements_identifier_public_class_method
content = <<-CONTENT
class Date
def self.now; end
private_class_method :now
end
class DateTime < Date
public_class_method :now
end
CONTENT
util_parser content
@parser.parse_statements @top_level
date, date_time = @top_level.classes.sort_by { |c| c.full_name }
date_now = date.method_list.first
date_time_now = date_time.method_list.sort_by { |m| m.full_name }.first
assert_equal :private, date_now.visibility
assert_equal :public, date_time_now.visibility
end
def test_parse_statements_identifier_private_class_method
content = <<-CONTENT
class Date
def self.now; end
public_class_method :now
end
class DateTime < Date
private_class_method :now
end
CONTENT
util_parser content
@parser.parse_statements @top_level
# TODO sort classes by default
date, date_time = @top_level.classes.sort_by { |c| c.full_name }
date_now = date.method_list.first
date_time_now = date_time.method_list.sort_by { |m| m.full_name }.first
assert_equal :public, date_now.visibility, date_now.full_name
assert_equal :private, date_time_now.visibility, date_time_now.full_name
end
def test_parse_statements_identifier_require
content = "require 'bar'"
util_parser content
@parser.parse_statements @top_level
assert_equal 1, @top_level.requires.length
end
def test_parse_statements_identifier_yields
comment = "##\n# :yields: x\n# :method: b\n# my method\n"
util_parser "module M\n#{comment}def_delegator :a, :b, :b\nend"
@parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL
m = @top_level.modules.first
assert_equal 'M', m.full_name
b = m.method_list.first
assert_equal 'M#b', b.full_name
assert_equal 'x', b.block_params
assert_equal 'my method', b.comment.text
assert_nil m.params, 'Module parameter not removed'
end
def test_parse_statements_stopdoc_TkALIAS
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
util_parser "\n# :stopdoc:\nalias old new"
@parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
assert_empty klass.aliases
assert_empty klass.unmatched_alias_lists
end
def test_parse_statements_stopdoc_TkIDENTIFIER_alias_method
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
util_parser "\n# :stopdoc:\nalias_method :old :new"
@parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
assert_empty klass.aliases
assert_empty klass.unmatched_alias_lists
end
def test_parse_statements_stopdoc_TkIDENTIFIER_metaprogrammed
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
util_parser "\n# :stopdoc:\n# attr :meta"
@parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
assert_empty klass.method_list
assert_empty klass.attributes
end
def test_parse_statements_stopdoc_TkCONSTANT
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
util_parser "\n# :stopdoc:\nA = v"
@parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
assert_empty klass.constants
end
def test_parse_statements_stopdoc_TkDEF
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
util_parser "\n# :stopdoc:\ndef m\n end"
@parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
assert_empty klass.method_list
end
def test_parse_statements_super
m = RDoc::AnyMethod.new '', 'm'
util_parser 'super'
@parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, m
assert m.calls_super
end
def test_parse_statements_super_no_method
content = "super"
util_parser content
@parser.parse_statements @top_level
assert_nil @parser.get_tk
end
def test_parse_statements_while_begin
util_parser <<-RUBY
class A
def a
while begin a; b end
end
end
def b
end
end
RUBY
@parser.parse_statements @top_level
c_a = @top_level.classes.first
assert_equal 'A', c_a.full_name
assert_equal 1, @top_level.classes.length
m_a = c_a.method_list.first
m_b = c_a.method_list.last
assert_equal 'A#a', m_a.full_name
assert_equal 'A#b', m_b.full_name
end
def test_parse_symbol_in_arg
util_parser ':blah "blah" "#{blah}" blah'
assert_equal 'blah', @parser.parse_symbol_in_arg
@parser.skip_tkspace
assert_equal 'blah', @parser.parse_symbol_in_arg
@parser.skip_tkspace
assert_equal nil, @parser.parse_symbol_in_arg
@parser.skip_tkspace
assert_equal nil, @parser.parse_symbol_in_arg
end
def test_parse_statements_alias_method
content = <<-CONTENT
class A
alias_method :a, :[] unless c
end
B = A
class C
end
CONTENT
util_parser content
@parser.parse_statements @top_level
# HACK where are the assertions?
end
def test_parse_top_level_statements_enddoc
util_parser <<-CONTENT
# :enddoc:
CONTENT
assert_throws :eof do
@parser.parse_top_level_statements @top_level
end
end
def test_parse_top_level_statements_stopdoc
@top_level.stop_doc
content = "# this is the top-level comment"
util_parser content
@parser.parse_top_level_statements @top_level
assert_empty @top_level.comment
end
def test_parse_top_level_statements_stopdoc_integration
content = <<-CONTENT
# :stopdoc:
class Example
def method_name
end
end
CONTENT
util_parser content
@parser.parse_top_level_statements @top_level
assert_equal 1, @top_level.classes.length
assert_empty @top_level.modules
assert @top_level.find_module_named('Example').ignored?
end
# This tests parse_comment
def test_parse_top_level_statements_constant_nodoc_integration
content = <<-CONTENT
class A
C = A # :nodoc:
end
CONTENT
util_parser content
@parser.parse_top_level_statements @top_level
klass = @top_level.find_module_named('A')
c = klass.constants.first
assert_nil c.document_self, 'C should not be documented'
end
def test_parse_yield_in_braces_with_parens
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
util_parser "def foo\nn.times { |i| yield nth(i) }\nend"
tk = @parser.get_tk
@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
foo = klass.method_list.first
assert_equal 'nth(i)', foo.block_params
end
def test_read_directive
parser = util_parser '# :category: test'
directive, value = parser.read_directive %w[category]
assert_equal 'category', directive
assert_equal 'test', value
assert_kind_of RDoc::RubyToken::TkNL, parser.get_tk
end
def test_read_directive_allow
parser = util_parser '# :category: test'
directive = parser.read_directive []
assert_nil directive
assert_kind_of RDoc::RubyToken::TkNL, parser.get_tk
end
def test_read_directive_empty
parser = util_parser '# test'
directive = parser.read_directive %w[category]
assert_nil directive
assert_kind_of RDoc::RubyToken::TkNL, parser.get_tk
end
def test_read_directive_no_comment
parser = util_parser ''
directive = parser.read_directive %w[category]
assert_nil directive
assert_kind_of RDoc::RubyToken::TkNL, parser.get_tk
end
def test_read_directive_one_liner
parser = util_parser '; end # :category: test'
directive, value = parser.read_directive %w[category]
assert_equal 'category', directive
assert_equal 'test', value
assert_kind_of RDoc::RubyToken::TkSEMICOLON, parser.get_tk
end
def test_read_documentation_modifiers
c = RDoc::Context.new
parser = util_parser '# :category: test'
parser.read_documentation_modifiers c, %w[category]
assert_equal 'test', c.current_section.title
end
def test_read_documentation_modifiers_notnew
m = RDoc::AnyMethod.new nil, 'initialize'
parser = util_parser '# :notnew: test'
parser.read_documentation_modifiers m, %w[notnew]
assert m.dont_rename_initialize
end
def test_read_documentation_modifiers_not_dash_new
m = RDoc::AnyMethod.new nil, 'initialize'
parser = util_parser '# :not-new: test'
parser.read_documentation_modifiers m, %w[not-new]
assert m.dont_rename_initialize
end
def test_read_documentation_modifiers_not_new
m = RDoc::AnyMethod.new nil, 'initialize'
parser = util_parser '# :not_new: test'
parser.read_documentation_modifiers m, %w[not_new]
assert m.dont_rename_initialize
end
def test_sanity_integer
util_parser '1'
assert_equal '1', @parser.get_tk.text
util_parser '1.0'
assert_equal '1.0', @parser.get_tk.text
end
def test_sanity_interpolation
last_tk = nil
util_parser 'class A; B = "#{c}"; end'
while tk = @parser.get_tk do last_tk = tk end
assert_equal "\n", last_tk.text
end
# If you're writing code like this you're doing it wrong
def test_sanity_interpolation_crazy
util_parser '"#{"#{"a")}" if b}"'
assert_equal '"#{"#{"a")}" if b}"', @parser.get_tk.text
assert_equal RDoc::RubyToken::TkNL, @parser.get_tk.class
end
def test_sanity_interpolation_curly
util_parser '%{ #{} }'
assert_equal '%Q{ #{} }', @parser.get_tk.text
assert_equal RDoc::RubyToken::TkNL, @parser.get_tk.class
end
def test_sanity_interpolation_format
util_parser '"#{stftime("%m-%d")}"'
while @parser.get_tk do end
end
def test_sanity_symbol_interpolation
util_parser ':"#{bar}="'
while @parser.get_tk do end
end
def test_scan_cr
content = <<-CONTENT
class C\r
def m\r
a=\\\r
123\r
end\r
end\r
CONTENT
util_parser content
@parser.scan
c = @top_level.classes.first
assert_equal 1, c.method_list.length
end
def test_scan_block_comment
content = <<-CONTENT
=begin rdoc
Foo comment
=end
class Foo
=begin
m comment
=end
def m() end
end
CONTENT
util_parser content
@parser.scan
foo = @top_level.classes.first
assert_equal 'Foo comment', foo.comment.text
m = foo.method_list.first
assert_equal 'm comment', m.comment.text
end
def test_scan_block_comment_nested # Issue #41
content = <<-CONTENT
require 'something'
=begin rdoc
findmeindoc
=end
module Foo
class Bar
end
end
CONTENT
util_parser content
@parser.scan
foo = @top_level.modules.first
assert_equal 'Foo', foo.full_name
assert_equal 'findmeindoc', foo.comment.text
bar = foo.classes.first
assert_equal 'Foo::Bar', bar.full_name
assert_equal '', bar.comment.text
end
def test_scan_block_comment_notflush
##
#
# The previous test assumes that between the =begin/=end blocs that there is
# only one line, or minima formatting directives. This test tests for those
# who use the =begin bloc with longer / more advanced formatting within.
#
##
content = <<-CONTENT
=begin rdoc
= DESCRIPTION
This is a simple test class
= RUMPUS
Is a silly word
=end
class StevenSimpleClass
# A band on my iPhone as I wrote this test
FRUIT_BATS="Make nice music"
=begin rdoc
A nice girl
=end
def lauren
puts "Summoning Lauren!"
end
end
CONTENT
util_parser content
@parser.scan
foo = @top_level.classes.first
assert_equal "= DESCRIPTION\n\nThis is a simple test class\n\n= RUMPUS\n\nIs a silly word",
foo.comment.text
m = foo.method_list.first
assert_equal 'A nice girl', m.comment.text
end
def test_scan_class_nested_nodoc
content = <<-CONTENT
class A::B # :nodoc:
end
CONTENT
util_parser content
@parser.scan
visible = @store.all_classes_and_modules.select { |mod| mod.display? }
assert_empty visible.map { |mod| mod.full_name }
end
def test_scan_constant_in_method
content = <<-CONTENT # newline is after M is important
module M
def m
A
B::C
end
end
CONTENT
util_parser content
@parser.scan
m = @top_level.modules.first
assert_empty m.constants
assert_empty @store.classes_hash.keys
assert_equal %w[M], @store.modules_hash.keys
end
def test_scan_constant_in_rescue
content = <<-CONTENT # newline is after M is important
module M
def m
rescue A::B
rescue A::C => e
rescue A::D, A::E
rescue A::F,
A::G
rescue H
rescue I => e
rescue J, K
rescue L =>
e
rescue M;
rescue N,
O => e
end
end
CONTENT
util_parser content
@parser.scan
m = @top_level.modules.first
assert_empty m.constants
assert_empty @store.classes_hash.keys
assert_equal %w[M], @store.modules_hash.keys
end
def test_scan_constant_nodoc
content = <<-CONTENT # newline is after M is important
module M
C = v # :nodoc:
end
CONTENT
util_parser content
@parser.scan
c = @top_level.modules.first.constants.first
assert c.documented?
end
def test_scan_constant_nodoc_block
content = <<-CONTENT # newline is after M is important
module M
C = v do # :nodoc:
end
end
CONTENT
util_parser content
@parser.scan
c = @top_level.modules.first.constants.first
assert c.documented?
end
def test_scan_duplicate_module
content = <<-CONTENT
# comment a
module Foo
end
# comment b
module Foo
end
CONTENT
util_parser content
@parser.scan
foo = @top_level.modules.first
expected = [
RDoc::Comment.new('comment b', @top_level)
]
assert_equal expected, foo.comment_location.map { |c, l| c }
end
def test_scan_meta_method_block
content = <<-CONTENT
class C
##
# my method
inline(:my_method) do |*args|
"this method used to cause z to disappear"
end
def z
end
CONTENT
util_parser content
@parser.scan
assert_equal 2, @top_level.classes.first.method_list.length
end
def test_scan_method_semi_method
content = <<-CONTENT
class A
def self.m() end; def self.m=() end
end
class B
def self.m() end
end
CONTENT
util_parser content
@parser.scan
a = @store.find_class_named 'A'
assert a, 'missing A'
assert_equal 2, a.method_list.length
b = @store.find_class_named 'B'
assert b, 'missing B'
assert_equal 1, b.method_list.length
end
def test_scan_markup_override
content = <<-CONTENT
# *awesome*
class C
# :markup: rd
# ((*radical*))
def m
end
end
CONTENT
util_parser content
@parser.scan
c = @top_level.classes.first
assert_equal 'rdoc', c.comment.format
assert_equal 'rd', c.method_list.first.comment.format
end
def test_scan_markup_first_comment
content = <<-CONTENT
# :markup: rd
# ((*awesome*))
class C
# ((*radical*))
def m
end
end
CONTENT
util_parser content
@parser.scan
c = @top_level.classes.first
assert_equal 'rd', c.comment.format
assert_equal 'rd', c.method_list.first.comment.format
end
def test_scan_rails_routes
util_parser <<-ROUTES_RB
namespace :api do
scope module: :v1 do
end
end
ROUTES_RB
@parser.scan
assert_empty @top_level.classes
assert_empty @top_level.modules
end
def test_scan_tomdoc_meta
util_parser <<-RUBY
# :markup: tomdoc
class C
# Signature
#
# find_by_<field>[_and_<field>...](args)
#
# field - A field name.
end
RUBY
@parser.scan
c = @top_level.classes.first
m = c.method_list.first
assert_equal "find_by_<field>[_and_<field>...]", m.name
assert_equal "find_by_<field>[_and_<field>...](args)\n", m.call_seq
expected =
doc(
head(3, 'Signature'),
list(:NOTE,
item(%w[field],
para('A field name.'))))
expected.file = @top_level
assert_equal expected, m.comment.parse
end
def test_scan_stopdoc
util_parser <<-RUBY
class C
# :stopdoc:
class Hidden
end
end
RUBY
@parser.scan
c = @top_level.classes.first
hidden = c.classes.first
refute hidden.document_self
assert hidden.ignored?
end
def test_scan_stopdoc_class_alias
util_parser <<-RUBY
# :stopdoc:
module A
B = C
end
RUBY
@parser.scan
assert_empty @store.all_classes
assert_equal 1, @store.all_modules.length
m = @store.all_modules.first
assert m.ignored?
end
def test_scan_stopdoc_nested
util_parser <<-RUBY
# :stopdoc:
class A::B
end
RUBY
@parser.scan
a = @store.modules_hash['A']
a_b = @store.classes_hash['A::B']
refute a.document_self, 'A is inside stopdoc'
assert a.ignored?, 'A is inside stopdoc'
refute a_b.document_self, 'A::B is inside stopdoc'
assert a_b.ignored?, 'A::B is inside stopdoc'
end
def test_scan_struct_self_brackets
util_parser <<-RUBY
class C < M.m
def self.[]
end
end
RUBY
@parser.scan
c = @store.find_class_named 'C'
assert_equal %w[C::[]], c.method_list.map { |m| m.full_name }
end
def test_scan_visibility
util_parser <<-RUBY
class C
def a() end
private :a
class << self
def b() end
private :b
end
end
RUBY
@parser.scan
c = @store.find_class_named 'C'
c_a = c.find_method_named 'a'
assert_equal :private, c_a.visibility
refute c_a.singleton
c_b = c.find_method_named 'b'
assert_equal :private, c_b.visibility
refute c_b.singleton
end
def test_stopdoc_after_comment
util_parser <<-EOS
module Bar
# hello
module Foo
# :stopdoc:
end
# there
class Baz
# :stopdoc:
end
end
EOS
@parser.parse_statements @top_level
foo = @top_level.modules.first.modules.first
assert_equal 'Foo', foo.name
assert_equal 'hello', foo.comment.text
baz = @top_level.modules.first.classes.first
assert_equal 'Baz', baz.name
assert_equal 'there', baz.comment.text
end
def tk klass, scan, line, char, name, text
klass = RDoc::RubyToken.const_get "Tk#{klass.to_s.upcase}"
token = if klass.instance_method(:initialize).arity == 3 then
raise ArgumentError, "name not used for #{klass}" if name
klass.new scan, line, char
else
klass.new scan, line, char, name
end
token.set_text text
token
end
def util_parser(content)
@parser = RDoc::Parser::Ruby.new @top_level, @filename, content, @options,
@stats
end
def util_two_parsers(first_file_content, second_file_content)
util_parser first_file_content
@parser2 = RDoc::Parser::Ruby.new @top_level2, @filename,
second_file_content, @options, @stats
end
end
| 23.064935 | 98 | 0.679683 |
79422f024097c1777cbc72efc8f23078e87becc1 | 3,941 | #
# Cookbook Name:: jenkins
# HWRP:: credentials_password
#
# Author:: Seth Chisamore <[email protected]>
#
# Copyright 2013-2014, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
require_relative 'credentials'
require_relative '_params_validate'
class Chef
class Resource::JenkinsPrivateKeyCredentials < Resource::JenkinsCredentials
require 'openssl'
# Chef attributes
provides :jenkins_private_key_credentials
# Set the resource name
self.resource_name = :jenkins_private_key_credentials
# Actions
actions :create, :delete
default_action :create
# Attributes
attribute :id,
kind_of: String,
regex: UUID_REGEX, # Private Key credentials must still have a UUID based ID
default: lazy { SecureRandom.uuid }
attribute :private_key,
kind_of: [String, OpenSSL::PKey::RSA],
required: true
attribute :passphrase,
kind_of: String
#
# Private key of the credentials . This should be the actual key
# contents (as opposed to the path to a private key file) in OpenSSH
# format.
#
# @param [String] arg
# @return [String]
#
def rsa_private_key
if private_key.is_a?(OpenSSL::PKey::RSA)
private_key.to_pem
else
OpenSSL::PKey::RSA.new(private_key).to_pem
end
end
end
end
class Chef
class Provider::JenkinsPrivateKeyCredentials < Provider::JenkinsCredentials
def load_current_resource
@current_resource ||= Resource::JenkinsPrivateKeyCredentials.new(new_resource.name)
super
if current_credentials
@current_resource.private_key(current_credentials[:private_key])
end
@current_resource
end
protected
#
# @see Chef::Resource::JenkinsCredentials#credentials_groovy
# @see https://github.com/jenkinsci/ssh-credentials-plugin/blob/master/src/main/java/com/cloudbees/jenkins/plugins/sshcredentials/impl/BasicSSHUserPrivateKey.java
#
def credentials_groovy
<<-EOH.gsub(/ ^{8}/, '')
import com.cloudbees.plugins.credentials.*
import com.cloudbees.jenkins.plugins.sshcredentials.impl.*
private_key = """#{new_resource.rsa_private_key}
"""
credentials = new BasicSSHUserPrivateKey(
CredentialsScope.GLOBAL,
#{convert_to_groovy(new_resource.id)},
#{convert_to_groovy(new_resource.username)},
new BasicSSHUserPrivateKey.DirectEntryPrivateKeySource(private_key),
#{convert_to_groovy(new_resource.passphrase)},
#{convert_to_groovy(new_resource.description)}
)
EOH
end
#
# @see Chef::Resource::JenkinsCredentials#attribute_to_property_map
#
def attribute_to_property_map
{
private_key: 'credentials.privateKey',
passphrase: 'credentials.passphrase.plainText',
}
end
#
# @see Chef::Resource::JenkinsCredentials#current_credentials
#
def current_credentials
super
# Normalize the private key
if @current_credentials && @current_credentials[:private_key]
@current_credentials[:private_key] = OpenSSL::PKey::RSA.new(@current_credentials[:private_key]).to_pem
end
@current_credentials
end
end
end
Chef::Platform.set(
resource: :jenkins_private_key_credentials,
provider: Chef::Provider::JenkinsPrivateKeyCredentials,
)
| 28.766423 | 166 | 0.692718 |
38dece6c426d37b6ddf759cc84bfebca2621e54c | 1,515 | require 'spec_helper'
describe Spree::Promotion::Rules::UserIsNotReferred, type: :model do
let(:rule) { described_class.new }
describe 'applicability' do
subject { rule.applicable?(promotable) }
context "when the promotable is an order" do
let(:promotable) { Spree::Order.new }
it { is_expected.to be true }
end
context "when the promotable is not a order" do
let(:promotable) { Spree::LineItem.new }
it { is_expected.to be false }
end
end
describe 'eligibility' do
let(:order) { create(:order, user: user) }
subject { rule.eligible?(order) }
context 'anonymous cart' do
let(:user) { nil }
it { is_expected.to be false }
it "sets an error message" do
rule.eligible?(order)
expect(rule.eligibility_errors.full_messages.first).
to eq "You need to login before applying this coupon code."
end
end
context 'cart with user' do
let(:user) { create(:user) }
context 'when the user has been referred by someone' do
let!(:referrer) { create(:user, referred_users: [user]) }
it { is_expected.to be false }
it "sets an error message" do
rule.eligible?(order)
expect(rule.eligibility_errors.full_messages.first).
to eq "User is referred. Promotion cannot be applied."
end
end
context 'when the user has not been referred by anyone' do
it { is_expected.to be true }
end
end
end
end
| 25.25 | 69 | 0.626403 |
5d9db1056af0f91fa21365c257bee2294579adb9 | 3,043 | # (C) Copyright 2020 Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
require_relative '../_client' # Gives access to @client
# Example: Actions with a Server Hardware Type
#
# Supported API variants:
# C7000, Synergy
# Resource Class used in this sample
shw_type_class = OneviewSDK.resource_named('ServerHardwareType', @client.api_version)
shw_class = OneviewSDK.resource_named('ServerHardware', @client.api_version)
def print_server_hardware_type(item)
puts "\n-- Server hardware type --",
"Uri: #{item['uri']}",
"Name: #{item['name']}",
"Description: #{item['description']}",
'----'
end
server_hardware = nil
item = nil
# It is possible to create a server hardware type with a server hardware only for C7000.
begin
puts "\nCreating server hardware type by the creation of server hardware."
options_server_hardware = {
hostname: @server_hardware_hostname,
username: @server_hardware_username,
password: @server_hardware_password,
name: 'Server Hardware Type OneViewSDK Test 2',
licensingIntent: 'OneView'
}
server_hardware = shw_class.new(@client, options_server_hardware)
server_hardware.add
# retrieving server hardware type
item = shw_type_class.new(@client, uri: server_hardware['serverHardwareTypeUri'])
item.retrieve!
print_server_hardware_type(item)
rescue OneviewSDK::RequestError
puts "\nIt's possible to create a server hardware type with a server hardware for C7000 only."
end
# List all server hardware types
list = shw_type_class.get_all(@client)
puts "\n#Listing all:"
list.each { |p| puts " #{p[:name]}" }
item ||= list.first
puts "\nUpdating name and description of server hardware type with name = '#{item['name']}' and description = name = '#{item['description']}'."
old_name = item['name']
old_description = item['description'] || ''
new_name = "#{old_name}_Updated"
new_description = "#{old_description}_Updated"
item.update(name: new_name, description: new_description)
item.retrieve!
puts "\nServer hardware type updated successfully!"
print_server_hardware_type(item)
puts "\nReturning to original state"
item.update(name: old_name, description: old_description)
item.retrieve!
puts "\nServer hardware type returned to original state!"
print_server_hardware_type(item)
# Removes a server hardware type if it is added through a server hardware
if server_hardware['uri']
server_hardware.remove if server_hardware
puts "\nAttempting removal of resource."
item.remove
puts "\nSucessfully removed."
end
| 35.8 | 143 | 0.754847 |
bbc5b7195f7ea055130385d52c3d1cb9c0cf90bd | 464 | require 'bundler/setup'
require './lib/die'
require './lib/cup'
require './lib/scorecard'
require './lib/player'
require 'rspec'
require 'pry'
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
# Disable RSpec exposing methods globally on `Module` and `main`
config.disable_monkey_patching!
config.expect_with :rspec do |c|
c.syntax = :expect
end
end
| 23.2 | 66 | 0.737069 |
1127dbd8b64ecac21256a31b2c40cb8b1533c792 | 250 | # frozen_string_literal: true
# @see SubRequest
class SubRequestDecorator < Draper::Decorator
delegate_all
# @return [String] e.g. '4pm'
def time
at.strftime '%l%P'
end
def html_class
'highlight' if needs_sub_in_group?
end
end
| 15.625 | 45 | 0.704 |
d5f03fdf4bbc451e3acfe0a2b09afb90c7ae679a | 202 | class Bee < Cask
url 'http://neat.io/bee/download.html'
appcast 'http://neat.io/appcasts/bee-appcast.xml'
homepage 'http://neat.io/bee/'
version 'latest'
sha256 :no_check
link 'Bee.app'
end
| 22.444444 | 51 | 0.688119 |
26ccba5ee3a2d8b9bac05fa2eaac681f58e866c5 | 952 | #
# Cookbook Name:: percona
# Recipe:: replication
#
require 'shellwords'
passwords = EncryptedPasswords.new(node, node['percona']['encrypted_data_bag'])
server = node['percona']['server']
replication_sql = server['replication']['replication_sql']
# define access grants
template replication_sql do
source 'replication.sql.erb'
variables(replication_password: passwords.replication_password)
owner 'root'
group 'root'
mode '0600'
sensitive true
only_if do
(server['replication']['host'] != '' || server['role'].include?('master')) && !::File.exist?(replication_sql)
end
end
root_pass = passwords.root_password.to_s
root_pass = Shellwords.escape(root_pass).prepend('-p') unless root_pass.empty?
execute 'mysql-set-replication' do # ~FC009 - `sensitive`
command "/usr/bin/mysql #{root_pass} < #{replication_sql}"
action :nothing
subscribes :run, resources("template[#{replication_sql}]"), :immediately
sensitive true
end
| 28 | 113 | 0.733193 |
3389f24839bc40a45e7eaabb3a353b0c9fbb0696 | 4,216 | RSpec.describe ResourceSharer do
before { allow(User).to receive_messages(:server_timezone => "UTC") }
describe "#share" do
subject do
described_class.new(:user => user,
:resource => resource_to_be_shared,
:tenants => tenants,
:features => features)
end
let(:user) do
FactoryBot.create(:user,
:role => "user",
:features => user_allowed_feature)
end
let(:user_allowed_feature) { "service" }
let(:resource_to_be_shared) { FactoryBot.create(:miq_template) }
let(:tenants) { [FactoryBot.create(:tenant)] }
let(:features) { :all }
context "with valid arguments" do
before do
expect(user.owned_shares.count).to eq(0)
expect(subject).to be_valid
subject.share
end
it "creates a share from the user to the tenant" do
expect(user.owned_shares.count).to eq(1)
end
end
context "product features" do
context "with the :all option on initialization" do
it "uses the user's current features" do
expect(subject.features).to match_array(user.miq_user_role.miq_product_features)
end
end
context "with an unauthorized product feature (across tree)" do
let(:features) { MiqProductFeature.find_by(:identifier => "host") }
let(:user_allowed_feature) { "service" }
before { EvmSpecHelper.seed_specific_product_features(%w(host service)) }
it "is invalid" do
expect(subject).not_to be_valid
expect(subject.errors.full_messages).to include(a_string_including("Features not permitted"))
end
end
context "with an unauthorized product feature (up tree)" do
let(:features) { MiqProductFeature.find_by(:identifier => "host") }
let(:user_allowed_feature) { "host_edit" }
before { EvmSpecHelper.seed_specific_product_features(%w(host)) }
it "is invalid" do
expect(subject).not_to be_valid
expect(subject.errors.full_messages).to include(a_string_including("Features not permitted"))
end
end
context "with a 'sees everything' product feature user" do
let(:features) { MiqProductFeature.find_by(:identifier => "host_edit") }
let(:user_allowed_feature) { "everything" }
before { EvmSpecHelper.seed_specific_product_features(%w(host_edit everything)) }
it "is valid" do
expect(subject).to be_valid
end
end
end
context "with an invalid resource" do
let(:resource_to_be_shared) { FactoryBot.build(:miq_group) }
it "is invalid" do
User.with_user(user) do
expect(subject).not_to be_valid
expect(subject.errors.full_messages).to include(a_string_including("Resource is not sharable"))
end
end
end
context "attempting to share a resource the user doesn't have access to via RBAC" do
let(:user) do
FactoryBot.create(:user,
:role => "user",
:features => user_allowed_feature,
:tenant => FactoryBot.create(:tenant, :name => "Tenant under root"))
end
let(:resource_to_be_shared) do
FactoryBot.create(:miq_template,
:tenant => FactoryBot.create(:tenant,
:name => "Sibling tenant"))
end
let(:tenants) { [user.current_tenant] } # Attempt to share a resource in Sibling tenant to one's own tenant
before { Tenant.seed }
it "is invalid" do
expect(subject).not_to be_valid
expect(subject.errors.full_messages).to include(a_string_including("is not authorized to share this resource"))
end
end
context "with tenants that aren't tenants" do
let(:tenants) { [FactoryBot.build(:miq_group)] }
it "is invalid" do
expect(subject).not_to be_valid
expect(subject.errors.full_messages)
.to include(a_string_including("Tenants must be an array of Tenant objects"))
end
end
end
end
| 34.842975 | 119 | 0.610294 |
e903f1b34f6bedd8a13b4d40c8536d8590ea87ab | 557 | module Admin::OverviewHelper
def render_events(events, later = false)
text = []
if events.any?
events.each_with_index { |evt, i| text << render(:partial => "#{evt.mode}_event", :locals => { :event => evt, :shaded => (i % 2 > 0), :later => later }) }
else
text << %(<li class="event-none shade">Nothing happening</li>)
end
%(<ul class="events">#{text.join}</ul>)
end
def event_time_for(event, long = false)
utc_to_local(event.created_at).send *(long ? [:to_ordinalized_s, :plain] : [:to_s, :time_only])
end
end
| 34.8125 | 160 | 0.614004 |
f834c0538a9e6009c358774dc880a61bd6f45b18 | 198 | class UserDecorator < Draper::Decorator
include Draper::LazyHelpers
delegate_all
alias user object
def name
return "You" if user == current_user
user.name || user.email
end
end
| 15.230769 | 40 | 0.712121 |
1ab394111fb24d2cc2c70fabffc29a9ccaa11f0e | 8,626 | TAP_MIGRATIONS = {
"adobe-air-sdk" => "homebrew/binary",
"afuse" => "homebrew/fuse",
"aimage" => "homebrew/boneyard",
"aplus" => "homebrew/boneyard",
"apple-gcc42" => "homebrew/dupes",
"appswitch" => "homebrew/binary",
"archivemount" => "homebrew/fuse",
"arpon" => "homebrew/boneyard",
"asm6" => "homebrew/boneyard",
"atari++" => "homebrew/x11",
"auctex" => "homebrew/tex",
"authexec" => "homebrew/boneyard",
"avfs" => "homebrew/fuse",
"aws-iam-tools" => "homebrew/boneyard",
"awsenv" => "Luzifer/tools",
"bbcp" => "homebrew/head-only",
"bcwipe" => "homebrew/boneyard",
"bindfs" => "homebrew/fuse",
"bochs" => "homebrew/x11",
"boost149" => "homebrew/versions",
"cantera" => "homebrew/science",
"cardpeek" => "homebrew/gui",
"catdoc" => "homebrew/boneyard",
"cdf" => "homebrew/boneyard",
"cdimgtools" => "homebrew/boneyard",
"celt" => "homebrew/boneyard",
"chktex" => "homebrew/tex",
"clam" => "homebrew/boneyard",
"clay" => "homebrew/boneyard",
"cloudfoundry-cli" => "pivotal/tap",
"clusterit" => "homebrew/x11",
"cmucl" => "homebrew/binary",
"comparepdf" => "homebrew/boneyard",
"connect" => "homebrew/boneyard",
"coremod" => "homebrew/boneyard",
"curlftpfs" => "homebrew/x11",
"cwm" => "homebrew/x11",
"dart" => "dart-lang/dart",
"datamash" => "homebrew/science",
"dbslayer" => "homebrew/boneyard",
"ddd" => "homebrew/x11",
"denyhosts" => "homebrew/boneyard",
"dgtal" => "homebrew/science",
"djmount" => "homebrew/fuse",
"dmenu" => "homebrew/x11",
"dotwrp" => "homebrew/science",
"drizzle" => "homebrew/boneyard",
"drush" => "homebrew/php",
"dsniff" => "homebrew/boneyard",
"dupx" => "homebrew/boneyard",
"dwm" => "homebrew/x11",
"dzen2" => "homebrew/x11",
"easy-tag" => "homebrew/gui",
"echoping" => "homebrew/boneyard",
"electric-fence" => "homebrew/boneyard",
"encfs" => "homebrew/fuse",
"ext2fuse" => "homebrew/fuse",
"ext4fuse" => "homebrew/fuse",
"fceux" => "homebrew/games",
"feh" => "homebrew/x11",
"ffts" => "homebrew/boneyard",
"figtoipe" => "homebrew/head-only",
"fleet-db" => "homebrew/boneyard",
"fox" => "homebrew/x11",
"freeglut" => "homebrew/x11",
"freerdp" => "homebrew/x11",
"fsv" => "homebrew/boneyard",
"fuse-zip" => "homebrew/fuse",
"fuse4x" => "homebrew/fuse",
"fuse4x-kext" => "homebrew/fuse",
"gant" => "homebrew/boneyard",
"gcsfuse" => "homebrew/fuse",
"gdrive" => "homebrew/boneyard",
"geda-gaf" => "homebrew/science",
"geeqie" => "homebrew/gui",
"geomview" => "homebrew/x11",
"ggobi" => "homebrew/science",
"giblib" => "homebrew/x11",
"git-encrypt" => "homebrew/boneyard",
"git-flow-clone" => "homebrew/boneyard",
"git-latexdiff" => "homebrew/tex",
"gitfs" => "homebrew/fuse",
"gle" => "homebrew/x11",
"gnunet" => "homebrew/boneyard",
"gobby" => "homebrew/gui",
"googlecl" => "homebrew/boneyard",
"gpredict" => "homebrew/x11",
"gptfdisk" => "homebrew/boneyard",
"grace" => "homebrew/x11",
"grads" => "homebrew/binary",
"graylog2-server" => "homebrew/boneyard",
"gromacs" => "homebrew/science",
"gsmartcontrol" => "homebrew/gui",
"gtk-chtheme" => "homebrew/gui",
"gtkglarea" => "homebrew/boneyard",
"gtkwave" => "homebrew/gui",
"guilt" => "homebrew/boneyard",
"gv" => "homebrew/x11",
"hatari" => "homebrew/x11",
"helios" => "spotify/public",
"hexchat" => "homebrew/gui",
"hllib" => "homebrew/boneyard",
"honeyd" => "homebrew/boneyard",
"hugs98" => "homebrew/boneyard",
"hwloc" => "homebrew/science",
"ifuse" => "homebrew/fuse",
"imake" => "homebrew/x11",
"inkscape" => "homebrew/gui",
"iojs" => "homebrew/versions",
"ipe" => "homebrew/boneyard",
"ipopt" => "homebrew/science",
"iptux" => "homebrew/gui",
"itsol" => "homebrew/science",
"iulib" => "homebrew/boneyard",
"jscoverage" => "homebrew/boneyard",
"jsl" => "homebrew/binary",
"jstalk" => "homebrew/boneyard",
"justniffer" => "homebrew/boneyard",
"kbtin" => "homebrew/boneyard",
"kerl" => "homebrew/head-only",
"kernagic" => "homebrew/gui",
"kismet" => "homebrew/boneyard",
"klavaro" => "homebrew/gui",
"kumofs" => "homebrew/boneyard",
"latex-mk" => "homebrew/tex",
"libdlna" => "homebrew/boneyard",
"libgtextutils" => "homebrew/science",
"libqxt" => "homebrew/boneyard",
"librets" => "homebrew/boneyard",
"libspotify" => "homebrew/binary",
"lilypond" => "homebrew/tex",
"lmutil" => "homebrew/binary",
"magit" => "homebrew/emacs",
"meld" => "homebrew/gui",
"mesalib-glw" => "homebrew/x11",
"mess" => "homebrew/games",
"metalua" => "homebrew/boneyard",
"mit-scheme" => "homebrew/x11",
"mlkit" => "homebrew/boneyard",
"morse" => "homebrew/x11",
"mp3fs" => "homebrew/fuse",
"mpio" => "homebrew/boneyard",
"mscgen" => "homebrew/x11",
"msgpack-rpc" => "homebrew/boneyard",
"mupdf" => "homebrew/x11",
"mysql-connector-odbc" => "homebrew/boneyard",
"mysql-proxy" => "homebrew/boneyard",
"mysqlreport" => "homebrew/boneyard",
"net6" => "homebrew/boneyard",
"newick-utils" => "homebrew/science",
"nlopt" => "homebrew/science",
"ntfs-3g" => "homebrew/fuse",
"octave" => "homebrew/science",
"opencv" => "homebrew/science",
"openfst" => "homebrew/science",
"opengrm-ngram" => "homebrew/science",
"ori" => "homebrew/fuse",
"p11-kit" => "homebrew/boneyard",
"pan" => "homebrew/boneyard",
"paq8px" => "homebrew/boneyard",
"par2tbb" => "homebrew/boneyard",
"pari" => "homebrew/x11",
"pathfinder" => "homebrew/boneyard",
"pcb" => "homebrew/science",
"pdf-tools" => "homebrew/emacs",
"pdf2image" => "homebrew/x11",
"pdfjam" => "homebrew/tex",
"pdftoipe" => "homebrew/head-only",
"pebble-sdk" => "pebble/pebble-sdk",
"pgplot" => "homebrew/x11",
"phash" => "homebrew/boneyard",
"pixie" => "homebrew/x11",
"pjsip" => "homebrew/boneyard",
"pocl" => "homebrew/science",
"pplatex" => "homebrew/tex",
"prooftree" => "homebrew/gui",
"pulse" => "homebrew/boneyard",
"pyenv-pip-rehash" => "homebrew/boneyard",
"pyxplot" => "homebrew/x11",
"qfits" => "homebrew/boneyard",
"qi" => "homebrew/boneyard",
"qiv" => "homebrew/boneyard",
"qrupdate" => "homebrew/science",
"rdesktop" => "homebrew/x11",
"rocket" => "homebrew/boneyard",
"rofs-filtered" => "homebrew/fuse",
"rubber" => "homebrew/tex",
"rxvt-unicode" => "homebrew/x11",
"s3-backer" => "homebrew/fuse",
"s3fs" => "homebrew/fuse",
"salt" => "homebrew/science",
"scantailor" => "homebrew/x11",
"sdelta3" => "homebrew/boneyard",
"sedna" => "homebrew/boneyard",
"shark" => "homebrew/science",
"shell.fm" => "homebrew/boneyard",
"simple-mtpfs" => "homebrew/fuse",
"sitecopy" => "homebrew/boneyard",
"slicot" => "homebrew/science",
"smartsim" => "homebrew/gui",
"solfege" => "homebrew/boneyard",
"sptk" => "homebrew/x11",
"sshfs" => "homebrew/fuse",
"stormfs" => "homebrew/fuse",
"sundials" => "homebrew/science",
"swi-prolog" => "homebrew/x11",
"sxiv" => "homebrew/x11",
"synfigstudio" => "homebrew/boneyard",
"syslog-ng" => "homebrew/boneyard",
"tabbed" => "homebrew/x11",
"telepathy-gabble" => "homebrew/boneyard",
"telepathy-glib" => "homebrew/boneyard",
"telepathy-idle" => "homebrew/boneyard",
"telepathy-mission-control" => "homebrew/boneyard",
"terminator" => "homebrew/gui",
"tetgen" => "homebrew/science",
"texmacs" => "homebrew/boneyard",
"texwrapper" => "homebrew/tex",
"threadscope" => "homebrew/gui",
"ticcutils" => "homebrew/science",
"tiger-vnc" => "homebrew/x11",
"timbl" => "homebrew/science",
"tmap" => "homebrew/boneyard",
"transmission-remote-gtk" => "homebrew/gui",
"tup" => "homebrew/fuse",
"uim" => "homebrew/x11",
"ume" => "homebrew/games",
"upnp-router-control" => "homebrew/gui",
"urweb" => "homebrew/boneyard",
"ushare" => "homebrew/boneyard",
"viewglob" => "homebrew/boneyard",
"vobcopy" => "homebrew/boneyard",
"wdfs" => "homebrew/fuse",
"whereami" => "homebrew/boneyard",
"why3" => "homebrew/tex",
"wkhtmltopdf" => "homebrew/boneyard",
"wmctrl" => "homebrew/x11",
"wopr" => "homebrew/science",
"wps2odt" => "homebrew/boneyard",
"x3270" => "homebrew/x11",
"xar" => "homebrew/dupes",
"xastir" => "homebrew/x11",
"xchat" => "homebrew/gui",
"xclip" => "homebrew/x11",
"xdotool" => "homebrew/x11",
"xdu" => "homebrew/x11",
"xmount" => "homebrew/fuse",
"xournal" => "homebrew/gui",
"xpa" => "homebrew/x11",
"xpdf" => "homebrew/x11",
"xplot" => "homebrew/x11",
"xspringies" => "homebrew/x11",
"xulrunner" => "homebrew/boneyard",
"yarp" => "homebrew/x11",
"ydict" => "homebrew/boneyard",
}
| 33.434109 | 53 | 0.608161 |
1af0b664ef8ce65aa094f9dd6be19c6b65153686 | 2,429 | # frozen_string_literal: true
RSpec.describe GraphQL::AnyCable do
subject do
AnycableSchema.execute(
query: query,
context: { channel: channel, subscription_id: subscription_id },
variables: {},
operation_name: "SomeSubscription",
)
end
let(:query) do
<<~GRAPHQL
subscription SomeSubscription { productUpdated { id } }
GRAPHQL
end
let(:expected_result) do
<<~JSON.strip
{"result":{"data":{"productUpdated":{"id":"1"}}},"more":true}
JSON
end
let(:channel) do
double
end
let(:anycable) { AnyCable.broadcast_adapter }
let(:subscription_id) do
"some-truly-random-number"
end
before do
allow(channel).to receive(:stream_from)
allow(channel).to receive(:params).and_return("channelId" => "ohmycables")
allow(anycable).to receive(:broadcast)
end
it "subscribes channel to stream updates from GraphQL subscription" do
subject
expect(channel).to have_received(:stream_from).with("graphql-subscription:#{subscription_id}")
end
it "broadcasts message when event is being triggered" do
subject
AnycableSchema.subscriptions.trigger(:product_updated, {}, { id: 1, title: "foo" })
expect(anycable).to have_received(:broadcast).with("graphql-subscription:#{subscription_id}", expected_result)
end
context "with multiple subscriptions in one query" do
let(:query) do
<<~GRAPHQL
subscription SomeSubscription {
productCreated { id title }
productUpdated { id }
}
GRAPHQL
end
context "triggering update event" do
it "broadcasts message only for update event" do
subject
AnycableSchema.subscriptions.trigger(:product_updated, {}, { id: 1, title: "foo" })
expect(anycable).to have_received(:broadcast).with("graphql-subscription:#{subscription_id}", expected_result)
end
end
context "triggering create event" do
let(:expected_result) do
<<~JSON.strip
{"result":{"data":{"productCreated":{"id":"1","title":"Gravizapa"}}},"more":true}
JSON
end
it "broadcasts message only for create event" do
subject
AnycableSchema.subscriptions.trigger(:product_created, {}, { id: 1, title: "Gravizapa" })
expect(anycable).to have_received(:broadcast).with("graphql-subscription:#{subscription_id}", expected_result)
end
end
end
end
| 28.244186 | 118 | 0.664059 |
182946e14997147fa1db32b830b897a25a871557 | 380 | require "nutrella/board_name_resolver"
require "nutrella/cache"
require "nutrella/command"
require "nutrella/configuration"
require "nutrella/developer_keys"
require "nutrella/task_board"
require "nutrella/task_board_name"
require "nutrella/version"
#
# A command line tool for associating a Trello board with the current git branch.
#
module Nutrella
extend DeveloperKeys
end
| 23.75 | 81 | 0.818421 |
bfc56ce45a69abf084d89b4b0782d974691a3f26 | 839 | module MoneyExample
class Money
attr_reader :amount, :currency
def initialize(amount, currency)
@amount = amount
@currency = currency
end
def equals?(another)
(self.amount == another.amount) && self.currency == (another.currency)
end
def times(multiplier)
MoneyExample::Money.new(amount * multiplier, currency)
end
def self.dollar(amount)
MoneyExample::Money.new(amount, "USD")
end
def self.swiss_franc(amount)
MoneyExample::Money.new(amount, "CHF")
end
def plus(addend)
MoneyExample::Sum.new(self, addend)
end
def reduce(bank, target_currency)
rate = bank.rate(self.currency, target_currency)
MoneyExample::Money.new(amount / rate, target_currency)
end
def to_s
"#{amount}, #{currency}"
end
end
end | 21.512821 | 76 | 0.644815 |
188033fb5179871f580457ab2d743d7b60d7ebce | 2,348 | shared_examples "a checksum implementation:" do |success_spec_matrix, fail_spec_matrix|
describe "of" do
success_spec_matrix.each do |spec_item|
it "calculates checksum: #{spec_item[0]} => #{spec_item[1]}" do
expect(described_class.of(spec_item[0])).to eq(spec_item[1])
end
end
fail_spec_matrix.each do |spec_item|
it "does not calculate checksum: #{spec_item[0]} => #{spec_item[1]}" do
expect(described_class.of(spec_item[0])).to_not eq(spec_item[1])
end
end
end
describe "valid?" do
success_spec_matrix.each do |spec_item|
spec_value = transform_spec_value(spec_item[0],spec_item[1])
it "returns true for #{spec_value}" do
expect(described_class.valid?(spec_value)).to be_truthy
end
end
fail_spec_matrix.each do |spec_item|
spec_value = transform_spec_value(spec_item[0],spec_item[1])
it "does not return true for #{spec_value}" do
expect(described_class.valid?(spec_value)).to_not be_truthy
end
end
end
describe "convert" do
success_spec_matrix.each do |spec_item|
spec_value = transform_spec_value(spec_item[0],spec_item[1])
it "transforms #{spec_item[0]} to #{spec_value}" do
expect(described_class.convert(spec_item[0])).to eq(spec_value)
end
end
fail_spec_matrix.each do |spec_item|
spec_value = transform_spec_value(spec_item[0],spec_item[1])
it "does not transform #{spec_item[0]} to #{spec_value}" do
expect(described_class.convert(spec_item[0])).to_not eq(spec_value)
end
end
end
context "invalid input" do
[12.34, true, false, nil, {}, [], Proc.new{}, Class.new, Module.new].each do |invalid_input|
it "#of raises an ArgumentError for #{invalid_input.inspect} (type: #{invalid_input.class})" do
expect{ described_class.of(invalid_input) }.to raise_error(ArgumentError)
end
it "#valid? raises an ArgumentError for #{invalid_input.inspect} (type: #{invalid_input.class})" do
expect{ described_class.valid?(invalid_input) }.to raise_error(ArgumentError)
end
it "#convert raises an ArgumentError for #{invalid_input.inspect} (type: #{invalid_input.class})" do
expect{ described_class.convert(invalid_input) }.to raise_error(ArgumentError)
end
end
end
end
| 36.123077 | 106 | 0.685264 |
ffe7be657e38348663a841e9f6f1493d6ad70e45 | 2,379 | # frozen_string_literal: true
require "json"
module Split
module Persistence
class CookieAdapter
def initialize(context)
@context = context
@request, @response = context.request, context.response
@cookies = @request.cookies
@expires = Time.now + cookie_length_config
end
def [](key)
hash[key.to_s]
end
def []=(key, value)
set_cookie(hash.merge!(key.to_s => value))
end
def delete(key)
set_cookie(hash.tap { |h| h.delete(key.to_s) })
end
def keys
hash.keys
end
private
def set_cookie(value = {})
cookie_key = :split.to_s
cookie_value = default_options.merge(value: JSON.generate(value))
if action_dispatch?
# The "send" is necessary when we call ab_test from the controller
# and thus @context is a rails controller, because then "cookies" is
# a private method.
@context.send(:cookies)[cookie_key] = cookie_value
else
set_cookie_via_rack(cookie_key, cookie_value)
end
end
def default_options
{ expires: @expires, path: '/' }
end
def set_cookie_via_rack(key, value)
delete_cookie_header!(@response.header, key, value)
Rack::Utils.set_cookie_header!(@response.header, key, value)
end
# Use Rack::Utils#make_delete_cookie_header after Rack 2.0.0
def delete_cookie_header!(header, key, value)
cookie_header = header['Set-Cookie']
case cookie_header
when nil, ''
cookies = []
when String
cookies = cookie_header.split("\n")
when Array
cookies = cookie_header
end
cookies.reject! { |cookie| cookie =~ /\A#{Rack::Utils.escape(key)}=/ }
header['Set-Cookie'] = cookies.join("\n")
end
def hash
@hash ||= begin
if cookies = @cookies[:split.to_s]
begin
JSON.parse(cookies)
rescue JSON::ParserError
{}
end
else
{}
end
end
end
def cookie_length_config
Split.configuration.persistence_cookie_length
end
def action_dispatch?
defined?(Rails) && @response.is_a?(ActionDispatch::Response)
end
end
end
end
| 25.042105 | 78 | 0.57377 |
1d4399f689dfee514aad3183bf5f4731fc140924 | 3,836 | require "spec_helper"
describe Mongoid::Relations::CounterCache do
describe '#reset_counters' do
context 'when counter is reset' do
let(:person) do
Person.create do |person|
person[:drugs_count] = 3
end
end
before do
Person.reset_counters person.id, :drugs
end
it 'returns zero' do
person.reload.drugs_count.should eq(0)
end
end
context 'when counter is reset with wrong id' do
it 'expect to raise an error' do
expect {
Person.reset_counters '1', :drugs
}.to raise_error
end
end
context 'when reset with invalid name' do
let(:person) do
Person.create
end
it 'expect to raise an error' do
expect {
Person.reset_counters person.id, :not_exist
}.to raise_error
end
end
context 'when counter gets messy' do
let(:person) do
Person.create
end
let!(:post) do
person.posts.create(title: "my first post")
end
before do
Person.update_counters(person.id, :posts_count => 10)
Person.reset_counters(person.id, :posts)
end
it 'resets to the right value' do
person.reload.posts_count.should eq(1)
end
end
end
describe '#update_counters' do
context 'when was 3 ' do
let(:person) do
Person.create do |person|
person[:drugs_count] = 3
end
end
context 'and update counter with 5' do
before do
Person.update_counters person.id, :drugs_count => 5
end
it 'return 8' do
person.reload.drugs_count.should eq(8)
end
end
context 'and update counter with -5' do
before do
Person.update_counters person.id, :drugs_count => -5
end
it 'return -2' do
person.reload.drugs_count.should eq(-2)
end
end
end
context 'when update with 2 and use a string argument' do
let(:person) { Person.create }
before do
Person.update_counters person.id, 'drugs_count' => 2
end
it 'returns 2' do
person.reload.drugs_count.should eq(2)
end
end
context 'when update more multiple counters' do
let(:person) { Person.create }
before do
Person.update_counters(person.id, :drugs_count => 2, :second_counter => 5)
end
it 'updates drugs_counter' do
person.reload.drugs_count.should eq(2)
end
it 'updates second_counter' do
person.reload.second_counter.should eq(5)
end
end
end
describe '#increment_counter' do
let(:person) { Person.create }
context 'when increment 3 times' do
before do
3.times { Person.increment_counter(:drugs_count, person.id) }
end
it 'returns 3' do
person.reload.drugs_count.should eq(3)
end
end
context 'when increment 3 times using string as argument' do
before do
3.times { Person.increment_counter('drugs_count', person.id) }
end
it 'returns 3' do
person.reload.drugs_count.should eq(3)
end
end
end
describe '#decrement_counter' do
let(:person) do
Person.create do |p|
p[:drugs_count] = 3
end
end
context 'when decrement 3 times' do
before do
3.times { Person.decrement_counter(:drugs_count, person.id) }
end
it 'returns 0' do
person.reload.drugs_count.should eq(0)
end
end
context 'when increment 3 times using string as argument' do
before do
3.times { Person.decrement_counter('drugs_count', person.id) }
end
it 'returns 0' do
person.reload.drugs_count.should eq(0)
end
end
end
end
| 20.513369 | 82 | 0.592544 |
385b04babcfa66dc5ca5d5d2b039aa49b03449bd | 20,093 | # frozen-string-literal: true
#
# The constraint_validations extension is designed to easily create database
# constraints inside create_table and alter_table blocks. It also adds
# relevant metadata about the constraints to a separate table, which the
# constraint_validations model plugin uses to setup automatic validations.
#
# To use this extension, you first need to load it into the database:
#
# DB.extension(:constraint_validations)
#
# Note that you should only need to do this when modifying the constraint
# validations (i.e. when migrating). You should probably not load this
# extension in general application code.
#
# You also need to make sure to add the metadata table for the automatic
# validations. By default, this table is called sequel_constraint_validations.
#
# DB.create_constraint_validations_table
#
# This table should only be created once. For new applications, you
# generally want to create it first, before creating any other application
# tables.
#
# Because migrations instance_exec the up and down blocks on a database,
# using this extension in a migration can be done via:
#
# Sequel.migration do
# up do
# extension(:constraint_validations)
# # ...
# end
# down do
# extension(:constraint_validations)
# # ...
# end
# end
#
# However, note that you cannot use change migrations with this extension,
# you need to use separate up/down migrations.
#
# The API for creating the constraints with automatic validations is
# similar to the validation_helpers model plugin API. However,
# instead of having separate validates_* methods, it just adds a validate
# method that accepts a block to the schema generators. Like the
# create_table and alter_table blocks, this block is instance_execed and
# offers its own DSL. Example:
#
# DB.create_table(:table) do
# Integer :id
# String :name
#
# validate do
# presence :id
# min_length 5, :name
# end
# end
#
# instance_exec is used in this case because create_table and alter_table
# already use instance_exec, so losing access to the surrounding receiver
# is not an issue.
#
# Here's a breakdown of the constraints created for each constraint validation
# method:
#
# All constraints except unique unless :allow_nil is true :: CHECK column IS NOT NULL
# presence (String column) :: CHECK trim(column) != ''
# exact_length 5 :: CHECK char_length(column) = 5
# min_length 5 :: CHECK char_length(column) >= 5
# max_length 5 :: CHECK char_length(column) <= 5
# length_range 3..5 :: CHECK char_length(column) >= 3 AND char_length(column) <= 5
# length_range 3...5 :: CHECK char_length(column) >= 3 AND char_length(column) < 5
# format /foo\\d+/ :: CHECK column ~ 'foo\\d+'
# format /foo\\d+/i :: CHECK column ~* 'foo\\d+'
# like 'foo%' :: CHECK column LIKE 'foo%' ESCAPE '\'
# ilike 'foo%' :: CHECK column ILIKE 'foo%' ESCAPE '\'
# includes ['a', 'b'] :: CHECK column IN ('a', 'b')
# includes [1, 2] :: CHECK column IN (1, 2)
# includes 3..5 :: CHECK column >= 3 AND column <= 5
# includes 3...5 :: CHECK column >= 3 AND column < 5
# operator :>, 1 :: CHECK column > 1
# operator :>=, 2 :: CHECK column >= 2
# operator :<, "M" :: CHECK column < 'M'
# operator :<=, 'K' :: CHECK column <= 'K'
# unique :: UNIQUE (column)
#
# There are some additional API differences:
#
# * Only the :message and :allow_nil options are respected. The :allow_blank
# and :allow_missing options are not respected.
# * A new option, :name, is respected, for providing the name of the constraint. It is highly
# recommended that you provide a name for all constraint validations, as
# otherwise, it is difficult to drop the constraints later.
# * The includes validation only supports an array of strings, and array of
# integers, and a range of integers.
# * There are like and ilike validations, which are similar to the format
# validation but use a case sensitive or case insensitive LIKE pattern. LIKE
# patters are very simple, so many regexp patterns cannot be expressed by
# them, but only a couple databases (PostgreSQL and MySQL) support regexp
# patterns.
# * The operator validation only supports >, >=, <, and <= operators, and the
# argument must be a string or an integer.
# * When using the unique validation, column names cannot have embedded commas.
# For similar reasons, when using an includes validation with an array of
# strings, none of the strings in the array can have embedded commas.
# * The unique validation does not support an arbitrary number of columns.
# For a single column, just the symbol should be used, and for an array
# of columns, an array of symbols should be used. There is no support
# for creating two separate unique validations for separate columns in
# a single call.
# * A drop method can be called with a constraint name in a alter_table
# validate block to drop an existing constraint and the related
# validation metadata.
# * While it is allowed to create a presence constraint with :allow_nil
# set to true, doing so does not create a constraint unless the column
# has String type.
#
# Note that this extension has the following issues on certain databases:
#
# * MySQL does not support check constraints (they are parsed but ignored),
# so using this extension does not actually set up constraints on MySQL,
# except for the unique constraint. It can still be used on MySQL to
# add the validation metadata so that the plugin can setup automatic
# validations.
# * On SQLite, adding constraints to a table is not supported, so it must
# be emulated by dropping the table and recreating it with the constraints.
# If you want to use this plugin on SQLite with an alter_table block,
# you should drop all constraint validation metadata using
# <tt>drop_constraint_validations_for(:table=>'table')</tt>, and then
# readd all constraints you want to use inside the alter table block,
# making no other changes inside the alter_table block.
#
# Related module: Sequel::ConstraintValidations
#
module Sequel
module ConstraintValidations
# The default table name used for the validation metadata.
DEFAULT_CONSTRAINT_VALIDATIONS_TABLE = :sequel_constraint_validations
OPERATORS = {:< => :lt, :<= => :lte, :> => :gt, :>= => :gte}.freeze
REVERSE_OPERATOR_MAP = {:str_lt => :<, :str_lte => :<=, :str_gt => :>, :str_gte => :>=,
:int_lt => :<, :int_lte => :<=, :int_gt => :>, :int_gte => :>=}.freeze
# Set the default validation metadata table name if it has not already
# been set.
def self.extended(db)
db.constraint_validations_table ||= DEFAULT_CONSTRAINT_VALIDATIONS_TABLE
end
# This is the DSL class used for the validate block inside create_table and
# alter_table.
class Generator
# Store the schema generator that encloses this validates block.
def initialize(generator)
@generator = generator
end
# Create constraint validation methods that don't take an argument
%w'presence unique'.each do |v|
class_eval(<<-END, __FILE__, __LINE__+1)
def #{v}(columns, opts=OPTS)
@generator.validation({:type=>:#{v}, :columns=>Array(columns)}.merge!(opts))
end
END
end
# Create constraint validation methods that take an argument
%w'exact_length min_length max_length length_range format like ilike includes'.each do |v|
class_eval(<<-END, __FILE__, __LINE__+1)
def #{v}(arg, columns, opts=OPTS)
@generator.validation({:type=>:#{v}, :columns=>Array(columns), :arg=>arg}.merge!(opts))
end
END
end
# Create operator validation. The op should be either +:>+, +:>=+, +:<+, or +:<=+, and
# the arg should be either a string or an integer.
def operator(op, arg, columns, opts=OPTS)
raise Error, "invalid operator (#{op}) used when creating operator validation" unless suffix = OPERATORS[op]
prefix = case arg
when String
"str"
when Integer
"int"
else
raise Error, "invalid argument (#{arg.inspect}) used when creating operator validation"
end
@generator.validation({:type=>:"#{prefix}_#{suffix}", :columns=>Array(columns), :arg=>arg}.merge!(opts))
end
# Given the name of a constraint, drop that constraint from the database,
# and remove the related validation metadata.
def drop(constraint)
@generator.validation({:type=>:drop, :name=>constraint})
end
# Alias of instance_exec for a nicer API.
def process(&block)
instance_exec(&block)
end
end
# Additional methods for the create_table generator to support constraint validations.
module CreateTableGeneratorMethods
# An array of stored validation metadata, used later by the database to create
# constraints.
attr_reader :validations
# Add a validation metadata hash to the stored array.
def validation(opts)
@validations << opts
end
# Call into the validate DSL for creating constraint validations.
def validate(&block)
Generator.new(self).process(&block)
end
end
# Additional methods for the alter_table generator to support constraint validations,
# used to give it a more similar API to the create_table generator.
module AlterTableGeneratorMethods
include CreateTableGeneratorMethods
# Alias of add_constraint for similarity to create_table generator.
def constraint(*args)
add_constraint(*args)
end
# Alias of add_unique_constraint for similarity to create_table generator.
def unique(*args)
add_unique_constraint(*args)
end
end
# The name of the table storing the validation metadata. If modifying this
# from the default, this should be changed directly after loading the
# extension into the database
attr_accessor :constraint_validations_table
# Create the table storing the validation metadata for all of the
# constraints created by this extension.
def create_constraint_validations_table
create_table(constraint_validations_table) do
String :table, :null=>false
String :constraint_name
String :validation_type, :null=>false
String :column, :null=>false
String :argument
String :message
TrueClass :allow_nil
end
end
# Modify the default create_table generator to include
# the constraint validation methods.
def create_table_generator(&block)
super do
extend CreateTableGeneratorMethods
@validations = []
instance_exec(&block) if block
end
end
# Drop the constraint validations table.
def drop_constraint_validations_table
drop_table(constraint_validations_table)
end
# Delete validation metadata for specific constraints. At least
# one of the following options should be specified:
#
# :table :: The table containing the constraint
# :column :: The column affected by the constraint
# :constraint :: The name of the related constraint
#
# The main reason for this method is when dropping tables
# or columns. If you have previously defined a constraint
# validation on the table or column, you should delete the
# related metadata when dropping the table or column.
# For a table, this isn't a big issue, as it will just result
# in some wasted space, but for columns, if you don't drop
# the related metadata, it could make it impossible to save
# rows, since a validation for a nonexistent column will be
# created.
def drop_constraint_validations_for(opts=OPTS)
ds = from(constraint_validations_table)
if table = opts[:table]
ds = ds.where(:table=>constraint_validations_literal_table(table))
end
if column = opts[:column]
ds = ds.where(:column=>column.to_s)
end
if constraint = opts[:constraint]
ds = ds.where(:constraint_name=>constraint.to_s)
end
unless table || column || constraint
raise Error, "must specify :table, :column, or :constraint when dropping constraint validations"
end
ds.delete
end
# Modify the default alter_table generator to include
# the constraint validation methods.
def alter_table_generator(&block)
super do
extend AlterTableGeneratorMethods
@validations = []
instance_exec(&block) if block
end
end
private
# After running all of the table alteration statements,
# if there were any constraint validations, run table alteration
# statements to create related constraints. This is purposely
# run after the other statements, as the presence validation
# in alter table requires introspecting the modified model
# schema.
def apply_alter_table_generator(name, generator)
super
unless generator.validations.empty?
gen = alter_table_generator
process_generator_validations(name, gen, generator.validations)
apply_alter_table(name, gen.operations)
end
end
# The value of a blank string. An empty string by default, but nil
# on Oracle as Oracle treats the empty string as NULL.
def blank_string_value
if database_type == :oracle
nil
else
''
end
end
# Return an unquoted literal form of the table name.
# This allows the code to handle schema qualified tables,
# without quoting all table names.
def constraint_validations_literal_table(table)
dataset.with_quote_identifiers(false).literal(table)
end
# Before creating the table, add constraints for all of the
# generators validations to the generator.
def create_table_from_generator(name, generator, options)
unless generator.validations.empty?
process_generator_validations(name, generator, generator.validations)
end
super
end
# For the given table, generator, and validations, add constraints
# to the generator for each of the validations, as well as adding
# validation metadata to the constraint validations table.
def process_generator_validations(table, generator, validations)
drop_rows = []
rows = validations.map do |val|
columns, arg, constraint, validation_type, message, allow_nil = val.values_at(:columns, :arg, :name, :type, :message, :allow_nil)
case validation_type
when :presence
string_check = columns.select{|c| generator_string_column?(generator, table, c)}.map{|c| [Sequel.trim(c), blank_string_value]}
generator_add_constraint_from_validation(generator, val, (Sequel.negate(string_check) unless string_check.empty?))
when :exact_length
generator_add_constraint_from_validation(generator, val, Sequel.&(*columns.map{|c| {Sequel.char_length(c) => arg}}))
when :min_length
generator_add_constraint_from_validation(generator, val, Sequel.&(*columns.map{|c| Sequel.char_length(c) >= arg}))
when :max_length
generator_add_constraint_from_validation(generator, val, Sequel.&(*columns.map{|c| Sequel.char_length(c) <= arg}))
when *REVERSE_OPERATOR_MAP.keys
generator_add_constraint_from_validation(generator, val, Sequel.&(*columns.map{|c| Sequel.identifier(c).public_send(REVERSE_OPERATOR_MAP[validation_type], arg)}))
when :length_range
op = arg.exclude_end? ? :< : :<=
generator_add_constraint_from_validation(generator, val, Sequel.&(*columns.map{|c| (Sequel.char_length(c) >= arg.begin) & Sequel.char_length(c).public_send(op, arg.end)}))
arg = "#{arg.begin}..#{'.' if arg.exclude_end?}#{arg.end}"
when :format
generator_add_constraint_from_validation(generator, val, Sequel.&(*columns.map{|c| {c => arg}}))
if arg.casefold?
validation_type = :iformat
end
arg = arg.source
when :includes
generator_add_constraint_from_validation(generator, val, Sequel.&(*columns.map{|c| {c => arg}}))
if arg.is_a?(Range)
if arg.begin.is_a?(Integer) && arg.end.is_a?(Integer)
validation_type = :includes_int_range
arg = "#{arg.begin}..#{'.' if arg.exclude_end?}#{arg.end}"
else
raise Error, "validates includes with a range only supports integers currently, cannot handle: #{arg.inspect}"
end
elsif arg.is_a?(Array)
if arg.all?{|x| x.is_a?(Integer)}
validation_type = :includes_int_array
elsif arg.all?{|x| x.is_a?(String)}
validation_type = :includes_str_array
else
raise Error, "validates includes with an array only supports strings and integers currently, cannot handle: #{arg.inspect}"
end
arg = arg.join(',')
else
raise Error, "validates includes only supports arrays and ranges currently, cannot handle: #{arg.inspect}"
end
when :like, :ilike
generator_add_constraint_from_validation(generator, val, Sequel.&(*columns.map{|c| Sequel.public_send(validation_type, c, arg)}))
when :unique
generator.unique(columns, :name=>constraint)
columns = [columns.join(',')]
when :drop
if generator.is_a?(Sequel::Schema::AlterTableGenerator)
unless constraint
raise Error, 'cannot drop a constraint validation without a constraint name'
end
generator.drop_constraint(constraint)
drop_rows << [constraint_validations_literal_table(table), constraint.to_s]
columns = []
else
raise Error, 'cannot drop a constraint validation in a create_table generator'
end
else
raise Error, "invalid or missing validation type: #{val.inspect}"
end
columns.map do |column|
{:table=>constraint_validations_literal_table(table), :constraint_name=>(constraint.to_s if constraint), :validation_type=>validation_type.to_s, :column=>column.to_s, :argument=>(arg.to_s if arg), :message=>(message.to_s if message), :allow_nil=>allow_nil}
end
end
ds = from(:sequel_constraint_validations)
unless drop_rows.empty?
ds.where([:table, :constraint_name]=>drop_rows).delete
end
ds.multi_insert(rows.flatten)
end
# Add the constraint to the generator, including a NOT NULL constraint
# for all columns unless the :allow_nil option is given.
def generator_add_constraint_from_validation(generator, val, cons)
if val[:allow_nil]
nil_cons = Sequel[val[:columns].map{|c| [c, nil]}]
cons = Sequel.|(nil_cons, cons) if cons
else
nil_cons = Sequel.negate(val[:columns].map{|c| [c, nil]})
cons = cons ? Sequel.&(nil_cons, cons) : nil_cons
end
if cons
generator.constraint(val[:name], cons)
end
end
# Introspect the generator to determine if column
# created is a string or not.
def generator_string_column?(generator, table, c)
if generator.is_a?(Sequel::Schema::AlterTableGenerator)
# This is the alter table case, which runs after the
# table has been altered, so just check the database
# schema for the column.
schema(table).each do |col, sch|
if col == c
return sch[:type] == :string
end
end
false
else
# This is the create table case, check the metadata
# for the column to be created to see if it is a string.
generator.columns.each do |col|
if col[:name] == c
return [String, :text, :varchar].include?(col[:type])
end
end
false
end
end
end
Database.register_extension(:constraint_validations, ConstraintValidations)
end
| 41.343621 | 266 | 0.678047 |
8798f3c202bca9653e6cf9636d9593301f2bbceb | 325 | require "action_view"
require "action_controller"
require "deface/template_helper"
require "deface/original_validator"
require "deface/applicator"
require "deface/search"
require "deface/override"
require "deface/parser"
require "deface/environment"
module Deface
if defined?(Rails)
require "deface/railtie"
end
end
| 20.3125 | 35 | 0.796923 |
f72db972038c7bb6a8ae8eda39795015857a58c0 | 129 | class AddHandicapTypeToTeam < ActiveRecord::Migration[5.0]
def change
add_column :teams, :handicap_type, :string
end
end
| 21.5 | 58 | 0.75969 |
28bdf5faf37e5adca05504915677556ffde3fb51 | 21,060 | # frozen_string_literal: true
Doorkeeper.configure do
# Change the ORM that doorkeeper will use (requires ORM extensions installed).
# Check the list of supported ORMs here: https://github.com/doorkeeper-gem/doorkeeper#orms
orm :active_record
# This block will be called to check whether the resource owner is authenticated or not.
resource_owner_authenticator do
raise "Please configure doorkeeper resource_owner_authenticator block located in #{__FILE__}"
# Put your resource owner authentication logic here.
# Example implementation:
# User.find_by(id: session[:user_id]) || redirect_to(new_user_session_url)
end
# If you didn't skip applications controller from Doorkeeper routes in your application routes.rb
# file then you need to declare this block in order to restrict access to the web interface for
# adding oauth authorized applications. In other case it will return 403 Forbidden response
# every time somebody will try to access the admin web interface.
#
# admin_authenticator do
# # Put your admin authentication logic here.
# # Example implementation:
#
# if current_user
# head :forbidden unless current_user.admin?
# else
# redirect_to sign_in_url
# end
# end
# You can use your own model classes if you need to extend (or even override) default
# Doorkeeper models such as `Application`, `AccessToken` and `AccessGrant.
#
# Be default Doorkeeper ActiveRecord ORM uses it's own classes:
#
# access_token_class "Doorkeeper::AccessToken"
# access_grant_class "Doorkeeper::AccessGrant"
# application_class "Doorkeeper::Application"
#
# Don't forget to include Doorkeeper ORM mixins into your custom models:
#
# * ::Doorkeeper::Orm::ActiveRecord::Mixins::AccessToken - for access token
# * ::Doorkeeper::Orm::ActiveRecord::Mixins::AccessGrant - for access grant
# * ::Doorkeeper::Orm::ActiveRecord::Mixins::Application - for application (OAuth2 clients)
#
# For example:
#
# access_token_class "MyAccessToken"
#
# class MyAccessToken < ApplicationRecord
# include ::Doorkeeper::Orm::ActiveRecord::Mixins::AccessToken
#
# self.table_name = "hey_i_wanna_my_name"
#
# def destroy_me!
# destroy
# end
# end
# Enables polymorphic Resource Owner association for Access Tokens and Access Grants.
# By default this option is disabled.
#
# Make sure you properly setup you database and have all the required columns (run
# `bundle exec rails generate doorkeeper:enable_polymorphic_resource_owner` and execute Rails
# migrations).
#
# If this option enabled, Doorkeeper will store not only Resource Owner primary key
# value, but also it's type (class name). See "Polymorphic Associations" section of
# Rails guides: https://guides.rubyonrails.org/association_basics.html#polymorphic-associations
#
# [NOTE] If you apply this option on already existing project don't forget to manually
# update `resource_owner_type` column in the database and fix migration template as it will
# set NOT NULL constraint for Access Grants table.
#
# use_polymorphic_resource_owner
# If you are planning to use Doorkeeper in Rails 5 API-only application, then you might
# want to use API mode that will skip all the views management and change the way how
# Doorkeeper responds to a requests.
#
# api_only
# Enforce token request content type to application/x-www-form-urlencoded.
# It is not enabled by default to not break prior versions of the gem.
#
# enforce_content_type
# Authorization Code expiration time (default: 10 minutes).
#
# authorization_code_expires_in 10.minutes
# Access token expiration time (default: 2 hours).
# If you want to disable expiration, set this to `nil`.
#
# access_token_expires_in 2.hours
# Assign custom TTL for access tokens. Will be used instead of access_token_expires_in
# option if defined. In case the block returns `nil` value Doorkeeper fallbacks to
# +access_token_expires_in+ configuration option value. If you really need to issue a
# non-expiring access token (which is not recommended) then you need to return
# Float::INFINITY from this block.
#
# `context` has the following properties available:
#
# * `client` - the OAuth client application (see Doorkeeper::OAuth::Client)
# * `grant_type` - the grant type of the request (see Doorkeeper::OAuth)
# * `scopes` - the requested scopes (see Doorkeeper::OAuth::Scopes)
# * `resource_owner` - authorized resource owner instance (if present)
#
# custom_access_token_expires_in do |context|
# context.client.additional_settings.implicit_oauth_expiration
# end
# Use a custom class for generating the access token.
# See https://doorkeeper.gitbook.io/guides/configuration/other-configurations#custom-access-token-generator
#
# access_token_generator '::Doorkeeper::JWT'
# The controller +Doorkeeper::ApplicationController+ inherits from.
# Defaults to +ActionController::Base+ unless +api_only+ is set, which changes the default to
# +ActionController::API+. The return value of this option must be a stringified class name.
# See https://doorkeeper.gitbook.io/guides/configuration/other-configurations#custom-base-controller
#
# base_controller 'ApplicationController'
# Reuse access token for the same resource owner within an application (disabled by default).
#
# This option protects your application from creating new tokens before old valid one becomes
# expired so your database doesn't bloat. Keep in mind that when this option is `on` Doorkeeper
# doesn't updates existing token expiration time, it will create a new token instead.
# Rationale: https://github.com/doorkeeper-gem/doorkeeper/issues/383
#
# You can not enable this option together with +hash_token_secrets+.
#
# reuse_access_token
# In case you enabled `reuse_access_token` option Doorkeeper will try to find matching
# token using `matching_token_for` Access Token API that searches for valid records
# in batches in order not to pollute the memory with all the database records. By default
# Doorkeeper uses batch size of 10 000 records. You can increase or decrease this value
# depending on your needs and server capabilities.
#
# token_lookup_batch_size 10_000
# Set a limit for token_reuse if using reuse_access_token option
#
# This option limits token_reusability to some extent.
# If not set then access_token will be reused unless it expires.
# Rationale: https://github.com/doorkeeper-gem/doorkeeper/issues/1189
#
# This option should be a percentage(i.e. (0,100])
#
# token_reuse_limit 100
# Only allow one valid access token obtained via client credentials
# per client. If a new access token is obtained before the old one
# expired, the old one gets revoked (disabled by default)
#
# When enabling this option, make sure that you do not expect multiple processes
# using the same credentials at the same time (e.g. web servers spanning
# multiple machines and/or processes).
#
# revoke_previous_client_credentials_token
# Hash access and refresh tokens before persisting them.
# This will disable the possibility to use +reuse_access_token+
# since plain values can no longer be retrieved.
#
# Note: If you are already a user of doorkeeper and have existing tokens
# in your installation, they will be invalid without adding 'fallback: :plain'.
#
# hash_token_secrets
# By default, token secrets will be hashed using the
# +Doorkeeper::Hashing::SHA256+ strategy.
#
# If you wish to use another hashing implementation, you can override
# this strategy as follows:
#
# hash_token_secrets using: '::Doorkeeper::Hashing::MyCustomHashImpl'
#
# Keep in mind that changing the hashing function will invalidate all existing
# secrets, if there are any.
# Hash application secrets before persisting them.
#
# hash_application_secrets
#
# By default, applications will be hashed
# with the +Doorkeeper::SecretStoring::SHA256+ strategy.
#
# If you wish to use bcrypt for application secret hashing, uncomment
# this line instead:
#
# hash_application_secrets using: '::Doorkeeper::SecretStoring::BCrypt'
# When the above option is enabled, and a hashed token or secret is not found,
# you can allow to fall back to another strategy. For users upgrading
# doorkeeper and wishing to enable hashing, you will probably want to enable
# the fallback to plain tokens.
#
# This will ensure that old access tokens and secrets
# will remain valid even if the hashing above is enabled.
#
# This can be done by adding 'fallback: plain', e.g. :
#
# hash_application_secrets using: '::Doorkeeper::SecretStoring::BCrypt', fallback: :plain
# Issue access tokens with refresh token (disabled by default), you may also
# pass a block which accepts `context` to customize when to give a refresh
# token or not. Similar to +custom_access_token_expires_in+, `context` has
# the following properties:
#
# `client` - the OAuth client application (see Doorkeeper::OAuth::Client)
# `grant_type` - the grant type of the request (see Doorkeeper::OAuth)
# `scopes` - the requested scopes (see Doorkeeper::OAuth::Scopes)
#
# use_refresh_token
# Provide support for an owner to be assigned to each registered application (disabled by default)
# Optional parameter confirmation: true (default: false) if you want to enforce ownership of
# a registered application
# NOTE: you must also run the rails g doorkeeper:application_owner generator
# to provide the necessary support
#
# enable_application_owner confirmation: false
# Define access token scopes for your provider
# For more information go to
# https://doorkeeper.gitbook.io/guides/ruby-on-rails/scopes
#
# default_scopes :public
# optional_scopes :write, :update
# Allows to restrict only certain scopes for grant_type.
# By default, all the scopes will be available for all the grant types.
#
# Keys to this hash should be the name of grant_type and
# values should be the array of scopes for that grant type.
# Note: scopes should be from configured_scopes (i.e. default or optional)
#
# scopes_by_grant_type password: [:write], client_credentials: [:update]
# Forbids creating/updating applications with arbitrary scopes that are
# not in configuration, i.e. +default_scopes+ or +optional_scopes+.
# (disabled by default)
#
# enforce_configured_scopes
# Change the way client credentials are retrieved from the request object.
# By default it retrieves first from the `HTTP_AUTHORIZATION` header, then
# falls back to the `:client_id` and `:client_secret` params from the `params` object.
# Check out https://github.com/doorkeeper-gem/doorkeeper/wiki/Changing-how-clients-are-authenticated
# for more information on customization
#
# client_credentials :from_basic, :from_params
# Change the way access token is authenticated from the request object.
# By default it retrieves first from the `HTTP_AUTHORIZATION` header, then
# falls back to the `:access_token` or `:bearer_token` params from the `params` object.
# Check out https://github.com/doorkeeper-gem/doorkeeper/wiki/Changing-how-clients-are-authenticated
# for more information on customization
#
# access_token_methods :from_bearer_authorization, :from_access_token_param, :from_bearer_param
# Forces the usage of the HTTPS protocol in non-native redirect uris (enabled
# by default in non-development environments). OAuth2 delegates security in
# communication to the HTTPS protocol so it is wise to keep this enabled.
#
# Callable objects such as proc, lambda, block or any object that responds to
# #call can be used in order to allow conditional checks (to allow non-SSL
# redirects to localhost for example).
#
# force_ssl_in_redirect_uri !Rails.env.development?
#
# force_ssl_in_redirect_uri { |uri| uri.host != 'localhost' }
# Specify what redirect URI's you want to block during Application creation.
# Any redirect URI is whitelisted by default.
#
# You can use this option in order to forbid URI's with 'javascript' scheme
# for example.
#
# forbid_redirect_uri { |uri| uri.scheme.to_s.downcase == 'javascript' }
# Allows to set blank redirect URIs for Applications in case Doorkeeper configured
# to use URI-less OAuth grant flows like Client Credentials or Resource Owner
# Password Credentials. The option is on by default and checks configured grant
# types, but you **need** to manually drop `NOT NULL` constraint from `redirect_uri`
# column for `oauth_applications` database table.
#
# You can completely disable this feature with:
#
# allow_blank_redirect_uri false
#
# Or you can define your custom check:
#
# allow_blank_redirect_uri do |grant_flows, client|
# client.superapp?
# end
# Specify how authorization errors should be handled.
# By default, doorkeeper renders json errors when access token
# is invalid, expired, revoked or has invalid scopes.
#
# If you want to render error response yourself (i.e. rescue exceptions),
# set +handle_auth_errors+ to `:raise` and rescue Doorkeeper::Errors::InvalidToken
# or following specific errors:
#
# Doorkeeper::Errors::TokenForbidden, Doorkeeper::Errors::TokenExpired,
# Doorkeeper::Errors::TokenRevoked, Doorkeeper::Errors::TokenUnknown
#
# handle_auth_errors :raise
# Customize token introspection response.
# Allows to add your own fields to default one that are required by the OAuth spec
# for the introspection response. It could be `sub`, `aud` and so on.
# This configuration option can be a proc, lambda or any Ruby object responds
# to `.call` method and result of it's invocation must be a Hash.
#
# custom_introspection_response do |token, context|
# {
# "sub": "Z5O3upPC88QrAjx00dis",
# "aud": "https://protected.example.net/resource",
# "username": User.find(token.resource_owner_id).username
# }
# end
#
# or
#
# custom_introspection_response CustomIntrospectionResponder
# Specify what grant flows are enabled in array of Strings. The valid
# strings and the flows they enable are:
#
# "authorization_code" => Authorization Code Grant Flow
# "implicit" => Implicit Grant Flow
# "password" => Resource Owner Password Credentials Grant Flow
# "client_credentials" => Client Credentials Grant Flow
#
# If not specified, Doorkeeper enables authorization_code and
# client_credentials.
#
# implicit and password grant flows have risks that you should understand
# before enabling:
# http://tools.ietf.org/html/rfc6819#section-4.4.2
# http://tools.ietf.org/html/rfc6819#section-4.4.3
#
# grant_flows %w[authorization_code client_credentials]
# Allows to customize OAuth grant flows that +each+ application support.
# You can configure a custom block (or use a class respond to `#call`) that must
# return `true` in case Application instance supports requested OAuth grant flow
# during the authorization request to the server. This configuration +doesn't+
# set flows per application, it only allows to check if application supports
# specific grant flow.
#
# For example you can add an additional database column to `oauth_applications` table,
# say `t.array :grant_flows, default: []`, and store allowed grant flows that can
# be used with this application there. Then when authorization requested Doorkeeper
# will call this block to check if specific Application (passed with client_id and/or
# client_secret) is allowed to perform the request for the specific grant type
# (authorization, password, client_credentials, etc).
#
# Example of the block:
#
# ->(flow, client) { client.grant_flows.include?(flow) }
#
# In case this option invocation result is `false`, Doorkeeper server returns
# :unauthorized_client error and stops the request.
#
# @param allow_grant_flow_for_client [Proc] Block or any object respond to #call
# @return [Boolean] `true` if allow or `false` if forbid the request
#
# allow_grant_flow_for_client do |grant_flow, client|
# # `grant_flows` is an Array column with grant
# # flows that application supports
#
# client.grant_flows.include?(grant_flow)
# end
# If you need arbitrary Resource Owner-Client authorization you can enable this option
# and implement the check your need. Config option must respond to #call and return
# true in case resource owner authorized for the specific application or false in other
# cases.
#
# Be default all Resource Owners are authorized to any Client (application).
#
# authorize_resource_owner_for_client do |client, resource_owner|
# resource_owner.admin? || client.owners_whitelist.include?(resource_owner)
# end
# Hook into the strategies' request & response life-cycle in case your
# application needs advanced customization or logging:
#
# before_successful_strategy_response do |request|
# puts "BEFORE HOOK FIRED! #{request}"
# end
#
# after_successful_strategy_response do |request, response|
# puts "AFTER HOOK FIRED! #{request}, #{response}"
# end
# Hook into Authorization flow in order to implement Single Sign Out
# or add any other functionality. Inside the block you have an access
# to `controller` (authorizations controller instance) and `context`
# (Doorkeeper::OAuth::Hooks::Context instance) which provides pre auth
# or auth objects with issued token based on hook type (before or after).
#
# before_successful_authorization do |controller, context|
# Rails.logger.info(controller.request.params.inspect)
#
# Rails.logger.info(context.pre_auth.inspect)
# end
#
# after_successful_authorization do |controller, context|
# controller.session[:logout_urls] <<
# Doorkeeper::Application
# .find_by(controller.request.params.slice(:redirect_uri))
# .logout_uri
#
# Rails.logger.info(context.auth.inspect)
# Rails.logger.info(context.issued_token)
# end
# Under some circumstances you might want to have applications auto-approved,
# so that the user skips the authorization step.
# For example if dealing with a trusted application.
#
# skip_authorization do |resource_owner, client|
# client.superapp? or resource_owner.admin?
# end
# Configure custom constraints for the Token Introspection request.
# By default this configuration option allows to introspect a token by another
# token of the same application, OR to introspect the token that belongs to
# authorized client (from authenticated client) OR when token doesn't
# belong to any client (public token). Otherwise requester has no access to the
# introspection and it will return response as stated in the RFC.
#
# Block arguments:
#
# @param token [Doorkeeper::AccessToken]
# token to be introspected
#
# @param authorized_client [Doorkeeper::Application]
# authorized client (if request is authorized using Basic auth with
# Client Credentials for example)
#
# @param authorized_token [Doorkeeper::AccessToken]
# Bearer token used to authorize the request
#
# In case the block returns `nil` or `false` introspection responses with 401 status code
# when using authorized token to introspect, or you'll get 200 with { "active": false } body
# when using authorized client to introspect as stated in the
# RFC 7662 section 2.2. Introspection Response.
#
# Using with caution:
# Keep in mind that these three parameters pass to block can be nil as following case:
# `authorized_client` is nil if and only if `authorized_token` is present, and vice versa.
# `token` will be nil if and only if `authorized_token` is present.
# So remember to use `&` or check if it is present before calling method on
# them to make sure you doesn't get NoMethodError exception.
#
# You can define your custom check:
#
# allow_token_introspection do |token, authorized_client, authorized_token|
# if authorized_token
# # customize: require `introspection` scope
# authorized_token.application == token&.application ||
# authorized_token.scopes.include?("introspection")
# elsif token.application
# # `protected_resource` is a new database boolean column, for example
# authorized_client == token.application || authorized_client.protected_resource?
# else
# # public token (when token.application is nil, token doesn't belong to any application)
# true
# end
# end
#
# Or you can completely disable any token introspection:
#
# allow_token_introspection false
#
# If you need to block the request at all, then configure your routes.rb or web-server
# like nginx to forbid the request.
# WWW-Authenticate Realm (default: "Doorkeeper").
#
# realm "Doorkeeper"
end
| 42.804878 | 109 | 0.738984 |
26d5f67e0d78febc244734f8b4b6a4bcf957496a | 3,981 | #!/usr/bin/env ruby
# Encoding: UTF-8
################################################################################
# Attempt to perform the 'determinePatterns' function from 'rooms.js'
# to determine what room map patterns can be applied to this dungeon.
# This is smaller in scope, however. We don't need to know which rooms
# match which patterns, just that a pattern can be matched somewhere.
################################################################################
module Zelda
module Patterns
# Returns an array of pattern names.
def self.patterns_available dungeon
output_patterns = []
# Read in all the patterns to an array.
patterns_js = Zelda::Config.read_map_patterns_js
# Loop through each room and see if it matches a pattern start room.
dungeon.rooms.each do |room|
# Loop through each pattern and see if it matches.
patterns_js.each do |pattern|
# For each 'room' in the pattern.
is_valid = true
pattern[:rooms].each do |pattern_room|
# These are relative to the first room with id = 1.
roomX = room.x + pattern_room[:relative][:x]
roomY = room.y - pattern_room[:relative][:y]
traversed_room = dungeon.rooms.room(roomX, roomY)
is_valid = false if !is_match(traversed_room, pattern_room)
break if !is_valid
end
output_patterns << pattern[:name] if is_valid
end
end
output_patterns.sort.uniq
end
private
# Little methods for finding all values or one value
# in an array of needles, within a haystack array.
def self.find_one haystack, needles
needles.any? do |i|
haystack.include?(i)
end
end
def self.find_all haystack, needles
needles.all? do |i|
haystack.include?(i)
end
end
# Does the room match the chosen pattern?
def self.is_match(room, pattern_room)
return false if !room
# If the room is an observatory, then it is not valid.
return false if room.observatory_dest != ''
# Loop through each 'pattern_room.absolute' property.
is_valid = true
[:all_of, :one_of, :none_of].each do |absolute_type|
absolute = pattern_room[:absolute][absolute_type]
keys = absolute.keys rescue []
keys.each do |property|
# ToDo: We are not yet specifying the equipment.
next if property == :equipment
# Make sure it matches the 'room' property.
# These are strings of letters, so check if it's in the string.
if room.send(property) != ''
# Split to array, if not already.
arr_abso = absolute[property]
arr_abso = arr_abso.split('') if !arr_abso.is_a?(Array)
arr_room = room.send(property)
arr_room = arr_room.split('') if !arr_room.is_a?(Array)
case absolute_type
# If it's not in the room property, then it's not valid.
when :one_of
is_valid = false if !find_one(arr_room, arr_abso)
# If it's not ALL in the room property, then it's not valid.
when :all_of
is_valid = false if !find_all(arr_room, arr_abso)
# If it IS in the room property, then it's not valid.
when :none_of
is_valid = false if find_one(arr_room, arr_abso)
end
elsif [:one_of, :all_of].include?(absolute_type)
is_valid = false
end
end
# No need to keep iterating if it's already proven to be invalid.
break if !is_valid
end
# Return whether or not the room and pattern room match.
is_valid
end
end
end
################################################################################
| 32.900826 | 80 | 0.557146 |
bfbab01e43a71ca6f30b7547a8d359b16dccd5e2 | 1,177 | # frozen_string_literal: true
module AcaEntities
# individual market class
class AcaIndividualMarket < Dry::Struct
# Marketplaces
# People
# PersonName (add time period)
# Roles
# ConsumerRole (employee)
# MemberRole (employee)
# Organizations
# Profiles (roles)
# SicCodes
# Locations
# SiteAddress (mailing address)
# ServiceAreas
# RatingAreas
# ContactMethods
# Phone
# Email
# Evidences
#
# Eligibilities
# QualifyingLifeEvents (enrollments)
# FinancialAssistance
# Enrollment period
# SpecialEnrollmentPeriod
# OpenEnrollmentPeriod
# Families
# Households
# TaxHouseholds
# Enrollments
# Groups (employers)
# Members (employees)
# Application
# Questionnaire
# Entities
# entities
# contracts (& rules)
# transforms
# events
# specs
# Entity namespace
# Products
# Health Insurance
# Dental Insurance
# Life Insurance
# Annuities
# Disability
# Medicaid
# FFM Account Transfer Protocol
# MAGI in the Cloud (MitC)
end
end
| 21.017857 | 42 | 0.609176 |
798d591726cc73a2783e84361b547c1d00784060 | 304 | class CreateCriteriaReviews < ActiveRecord::Migration[5.2]
def change
create_table :criteria_reviews do |t|
t.references :criterion, foreign_key: true
t.references :review, foreign_key: true
t.integer :score
t.text :comment
t.timestamps
end
end
end
| 23.384615 | 58 | 0.661184 |
87f957b8a51500b65c244daae26ca6e9a8f6e11e | 608 | module LogRunes
class LoggerFactory
def self.set(config, opts)
if Rails.env.development? || Rails.env.test?
# Use a stdout logger to avoid piling up a mostly useless giant log file
stdout_logger = ActiveSupport::Logger.new(STDOUT)
config.logger = ActiveSupport::TaggedLogging.new(stdout_logger)
return
end
log_base = opts[:dir] || "#{Rails.root}/log"
log_name = opts[:name] || Rails.env
l = ActiveSupport::Logger.new("#{log_base}/#{log_name}.log", 'daily')
config.logger = opts[:not_tagged] ? l : ActiveSupport::TaggedLogging.new(l)
end
end
end
| 25.333333 | 79 | 0.674342 |
619c7f082d4a041ccc79894d9630bfabbad119a8 | 907 | module YmPermalinks::Permalinkable
def self.included(base)
base.has_many :permalinks, :as => :resource, :autosave => true, :dependent => :destroy
base.has_one :permalink, :as => :resource, :conditions => {:active => true}, :autosave => true
base.before_validation :set_permalink_path
base.after_validation :set_permalink_errors
end
def permalink_path
permalink.try(:path)
end
def permalink_path=(val)
(self.permalink || self.build_permalink).path = val
end
private
def set_permalink_errors
permalink_errors = permalink.try(:errors).try(:get, :path)
errors.add(:permalink_path, permalink_errors) if permalink_errors.present?
end
def set_permalink_path
return true unless permalink
if permalink.path.present?
self.permalink.path = permalink.path.to_url
else
self.permalink.generate_unique_path!(to_s)
end
end
end | 28.34375 | 98 | 0.713341 |
1de7096666c604e60ceca4c620b0a34d2b5f8ea5 | 3,121 | RSpec.describe RVNC do
describe '.variables' do
it 'node_cvasgn' do
variables = RVNC.variables(File.expand_path('examples/node_cdecl.rb', __dir__))
expect(variables).to eq(
[
{ name: 'FOO', location: 'spec/examples/node_cdecl.rb:1' },
{ name: 'BAR', location: 'spec/examples/node_cdecl.rb:2' },
{ name: 'BAZ', location: 'spec/examples/node_cdecl.rb:3' },
]
)
end
it 'node_cvasgn' do
variables = RVNC.variables(File.expand_path('examples/node_cvasgn.rb', __dir__))
expect(variables).to eq(
[
{ name: '@@bar', location: 'spec/examples/node_cvasgn.rb:2' },
{ name: '@@baz', location: 'spec/examples/node_cvasgn.rb:3' },
]
)
end
it 'node_lasgn' do
variables = RVNC.variables(File.expand_path('examples/node_lasgn.rb', __dir__))
expect(variables).to eq(
[
{ name: 'a', location: 'spec/examples/node_lasgn.rb:1' },
{ name: 'b', location: 'spec/examples/node_lasgn.rb:2' },
{ name: 'c', location: 'spec/examples/node_lasgn.rb:3' },
{ name: 'd', location: 'spec/examples/node_lasgn.rb:5' },
{ name: 'e', location: 'spec/examples/node_lasgn.rb:5' },
{ name: 'f', location: 'spec/examples/node_lasgn.rb:6' },
{ name: 'g', location: 'spec/examples/node_lasgn.rb:7' },
{ name: 'h', location: 'spec/examples/node_lasgn.rb:8' },
{ name: 'i', location: 'spec/examples/node_lasgn.rb:9' },
]
)
end
it 'node_iasgn' do
variables = RVNC.variables(File.expand_path('examples/node_iasgn.rb', __dir__))
expect(variables).to eq(
[
{ name: '@foo', location: 'spec/examples/node_iasgn.rb:3' },
{ name: '@user', location: 'spec/examples/node_iasgn.rb:4' },
{ name: '@a', location: 'spec/examples/node_iasgn.rb:5' },
{ name: 'b', location: 'spec/examples/node_iasgn.rb:5' },
]
)
end
it 'node_masgn' do
variables = RVNC.variables(File.expand_path('examples/node_masgn.rb', __dir__))
expect(variables).to eq(
[
{ name: 'foo', location: 'spec/examples/node_masgn.rb:1' },
{ name: 'bar', location: 'spec/examples/node_masgn.rb:1' },
{ name: 'a', location: 'spec/examples/node_masgn.rb:1' },
{ name: 'vars', location: 'spec/examples/node_masgn.rb:2' },
{ name: '_', location: 'spec/examples/node_masgn.rb:2' }
]
)
end
it 'node_gasgn' do
variables = RVNC.variables(File.expand_path('examples/node_gasgn.rb', __dir__))
expect(variables).to eq(
[
{ name: '$foo', location: 'spec/examples/node_gasgn.rb:1' },
{ name: '$bar', location: 'spec/examples/node_gasgn.rb:2' }
]
)
end
it 'node_op_asgn_or' do
variables = RVNC.variables(File.expand_path('examples/node_op_asgn_or.rb', __dir__))
expect(variables).to eq(
[
{ name: 'foo', location: 'spec/examples/node_op_asgn_or.rb:1' },
]
)
end
end
end
| 36.290698 | 90 | 0.57033 |
0133e399b42fd3d7e3a1c918c42e74d748753a8f | 1,766 | #
# Autogenerated by Thrift Compiler (0.9.0)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
require "thrift"
module Prey
module Thrift
module Status
NOT_CONFIGURED = 0
QUIESCENT = 1
READ_ONLY = 2
UP = 3
VALUE_MAP = {0 => "NOT_CONFIGURED", 1 => "QUIESCENT", 2 => "READ_ONLY", 3 => "UP"}
VALID_VALUES = Set.new([NOT_CONFIGURED, QUIESCENT, READ_ONLY, UP]).freeze
end
class Item
include ::Thrift::Struct, ::Thrift::Struct_Union
DATA = 1
ID = 2
FIELDS = {
DATA => {:type => ::Thrift::Types::STRING, :name => 'data', :binary => true},
ID => {:type => ::Thrift::Types::I64, :name => 'id'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class QueueInfo
include ::Thrift::Struct, ::Thrift::Struct_Union
HEAD_ITEM = 1
ITEMS = 2
BYTES = 3
JOURNAL_BYTES = 4
AGE = 5
WAITERS = 6
OPEN_TRANSACTIONS = 7
FIELDS = {
HEAD_ITEM => {:type => ::Thrift::Types::STRING, :name => 'head_item', :binary => true, :optional => true},
ITEMS => {:type => ::Thrift::Types::I64, :name => 'items'},
BYTES => {:type => ::Thrift::Types::I64, :name => 'bytes'},
JOURNAL_BYTES => {:type => ::Thrift::Types::I64, :name => 'journal_bytes'},
AGE => {:type => ::Thrift::Types::I64, :name => 'age'},
WAITERS => {:type => ::Thrift::Types::I32, :name => 'waiters'},
OPEN_TRANSACTIONS => {:type => ::Thrift::Types::I32, :name => 'open_transactions'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
end
end
| 26.358209 | 114 | 0.556625 |
6a94f1812e7a90b60f93e8789cb168defa344514 | 1,709 | #!/usr/bin/env rspec
# frozen_string_literal: true
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
require_relative '../rack_helper'
require 'utopia/exceptions'
require 'utopia/controller'
RSpec.describe Utopia::Exceptions::Mailer do
include_context "rack app", File.expand_path("mailer_spec.ru", __dir__)
before(:each) do
Mail::TestMailer.deliveries.clear
end
it "should send an email to report the failure" do
expect{get "/blow"}.to raise_error('Arrrh!')
last_mail = Mail::TestMailer.deliveries.last
expect(last_mail.to_s).to include("GET", "blow", "request.ip", "HTTP_", "TharSheBlows")
end
end
| 38.840909 | 89 | 0.760679 |
0125a9e3de5aabef2c45dfd2b4823fa3608b4893 | 1,624 | # encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20141021160014) do
create_table "role_subscriptions", force: true do |t|
t.integer "role_id"
t.integer "authorizable_id"
t.string "authorizable_type"
end
add_index "role_subscriptions", ["authorizable_id", "authorizable_type"], name: "index_role_subs_on_auth_id_and_auth_type_authist"
add_index "role_subscriptions", ["role_id"], name: "index_role_subscriptions_on_role_id"
create_table "roles", force: true do |t|
t.string "name"
t.boolean "shoe_lacing"
end
create_table "roles_roles", force: true do |t|
t.integer "role_id"
t.integer "includer_id"
end
add_index "roles_roles", ["includer_id"], name: "index_roles_roles_on_includer_id"
add_index "roles_roles", ["role_id"], name: "index_roles_roles_on_role_id"
create_table "users", force: true do |t|
t.string "username"
end
end
| 37.767442 | 132 | 0.759236 |
ac99cd7ee36920e4f996f786328c117e636ce856 | 542 | #
# test_vmio.rb
#
# Copyright (c) 2011 by Daniel Kelley
#
# $Id:$
#
require 'test/unit'
require 'gmpforth'
require 'gmpforth/cli'
require 'noredef'
require 'vmio'
class TestVMIO < Test::Unit::TestCase
def setup
@vc = GMPForth::VMCompiler.new GMPForth::CLI::sysopt
# make addr 0-3 illegal
4.times { @vc.vm.asm(:vm_nop) }
@vc.vm.fence = @vc.vm.dot
@vc.include('.')
@vc.scan('src/vm/forth32.fs')
# minus one / mask with all bits set
@m1 = @vc.vm.modulus - 1
end
extend NoRedef
include VMIO
end
| 16.9375 | 56 | 0.630996 |
33275f3bc59df25ea606a6b4cbbf20c69cf23751 | 652 | ones = [''] +
%w(one two three four five six seven eight nine) +
%w(ten eleven twelve thirteen fourteen fifteen) +
%w(sixteen seventeen eighteen nineteen)
tens = ['',''] + %w(twenty thirty forty fifty sixty seventy eighty ninety)
sum = 0
(1..1000).each do |i|
if i >= 1000
sum += ones[i/1000].length
sum += 'thousand'.length
i %= 1000
sum += 'and'.length unless 0 == i
end
if i >= 100
sum += ones[i/100].length
sum += 'hundred'.length
i %= 100
sum += 'and'.length unless 0 == i
end
if i >= 20
sum += tens[i/10].length
sum += ones[i%10].length
else
sum += ones[i].length
end
end
puts sum
| 23.285714 | 74 | 0.588957 |
87a34e29bd504d845597fafcaeb4087478ccc280 | 658 | cask '1password-cli' do
version '0.2.1'
sha256 'fd15c2c0e429623e3d0bff17f7f94867cd5d8b55d10f69076c2ec277da755d77'
# cache.agilebits.com/dist/1P/op/pkg was verified as official when first introduced to the cask
url "https://cache.agilebits.com/dist/1P/op/pkg/v#{version}/op_darwin_amd64_v#{version}.zip"
appcast 'https://app-updates.agilebits.com/product_history/CLI',
checkpoint: '869d4d4fa733f66ac0b01f7dd98ace84984b5afec7e7adbfa1e6fd13b474dc41'
name '1Password CLI'
homepage 'https://support.1password.com/command-line/'
gpg 'op.sig', key_url: 'https://keybase.io/1password/pgp_keys.asc'
binary 'op'
zap trash: '~/.op'
end
| 38.705882 | 97 | 0.761398 |
5d5171b358c54907c13e105d4c2ab747cce19671 | 1,137 | require "discorb"
require "json"
client = Discorb::Client.new
client.once :standby do
puts "Logged in as #{client.user}"
end
def bookmark_channel(guild)
guild.channels.find { |c| c.is_a?(Discorb::TextChannel) && c.name == "bookmarks" }
end
def build_embed_from_message(message)
embed = Discorb::Embed.new
embed.description = message.content
embed.author = Discorb::Embed::Author.new(message.author.to_s_user, icon: message.author.avatar.url)
embed.timestamp = message.timestamp
embed.footer = Discorb::Embed::Footer.new("Message ID: #{message.id}")
embed
end
client.message_command("Bookmark", guild_ids: [857373681096327180]) do |interaction, message|
unless channel = bookmark_channel(interaction.guild)
interaction.post("Bookmark channel not found. Please create one called `bookmarks`.", ephemeral: true)
next
end
channel.post(
message.jump_url,
embed: build_embed_from_message(message),
).wait
interaction.post("Bookmarked!", ephemeral: true)
end
client.change_presence(
Discorb::Activity.new(
"Open message context menu to bookmark"
)
)
client.run(ENV["DISCORD_BOT_TOKEN"])
| 27.071429 | 106 | 0.741425 |
21b824eba924cad11be78609401d14b51cb9a6a4 | 6,738 | #! /usr/bin/env ruby
require 'spec_helper'
require 'puppet/test_ca'
require 'puppet/certificate_factory'
describe Puppet::CertificateFactory, :unless => RUBY_PLATFORM == 'java' do
let :serial do OpenSSL::BN.new('12') end
let :name do "example.local" end
let :x509_name do OpenSSL::X509::Name.new([['CN', name]]) end
let :key do Puppet::SSL::Key.new(name).generate end
let :csr do
csr = Puppet::SSL::CertificateRequest.new(name)
csr.generate(key)
csr
end
let(:issuer) { Puppet::TestCa.new.ca_cert }
describe "when generating the certificate" do
it "should return a new X509 certificate" do
a = subject.build(:server, csr, issuer, serial)
b = subject.build(:server, csr, issuer, serial)
# The two instances are equal in every aspect except that they are
# different instances - they are `==`, but not hash `eql?`
expect(a).not_to eql(b)
end
it "should set the certificate's version to 2" do
expect(subject.build(:server, csr, issuer, serial).version).to eq(2)
end
it "should set the certificate's subject to the CSR's subject" do
cert = subject.build(:server, csr, issuer, serial)
expect(cert.subject).to eq x509_name
end
it "should set the certificate's issuer to the Issuer's subject" do
cert = subject.build(:server, csr, issuer, serial)
expect(cert.issuer).to eq issuer.subject
end
it "should set the certificate's public key to the CSR's public key" do
cert = subject.build(:server, csr, issuer, serial)
expect(cert.public_key).to be_public
expect(cert.public_key.to_s).to eq(csr.content.public_key.to_s)
end
it "should set the certificate's serial number to the provided serial number" do
cert = subject.build(:server, csr, issuer, serial)
expect(cert.serial).to eq(serial)
end
it "should have 24 hours grace on the start of the cert" do
cert = subject.build(:server, csr, issuer, serial)
expect(cert.not_before).to be_within(30).of(Time.now - 24*60*60)
end
it "should not allow a non-integer TTL" do
[ 'foo', 1.2, Time.now, true ].each do |ttl|
expect { subject.build(:server, csr, issuer, serial, ttl) }.to raise_error(ArgumentError)
end
end
it "should respect a custom TTL for the CA" do
now = Time.now.utc
Time.expects(:now).at_least_once.returns(now)
cert = subject.build(:server, csr, issuer, serial, 12)
expect(cert.not_after.to_i).to eq(now.to_i + 12)
end
it "should adds an extension for the nsComment" do
cert = subject.build(:server, csr, issuer, serial)
expect(cert.extensions.map {|x| x.to_h }.find {|x| x["oid"] == "nsComment" }).to eq(
{ "oid" => "nsComment",
# Note that this output is due to a bug in OpenSSL::X509::Extensions
# where the values of some extensions are not properly decoded
"value" => ".(Puppet Ruby/OpenSSL Internal Certificate",
"critical" => false }
)
end
it "should add an extension for the subjectKeyIdentifer" do
cert = subject.build(:server, csr, issuer, serial)
ef = OpenSSL::X509::ExtensionFactory.new(issuer, cert)
expect(cert.extensions.map { |x| x.to_h }.find {|x| x["oid"] == "subjectKeyIdentifier" }).to eq(
ef.create_extension("subjectKeyIdentifier", "hash", false).to_h
)
end
it "should add an extension for the authorityKeyIdentifer" do
cert = subject.build(:server, csr, issuer, serial)
ef = OpenSSL::X509::ExtensionFactory.new(issuer, cert)
expect(cert.extensions.map { |x| x.to_h }.find {|x| x["oid"] == "authorityKeyIdentifier" }).to eq(
ef.create_extension("authorityKeyIdentifier", "keyid:always", false).to_h
)
end
# See #2848 for why we are doing this: we need to make sure that
# subjectAltName is set if the CSR has it, but *not* if it is set when the
# certificate is built!
it "should not add subjectAltNames from dns_alt_names" do
Puppet[:dns_alt_names] = 'one, two'
# Verify the CSR still has no extReq, just in case...
expect(csr.request_extensions).to eq([])
cert = subject.build(:server, csr, issuer, serial)
expect(cert.extensions.find {|x| x.oid == 'subjectAltName' }).to be_nil
end
it "should add subjectAltName when the CSR requests them" do
Puppet[:dns_alt_names] = ''
expect = %w{one two} + [name]
csr = Puppet::SSL::CertificateRequest.new(name)
csr.generate(key, :dns_alt_names => expect.join(', '))
expect(csr.request_extensions).not_to be_nil
expect(csr.subject_alt_names).to match_array(expect.map{|x| "DNS:#{x}"})
cert = subject.build(:server, csr, issuer, serial)
san = cert.extensions.find {|x| x.oid == 'subjectAltName' }
expect(san).not_to be_nil
expect.each do |name|
expect(san.value).to match(/DNS:#{name}\b/i)
end
end
it "can add custom extension requests" do
csr = Puppet::SSL::CertificateRequest.new(name)
csr.generate(key)
csr.stubs(:request_extensions).returns([
{'oid' => '1.3.6.1.4.1.34380.1.2.1', 'value' => 'some-value'},
{'oid' => 'pp_uuid', 'value' => 'some-uuid'},
])
cert = subject.build(:client, csr, issuer, serial)
# The cert must be signed before being later DER-decoding
signer = Puppet::SSL::CertificateSigner.new
signer.sign(cert, key)
wrapped_cert = Puppet::SSL::Certificate.from_instance cert
priv_ext = wrapped_cert.custom_extensions.find {|ext| ext['oid'] == '1.3.6.1.4.1.34380.1.2.1'}
uuid_ext = wrapped_cert.custom_extensions.find {|ext| ext['oid'] == 'pp_uuid'}
# The expected results should be DER encoded, the Puppet cert wrapper will turn
# these into normal strings.
expect(priv_ext['value']).to eq 'some-value'
expect(uuid_ext['value']).to eq 'some-uuid'
end
# Can't check the CA here, since that requires way more infrastructure
# that I want to build up at this time. We can verify the critical
# values, though, which are non-CA certs. --daniel 2011-10-11
{ :ca => 'CA:TRUE',
:terminalsubca => ['CA:TRUE', 'pathlen:0'],
:server => 'CA:FALSE',
:ocsp => 'CA:FALSE',
:client => 'CA:FALSE',
}.each do |name, value|
it "should set basicConstraints for #{name} #{value.inspect}" do
cert = subject.build(name, csr, issuer, serial)
bc = cert.extensions.find {|x| x.oid == 'basicConstraints' }
expect(bc).to be
expect(bc.value.split(/\s*,\s*/)).to match_array(Array(value))
end
end
end
end
| 38.947977 | 104 | 0.638765 |
bf67344b1ea1e0cfb62a65b9a71fdf6cfa18307c | 1,635 | require 'test_helper'
class FollowingTest < ActionDispatch::IntegrationTest
def setup
@user = users(:jared)
@other_user = users(:archer)
log_in_as(@user)
end
test "following page" do
get following_user_path(@user)
assert_not @user.following.empty?
assert_match @user.following.count.to_s, response.body
@user.following.each do |user|
assert_select "a[href=?]", user_path(user)
end
end
test "followers page" do
get followers_user_path(@user)
assert_not @user.followers.empty?
assert_match @user.followers.count.to_s, response.body
@user.followers.each do |user|
assert_select "a[href=?]", user_path(user)
end
end
test "should follow a user the standard way" do
assert_difference '@user.following.count', 1 do
post relationships_path, params: { followed_id: @other_user.id }
end
end
test "should follow a user with Ajax" do
assert_difference '@user.following.count', 1 do
post relationships_path, xhr: true, params: { followed_id: @other_user.id }
end
end
test "should unfollow a user the standard way" do
@user.follow(@other_user)
relationship = @user.active_relationships.find_by(followed_id: @other_user.id)
assert_difference '@user.following.count', -1 do
delete relationship_path(relationship)
end
end
test "should unfollow a user with Ajax" do
@user.follow(@other_user)
relationship = @user.active_relationships.find_by(followed_id: @other_user.id)
assert_difference '@user.following.count', -1 do
delete relationship_path(relationship), xhr: true
end
end
end
| 29.196429 | 82 | 0.708869 |
e2a2b89841b233356dc764bd2a29f4870c43c3b6 | 126 | FactoryBot.define do
factory :user do
sequence(:email) { |n| "test#{n}@email.com" }
password 'Password1!'
end
end
| 18 | 49 | 0.642857 |
0855fe38b50ace1b89226162f8b9b96862b37e60 | 8,287 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe 'validate_length_of' do
include ModelBuilder
# Defines a model, create a validation and returns a raw matcher
def define_and_validate(options={})
options = options.merge(:within => 3..5) if options.slice(:in, :within, :maximum, :minimum, :is).empty?
@model = define_model :product, :size => :string, :category => :string do
validates_length_of :size, options
end
validate_length_of(:size)
end
describe 'messages' do
before(:each){ @matcher = define_and_validate }
it 'should contain a description' do
@matcher.within(3..5)
@matcher.description.should == 'ensure length of size is within 3..5 characters'
@matcher.within(nil).in(3..5)
@matcher.description.should == 'ensure length of size is within 3..5 characters'
@matcher.in(nil).is(3)
@matcher.description.should == 'ensure length of size is equal to 3 characters'
@matcher.is(nil).maximum(5)
@matcher.description.should == 'ensure length of size is maximum 5 characters'
@matcher.maximum(nil).minimum(3)
@matcher.description.should == 'ensure length of size is minimum 3 characters'
@matcher.allow_nil(false)
@matcher.description.should == 'ensure length of size is minimum 3 characters and not allowing nil values'
@matcher.allow_blank
@matcher.description.should == 'ensure length of size is minimum 3 characters, not allowing nil values, and allowing blank values'
end
it 'should set less_than_min_length? message' do
@matcher.within(4..5).matches?(@model)
@matcher.failure_message.should == 'Expected Product to be invalid when size length is less than 4 characters'
end
it 'should set exactly_min_length? message' do
@matcher.should_receive(:less_than_min_length?).and_return(true)
@matcher.within(2..5).matches?(@model)
@matcher.failure_message.should == 'Expected Product to be valid when size length is 2 characters'
end
it 'should set more_than_max_length? message' do
@matcher.within(3..4).matches?(@model)
@matcher.failure_message.should == 'Expected Product to be invalid when size length is more than 4 characters'
end
it 'should set exactly_max_length? message' do
@matcher.should_receive(:more_than_max_length?).and_return(true)
@matcher.within(3..6).matches?(@model)
@matcher.failure_message.should == 'Expected Product to be valid when size length is 6 characters'
end
it 'should set allow_blank? message' do
@matcher.within(3..5).allow_blank.matches?(@model)
@matcher.failure_message.should == 'Expected Product to allow blank values for size'
end
it 'should set allow_nil? message' do
@matcher.within(3..5).allow_nil.matches?(@model)
@matcher.failure_message.should == 'Expected Product to allow nil values for size'
end
end
describe 'matcher' do
# Wrap specs without options. Usually a couple specs.
describe 'without options' do
before(:each){ define_and_validate }
it { should validate_length_of(:size, :within => 3..5) }
it { should_not validate_length_of(:category, :within => 3..5) }
end
describe "with message option" do
if RAILS_VERSION =~ /^2.3/
it { should define_and_validate(:message => 'not valid').within(3..5).message('not valid') }
it { should_not define_and_validate(:message => 'not valid').within(3..5).message('valid') }
else
it { should define_and_validate(:too_short => 'not valid', :too_long => 'not valid').within(3..5).message('not valid') }
it { should_not define_and_validate(:too_short => 'not valid', :too_long => 'not valid').within(3..5).message('valid') }
end
it { should define_and_validate(:is => 4, :message => 'not valid').is(4).message('not valid') }
it { should_not define_and_validate(:is => 4, :message => 'not valid').is(4).message('valid') }
end
describe "with too_short option" do
it { should define_and_validate(:too_short => 'not valid').within(3..5).too_short('not valid') }
it { should_not define_and_validate(:too_short => 'not valid').within(3..5).too_short('valid') }
end
describe "with too_long option" do
it { should define_and_validate(:too_long => 'not valid').within(3..5).too_long('not valid') }
it { should_not define_and_validate(:too_long => 'not valid').within(3..5).too_long('valid') }
end
describe "with wrong_length option" do
it { should define_and_validate(:is => 4, :wrong_length => 'not valid').is(4).wrong_length('not valid') }
it { should_not define_and_validate(:is => 4, :wrong_length => 'not valid').is(4).wrong_length('valid') }
end
describe "with within option" do
it { should define_and_validate(:within => 3..5).within(3..5) }
it { should_not define_and_validate(:within => 3..5).within(2..5) }
it { should_not define_and_validate(:within => 3..5).within(4..5) }
it { should_not define_and_validate(:within => 3..5).within(3..4) }
it { should_not define_and_validate(:within => 3..5).within(3..6) }
end
describe "with in option" do
it { should define_and_validate(:in => 3..5).within(3..5) }
it { should_not define_and_validate(:in => 3..5).within(2..5) }
it { should_not define_and_validate(:in => 3..5).within(4..5) }
it { should_not define_and_validate(:in => 3..5).within(3..4) }
it { should_not define_and_validate(:in => 3..5).within(3..6) }
end
describe "with minimum option" do
it { should define_and_validate(:minimum => 3).minimum(3) }
it { should_not define_and_validate(:minimum => 3).minimum(2) }
it { should_not define_and_validate(:minimum => 3).minimum(4) }
end
describe "with maximum option" do
it { should define_and_validate(:maximum => 3).maximum(3) }
it { should_not define_and_validate(:maximum => 3).maximum(2) }
it { should_not define_and_validate(:maximum => 3).maximum(4) }
end
describe "with is option" do
it { should define_and_validate(:is => 3).is(3) }
it { should_not define_and_validate(:is => 3).is(2) }
it { should_not define_and_validate(:is => 3).is(4) }
end
describe "with token and separator options" do
describe "and words as tokens" do
before(:each) do
@matcher = define_and_validate(:within => 3..5, :tokenizer => lambda { |str| str.scan(/\w+/) })
end
it { should @matcher.within(3..5).token("word").separator(" ") }
it { should_not @matcher.within(2..5).token("word").separator(" ") }
it { should_not @matcher.within(4..5).token("word").separator(" ") }
it { should_not @matcher.within(3..4).token("word").separator(" ") }
it { should_not @matcher.within(3..6).token("word").separator(" ") }
it { should_not @matcher.within(3..5).token("word").separator("") }
it { should_not @matcher.within(3..5).token("word").separator(" a ") }
end
describe "and digits as tokens" do
before(:each) do
@matcher = define_and_validate(:within => 3..5, :tokenizer => lambda { |str| str.scan(/\d+/) })
end
it { should @matcher.within(3..5).token("1").separator(" ") }
it { should_not @matcher.within(3..5).token("a").separator("") }
end
end
# Those are macros to test optionals which accept only boolean values
create_optional_boolean_specs(:allow_nil, self)
create_optional_boolean_specs(:allow_blank, self)
end
# In macros we include just a few tests to assure that everything works properly
describe 'macros' do
before(:each) { define_and_validate }
should_validate_length_of :size, :in => 3..5
should_validate_length_of :size, :within => 3..5
should_not_validate_length_of :size, :within => 2..5
should_not_validate_length_of :size, :within => 4..5
should_not_validate_length_of :size, :within => 3..4
should_not_validate_length_of :size, :within => 3..6
should_not_validate_length_of :category, :in => 3..5
should_validate_length_of :size do |m|
m.in = 3..5
end
end
end
| 42.280612 | 136 | 0.658019 |
e8b4c3f660b73fc98cb3f5be141c638770aee61c | 544 | # frozen_string_literal: true
require 'thor'
module Yomou
module Commands
class Clean < Thor
namespace :clean
desc 'novel [TYPE]', 'Command description...'
method_option :help, aliases: '-h', type: :boolean,
desc: 'Display usage information'
def novel(type=nil)
if options[:help]
invoke :help, ['novel']
else
require_relative 'clean/novel'
Yomou::Commands::Clean::Novel.new(type, options).execute
end
end
end
end
end
| 21.76 | 66 | 0.579044 |
182e38e0f01abfcc70001308c9bc90ad32d8c384 | 2,800 | RSpec.shared_examples 'required chart parameters' do
it 'requires country_id' do
get url, params: filter_params.except(:country_id)
expect(@response).to have_http_status(:bad_request)
expect(JSON.parse(@response.body)).to eq(
'error' => 'param is missing or the value is empty: Required param country_id missing'
)
end
it 'requires commodity_id' do
get url, params: filter_params.except(:commodity_id)
expect(@response).to have_http_status(:bad_request)
expect(JSON.parse(@response.body)).to eq(
'error' => 'param is missing or the value is empty: Required param commodity_id missing'
)
end
it 'requires cont_attribute_id' do
get url, params: filter_params.except(:cont_attribute_id)
expect(@response).to have_http_status(:bad_request)
expect(JSON.parse(@response.body)).to eq(
'error' => 'param is missing or the value is empty: Required param cont_attribute_id missing'
)
end
it 'requires start_year' do
get url, params: filter_params.except(:start_year)
expect(@response).to have_http_status(:bad_request)
expect(JSON.parse(@response.body)).to eq(
'error' => 'param is missing or the value is empty: Required param start_year missing'
)
end
end
RSpec.shared_examples 'required node values chart parameters' do
it 'requires country_id' do
get url, params: filter_params.except(:country_id)
expect(@response).to have_http_status(:bad_request)
expect(JSON.parse(@response.body)).to eq(
'error' => 'param is missing or the value is empty: Required param country_id missing'
)
end
it 'requires commodity_id' do
get url, params: filter_params.except(:commodity_id)
expect(@response).to have_http_status(:bad_request)
expect(JSON.parse(@response.body)).to eq(
'error' => 'param is missing or the value is empty: Required param commodity_id missing'
)
end
it 'requires cont_attribute_id' do
get url, params: filter_params.except(:cont_attribute_id)
expect(@response).to have_http_status(:bad_request)
expect(JSON.parse(@response.body)).to eq(
'error' => 'param is missing or the value is empty: Required param cont_attribute_id missing'
)
end
it 'requires node_id' do
get url, params: filter_params.except(:node_id)
expect(@response).to have_http_status(:bad_request)
expect(JSON.parse(@response.body)).to eq(
'error' => 'param is missing or the value is empty: Required param node_id missing'
)
end
it 'requires start_year' do
get url, params: filter_params.except(:start_year)
expect(@response).to have_http_status(:bad_request)
expect(JSON.parse(@response.body)).to eq(
'error' => 'param is missing or the value is empty: Required param start_year missing'
)
end
end
| 40.57971 | 99 | 0.716071 |
bb6dcc23f03801c12b38c8ba7621587319082270 | 489 | cask 'marker-import' do
version '2.1.5.0'
sha256 '4e38726e733bc0ad57bf38a4a44d4fe0d18ab665043f8a2baaa1d26391e4035e'
# digitalrebellion.com was verified as official when first introduced to the cask
url "http://www.digitalrebellion.com/download/markerimport?version=#{version.no_dots}"
name 'Kollaborate Marker Import'
homepage 'https://www.kollaborate.tv/resources'
app 'Marker Import.app'
zap delete: '~/Library/Preferences/com.digitalrebellion.MarkerImport.plist'
end
| 34.928571 | 88 | 0.789366 |
620031275cfd470744cd33ce09f91dd4a75461f7 | 918 | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/sms_my_bus/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Matt Gauger", "Jaymes Waters", "Ashe Dryden"]
gem.email = ["[email protected]", "[email protected]", "[email protected]"]
gem.description = %q{A gem to talk to the awesome SMSMyBus API in Madison, WI.}
gem.summary = %q{SMSMyBus API integration}
gem.homepage = "http://github.com/bendyworks/sms_my_bus"
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
gem.files = `git ls-files`.split("\n")
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
gem.name = "sms_my_bus"
gem.require_paths = ["lib"]
gem.version = SmsMyBus::VERSION
gem.add_dependency 'curb'
gem.add_development_dependency 'rspec'
gem.add_development_dependency 'pry'
end
| 41.727273 | 96 | 0.650327 |
1d77cfc6da1e9eb0cbb3044054103c9551acb697 | 1,040 | #!/usr/bin/env rackup
# frozen_string_literal: true
require_relative 'config/environment'
self.freeze_app
if UTOPIA.production?
# Handle exceptions in production with a error page and send an email notification:
use Utopia::Exceptions::Handler
use Utopia::Exceptions::Mailer
else
# We want to propate exceptions up when running tests:
use Rack::ShowExceptions unless UTOPIA.testing?
end
# serve static files from public/
use Utopia::Static, root: 'public'
use Utopia::Redirection::Rewrite, {
'/' => '/welcome/index'
}
use Utopia::Redirection::DirectoryIndex
use Utopia::Redirection::Errors, {
404 => '/errors/file-not-found'
}
require 'utopia/localization'
use Utopia::Localization,
default_locale: 'en',
locales: ['en', 'de', 'ja', 'zh']
require 'utopia/session'
use Utopia::Session,
expires_after: 3600 * 24,
secret: UTOPIA.secret_for(:session),
secure: true
use Utopia::Controller
# serve static files from pages/
use Utopia::Static
# Serve dynamic content
use Utopia::Content
run lambda { |env| [404, {}, []] }
| 20.8 | 84 | 0.735577 |
03b49264acd33c13f42881a57b7ebe712782c33f | 2,203 | module Bot
module Commands
# command kicks a user from the server, requires user to have "kick members" permission
module Ban
extend Discordrb::Commands::CommandContainer
command :ban do |event, *args|
if event.user.permission?(:ban_members) && Bot::JADE.profile.on(event.server).permission?(:ban_members)
redis = Redis.new
if Bot::JADE.parse_mention(args[0])
user_target = Bot::JADE.parse_mention(args[0])
event.send_message("**#{user_target.username}##{user_target.tag}** has been banned from the server :p")
if Bot::JADE.profile.on(event.server).permission?(:manage_channels) && Bot::JADE.profile.on(event.server).permission?(:manage_server)
mod_log = event.server.text_channels.find { |c| c.name == 'mod-log' }
mod_log = event.server.create_channel('mod-log') if mod_log.nil?
if Bot::JADE.profile.on(event.server).permission?(:send_messages, mod_log)
reason = ''
redis.set "#{event.server.id}:#{user_target.id}:BANKICK", true
if args.size > 1
args[1..(args.size - 1)].each { |word| reason += "#{word} " }
else
reason = 'No reason given.'
end
mod_log.send_embed do |embed|
embed.title = 'Ban'
embed.description = "#{event.user.username}##{event.user.tag} has banned #{user_target.username}##{user_target.tag}"
embed.timestamp = Time.now
embed.color = '88AOBD'
embed.add_field(name: 'Reason', value: reason.to_s)
embed.footer = Discordrb::Webhooks::EmbedFooter.new(text: "Member Count: #{event.server.member_count - 1}")
embed.author = Discordrb::Webhooks::EmbedAuthor.new(name: "#{event.user.username}##{event.user.tag}", icon_url: event.user.avatar_url.to_s)
end
end
end
end
redis.close
event.server.ban(user_target)
else
event.send_message('please **mention** a valid user')
end
end
end
end
end
| 43.196078 | 157 | 0.575125 |
797517bf084b1ad9a3c1d80f3d34c409a7be6702 | 8,146 | =begin
#DocuSign REST API
#The DocuSign REST API provides you with a powerful, convenient, and simple Web services API for interacting with DocuSign.
OpenAPI spec version: v2
Contact: [email protected]
Generated by: https://github.com/swagger-api/swagger-codegen.git
=end
require 'date'
module DocuSign_eSign
# Contains information about a billing invoice.
class BillingInvoice
# Reserved: TBD
attr_accessor :amount
# Reserved: TBD
attr_accessor :balance
# Reserved: TBD
attr_accessor :due_date
# Reserved: TBD
attr_accessor :invoice_id
# Reserved: TBD
attr_accessor :invoice_items
# Reserved: TBD
attr_accessor :invoice_number
# Contains a URI for an endpoint that you can use to retrieve invoice information.
attr_accessor :invoice_uri
#
attr_accessor :non_taxable_amount
#
attr_accessor :pdf_available
#
attr_accessor :taxable_amount
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'amount' => :'amount',
:'balance' => :'balance',
:'due_date' => :'dueDate',
:'invoice_id' => :'invoiceId',
:'invoice_items' => :'invoiceItems',
:'invoice_number' => :'invoiceNumber',
:'invoice_uri' => :'invoiceUri',
:'non_taxable_amount' => :'nonTaxableAmount',
:'pdf_available' => :'pdfAvailable',
:'taxable_amount' => :'taxableAmount'
}
end
# Attribute type mapping.
def self.swagger_types
{
:'amount' => :'String',
:'balance' => :'String',
:'due_date' => :'String',
:'invoice_id' => :'String',
:'invoice_items' => :'Array<BillingInvoiceItem>',
:'invoice_number' => :'String',
:'invoice_uri' => :'String',
:'non_taxable_amount' => :'String',
:'pdf_available' => :'String',
:'taxable_amount' => :'String'
}
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
return unless attributes.is_a?(Hash)
# convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
if attributes.has_key?(:'amount')
self.amount = attributes[:'amount']
end
if attributes.has_key?(:'balance')
self.balance = attributes[:'balance']
end
if attributes.has_key?(:'dueDate')
self.due_date = attributes[:'dueDate']
end
if attributes.has_key?(:'invoiceId')
self.invoice_id = attributes[:'invoiceId']
end
if attributes.has_key?(:'invoiceItems')
if (value = attributes[:'invoiceItems']).is_a?(Array)
self.invoice_items = value
end
end
if attributes.has_key?(:'invoiceNumber')
self.invoice_number = attributes[:'invoiceNumber']
end
if attributes.has_key?(:'invoiceUri')
self.invoice_uri = attributes[:'invoiceUri']
end
if attributes.has_key?(:'nonTaxableAmount')
self.non_taxable_amount = attributes[:'nonTaxableAmount']
end
if attributes.has_key?(:'pdfAvailable')
self.pdf_available = attributes[:'pdfAvailable']
end
if attributes.has_key?(:'taxableAmount')
self.taxable_amount = attributes[:'taxableAmount']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properies with the reasons
def list_invalid_properties
invalid_properties = Array.new
return invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
amount == o.amount &&
balance == o.balance &&
due_date == o.due_date &&
invoice_id == o.invoice_id &&
invoice_items == o.invoice_items &&
invoice_number == o.invoice_number &&
invoice_uri == o.invoice_uri &&
non_taxable_amount == o.non_taxable_amount &&
pdf_available == o.pdf_available &&
taxable_amount == o.taxable_amount
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Fixnum] Hash code
def hash
[amount, balance, due_date, invoice_id, invoice_items, invoice_number, invoice_uri, non_taxable_amount, pdf_available, taxable_amount].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.swagger_types.each_pair do |key, type|
if type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end # or else data not found in attributes(hash), not an issue as the data can be optional
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :BOOLEAN
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
temp_model = DocuSign_eSign.const_get(type).new
temp_model.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
next if value.nil?
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
| 28.989324 | 145 | 0.616744 |
267cca35723d21c007702f56abbb28b91ac369b2 | 249 | # frozen_string_literal: true
module Lightning
module Exceptions
class CannotSignWithoutChanges < StandardError
attr_accessor :commitments
def initialize(commitments)
@commitments = commitments
end
end
end
end
| 19.153846 | 50 | 0.722892 |
0815a8850adace81012e22802a4966d2d9517fac | 482 | require "attractor/ruby/version"
require "attractor"
require "attractor/registry_entry"
require "attractor/calculators/base_calculator"
require "attractor/calculators/ruby_calculator"
require "attractor/detectors/base_detector"
require "attractor/detectors/ruby_detector"
module Attractor
module Ruby
class Error < StandardError; end
Attractor.register(Attractor::RegistryEntry.new(type: "rb", detector_class: RubyDetector, calculator_class: RubyCalculator))
end
end
| 28.352941 | 128 | 0.817427 |
87e704def9102ee07c41d2849e8213358ce28182 | 369 | require "bundler/setup"
require "all_companies"
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
# Disable RSpec exposing methods globally on `Module` and `main`
config.disable_monkey_patching!
config.expect_with :rspec do |c|
c.syntax = :expect
end
end
| 24.6 | 66 | 0.756098 |
38618e2126cae151b2227675c36805df7c6b4677 | 2,550 | # Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
module Azure::ApiManagement::Mgmt::V2016_07_07
module Models
#
# Configuration of a virtual network to which API Management service is
# deployed.
#
class VirtualNetworkConfiguration
include MsRestAzure
# @return [String] The virtual network ID. This is typically a GUID.
# Expect a null GUID by default.
attr_accessor :vnetid
# @return [String] The name of the subnet.
attr_accessor :subnetname
# @return [String] The name of the subnet Resource ID. This has format
# /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/{virtual
# network name}/subnets/{subnet name}.
attr_accessor :subnet_resource_id
# @return [String] The location of the virtual network.
attr_accessor :location
#
# Mapper for VirtualNetworkConfiguration class as Ruby Hash.
# This will be used for serialization/deserialization.
#
def self.mapper()
{
client_side_validation: true,
required: false,
serialized_name: 'VirtualNetworkConfiguration',
type: {
name: 'Composite',
class_name: 'VirtualNetworkConfiguration',
model_properties: {
vnetid: {
client_side_validation: true,
required: false,
read_only: true,
serialized_name: 'vnetid',
type: {
name: 'String'
}
},
subnetname: {
client_side_validation: true,
required: false,
read_only: true,
serialized_name: 'subnetname',
type: {
name: 'String'
}
},
subnet_resource_id: {
client_side_validation: true,
required: false,
serialized_name: 'subnetResourceId',
type: {
name: 'String'
}
},
location: {
client_side_validation: true,
required: false,
serialized_name: 'location',
type: {
name: 'String'
}
}
}
}
}
end
end
end
end
| 30 | 134 | 0.535294 |
1a9f2b24be401ae60e5a0502149ca92f1d66d374 | 1,868 | class ThinkingSphinx::Context
attr_reader :indexed_models
def initialize(*models)
@indexed_models = []
end
def prepare
ThinkingSphinx::Configuration.instance.indexed_models.each do |model|
add_indexed_model model
end
return unless indexed_models.empty?
load_models
add_indexed_models
end
def define_indexes
indexed_models.each { |model|
model.constantize.define_indexes
}
end
def add_indexed_model(model)
model = model.name if model.is_a?(Class)
indexed_models << model
indexed_models.uniq!
indexed_models.sort!
end
def superclass_indexed_models
klasses = indexed_models.collect { |name| name.constantize }
klasses.reject { |klass|
klass.superclass.ancestors.any? { |ancestor| klasses.include?(ancestor) }
}.collect { |klass| klass.name }
end
private
def add_indexed_models
Object.subclasses_of(ActiveRecord::Base).each do |klass|
add_indexed_model klass if klass.has_sphinx_indexes?
end
end
# Make sure all models are loaded - without reloading any that
# ActiveRecord::Base is already aware of (otherwise we start to hit some
# messy dependencies issues).
#
def load_models
ThinkingSphinx::Configuration.instance.model_directories.each do |base|
Dir["#{base}**/*.rb"].each do |file|
model_name = file.gsub(/^#{base}([\w_\/\\]+)\.rb/, '\1')
next if model_name.nil?
camelized_model = model_name.camelize
next if ::ActiveRecord::Base.send(:subclasses).detect { |model|
model.name == camelized_model
}
begin
camelized_model.constantize
rescue Exception => err
STDERR.puts "Warning: Error loading #{file}:"
STDERR.puts err.message
STDERR.puts err.backtrace.join("\n"), ''
end
end
end
end
end
| 25.243243 | 79 | 0.669165 |
1defaa0ef9ac302bc25753fc140e16a76716c165 | 184 | #!/usr/bin/env ruby
require 'cgi'
require './lotos/core.rb'
require './lotos/view.rb'
require './lotos/logic.rb'
module Lotos
def self.run
app = Lotos::App.new
end
end
| 10.823529 | 26 | 0.646739 |
01527541a6172c5257272f5f21bc499f611efe17 | 3,326 | require 'json'
module Databasedotcom
module Chatter
# Parent class of all feeds and inherits from Collection. This class is not intended to be instantiated. Methods should be called on subclasses, which are all are dynamically defined (except for FilterFeed). Defined feeds are *NewsFeed*, *UserProfileFeed*, *RecordFeed*, *ToFeed*, *PeopleFeed*, *GroupsFeed*, *FilesFeed*, *CompanyFeed*, and *FilterFeed*.
class Feed < Collection
# Returns an enumerable Feed of FeedItem objects that make up the feed with the specified _id_. Should not be called as a class method on Feed, but as a method on subclasses.
#
# NewsFeed.find(@client) #=> [#<FeedItem ...>, #<FeedItem ...>, ...]
# PeopleFeed.find(@client, "userid") #=> [#<FeedItem ...>, #<FeedItem ...>, ...]
# FilterFeed.find(@client, "me", "000") #=> [#<FeedItem ...>, #<FeedItem ...>, ...]
#
# _id_prefix_ is only applicable for FilterFeed.
def self.find(client, id="me", id_prefix=nil)
path_components = %w(services data)
path_components << "v#{client.version}"
path_components.concat(%w(chatter feeds))
path_components << feed_type
path_components << id unless feed_type == "company"
path_components << id_prefix
path_components << "feed-items"
path = "/" + path_components.compact.join('/')
result = client.http_get(path)
response = JSON.parse(result.body)
collection = self.new(client, nil, response["nextPageUrl"], response["previousPageUrl"], response["currentPageUrl"])
response["items"].each do |item|
collection << FeedItem.new(client, item)
end
collection
end
# Posts a FeedItem to a Feed specified by _user_id_. Should not be called as a class method on Feed, but as a method on subclasses.
#
# UserProfileFeed.post(@client, "me", :text => "This is a status update about Salesforce.", :url => "http://www.salesforce.com")
#
# Returns the newly created FeedItem.
def self.post(client, user_id, parameters)
url = "/services/data/v#{client.version}/chatter/feeds/#{feed_type}/#{user_id}/feed-items"
response = client.http_post(url, nil, parameters)
Databasedotcom::Chatter::FeedItem.new(client, response.body)
end
# Posts a file to a Feed specified by _user_id_. Should not be called as a class method on Feed, but as a method on subclasses.
#
# UserProfileFeed.post_file(@client, "me", File.open("MyFile"), "text/plain", "MyFile", :desc => "This is an uploaded text file.")
#
# Returns the newly created FeedItem.
def self.post_file(client, user_id, io, file_type, file_name, parameters={})
url = "/services/data/v#{client.version}/chatter/feeds/#{feed_type}/#{user_id}/feed-items"
response = client.http_multipart_post(url, {"feedItemFileUpload" => UploadIO.new(io, file_type, file_name), "fileName" => file_name}, parameters)
Databasedotcom::Chatter::FeedItem.new(client, response.body)
end
private
def self.feed_type
self.name.match(/.+::(.+)Feed$/)[1].resourcerize
end
end
FEED_TYPES = %w(News UserProfile Record To People Groups Files Company)
end
end | 51.96875 | 358 | 0.646723 |
abd39fa302e98290a391885f6bfdf6503efe00d6 | 1,576 | module Bot::DiscordCommands
module Info
extend Discordrb::Commands::CommandContainer
command(:info) do |event|
event.channel.send_embed do |embed|
embed.colour = 0xff8040
embed.add_field name: "**Information**", value: " **Name** : CodeMonkey Games \n **Version** : 1.5 \n **Developer** : [@pdebashis](https://pdebashis.github.io)\n **Written In** : Ruby Language (discordrb)\n **Source** : [Github](https://github.com/pdebashis/discordrb-dota3)\n **Invite Link** : [Server Invite](#{Bot::BOT.invite_url})"
embed.thumbnail = Discordrb::Webhooks::EmbedThumbnail.new(
url: 'https://cdn4.iconfinder.com/data/icons/school-subjects/256/Informatics-512.png'
)
end
end
command(:nist_info) do |event|
event.channel.send_embed do |embed|
embed.colour = 0xff8040
embed.add_field name: "**Commands Available**\n", value: " **\\nist_info** : Display this info\n**\\nist_stats** : Get all batch counts\n **\\nist_others** : Get users without batch info\n **\\nist_export [batch]** : Export users with username (with batch filter)\n**\\nist_poll {type} {survey} {option1} {option2} ...** : Create Poll\n\n **Poll Types** : \ncolors,shapes,numbers,letters,food,faces\n\n**\\trade help** : Display the trading help menu\n**\\jobs <location> <keywords> ...** : Search and display any new jobs (last 24 hours)\n"
embed.thumbnail = Discordrb::Webhooks::EmbedThumbnail.new(
url: 'https://cdn4.iconfinder.com/data/icons/school-subjects/256/Informatics-512.png'
)
end
end
end
end | 63.04 | 560 | 0.668782 |
4a52ae8a24b497ba08188d4c72ee20c6f5886a72 | 1,725 |
Pod::Spec.new do |s|
s.name = "AFNetworkingTask"
s.version = "1.2.2"
s.summary = "AFNetworking Sample Task....."
s.homepage = "https://github.com/junhaiyang/AFNetworkingTask"
s.license = "MIT"
s.author = { "yangjunhai" => "[email protected]" }
s.ios.deployment_target = "7.0"
s.ios.framework = 'UIKit'
s.source = { :git => 'https://github.com/junhaiyang/AFNetworkingTask.git' , :tag => '1.2.2'}
s.requires_arc = true
s.source_files = 'AFNetworkingTask/Classes/*.{h,m,mm}'
s.subspec 'AFTextResponseSerializer' do |ds|
ds.source_files = 'AFNetworkingTask/Classes/AFTextResponseSerializer/*.{h,m,mm}'
end
s.subspec 'AFGIFResponseSerializer' do |ds|
ds.source_files = 'AFNetworkingTask/Classes/AFGIFResponseSerializer/*.{h,m,mm}'
end
s.subspec 'AFNetworkActivityLogger' do |ds|
ds.source_files = 'AFNetworkingTask/Classes/AFNetworkActivityLogger/*.{h,m,mm}'
end
s.subspec 'AFgzipRequestSerializer' do |ds|
ds.source_files = 'AFNetworkingTask/Classes/AFgzipRequestSerializer/*.{h,m,mm}'
end
s.subspec 'NSObjectKeyValueOption' do |ds|
ds.source_files = 'AFNetworkingTask/Classes/NSObjectKeyValueOption/*.{h,m,mm}'
end
s.subspec 'UIKit' do |ks|
ks.source_files = 'AFNetworkingTask/Classes/UIKit/*.{h,m,mm}'
end
s.dependency 'AFNetworking' , '~> 3.1.0'
s.dependency 'Godzippa' , '~> 1.1.0'
s.dependency 'YLGIFImage' , '~> 0.11'
s.dependency 'TMCache' , '~> 2.1.0'
s.dependency 'MJExtension' , '~> 3.0.10'
s.dependency 'YKWebPImage', '~> 1.0'
end
| 24.295775 | 95 | 0.608116 |
1cebf97301a1f85689d2cb6a47dbb9554d7306dc | 390 | name "homebrew"
maintainer "Opscode, Inc."
maintainer_email "[email protected]"
license "Apache 2.0"
description "Install Homebrew and use it as your package provider in Mac OS X"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "1.2.0"
recipe "homebrew", "Install Homebrew"
supports "mac_os_x"
| 39 | 83 | 0.658974 |
39cc9ed2fa14d5a76aed4b14ee4d073bb7a6ca8d | 636 | Pod::Spec.new do |s|
s.name = 'NanoStore'
s.version = '2.1.4'
s.license = 'BSD'
s.summary = 'NanoStore is an open source, lightweight schema-less local key-value document store written in Objective-C for Mac OS X and iOS.'
s.homepage = 'https://github.com/tciuro/NanoStore'
s.authors = { 'Tito Ciuro' => '[email protected]' }
s.source = { :git => 'git://github.com/tciuro/NanoStore.git', :tag => '2.1.4' }
s.source_files = 'Classes/**/*.{h,m}'
s.clean_paths = FileList['*'].exclude(/(Classes|README.md|LICENSE)$/)
s.library = 'sqlite3'
s.requires_arc = true
end
| 45.428571 | 150 | 0.597484 |
1d0b359143900f937853578efe70bab5aad6f496 | 1,043 | # This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path(File.dirname(__FILE__) + "/../config/environment") #nf patching generated spec_helper
#require File.dirname(__FILE__) + "/../config/environment" unless defined?(Rails)
require 'rspec/rails'
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
Rspec.configure do |config|
# == Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
config.mock_with :rspec
# If you'd prefer not to run each of your examples within a transaction,
# uncomment the following line.
# config.use_transactional_examples = false
config.use_transactional_examples = true
config.include Devise::TestHelpers, :type => :controller
end
| 35.965517 | 110 | 0.73442 |
016a6d06165415fc71ede5bd1e34d944c3b3b68e | 5,990 | require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
require 'rubygems/commands/sources_command'
class TestGemCommandsSourcesCommand < RubyGemTestCase
def setup
super
@cmd = Gem::Commands::SourcesCommand.new
@new_repo = "http://beta-gems.example.com"
end
def test_execute
util_setup_spec_fetcher
@cmd.handle_options []
use_ui @ui do
@cmd.execute
end
expected = <<-EOF
*** CURRENT SOURCES ***
#{@gem_repo}
EOF
assert_equal expected, @ui.output
assert_equal '', @ui.error
end
def test_execute_add
util_setup_fake_fetcher
si = Gem::SourceIndex.new
si.add_spec @a1
specs = si.map do |_, spec|
[spec.name, spec.version, spec.original_platform]
end
specs_dump_gz = StringIO.new
Zlib::GzipWriter.wrap specs_dump_gz do |io|
Marshal.dump specs, io
end
@fetcher.data["#{@new_repo}/specs.#{@marshal_version}.gz"] =
specs_dump_gz.string
@cmd.handle_options %W[--add #{@new_repo}]
util_setup_spec_fetcher
use_ui @ui do
@cmd.execute
end
assert_equal [@gem_repo, @new_repo], Gem.sources
expected = <<-EOF
#{@new_repo} added to sources
EOF
assert_equal expected, @ui.output
assert_equal '', @ui.error
end
def test_execute_add_nonexistent_source
util_setup_fake_fetcher
uri = "http://beta-gems.example.com/specs.#{@marshal_version}.gz"
@fetcher.data[uri] = proc do
raise Gem::RemoteFetcher::FetchError.new('it died', uri)
end
Gem::RemoteFetcher.fetcher = @fetcher
@cmd.handle_options %w[--add http://beta-gems.example.com]
util_setup_spec_fetcher
use_ui @ui do
@cmd.execute
end
expected = <<-EOF
Error fetching http://beta-gems.example.com:
\tit died (#{uri})
EOF
assert_equal expected, @ui.output
assert_equal '', @ui.error
end
def test_execute_add_bad_uri
@cmd.handle_options %w[--add beta-gems.example.com]
util_setup_spec_fetcher
use_ui @ui do
@cmd.execute
end
assert_equal [@gem_repo], Gem.sources
expected = <<-EOF
beta-gems.example.com is not a URI
EOF
assert_equal expected, @ui.output
assert_equal '', @ui.error
end
def test_execute_add_legacy
util_setup_fake_fetcher
util_setup_source_info_cache
si = Gem::SourceIndex.new
si.add_spec @a1
@fetcher.data["#{@new_repo}/yaml"] = ''
@cmd.handle_options %W[--add #{@new_repo}]
use_ui @ui do
@cmd.execute
end
assert_equal [@gem_repo], Gem.sources
expected = <<-EOF
WARNING: RubyGems 1.2+ index not found for:
\t#{@new_repo}
Will cause RubyGems to revert to legacy indexes, degrading performance.
EOF
assert_equal "#{@new_repo} added to sources\n", @ui.output
assert_equal expected, @ui.error
end
def test_execute_clear_all
@cmd.handle_options %w[--clear-all]
util_setup_source_info_cache
cache = Gem::SourceInfoCache.cache
cache.update
cache.write_cache
assert File.exist?(cache.system_cache_file),
'system cache file'
assert File.exist?(cache.latest_system_cache_file),
'latest system cache file'
util_setup_spec_fetcher
fetcher = Gem::SpecFetcher.fetcher
# HACK figure out how to force directory creation via fetcher
#assert File.directory?(fetcher.dir), 'cache dir exists'
use_ui @ui do
@cmd.execute
end
expected = <<-EOF
*** Removed specs cache ***
*** Removed user source cache ***
*** Removed latest user source cache ***
*** Removed system source cache ***
*** Removed latest system source cache ***
EOF
assert_equal expected, @ui.output
assert_equal '', @ui.error
assert !File.exist?(cache.system_cache_file),
'system cache file'
assert !File.exist?(cache.latest_system_cache_file),
'latest system cache file'
assert !File.exist?(fetcher.dir), 'cache dir removed'
end
def test_execute_remove
@cmd.handle_options %W[--remove #{@gem_repo}]
util_setup_spec_fetcher
use_ui @ui do
@cmd.execute
end
expected = "#{@gem_repo} removed from sources\n"
assert_equal expected, @ui.output
assert_equal '', @ui.error
end
def test_execute_remove_no_network
@cmd.handle_options %W[--remove #{@gem_repo}]
util_setup_fake_fetcher
@fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do
raise Gem::RemoteFetcher::FetchError
end
use_ui @ui do
@cmd.execute
end
expected = "#{@gem_repo} removed from sources\n"
assert_equal expected, @ui.output
assert_equal '', @ui.error
end
def test_execute_update
@cmd.handle_options %w[--update]
util_setup_fake_fetcher
source_index = util_setup_spec_fetcher @a1
specs = source_index.map do |name, spec|
[spec.name, spec.version, spec.original_platform]
end
@fetcher.data["#{@gem_repo}specs.#{Gem.marshal_version}.gz"] =
util_gzip Marshal.dump(specs)
latest_specs = source_index.latest_specs.map do |spec|
[spec.name, spec.version, spec.original_platform]
end
@fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] =
util_gzip Marshal.dump(latest_specs)
use_ui @ui do
@cmd.execute
end
assert_equal "source cache successfully updated\n", @ui.output
assert_equal '', @ui.error
end
def test_execute_update_legacy
@cmd.handle_options %w[--update]
util_setup_fake_fetcher
util_setup_source_info_cache
Gem::SourceInfoCache.reset
si = Gem::SourceIndex.new
si.add_spec @a1
@fetcher.data["#{@gem_repo}yaml"] = YAML.dump si
@fetcher.data["#{@gem_repo}Marshal.#{@marshal_version}"] = si.dump
use_ui @ui do
@cmd.execute
end
expected = <<-EOF
Bulk updating Gem source index for: #{@gem_repo}
source cache successfully updated
EOF
assert_equal expected, @ui.output
assert_equal '', @ui.error
end
end
| 21.781818 | 75 | 0.673289 |
ed9fe9479451415632d22b96f5f8602fd0216a06 | 55 | class Api::BaseController < ActionController::Base
end
| 18.333333 | 50 | 0.818182 |
d5ce82c902dcf4c49d0d83842323cfeece158eff | 12,251 | # frozen_string_literal: true
module Alchemy
module Admin
class PagesController < Alchemy::Admin::BaseController
include OnPageLayout::CallbacksRunner
helper "alchemy/pages"
before_action :load_page, except: [:index, :flush, :new, :order, :create, :copy_language_tree, :link, :sort]
authorize_resource class: Alchemy::Page, except: [:index, :tree]
before_action only: [:index, :tree, :flush, :new, :order, :create, :copy_language_tree] do
authorize! :index, :alchemy_admin_pages
end
include Alchemy::Admin::CurrentLanguage
before_action :set_translation,
except: [:show]
before_action :set_root_page,
only: [:index, :show, :sort, :order]
before_action :run_on_page_layout_callbacks,
if: :run_on_page_layout_callbacks?,
only: [:show]
def index
if !@page_root
@language = @current_language
@languages_with_page_tree = Language.on_current_site.with_root_page
@page_layouts = PageLayout.layouts_for_select(@language.id)
end
end
# Returns all pages as a tree from the root given by the id parameter
#
def tree
render json: serialized_page_tree
end
# Used by page preview iframe in Page#edit view.
#
def show
@preview_mode = true
Page.current_preview = @page
# Setting the locale to pages language, so the page content has it's correct translations.
::I18n.locale = @page.language.locale
render(layout: Alchemy::Config.get(:admin_page_preview_layout) || "application")
end
def info
render layout: !request.xhr?
end
def new
@page ||= Page.new(layoutpage: params[:layoutpage] == "true", parent_id: params[:parent_id])
@page_layouts = PageLayout.layouts_for_select(@current_language.id, @page.layoutpage?)
@clipboard = get_clipboard("pages")
@clipboard_items = Page.all_from_clipboard_for_select(@clipboard, @current_language.id, @page.layoutpage?)
end
def create
@page = paste_from_clipboard || Page.new(page_params)
if @page.save
flash[:notice] = Alchemy.t("Page created", name: @page.name)
do_redirect_to(redirect_path_after_create_page)
else
new
render :new
end
end
# Edit the content of the page and all its elements and contents.
#
# Locks the page to current user to prevent other users from editing it meanwhile.
#
def edit
# fetching page via before filter
if page_is_locked?
flash[:warning] = Alchemy.t("This page is locked", name: @page.locker_name)
redirect_to admin_pages_path
elsif page_needs_lock?
@page.lock_to!(current_alchemy_user)
end
@preview_url = Alchemy::Admin::PREVIEW_URL.url_for(@page)
@layoutpage = @page.layoutpage?
end
# Set page configuration like page names, meta tags and states.
def configure
@page_layouts = PageLayout.layouts_with_own_for_select(@page.page_layout, @current_language.id, @page.layoutpage?)
end
# Updates page
#
# * fetches page via before filter
#
def update
# stores old page_layout value, because unfurtunally rails @page.changes does not work here.
@old_page_layout = @page.page_layout
if @page.update(page_params)
@notice = Alchemy.t("Page saved", name: @page.name)
@while_page_edit = request.referer.include?("edit")
unless @while_page_edit
@tree = serialized_page_tree
end
else
configure
end
end
# Fetches page via before filter, destroys it and redirects to page tree
def destroy
if @page.destroy
flash[:notice] = Alchemy.t("Page deleted", name: @page.name)
# Remove page from clipboard
clipboard = get_clipboard("pages")
clipboard.delete_if { |item| item["id"] == @page.id.to_s }
end
respond_to do |format|
format.js do
@redirect_url = if @page.layoutpage?
alchemy.admin_layoutpages_path
else
alchemy.admin_pages_path
end
render :redirect
end
end
end
def link
@attachments = Attachment.all.collect { |f|
[f.name, download_attachment_path(id: f.id, name: f.urlname)]
}
end
def fold
# @page is fetched via before filter
@page.fold!(current_alchemy_user.id, [email protected]?(current_alchemy_user.id))
respond_to do |format|
format.js
end
end
# Leaves the page editing mode and unlocks the page for other users
def unlock
# fetching page via before filter
@page.unlock!
flash[:notice] = Alchemy.t(:unlocked_page, name: @page.name)
@pages_locked_by_user = Page.from_current_site.locked_by(current_alchemy_user)
respond_to do |format|
format.js
format.html {
redirect_to params[:redirect_to].blank? ? admin_pages_path : params[:redirect_to]
}
end
end
def visit
@page.unlock!
redirect_to show_page_url(
urlname: @page.urlname,
locale: prefix_locale? ? @page.language_code : nil,
host: @page.site.host == "*" ? request.host : @page.site.host,
)
end
# Sets the page public and updates the published_at attribute that is used as cache_key
#
def publish
# fetching page via before filter
@page.publish!
flash[:notice] = Alchemy.t(:page_published, name: @page.name)
redirect_back(fallback_location: admin_pages_path)
end
def copy_language_tree
language_root_to_copy_from.copy_children_to(copy_of_language_root)
flash[:notice] = Alchemy.t(:language_pages_copied)
redirect_to admin_pages_path
end
def sort
@sorting = true
end
# Receives a JSON object representing a language tree to be ordered
# and updates all pages in that language structure to their correct indexes
def order
neworder = JSON.parse(params[:set])
tree = create_tree(neworder, @page_root)
Alchemy::Page.transaction do
tree.each do |key, node|
dbitem = Page.find(key)
dbitem.update_node!(node)
end
end
flash[:notice] = Alchemy.t("Pages order saved")
do_redirect_to admin_pages_path
end
def flush
@current_language.pages.flushables.update_all(published_at: Time.current)
# We need to ensure, that also all layoutpages get the +published_at+ timestamp set,
# but not set to public true, because the cache_key for an element is +published_at+
# and we don't want the layout pages to be present in +Page.published+ scope.
@current_language.pages.flushable_layoutpages.update_all(published_at: Time.current)
respond_to { |format| format.js }
end
private
def copy_of_language_root
Page.copy(
language_root_to_copy_from,
language_id: params[:languages][:new_lang_id],
language_code: @current_language.code,
)
end
def language_root_to_copy_from
Page.language_root_for(params[:languages][:old_lang_id])
end
# Returns the current left index and the aggregated hash of tree nodes indexed by page id visited so far
#
# Visits a batch of children nodes, assigns them the correct ordering indexes and spuns recursively the same
# procedure on their children, if any
#
# @param [Array]
# An array of children nodes to be visited
# @param [Integer]
# The lft attribute that should be given to the first node in the array
# @param [Integer]
# The page id of the parent of this batch of children nodes
# @param [Integer]
# The depth at which these children reside
# @param [Hash]
# A Hash of TreeNode's indexed by their page ids
# @param [String]
# The url for the parent node of these children
# @param [Boolean]
# Whether these children reside in a restricted branch according to their ancestors
#
def visit_nodes(nodes, my_left, parent, depth, tree, url, restricted)
nodes.each do |item|
my_right = my_left + 1
my_restricted = item["restricted"] || restricted
urls = process_url(url, item)
if item["children"]
my_right, tree = visit_nodes(item["children"], my_left + 1, item["id"], depth + 1, tree, urls[:children_path], my_restricted)
end
tree[item["id"]] = TreeNode.new(my_left, my_right, parent, depth, urls[:my_urlname], my_restricted)
my_left = my_right + 1
end
[my_left, tree]
end
# Returns a Hash of TreeNode's indexed by their page ids
#
# Grabs the array representing a tree structure of pages passed as a parameter,
# visits it and creates a map of TreeNodes indexed by page id featuring Nested Set
# ordering information consisting of the left, right, depth and parent_id indexes as
# well as a node's url and restricted status
#
# @param [Array]
# An Array representing a tree of Alchemy::Page's
# @param [Alchemy::Page]
# The root page for the language being ordered
#
def create_tree(items, rootpage)
_, tree = visit_nodes(items, rootpage.lft + 1, rootpage.id, rootpage.depth + 1, {}, "", rootpage.restricted)
tree
end
# Returns a pair, the path that a given tree node should take, and the path its children should take
#
# This function will add a node's own slug into their ancestor's path
# in order to create the full URL of a node
#
# @param [String]
# The node's ancestors path
# @param [Hash]
# A children node
#
def process_url(ancestors_path, item)
default_urlname = (ancestors_path.blank? ? "" : "#{ancestors_path}/") + item["slug"].to_s
{ my_urlname: default_urlname, children_path: default_urlname }
end
def load_page
@page = Page.find(params[:id])
end
def pages_from_raw_request
request.raw_post.split("&").map do |i|
parts = i.split("=")
{
parts[0].gsub(/[^0-9]/, "") => parts[1],
}
end
end
def redirect_path_after_create_page
if @page.editable_by?(current_alchemy_user)
params[:redirect_to] || edit_admin_page_path(@page)
else
admin_pages_path
end
end
def page_params
params.require(:page).permit(*secure_attributes)
end
def secure_attributes
if can?(:create, Alchemy::Page)
Page::PERMITTED_ATTRIBUTES + [:language_root, :parent_id, :language_id, :language_code]
else
Page::PERMITTED_ATTRIBUTES
end
end
def page_is_locked?
return false if [email protected](:logged_in?)
return false if !current_alchemy_user.respond_to?(:id)
@page.locked? && @page.locker.id != current_alchemy_user.id
end
def page_needs_lock?
return true unless @page.locker
@page.locker.try!(:id) != current_alchemy_user.try!(:id)
end
def paste_from_clipboard
if params[:paste_from_clipboard]
source = Page.find(params[:paste_from_clipboard])
parent = Page.find_by(id: params[:page][:parent_id])
Page.copy_and_paste(source, parent, params[:page][:name])
end
end
def set_root_page
@page_root = @current_language.root_page
end
def serialized_page_tree
PageTreeSerializer.new(@page, ability: current_ability,
user: current_alchemy_user,
full: params[:full] == "true")
end
end
end
end
| 33.110811 | 137 | 0.61897 |
e98fa50cb1b8865db8d1a493996b8ce9b71c3b06 | 86 | # desc "Explaining what the task does"
# task :dynasore do
# # Task goes here
# end
| 17.2 | 38 | 0.674419 |
d5d8d0a3f39a25f470351f42845fc62b73bd0482 | 3,475 | #
# Copyright:: Chef Software Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# We use the version in util-linux, and only build the libuuid subdirectory
name "libzmq"
default_version "4.0.7"
license "LGPL-3.0"
license_file "COPYING"
license_file "COPYING.LESSER"
skip_transitive_dependency_licensing true
version "4.2.2" do
source md5: "52499909b29604c1e47a86f1cb6a9115"
dependency "libsodium"
end
version "4.1.4" do
source md5: "a611ecc93fffeb6d058c0e6edf4ad4fb"
dependency "libsodium"
end
# Last stable version for "4.0.x"
version "4.0.7" do
source sha256: "e00b2967e074990d0538361cc79084a0a92892df2c6e7585da34e4c61ee47b03"
dependency "libsodium"
end
version "4.0.5" do
source md5: "73c39f5eb01b9d7eaf74a5d899f1d03d"
dependency "libsodium"
end
version "4.0.4" do
source md5: "f3c3defbb5ef6cc000ca65e529fdab3b"
dependency "libsodium"
end
relative_path "zeromq-#{version}"
if version.satisfies?(">= 4.2.0")
source url: "https://github.com/zeromq/libzmq/releases/download/v#{version}/zeromq-#{version}.tar.gz"
else
source url: "http://download.zeromq.org/zeromq-#{version}.tar.gz"
end
build do
env = with_standard_compiler_flags(with_embedded_path)
if aix?
# In tcp_connector.hpp the `open` method was getting redefined to open64 because the compiler's `_LARGE_FILES` flag
# is set. We renamed `open` to `openn` to keep it from getting redefined during compilation.
# reference: https://www.ibm.com/support/knowledgecenter/en/ssw_aix_71/com.ibm.aix.genprogc/writing_programsa_access.htm
# reference: https://www.ibm.com/support/knowledgecenter/ssw_aix_71/com.ibm.aix.basetrf1/open.htm
patch source: "zeromq-aix-4.2.2-LARGE_FILES.patch", plevel: 0, env: env
# When trying to run libzmq and request a socket we were seeing failures (resulting in core dumps) around the use of mutexes.
# We eventually narrowed this down to the `atomic_counter.hpp`. This class has a bunch of overrides to support atomic
# operations using system or compiler native features. As a fallback it would use a mutex to perform atomic operations but
# we were seeing that mutex never be initialized. So we added support for the built-in AIX atomic operations fetch_and_add.
patch source: "zeromq-aix-4.2.2-atomic-counter-fetch_and_add.patch", plevel: 0, env: env
end
# If we were building with CMake this would be the default
# and newer versions of libzmq use this as the default.
env["CPPFLAGS"] = "#{env["CPPFLAGS"]} -DFD_SETSIZE=1024" if windows?
# Some test files use inet_pton which is not readily available on windows.
if version.satisfies?(">= 4") && version.satisfies?("< 4.1") && windows?
patch source: "zeromq-4.0.11_mingw_inet_pton.patch", env: env
end
config_command = [
"--with-libsodium",
"--without-documentation",
"--disable-dependency-tracking",
]
configure(*config_command, env: env)
make "-j #{workers}", env: env
make "-j #{workers} install", env: env
end
| 38.186813 | 129 | 0.746187 |
b98b988ffbead1bd5482c1a8c1a147832c3833a9 | 1,360 | class Ht < Formula
desc "Viewer/editor/analyzer for executables"
homepage "https://hte.sourceforge.io/"
url "https://downloads.sourceforge.net/project/hte/ht-source/ht-2.1.0.tar.bz2"
sha256 "31f5e8e2ca7f85d40bb18ef518bf1a105a6f602918a0755bc649f3f407b75d70"
license "GPL-2.0"
livecheck do
url :stable
end
bottle do
cellar :any
rebuild 1
sha256 "330aeebfe496dbe213285aed3ab6d2dfad6a709f86b43ac8ad8a33798b08c2fe" => :catalina
sha256 "0669645033eb4eeecad54df5e43bc733ce4cc527fa52f2277c002296b2207753" => :mojave
sha256 "8c604066c63fa1eba3bb547626bbc280ea4446bb2961cb54e8b4fc7b829af5c4" => :high_sierra
sha256 "197a62339202dd45529bbf42b67addc35939dbae43cc9704ff15d75e5ad62d01" => :sierra
sha256 "4556713b40bfd3846c7c03a02c174bff2a771fba4084721b6faed88437c3c1a2" => :el_capitan
end
depends_on "lzo"
uses_from_macos "ncurses"
def install
# Fix compilation with Xcode 9
# https://github.com/sebastianbiallas/ht/pull/18
inreplace "htapp.cc", "(abs(a - b) > 1)", "(abs((int)a - (int)b))"
chmod 0755, "./install-sh"
system "./configure", "--disable-dependency-tracking",
"--prefix=#{prefix}",
"--disable-x11-textmode"
system "make", "install"
end
test do
assert_match "ht #{version}", shell_output("#{bin}/ht -v")
end
end
| 32.380952 | 93 | 0.708824 |
189a94232655e4a87296482e996e969daf893be8 | 215 | require 'helper'
class UserStoreTest < Test::Unit::TestCase
context "A UserStore" do
should "know its version" do
store = CloudKit::UserStore.new
assert_equal 1, store.version
end
end
end
| 16.538462 | 42 | 0.683721 |
620697a8dc60c556f707f7e0faacfeac383c31d0 | 603 | class PostsController < ApplicationController
before_action :authenticate_user!
def index
@post = Post.new
timeline_posts
end
def create
@post = current_user.posts.new(post_params)
if @post.save
redirect_to posts_path, notice: 'Post was successfully created.'
else
timeline_posts
render :index, alert: 'Post was not created.'
end
end
private
def timeline_posts
@user = current_user
@timeline_posts ||= Post.own_and_friends_of(@user).ordered_by_most_recent
end
def post_params
params.require(:post).permit(:content)
end
end
| 19.451613 | 77 | 0.706468 |
18bd28a166e558206573f7da0c15f61de612083c | 4,305 | # Patches for Qt must be at the very least submitted to Qt's Gerrit codereview
# rather than their bug-report Jira. The latter is rarely reviewed by Qt.
class Qt < Formula
desc "Cross-platform application and UI framework"
homepage "https://www.qt.io/"
url "https://download.qt.io/official_releases/qt/5.13/5.13.1/single/qt-everywhere-src-5.13.1.tar.xz"
mirror "https://qt.mirror.constant.com/archive/qt/5.13/5.13.1/single/qt-everywhere-src-5.13.1.tar.xz"
mirror "https://ftp.osuosl.org/pub/blfs/conglomeration/qt5/qt-everywhere-src-5.13.1.tar.xz"
sha256 "adf00266dc38352a166a9739f1a24a1e36f1be9c04bf72e16e142a256436974e"
revision 1 unless OS.mac?
head "https://code.qt.io/qt/qt5.git", :branch => "dev", :shallow => false
bottle do
cellar :any
sha256 "d734eff21324701858605d7896763cbba2440c1350969cd3804d3969b3147d89" => :catalina
sha256 "a58effe9b3aa460fcd6cc41aa4cef235b6e88d83fe1c863100a6423a37482f8b" => :mojave
sha256 "eae71268c2333dd6429a704123021ccca05737a629f89d5f7efbf1b1b7c0250b" => :high_sierra
sha256 "3af3d51d19936f6e46bab0f1dc6c3b1e650090796d74110a2b607b985006b0b1" => :sierra
sha256 "eddf9aa0c4a56e4a09762510f0dbeb85e817357a18c0b3eb384f67230d2f55b6" => :x86_64_linux
end
keg_only "Qt 5 has CMake issues when linked"
depends_on "pkg-config" => :build
depends_on :xcode => :build if OS.mac?
depends_on :macos => :sierra if OS.mac?
unless OS.mac?
depends_on "fontconfig"
depends_on "glib"
depends_on "icu4c"
depends_on "libproxy"
depends_on "pulseaudio"
depends_on "python@2"
depends_on "sqlite"
depends_on "systemd"
depends_on "libxkbcommon"
depends_on "linuxbrew/xorg/mesa"
depends_on "linuxbrew/xorg/xcb-util-image"
depends_on "linuxbrew/xorg/xcb-util-keysyms"
depends_on "linuxbrew/xorg/xcb-util-renderutil"
depends_on "linuxbrew/xorg/xcb-util"
depends_on "linuxbrew/xorg/xcb-util-wm"
depends_on "linuxbrew/xorg/xorg"
end
def install
args = %W[
-verbose
-prefix #{prefix}
-release
-opensource -confirm-license
-qt-libpng
-qt-libjpeg
-qt-freetype
-qt-pcre
-nomake examples
-nomake tests
-pkg-config
-dbus-runtime
-proprietary-codecs
]
if OS.mac?
args << "-no-rpath"
args << "-system-zlib"
elsif OS.linux?
args << "-system-xcb"
args << "-R#{lib}"
# https://bugreports.qt.io/projects/QTBUG/issues/QTBUG-71564
args << "-no-avx2"
args << "-no-avx512"
args << "-qt-zlib"
end
system "./configure", *args
system "make"
ENV.deparallelize
system "make", "install"
# Some config scripts will only find Qt in a "Frameworks" folder
frameworks.install_symlink Dir["#{lib}/*.framework"]
# The pkg-config files installed suggest that headers can be found in the
# `include` directory. Make this so by creating symlinks from `include` to
# the Frameworks' Headers folders.
Pathname.glob("#{lib}/*.framework/Headers") do |path|
include.install_symlink path => path.parent.basename(".framework")
end
# Move `*.app` bundles into `libexec` to expose them to `brew linkapps` and
# because we don't like having them in `bin`.
# (Note: This move breaks invocation of Assistant via the Help menu
# of both Designer and Linguist as that relies on Assistant being in `bin`.)
libexec.mkpath
Pathname.glob("#{bin}/*.app") { |app| mv app, libexec }
end
def caveats; <<~EOS
We agreed to the Qt open source license for you.
If this is unacceptable you should uninstall.
EOS
end
test do
(testpath/"hello.pro").write <<~EOS
QT += core
QT -= gui
TARGET = hello
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
EOS
(testpath/"main.cpp").write <<~EOS
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
qDebug() << "Hello World!";
return 0;
}
EOS
system bin/"qmake", testpath/"hello.pro"
system "make"
assert_predicate testpath/"hello", :exist?
assert_predicate testpath/"main.o", :exist?
system "./hello"
end
end
| 31.654412 | 103 | 0.670151 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.